Wrapping build.conf to use it more conveniently

The Genode build system uses GNU Make to build all components as well as to drive the run-tool for automated testing. A key piece is the build.conf file that for one configures the build system (specs, repositories etc. pp) and for the other sets various run-tool options. Over the years, instead of dealing with adapting the file directly, I started to use simple wrapper snippets to make testing on a variety of machines more convenient.

I know that some of my colleagues maintain their own scripts or snippets for the same purpose, so this post here is an insight in how I “stream-lined” my workflow rather than a recommendation on how it should be done.

That being said, let us start by creating a fresh build directory for x86_64:

<genode-dir>/tool/create_builddir x86_64

I will spare you the contents of the file (after all you can check it easily yourself) but after creating the directory the usual

(GNU) sed -i 's/^#R/R/' <genode-dir>/build/x86_64/etc/build.conf

dance that will enable all pre-configured repositories at once while

(GNU) sed -i 's/KERNEL\>/#&/' <genode-dir>/build/x86_64/etc/build.conf

will disable the default KERNEL fallback and

echo 'include $(GENODE_DIR)/mk/wrapper.mk' \ >> <genode-dir>/build/x86_64/etc/build.conf

will add my main wrapper snippet.

The snippet basically looks as follows:

ifneq ($(KERNEL),linux) RUN_OPT := --include boot_dir/$(KERNEL) # include run module wrapper snippets MK_DIR := $(GENODE_DIR)/mk include $(MK_DIR)/amt.mk include $(MK_DIR)/amt_log.mk include $(MK_DIR)/qemu.mk include $(MK_DIR)/serial.mk include $(MK_DIR)/tftp.mk include $(MK_DIR)/iso.mk include $(MK_DIR)/disk.mk include $(MK_DIR)/ipxe.mk include $(MK_DIR)/uefi.mk ifneq ($(WSMAN),) RUN_OPT += --amt-tool wsman else RUN_OPT += --amt-tool amttool endif ifneq ($(SERIAL),) RUN_OPT += --log-serial-filter 'stdbuf -o0 tr "\200-\377" "."' endif # machines selectable by M= ifeq ($(M),qemu) ISO=1 RUN_OPT += --include power_on/qemu --include log/qemu endif ifeq ($(M),test4_x201) AMT_HOST=10.23.42.201 AMT_PASSWORD=t0ps3cr3t AMT=1 SERIAL=1 TFTP=1 endif ifeq ($(M),test_x250) AMT_HOST=test_x250-amt.foo.bar AMT_PASSWORD=t0ps3cr3t AMT=1 AMT_LOG=1 TFTP=1 WSMAN=1 endif ifeq ($(M),ds57u) TFTP=1 SERIAL=1 endif ifeq ($(M),wand_quad) # arg1: on or off / arg2: port number _power_energenie = --include power_$1/energenie \ --power-$1-energenie-host energenie.foo.bar \ --power-$1-energenie-password t0ps3cr3t \ --power-$1-energenie-port $2 RUN_OPT += $(call _power_energenie,on,4) RUN_OPT += --include load/tftp \ --load-tftp-base-dir /var/tftp \ --load-tftp-offset-dir /wand_quad \ --load-tftp-absolute RUN_OPT += --include image/uboot RUN_OPT += --include log/serial \ --log-serial-cmd 'socat -s - tcp:host.foo.bar:1234' RUN_OPT += $(call _power_energenie,off,4) endif endif # !KERNEL=linux ifneq ($(D),) RUN_OPT += --depot-user $(D) else RUN_OPT += --depot-user cnuke endif ifneq ($(AP),) RUN_OPT += --autopilot endif ifneq ($(K),) RUN_OPT += --preserve-genode-dir endif ifneq ($(QT),) QEMU_OPT += --trace events=/tmp/qemu-events.txt endif

As you can see, as long as I do not test on linux a bunch of other snippets will get included. For example amt_log.mk contains the following

ifneq ($(AMT_LOG),) $(info *************************) $(info **** Using log/amt ****) $(info *************************) $(info ) ifeq ($(AMT_HOST),) $(error AMT_HOST not set) endif ifeq ($(AMT_PASSWORD),) $(error AMT_PASSWORD not set) endif RUN_OPT_amt_log += --include log/amt --log-amt-host $(AMT_HOST) \ --log-amt-password $(AMT_PASSWORD) export RUN_OPT += $(RUN_OPT_amt_log) endif

whereas iso.mk is just

ifneq ($(ISO),) $(info ***************************) $(info **** Using image/iso ****) $(info ***************************) $(info ) RUN_OPT_iso = --include image/iso export RUN_OPT += $(RUN_OPT_iso) endif

For each of the machines the appropiate snippets get enabled by setting the make variable to a useful value, either just not empty or the value the run module expects.

When I now want test some run script on different platforms or machines I just execute

make run/demo KERNEL=linux

or

make run/demo KERNEL=nova M=qemu

or

make run/demo KERNEL=nova M=test_x250

(I guess you got the hang of it by now) or in case I just need the .iso to deploy it somewhere else

make run/genodians KERNEL=nova ISO=1 D=local

will do the trick.

I am sure even those small snippets could be better organized or written in a way that various aspects could be overwritten on the commandline and the variable names could be made more explicit but this construct has served me suprisingly well so far. Notwithstanding, it might inspire you to come up with your own take on this topic.