Skip to content

OasisDigital/bazel-c-cpp-toolchain

Repository files navigation

Oasis Digital Bazel examples

We use these examples to teach Bazel, but you are welcome to study them for your own purposes!

https://oasisdigital.com/class/bazel

Cross-compile toolchain example

This is an example of cross-compiling with a custom toolchain.

It is not intended to be production-grade, but rather to be useful in explaining how to set up toolchains.

Tool installation

Ideally we'll build all the tools from source using Bazel, but to keep the focus on toolchain setup, install them with your OS package manager instead.

sudo apt install cc65 stella
brew install cc65 stella

(Not working yet here:) On windows, download the cc65 precompiled binaries.

https://sourceforge.net/projects/cc65/files/cc65-snapshot-win32.zip

Build

the old way: make

the new way: bazel build '...'

Run

Run the make-generated binary:

stella game/hello
/usr/local/Cellar/stella/6.6/Stella.app/Contents/MacOS/Stella game/hello

Run the Bazel-generated binary:

stella bazel-out/darwin-fastbuild/bin/game/hello
/usr/local/Cellar/stella/6.6/Stella.app/Contents/MacOS/Stella bazel-out/darwin-fastbuild/bin/game/hello

Future enhancement

Consider building the cc65 toolchain hermetically instead of relying on an OS-level package.

https://github.com/cc65/cc65/archive/refs/heads/master.zip

Consider showing how to adopt an off-the-shelf embedded toolchain, from this collection:

https://github.com/silvergasp/bazel-embedded

Consider demonstrating this LLVM toolchain:

https://github.com/grailbio/bazel-toolchain

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published