From 8d0f51520e44720a480e50e2ceccb1fed20ce190 Mon Sep 17 00:00:00 2001 From: nosamad Date: Sun, 31 Mar 2019 21:24:26 +0200 Subject: [PATCH] adds support for build type and allows to run gdb in container --- Makefile | 30 ++++++++++++++----------- build/amd64-ubuntu-builder.dockerfile | 1 - build/arm32v7-ubuntu-builder.dockerfile | 1 - 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 25ea33b..a17c596 100644 --- a/Makefile +++ b/Makefile @@ -105,7 +105,11 @@ BUILDSILENT := $(if $(BUILDVERBOSE),,1) $(BUILDSILENT)NINJAFLAGS += -v DOCKER_RUNFLAGS += --device /dev/fuse -DOCKER_RUNFLAGS += --cap-add SYS_ADMIN --security-opt apparmor:unconfined +DOCKER_RUNFLAGS += --cap-add SYS_ADMIN +DOCKER_RUNFLAGS += --security-opt apparmor:unconfined + +DOCKER_RUNFLAGS += --cap-add SYS_PTRACE +DOCKER_RUNFLAGS += --security-opt seccomp=unconfined DOCKER_RUNFLAGS += --interactive DOCKER_RUNFLAGS += --rm @@ -128,7 +132,7 @@ OUT_TARGETS += $(addprefix $(OUT)/,$(TARGETS)) OUT_DIRS += $(OUT) OUT_DIRS += $(OUT)/docker OUT_DIRS += $(OUT)/src -OUT_DIRS += $(addsuffix /usr/bin,$(OUT_TARGETS)) +OUT_DIRS += $(addsuffix /$(BUILDTYPE),$(OUT_TARGETS)) BUILD_TARGETS += $(addprefix build-,$(TARGETS)) CHECK_TARGETS += $(addprefix check-,$(TARGETS)) @@ -149,29 +153,29 @@ $(VERBOSE)SILENT := @ $(HOST_CONTAINER)image_run_volumes += '$(realpath $(PROJECT_ROOT)):$(CONTAINER_PROJECT_ROOT):cached' $(HOST_CONTAINER)image_run_volumes += '$(realpath $(OUT)/$1):$(CONTAINER_OUT)/$1:delegated' -image_name = $(REGISTRY_PREFIX)$(subst -,/,$1)/$(PROJECT_NAME):$(VERSION) -image_run = $(DOCKER) run $(DOCKER_RUNFLAGS) $3 \ - $(addprefix --volume ,$(call image_run_volumes,$1)) \ +container_name = $(REGISTRY_PREFIX)$(subst -,/,$1)/$(PROJECT_NAME):$(VERSION) +container_run = $(DOCKER) run $(DOCKER_RUNFLAGS) $3 \ + $(addprefix --volume ,$(call container_run_volumes,$1)) \ --workdir '$(CONTAINER_OUT)/$1/$(BUILDTYPE)' \ - $(call image_name,$1) \ + $(call container_name,$1) \ $2 image_rule = \ $$(OUT)/docker/$1: $$(OUT)/docker/$1.dockerfile $$(EXTRACT_TARGETS) $$(PROJECT_ROOT)/Makefile; \ $$(SILENT)$$(call image,$1) image = \ - $(call echo_if_silent,TARGET=$1 docker build $(call image_name,$1) $(OUT)) \ - && $(DOCKER) build $(DOCKER_BUILDFLAGS) --iidfile $@ --file $< --tag $(call image_name,$1) $(OUT) + $(call echo_if_silent,TARGET=$1 docker build $(call container_name,$1) $(OUT)) \ + && $(DOCKER) build $(DOCKER_BUILDFLAGS) --iidfile $@ --file $< --tag $(call container_name,$1) $(OUT) configure_rule = \ - $$(OUT)/$1/CMakeCache.txt: $$(PROJECT_ROOT)/CMakeLists.txt $$(OUT)/docker/$1 | $$(OUT)/$1/usr/bin/gdb; \ + $$(OUT)/$1/$$(BUILDTYPE)/CMakeCache.txt: $$(PROJECT_ROOT)/CMakeLists.txt $$(OUT)/docker/$1; \ $$(SILENT)$$(call configure,$1) configure = \ $(call run,$1,sh -c 'cmake $(CMAKEFLAGS) $(CONTAINER_PROJECT_ROOT) && $(CONTAINER_PROJECT_ROOT)/build/discover_cc_settings.sh $(notdir $@) $(realpath $(dir $@))') \ && touch $(addprefix $(dir $@)/,include_dirs.txt) $@ build_rule = \ - build-$1: $$(OUT)/$1/CMakeCache.txt; \ + build-$1: $$(OUT)/$1/$$(BUILDTYPE)/CMakeCache.txt; \ $$(SILENT)$$(call build,$1) build = $(call run,$1,ninja $(PARALLELMFLAGS) $(NINJAFLAGS) $(GOALS)) @@ -186,7 +190,7 @@ memcheck = $(call run,$1,ctest -T memcheck $(CTESTFLAGS)) run_rule = \ run-$1: $$(OUT)/docker/$1; \ $$(SILENT)$$(call run,$1,bash,--tty) || true -run = $(call echo_if_silent,TARGET=$1 $2) && $(call container_run,$1,$2,$3) +run = $(call echo_if_silent,TARGET=$1 BUILDTYPE=$(BUILDTYPE) $2) && $(call container_run,$1,$2,$3) clean_rule = \ clean-$1: ; \ @@ -194,13 +198,13 @@ clean_rule = \ clean = rm -rf $(OUT)/$1 discover_cc_settings_rule = \ - $$(OUT)/$1/include_dirs.txt: $$(OUT)/$1/CMakeCache.txt; \ + $$(OUT)/$1/$$(BUILDTYPE)/include_dirs.txt: $$(OUT)/$1/$$(BUILDTYPE)/CMakeCache.txt; \ $$(SILENT)$$(call discover_cc_settings,$1) discover_cc_settings = \ $(call run,$1,$(CONTAINER_PROJECT_ROOT)/build/discover_cc_settings.sh $(notdir $<) $(realpath $(dir $<))) discover_cc_rule = \ - discover-cc-$1: $$(OUT)/$1/include_dirs.txt; \ + discover-cc-$1: $$(OUT)/$1/$$(BUILDTYPE)/include_dirs.txt; \ $$(SILENT)$$(call discover_cc,$1) discover_cc = cat $< diff --git a/build/amd64-ubuntu-builder.dockerfile b/build/amd64-ubuntu-builder.dockerfile index 1f78647..20c6272 100644 --- a/build/amd64-ubuntu-builder.dockerfile +++ b/build/amd64-ubuntu-builder.dockerfile @@ -12,7 +12,6 @@ RUN set -x \ pkg-config \ rsync \ gdb \ - gdbserver \ valgrind \ && rm -rf /var/lib/apt/lists/* diff --git a/build/arm32v7-ubuntu-builder.dockerfile b/build/arm32v7-ubuntu-builder.dockerfile index 295b2f2..c6a12d6 100644 --- a/build/arm32v7-ubuntu-builder.dockerfile +++ b/build/arm32v7-ubuntu-builder.dockerfile @@ -14,7 +14,6 @@ RUN set -x \ pkg-config \ rsync \ gdb \ - gdbserver \ && rm -rf /var/lib/apt/lists/* COPY src /usr/local/src