Fake build system
Brother project of fake-kotlin.
- Use
- Build
- Test
- All of this but with fake
- Build, test, install, etc.
Execute fake <task>
in directory with fake.yaml
.
fake.yaml
contains description of tasks in following format:
- task-name
- "
run
": command that is executed when target is out of date - "
dependencies
" (optional): contains one dependency or list of dependencies
If dependencies not specified, task will be executed iftarget
file doesn't exist - "
target
" (optional): contains name of target file that will be produced after successful execution of this task
If target isn't specified, task is executed unconditionally
- "
Some details:
- fake fails if malformed task is met while processing dependencies of the
<task>
- A task considered malformed when
run
property is undefined or any property is defined incorrectly. - fake fails immediately if the
<task>
is malformed. - If one of the dependencies is malformed, fake continues processing of other dependencies, but fails at the end.
- (Note: fake-kotlin behaves differently)
- A task considered malformed when
- If dependency is not defined as a task in
fake.yaml
, fake will try to find a file with the same name- If such file can't be found, fake remembers this as an error and continues processing. fake will fail in the end.
- If there's a cyclic dependency (
task1 -> task2 -> task3 -> task1
), fake immediately fails. - When fake fails, list of occurred errors is printed
- all detected malformed tasks and non-existent dependencies are listed.
Example:
# fake.yaml
compile:
dependencies: main.cpp
target: main.o
run: g++ -c main.cpp -o main.o
build:
dependencies:
- compile
target: main
run: g++ main.o -o main
exec:
dependencies:
- build
run: ./main
~/my_project$ fake exec # Executes all tasks
> [compile]: g++ -c main.cpp -o main.o
> [build]: g++ main.o -o main
> [exec]: ./main
Finished!
~/my_project$ fake exec # Executes only 'exec'
> [exec]: ./main
Finished!
~/my_project$ rm ./main # Delete target of 'build'
~/my_project$ fake exec # Executes 'compile' and 'exec'
> [build]: g++ main.o -o main
> [exec]: ./main
Finished!
~/my_project$ rm ./main.o # Delete target of 'compile'
~/my_project$ fake exec # Executes all tasks
> [compile]: g++ -c main.cpp -o main.o
> [build]: g++ main.o -o main
> [exec]: ./main
Finished!
Requirements:
- CMake 3.16+
- Build tool with CMake generator (Make, Ninja, etc.)
- C/C++ Compiler
- gcc 5.0+ / clang 5.0+ on Linux
- MSVC 2015+ on Windows
Also uses these:
jbeder/yaml-cpp
- library for work with YAMLgoogle/googletest
- unit-test library for C++
You can build this project with your IDE, or from terminal:
- Linux
./build.sh
- Windows
.\build.bat
If yaml-cpp
or googletest
can't be found, they are fetched from GitHub.
Executable binary will be placed in build
directory on Linux and in build/Release
directory on Windows
If you have vcpkg (or maybe other package manager that can be integrated with CMake this way)
you can specify location of cmake toolchain file with toolchain
option for the script file:
- Linux
./build.sh toolchain /path/to/toolchain/file
- Windows
.\build.bat toolchain "C:\\path\\to\\toolchain\\file"`
For vcpkg path is "[VCPKG_ROOT]/scripts/buildsystems/vcpkg.cmake"
If build scripts are not working for you, I recommend using CLion / Visual Studio IDEs to build the project.
You can try building the project with CMake and parameters to your taste:
cmake -S . -B [Build dir] -G [Generator] -DCMAKE_BUILD_TYPE=[Build type] [Your other options]
cmake --build [Build dir] --target fake --config [Build type]
Unit tests are located in gtest
directory.
If you used IDE to build the project it's likely that you have tests available there.
If you built tests with build.sh
/build.bat
you can build tests from terminal.
- Linux
./gtest.sh
- Windows
.\gtest.bat
If you built it manually you can build and run these tests manually too:
cmake --build [Build dir] --target test
cd [Build dir]/gtest
ctest
These aren't intended for Unit-testing, just to test if CI works properly...
Executes only 2 tests:
- Basic: checks if program fails when there's no
fake.yaml
, there's no<task>
argument, and not fails when executed with correctfake.yaml
. - Cyclic dependency: checks if fake fails when called for different tasks.
If you already have fake installed on your system you can do all of this with help of fake.
This repository has fake.yaml
in its root and can be built with fake.
You still need all the other required software, it's just funny replacement for build and test scripts :(
You also can use fake-kotlin to build this project
Main tasks:
configure
- configures CMakebuild
- builds fake from sourcesbuild-tests
- builds test executable from sourcesrun-tests
- runs testsclean
(Linux only) - cleans build directory
Bonus:
install
(Linux only) - installs fake in/usr/local/bin
(requires permissions to access the folder)remove
(Linux only) - removes fake from said directory (also requires permissions)update
- pulls the latest version of this repository from git
and other...
With fake you can shorten building and testing fake to:
fake run-tests