-
Notifications
You must be signed in to change notification settings - Fork 0
Build System
A modular hierarchical GNU-make based build system.
- Hierarchical yet not recursive
- Modular
- Builds outside the source tree
- Fully parallel and dependencies tracked
- Download the cxxblocks/build, if you plan to have project-specific plugins (below assumes you do) then store it outside your project tree
- Create a symlink to
.../build/makefile
at the top of your project directory tree (just above “src” directory). - Optionally create
build/plugins/*.mk
on the same level as the symlink in #2, the build system will source all these files on startup. - In each folder participating in the build under src there should be a file rules.mk. It can be empty in which case the target living in the folder will be a
PHONY
echo target. To make it do something more than logging two variables should be defined in therules.mk
:TARGET_NAME
andTARGET_TYPE
. The former defaults to the name of the bottom most enclosing directory, the latter is a plugin name to be used for the build and defaults toPHONY
. A third variableTARGET_DEPENDS
lists (comma or space separated) targets which the current target depends on.
###Plugins
There is no plugin API as such, build system just includes all *.mk
files from build/plugins
, leaving user the full freedom of injecting whatever code to the build system should the need exists.
###Builders
Builder is a form of plugin used to build normalized targets. It can be almost anything, but must define two macros BUILDERS_<name>_CODE
and BUILDERS_<name>_ARGS
. The former should be a function taking a single argument, the target name; the latter should be a list of arguments the target should export in order to be build-able by this builder.
The below example defines the builder DUMMY
taking a single argument MESSAGE
from from the target, echoing the message prefixed with the target name, and creating an empty file <target_name>.built
in the working directory
MY_NAME:=DUMMY
$(info loading $$(MY_NAME) builder...)
BUILDERS_$(MY_NAME)_ARGS := SOURCES
define BUILDERS_$$(MY_NAME)_CODE
.PHONY: $(1)
$(1): $$(WORK_DIR)/$(1).built
@echo "building $(1) with $$(MY_NAME): $$(TARGETS_$(1)_MESSAGE)"
$$(WORK_DIR)/$(1).built:
@echo "building $$(WORK_DIR)/$(1).built with $$(MY_NAME)"
endef
$(info loaded $$(MY_NAME) builder)
undefine MY_NAME
The rules.mk
in the target's source directory should look as follows to be built with the builder DUMMY
TARGET_NAME:=mytarget
TARGET_TYPE:=DUMMY
TARGET_MESSAGE:="test argument to pass into the builder"