sandermertens / bake Goto Github PK
View Code? Open in Web Editor NEWBake, A build system for building, testing and running C & C++ projects
License: GNU General Public License v3.0
Bake, A build system for building, testing and running C & C++ projects
License: GNU General Public License v3.0
I'm getting the following error trying to bake a minimal example:
[ build] application mycake => '.'
: error LNK2001: unresolved external symbol mainCRTStartup
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\LIBCMT.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
Why is bake trying to use the wrong library? The correct one exists in ...\VC\LIB\amd64\
.
Hi,
I'm currently using bake for one of my c++ projects and I really love it.
I want to move the location of the project to another directory on my computer.
Can you change the path to the project without uninstalling & reinstalling the project (using bake uninstall & bake install)?
Thanks,
Yuval Dolev
See:
Line 1063 in ef8b880
Bake's README lists "BAKE_ARCHITECTURE" as the environment variable used to specify processor architecture, but the line referenced above stores the initialized value in "BAKE_ARCH".
Would it be okay to submit a PR that corrects this? If you suspect that user code uses both "BAKE_ARCHITECTURE" and "BAKE_ARCH", we could maintain compatibility like this:
ut_setenv("BAKE_ARCH", UT_ARCH);
ut_setenv("BAKE_ARCHITECTURE", UT_ARCH);
...but it would be nice to simply replace "BAKE_ARCH" and have one definitive variable, if that sounds safe.
Cheers!
There is no clear what you building debug
or release
on setup
and other build commands.
Failed to execute process '/usr/local/bin/bake'. Reason:
exec: Exec format error
The file '/usr/local/bin/bake' is marked as an executable but could not be run by the operating system.
I'm using arch linux with zen-kernel
To make the directory names of the build-linux
and build-darwin
directories in the C/C++ driver projects consistent with those in the root of the bake tool (and $(uname)
), they should be changed to upper case names.
This requires a change in the utility layer of bake, as the UT_OS_STRING
macro is used during bake setup to identify which makefiles should be used. Changing this macro will also affect other things, like the location where BAKE_TARGET
binaries/headers/etc are stored, and where inside the project bin
folder the binaries are stored.
I cant seem to get the sdl2 system working ,no idea how to get it installed manually either .I am getting Undefined references from the missing sdl2.lib but I have no idea where to put it.
The actual error below:
Creating library flecs-systems-sdl2.git\bin\x64-Windows-debug\flecs_systems_sdl2.lib and object flecs-systems-sdl2.git\bin\x64-Windows-debug\flecs_systems_sdl2.exp
main.obj : error LNK2019: unresolved external symbol SDL_GetError referenced in function FlecsSystemsSdl2Import
Also is it possible to decouple the projects using bake since I see that there is a specific bake_config in every of these projects which makes it very difficult to manually build things when bake doesnt work. Sorry it is just very frustating when a high level build system does not work as intended.
That's is needed for generating single-header libs, as a result, it will provide much easier integration to non-bake
build environments by just including a single header file.
Reference:
https://github.com/nlohmann/json/tree/develop/third_party/amalgamate
I installed bake on windows 10. And,
bake new game -t sdl2.basic
bake run game
I got the following error message.
[ error] missing dependency 'sdl2'
How can I make Bake find sdl2?
I tried Atom, Sublime and VS Code.
I suppose the way bake manages dependencies and header files confuses them, is there a simple solution?
Example: EcsPosition2D is an undefined declaration.
Enable bake projects to be built on Windows.
For the port, the following items need to happen:
A port of the bake code. Bake is already using a operating system independent API which is located in the "util" directory. This code includes pthread (threading), dl (shared objects), exec* functions (spawning processes) and file system operations.
Adapt package management to Windows. In macOS / Linux, bake is stored in $HOME/bake. On Windows, it would make sense to also store packages under the user's directory. References to $HOME and ~ will have to be ported to point to the Windows equivalent.
Port environment management. Bake manages environment variables, and automatically exports variables when building. It automatically finds a configuration file in the current path which contains the variables, and exports them within the scope of the process. The Windows command line doesn't have the concept of "sourcing", so exporting the bake environment to a shell will have to work differently.
Make bake executable available across the system. When bake is installed on macOS or Linux, a shell script is installed to /usr/local/bin that invokes a bake executable stored in the user $HOME directory. This allows different users to have different versions of bake. For Windows a similar system needs to be invented.
Create a bake driver that either invokes the Microsoft Visual Studio compiler. The interface should be largely the same as the macOS/Linux C driver, but obviously compiler commands will be different.
To ensure that this functionality works and keeps working, this issues should not be closed until there is a Windows CI build that validates whether the aforementioned is working,.
As a bake
newbie with plenty of cargo
experience (similar tool in Rust world), I created my first project:
$ bake init hello
Created new package with id 'hello'
I then proceeded to build the project with bake
:
$ cd hello
$ bake
build package 'hello' in '.'
OK, so it built something, but what and where? Running find
reveals that it built a shared library:
$ find .
...
./bin/x64-linux-debug/libhello.so
I suppose I need to configure project type somehow. The output of bake init -h
shows that the main bake
executable has a --type
command line option:
$ bake init --help
Usage: bake [options] <command> <path>
Options:
..
--type <project type> Manually specify a project type (default = "package")
I assume that can be passed to bake init
too, but what value to pass if I want an regular executable?
The tool does not seem to provide any information:
$ bake init --type list hello
error 'list' is not a valid project kind
$ bake init --type help hello
error 'help' is not a valid project kind
So with a little bit of help from git grep
, I managed to find the right type:
$ bake init --type application hello
Created new application with id 'hello'
I can also build it:
cd hello
bake
$ which bin/x64-linux-debug/hello
./bin/x64-linux-debug/hello
It's bit annoying to have to type bake
and that long executable path but perhaps bake
can do it for us:
$ bake run
error path 'run' not found
Unfortunately not.
For reference, here's what the session would have looked like with cargo
:
$ cargo init hello
Created binary (application) project
$ cd hello
$ cargo run
Compiling hello v0.1.0 (/home/penberg/tmp/hello)
Finished dev [unoptimized + debuginfo] target(s) in 0.84s
Running `target/debug/hello`
Hello, world!
Oh, but what if I had actually wanted to build a library?
penberg@nero tmp]$ cargo init --help
cargo-init
Create a new cargo package in an existing directory
USAGE:
cargo init [OPTIONS] [--] [path]
OPTIONS:
...
--bin Use a binary (application) template [default]
--lib Use a library template
ARGS:
<path> [default: .]
Looks like I need to pass the --lib
argument to cargo init
.
There are a number of issues when using environments that have projects built with different build configurations (debug, release). The known issues are:
bake list
will not show packages unless you specify the right configuration (example: bake list --cfg release
)bake run
cannot find packages if they were cloned while using a different build configurationThe following behavior would be more desirable:
bake list
shows all packages, and for which configurations they have been builtbake run
should build a project if it hasn't been built yet for the specified configurationWhen the target OS is specified in the BAKE_OS
environment variable, and when the target OS is different than the host OS, os
template functions will fail to match against the target OS. For example:
In bake.json:
{
"environment": {
"ios": {
"BAKE_OS": "ios",
"BAKE_ARCHITECTURE": "arm64"
}
}
}
In project.json
"${os ios}": {
"cflags": [
"-target $BAKE_ARCHITECTURE-apple-$BAKE_OS"
]
}
The os
check here fails to match because it compares against the host OS ("Darwin" in my case).
This could be intended behaviour, but, if so, I don't see any other mechanism in Bake for branching project settings off of the build target ๐
bake.load
looks like it manages a similar set of OS-related strings as bake.util.os
. And bake.load.ut_load_init(...)
has this nice bit of code:
if (!os) {
os = ut_getenv("BAKE_OS");
if (!os) {
os = UT_OS_STRING;
}
}
// ...
UT_OS = ut_strdup(os);
// ...
ut_setenv("BAKE_OS", UT_OS);
UT_OS_STRING
is always a representation of the host OS, and BAKE_OS
is the same unless the user overrides it in their config. Given that, would it be safe and reasonable to change the OS-matching logic to compare against BAKE_OS
instead of UT_OS_STRING
?
trying to set up bake with vs2019
Command line used
C:\Users\Davids 3th PC\Desktop\DreamerUniverse>git clone https://github.com/SanderMertens/bake
Cloning into 'bake'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 5910 (delta 14), reused 38 (delta 9), pack-reused 5851
Receiving objects: 100% (5910/5910), 1.97 MiB | 1.68 MiB/s, done.
Resolving deltas: 100% (3764/3764), done.
C:\Users\Davids 3th PC\Desktop\DreamerUniverse>cd build-Windows
The system cannot find the path specified.
C:\Users\Davids 3th PC\Desktop\DreamerUniverse>cd bake
C:\Users\Davids 3th PC\Desktop\DreamerUniverse\bake>cd build-Windows
C:\Users\Davids 3th PC\Desktop\DreamerUniverse\bake\build-Windows>nmake
Microsoft (R) Program Maintenance Utility Version 14.25.28614.0
Copyright (C) Microsoft Corporation. All rights reserved.
"==== Building bake (debug) ===="
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\nmake.exe" /NOLOGO /F bake.mak config=debug all
attribute.c
build.c
bundle.c
config.c
crawler.c
driver.c
filelist.c
git.c
install.c
json_utils.c
main.c
project.c
rule.c
run.c
setup.c
dl.c
fs.c
vs.c
thread.c
proc.c
err.c
code.c
env.c
expr.c
file.c
fs.c
iter.c
jsw_rbtree.c
ll.c
load.c
log.c
C:\Users\Davids 3th PC\Desktop\DreamerUniverse\bake\util\src\log.c(1375) : warning C4700: uninitialized local variable 'empty_list' used
memory.c
os.c
parson.c
path.c
rb.c
strbuf.c
C:\Users\Davids 3th PC\Desktop\DreamerUniverse\bake\util\src\strbuf.c(311) : warning C4700: uninitialized local variable 'args' used
C:\Users\Davids 3th PC\Desktop\DreamerUniverse\bake\util\src\strbuf.c(281) : warning C4700: uninitialized local variable 'args' used
string.c
time.c
util.c
version.c
Linking bake
Creating library ..\bake.lib and object ..\bake.exp
C:\Users\Davids 3th PC\Desktop\DreamerUniverse\bake\build-Windows>cd ..
C:\Users\Davids 3th PC\Desktop\DreamerUniverse\bake>bake setup
[ ] Bake setup, installing to ~/bake
[WARNING] copying script to 'C:\Windows\system32', requires administrator privileges
from failed to create global bake script, rerun setup with --local
C:\Users\Davids 3th PC\Desktop\DreamerUniverse\bake>bake setup --local
[ ] Bake setup, installing to ~/bake
[ done] copy bake executable
[ done] bake environment reset
[ done] install bake include files
[ done] install include files for 'bake.util'
[ done] build 'bake.util'
[ done] install 'bake.util' to bake environment
[ done] install include files for 'bake.lang.c'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\link.exe"' : return code '0x49d'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
[ error] 'nmake /NOLOGO /F Makefile clean all' (result 2)
error failed to build 'bake.lang.c'
command line run from administrator visual studio command line from administrator user
When building or running bake projects, their dependencies are currently not rebuilt, even if there have been changes. In some scenarios this can be inconvenient, in particular when building a project with a new build configuration.
Since bake stores binaries for different configurations (debug
, release
) in different locations, and bake does not mix binaries when linking, trying to rebuild a project in release mode, will also require all dependencies to be rebuilt in release mode. It would be convenient if bake can automatically do this.
Recursive building will have a performance overhead which can be significant, and thus should not be enabled by default. However bake run
is ran less frequently and should work regardless of the current state of the environment (a bake run
should work after a bake clone
, regardless of with which configuration bake clone
was executed), so for bake run
, recursive builds should be enabled by default.
Hi, is there an easy way to use precompiled headers with bake?
For example in Premake I can just use pchheader & pchsource to specify my precompiled header and its source file (for Windows).
Does bake have a similar way to do it?
Thanks!
Different compilers, linkers and other tools of toolchains have different features and different flags controlling the same features. So the following facilities are needed:
Implement a bake test command that discovers and runs tests for all discovered bake projects. The bake test command should also build test projects and their dependencies (using recursive builds) in a "test" configuration, which will be like debug
, but with code coverage enabled.
It says cloning into etc... then after a second it says segmentation fault core dumped
is it just me? i tried multiple repositories
In cmake, you'd use this kind of monstrosity:
# Download and unpack googletest at configure time
configure_file(${CMAKE_SOURCE_DIR}/cmake/GoogleTest-CMakeLists.txt.in ${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()
# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
# Now simply link against gtest or gtest_main as needed. Eg
add_executable(mylib_test
src/main.cpp
...
)
Currently bake does little to ensure that projects are run with the correct versions of their dependencies. It is essentially left up to a developer to make sure that his bake environment contains a set of projects that are compatible.
This works alright when developing packages as the environment is not likely to change that often, but is fragile when running applications, particularly from another developers, that developed against their own bake environment.
One design goal of bake is to be able to do run applications directly from a repository, while bake downloads all its dependencies automatically, like this:
bake run --url https://github.com/SanderMertens/example
To enable this, package managers typically let applications/packages specify their dependencies + version constraints, and let a package manager figure out which set of packages is to be used. In practice, this is quite complicated to do right, as a set of constraints may have multiple valid solutions, introducing arbitrary behavior that makes the system behave unpredictably.
Another disadvantage of this approach is that it is hard to (if possible at all) reuse installed packages across applications, since small differences in version constraints may yield very different solutions. In practice this means that applications will typically end up with their own private installed set of packages, with potentially a lot of redundantly stored packages.
To keep systems predictable while at the same time allowing for reusing packages, bake will support the concept of a "bundle". A bundle is a set of packages, annotated with a repository, branch and tag / commit id that describes a consistent environment. Applications do not specify versions on other packages themselves, but instead specify a bundle.
It is up to the maintainer of an application to specify which bundle + bundle version the application is built for. An application may require multiple bundles at once. If two bundles conflict (they require different versions of the same package) it is up to the application developer to resolve this, possibly by creating a new bundle (there always should be a solution, otherwise the application could not have been developed).
This lets application developers and package developers develop their projects independently of each other. Only when the application developer is confident the application can be built against a new version of a bundle, the bundle version will be updated.
This issue will be open for a while to capture design details and feedback before implementation starts.
Currently there is not possible to use external driver without manual installing via command line so this step must be avoided and external driver must be resolved in same way like regular project dependency.
Just so you're aware there is already a VERY similar project with the same name already in existence. You might want to rename this before it gets much traction.
bake generate cmake
Is there a way I can either 1) take the executable I'm building and instruct bake to build all of its libraries as static libraries then link them into the executable, or 2) programmatically get all the libraries depended on so that I can copy them into a directory to bundle alongside of the executable for a standalone release?
I've looked into the various configuration options and haven't found anything yet in regards to doing either
While it would be possible to manually do it myself because I do generally know where bake keeps the libraries, it would be pretty helpful to not have to do this pretty major step in the release process of, say, a game, manually.
Currently bake defaults to gcc on Linux, and clang on macOS. This should be configurable, either through setting the CC
or CXX
environment variables.
Running bake -v
uses the --verbosity option. This confused me because i expected it to display the version but instead the output was no projects found in '.'
Hi!
We need to add an option to skip the check of presence of external symbols in C shared libraries used as program's extensions like PostgreSQL to avoid the gcc -z defs option
.
Proposed API:
check-symbols | bool | Check symbols presence in package (default=true)
We will make a PR to solve this need.
I just found this project on my news feed and it looks amazing
but while reading the README i didn't understand how to link to an external library
for example i googled an SFML helloworld and it includes the library like this
(#include <SFML/Window.hpp>)
then links it like this
(g++ -o sfml_hello sfml_hello.cpp -lsfml-graphics -lsfml-window -lsfml-system)
so what is the equivalent of (-lsome-library) in bake json file :D
This is the helloworld example:
gist.github.com/emersonmx/31004a311efb2876d187
Maybe you can make a working example of this code in the examples/cpp folder :D
I get the impression that this repo (SanderMertens/bake) is the upstream, however github says it's a fork of Cortoproject/bake. Perhaps you could somehow break that link so that people don't think that Cortoproject/bake is the upstream?
According to this question you'd have to contact support to "de-fork" it / break the fork link.
When creating a new template project, it is not automatically added to the bake environment, and requires a user to explicitly build the project first. Since building a template project doesn't actually "build" anything (it just copies files to the bake environment), it would be more convenient if this happened when the template is created, so it can be used immediately.
Additionally, the current command to create a new template is not consistent with how other projects are created:
bake new my_pkg --package
bake new my_tmpl --type template
This should be changed to:
bake new my_tmpl --template
Furthermore, currently there is no straightforward way to uninstall templates. Since templates live in a separate namespace from normal projects, bake uninstall template_name
doesn't work. The uninstall command should allow removing templates, by adding the --template
option.
Implement a simple test framework as a bake driver (derived from https://github.com/cortoproject/corto-test). The test framework will do code generation of test cases and the code that invokes the test runner, and will allow for configuration of test suites and test cases from the JSON file:
{
"id": "test",
"type": "application",
"value": {
"public": false
},
"test": {
"testsuites": [{
"id": "my_first_suite",
"testcases": [
"tc_first_test",
"tc_second_test",
"tc_third_test"
]
}]
}
}
The bake coverage command will parse the output of a test run with code coverage, and report which files have been covered and by how much.
Hello,
There is an app on Android called Termux, and it has a large number of linux packages compiled in its repository, among the build tools it has make,cmake,ninja,(i don't know other ones) .. so since this project was small i thought there are good chances that i don't get a lot of dependencies, i cloned it and tried compiling and it failed because it couldn't find #include <execinfo.h>
inside unil.h
which is provided by perl
package
Are there any workarounds? even if that was solved, is there a larger reason that it couldn't work on Android?
Example would be Protobuf.
The JSON parser used by bake (parson) has support for comments, but requires a special function to be called (json_parse_file_with_comments
). This will enable adding /* */
and //
comments to the project.json file.
Hi,
I'm trying to include a header from a package that I wrote and built using bake in an application that uses the package, but am getting an error.
The header is in a folder with the package's name within the package's include folder.
When I'm trying to #include "Lib/Header.h" from files inside the package itself it compiles successfully, because I added an include statement inside the project.json's "lang.cpp" property for the include folder.
But when I'm trying to do the same include from the application it says that the header does not exist.
Do I need to manually add an include directory to the application's project.json?
Thanks!
Will it ever be possible to build Qt based applications?
I can't think of anything more bloated than Qt so I have to ask ๐
It should be possible to create new test projects with bake new
. To do this, a user should run the following command from a project directory:
bake new test
This will create a new test project which has the test driver configured in the project.json
, sets the project kind to local (so the project doesn't end up in the bake environment) and adds the package under test to the list of dependencies.
Additionally, it will be able to create a test project with a different name, while specifying the --test
command:
bake new api_test --test
bake_util.h
and posix.proc.c
both rely on ptrace. I don't think ptrace is part of the POSIX standard (assuming the Wikipedia page is accurate).
macOS still includes the header in its official SDK, but other Apple platforms (iOS, tvOS, watchOS) don't include it. Consequently, bake.util
can't currently be used as-is by any bake packages targeting one of those platforms (like Flecs).
Is there perhaps a POSIX-standard implementation that could be swapped in as a replacement? ๐
Hi, I'm using bake for a c++ project, and it's awesome.
I wanted to link the project with a library that is only available for linux so I used ${os linux} but I'm getting an error:
error environment variable '' is not set
error environment variable '' is not set
from environment variable '' is not set
from environment variable '' is not set
from environment variable '' is not set
from environment variable '' is not set
from environment variable '' is not set
from failed to locate binary for package 'bake.${os linux}'
from could not load driver 'bake.${os linux}'
This is my project.json file:
{
"id": "Jobs",
"type": "package",
"value": {
"author": "Yuval Dolev",
"description": "A job scheduler that uses natural sounding syntax for C++",
"version": "1.0.0",
"repository": "Jobs",
"license": "MIT License",
"language": "cpp"
},
"lang.cpp": {
"include": ["include"],
"cpp-standard": "c++17"
},
"${os linux}": {
"lang.cpp": {
"lib": ["m"]
}
}
}
Is there a problem with my project.json?
Thanks!
I built bake
and ran bake setup
as instructed in the documentation.
However, I then noticed that the process wants to install something to /usr/local/
:
$ ./bake setup
Bake setup, installing to $BAKE_HOME ('/home/penberg/bake')
ATTENTION copying script to '/usr/local/bin', setup may request password
That's not something I wanted to do for trying out a new tool. Instead, I attempted to copy the bake
executable to $HOME/bin
, but the tool fails to start:
$ cp bake /home/penberg/bin/
$ bake
from could not load driver 'bake.lang.c'
from failed to load driver for language 'c'
It would be nice if there was a installation method that did not require root access.
Bake can currently spit out macOS dylibs but there doesn't appear to be a way to get iOS ARM dylibs built.
I used the Getting Started for the bake project to install the tool for windows. (I used an admin prompt, but apparently it still didn't think it had permissions to install the tool globally -- could be related?)
Then, following the Getting Started for the flecs project, I'm trying to bake new my_app -t flecs
. But the flecs template isn't installed.
C:\src\personal\flecs-playground> bake new test_app -t flecs INFO: Could not find files for the given pattern(s). **********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.4
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
error template 'flecs' not found
C:\src\personal\flecs-playground>
Would you like to add more error handling for return values from functions like the following?
I really like this build system, itโs really awesome!
I only have one question: How do you add preprocessor definitions using bake?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.