From 6edcc72364305083e11a2fdce6287ecd7393b260 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Mon, 10 Oct 2022 16:51:07 -0300 Subject: [PATCH] fix paths in Makefile --- examples/zephyr/device-dashboard/Makefile | 47 +++++++++++++---------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/examples/zephyr/device-dashboard/Makefile b/examples/zephyr/device-dashboard/Makefile index ed4aca95..1c329a82 100644 --- a/examples/zephyr/device-dashboard/Makefile +++ b/examples/zephyr/device-dashboard/Makefile @@ -1,7 +1,13 @@ -PROJECT_DIR ?= /workdir +MONGOOSE_ROOT ?= $(realpath $(CURDIR)/../../..) +DOCKER_PROJECT_DIR ?= /workdir ZEPHYR_DIR ?= zephyrproject -BOARD ?= qemu_x86 +PROJECT_NAME = $(notdir $(CURDIR)) +PROJECT_PATH = $(realpath $(CURDIR)) +ZEPHYR_PATH = $(realpath $(CURDIR)/..)/$(ZEPHYR_DIR) +DOCKER_PROJECT_PATH = $(DOCKER_PROJECT_DIR)/$(PROJECT_NAME) +DOCKER_ZEPHYR_PATH = $(DOCKER_PROJECT_DIR)/$(ZEPHYR_DIR) +BOARD ?= qemu_x86 ifeq "$(BOARD)" "qemu_x86" OVERLAY ?= -DOVERLAY_CONFIG=overlay-e1000.conf else @@ -10,7 +16,7 @@ endif SHAREUSB ?= --privileged -v /dev/bus/usb/:/dev/bus/usb SHARETUN ?= --cap-add=NET_ADMIN --device /dev/net/tun --net=host -DOCKER ?= docker run --rm -v $(realpath $(CURDIR)):$(PROJECT_DIR) +DOCKER ?= docker run --rm -v $(PROJECT_PATH):$(DOCKER_PROJECT_PATH) -v $(ZEPHYR_PATH):$(DOCKER_ZEPHYR_PATH) REPO ?= zephyrprojectrtos/ci @@ -18,35 +24,36 @@ example: true build: - cp ../../../mongoose.[c,h] src/ - $(DOCKER) $(REPO) /bin/sh -c 'cd $(PROJECT_DIR)/$(ZEPHYR_DIR)/zephyr && \ - west build -b $(BOARD) -p auto $(PROJECT_DIR) $(OVERLAY) --build-dir $(PROJECT_DIR)/build' + cp $(MONGOOSE_ROOT)/mongoose.[c,h] src/ + $(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH)/zephyr && \ + west build -b $(BOARD) -p auto $(DOCKER_PROJECT_PATH) $(OVERLAY) --build-dir $(DOCKER_PROJECT_PATH)/build' run: - $(DOCKER) -it $(SHARETUN) $(REPO) /bin/sh -c 'cd $(PROJECT_DIR)/$(ZEPHYR_DIR) && \ - west build -t run --build-dir $(PROJECT_DIR)/build' + $(DOCKER) -it $(SHARETUN) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \ + west build -t run --build-dir $(DOCKER_PROJECT_PATH)/build' clean: - $(DOCKER) $(REPO) /bin/sh -c 'cd $(PROJECT_DIR)/$(ZEPHYR_DIR) && \ - west build -t clean --build-dir $(PROJECT_DIR)/build' + $(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \ + west build -t clean --build-dir $(DOCKER_PROJECT_PATH)/build' pristine: - $(DOCKER) $(REPO) /bin/sh -c 'cd $(PROJECT_DIR)/$(ZEPHYR_DIR) && \ - west build -t pristine --build-dir $(PROJECT_DIR)/build' + $(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \ + west build -t pristine --build-dir $(DOCKER_PROJECT_PATH)/build' flash: - $(DOCKER) $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(PROJECT_DIR)/$(ZEPHYR_DIR) && \ - west flash --build-dir $(PROJECT_DIR)/build' + $(DOCKER) $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \ + west flash --build-dir $(DOCKER_PROJECT_PATH)/build' debug: - $(DOCKER) -it $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(PROJECT_DIR)/$(ZEPHYR_DIR) && \ - west debug --build-dir $(PROJECT_DIR)/build' + $(DOCKER) -it $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \ + west debug --build-dir $(DOCKER_PROJECT_PATH)/build' .PHONY: build flash zephyr clean pristine run -zephyr: -ifeq ($(wildcard $(ZEPHYR_DIR)/.*),) - $(DOCKER) $(REPO) /bin/sh -c 'cd $(PROJECT_DIR) && west init ./$(ZEPHYR_DIR)' +zephyr: +ifeq ($(wildcard $(ZEPHYR_PATH)/.*),) + mkdir $(ZEPHYR_PATH) + $(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_PROJECT_DIR) && west init ./$(ZEPHYR_DIR)' endif - $(DOCKER) $(REPO) /bin/sh -c 'cd $(PROJECT_DIR)/$(ZEPHYR_DIR) && west update' + $(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && west update'