The Project.meta file

What is the Project.meta file

The Project.meta file is bakes configuration file.

  • Every project has a Project.meta file in the project root directory.
  • A Project.meta file contains one or more build configurations.
  • A build configuration consists of toolchain settings, files to build, custom steps, etc.

Example

Project.meta file of Main project Project.meta file of Sub project
Project {
    ExecutableConfig Debug {
        Dependency Sub, config: Debug
        Files "**/*.cpp"
        IncludeDir "include"
        DefaultToolchain GCC {
            Compiler CPP {
                Flags "-Wall"
            }
        }
        PostSteps {
            CommandLine "echo $(ArtifactName) built."
        }
    }
}
Project {
    LibraryConfig Debug {
        Files "**/*.cpp"
        IncludeDir "include"
        IncludeDir "Main/include"
        ExternalLibrarySearchPath "lib"
        ExternalLibrary "a"
        ExternalLibrary "b"
        Toolchain {
            Compiler CPP {
                Flags add: "-g3"
            }
        }
    }
}

Let’s assume that Main and Sub are located in the same workspace root. To build the executable, bake can be called from the Main directory.

User@Host:~/my_project$ bake -b Debug

What happens now?

  1. Reading Project.meta of Main

  2. Reading Project.meta of dependencies (Sub)

  3. Compiling sources of Sub, e.g.:
    User@Host:~$ g++ -c -Wall -g3 -Iinclude -I../Main/include -o Debug_Main/src/xy.o src/xy.cpp
    
    • Wall is taken from the DefaultToolchain and -g3 is added by the toolchain of the Sub project.
    • The include path to Main is automatically adjusted.
    • The order of includes is the same as in Project.meta.
    • g++, -c and -I are used, because GCC was specified in the DefaultToolchain.
  4. Archiving the library, e.g.:

    User@Host:~$ ar -rc Debug_Main/libSub.a Debug_Main/src/xy.o
    
  5. Compiling sources of Main, e.g.:

    User@Host:~$ g++ -c -Wall -Iinclude -o Debug/src/main.o src/main.cpp
    
  6. Linking executable, e.g.:

    User@Host:~$ g++ -o Debug/Main.exe Debug/src/main.o ../Sub/Debug_Main/libSub.a -L../Sub/lib -la -lb
    

    The library search paths and libraries are added in the specified order.

  7. Executing the post step

    User@Host:~$ echo Main.exe built.
    

    The variable was automatically substituted.