From 8b826c72fd93500aa2fb2eead6ea543b90eaa400 Mon Sep 17 00:00:00 2001 From: Peter Steenbergen Date: Tue, 10 Dec 2019 13:21:49 +0100 Subject: [PATCH] MycroftOS: BNuilding now uses a proper Makefile. - Big thx once again to the HassOS guys. --- Makefile | 43 +++++++++++++++++++ ...ycroftos_rpi3_defconfig => rpi3_defconfig} | 0 documentation/building.md | 12 ++++-- scripts/build.sh | 17 -------- 4 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 Makefile rename buildroot-external/configs/{mycroftos_rpi3_defconfig => rpi3_defconfig} (100%) delete mode 100755 scripts/build.sh diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..c88b5ee6 --- /dev/null +++ b/Makefile @@ -0,0 +1,43 @@ +RELEASE_DIR = release + +BUILDROOT=buildroot +BUILDROOT_EXTERNAL=buildroot-external +DEFCONFIG_DIR = $(BUILDROOT_EXTERNAL)/configs + +TARGETS := $(notdir $(patsubst %_defconfig,%,$(wildcard $(DEFCONFIG_DIR)/*_defconfig))) +TARGETS_CONFIG := $(notdir $(patsubst %_defconfig,%-config,$(wildcard $(DEFCONFIG_DIR)/*_defconfig))) + +.NOTPARALLEL: $(TARGETS) $(TARGETS_CONFIG) all + +.PHONY: $(TARGETS) $(TARGETS_CONFIG) all clean help + +all: $(TARGETS) + +$(RELEASE_DIR): + mkdir -p $(RELEASE_DIR) + +$(TARGETS_CONFIG): %-config: + @echo "config $*" + $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=../$(BUILDROOT_EXTERNAL) "$*_defconfig" + +$(TARGETS): %: $(RELEASE_DIR) %-config + @echo "build $@" + $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=../$(BUILDROOT_EXTERNAL) 2>&1 | tee logs/buildroot_output.txt + cp -f $(BUILDROOT)/output/images/sdcard.img $(RELEASE_DIR)/MycroftOS_$@.img + + # Do not clean when building for one target +ifneq ($(words $(filter $(TARGETS),$(MAKECMDGOALS))), 1) + @echo "clean $@" + $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=../$(BUILDROOT_EXTERNAL) clean +endif + @echo "finished $@" + +clean: + $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=../$(BUILDROOT_EXTERNAL) clean + +help: + @echo "Supported targets: $(TARGETS)" + @echo "Run 'make ' to build a target image." + @echo "Run 'make all' to build all target images." + @echo "Run 'make clean' to clean the build output." + @echo "Run 'make -config' to configure buildroot for a target." diff --git a/buildroot-external/configs/mycroftos_rpi3_defconfig b/buildroot-external/configs/rpi3_defconfig similarity index 100% rename from buildroot-external/configs/mycroftos_rpi3_defconfig rename to buildroot-external/configs/rpi3_defconfig diff --git a/documentation/building.md b/documentation/building.md index a49b38d6..0f6f0a1d 100644 --- a/documentation/building.md +++ b/documentation/building.md @@ -17,9 +17,15 @@ If this is the very first time you are going to build an image, you need to exec This will patch the Buildroot packages. ## Building the image. -We can build the image(s) by running the following command; +Building the image(s) can be done by utilizing a proper Makefile;
-- ./scripts/build.sh +To see the available commands, just run: 'make help'
-At this moment only one image get's build. Namely the one for RPi3. Later on in time this section will get expanded with other possible supported hardware. +As example to build the rpi3 version;
+make clean
+make rpi3-config
+make rpi3
+
+To build all available buids, run;
+make all diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100755 index 65197dbf..00000000 --- a/scripts/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -set -e - -mkdir -p release -mkdir -p logs - -all_platforms=(rpi3) -for platform in "${all_platforms[@]}"; do - make -C buildroot BR2_EXTERNAL=../buildroot-external clean - make -C buildroot BR2_EXTERNAL=../buildroot-external mycroftos_${platform}_defconfig - - # Optional if you need to change stuff, uncomment the next line. - # make -C buildroot BR2_EXTERNAL=../buildroot-external menuconfig - - make -C buildroot BR2_EXTERNAL=../buildroot-external 2>&1 | tee logs/buildroot_output.txt - cp -f buildroot/output/images/sdcard.img release/MycroftOS_${platform}.img -done