From 067f9f0f4c10c42459c02b79535fb7557427384d Mon Sep 17 00:00:00 2001 From: tkl Date: Mon, 1 Aug 2016 13:34:25 +0200 Subject: [PATCH 01/10] test var scope --- .gitlab-ci.yml | 23 +++++++--------- Makefile | 4 +++ source/firmware/firmware_version.h | 15 ----------- source/firmware/version.h | 10 +++++++ source/scripts/deploy_container.py | 43 ++++++++++++++++++++++++++++++ source/scripts/release_number.py | 43 ++++++++++++++++++++++++++++++ 6 files changed, 109 insertions(+), 29 deletions(-) delete mode 100644 source/firmware/firmware_version.h create mode 100644 source/firmware/version.h create mode 100755 source/scripts/deploy_container.py create mode 100755 source/scripts/release_number.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5fe0068..c7eda7a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,7 @@ - - variables: -# PRODUCT_NAME: "AG" -# PRODUCT_VARIANT: "NA" -# PRODUCT_VARIANT: "EU" -# PRODUCT_VARIANT: "CN" -# PROJECT_VERSION: "10" -# SW_MAJOR: "1" -# SW_MINOR: "3" + SW_KERNEL: "0" + SW_MAJOR: "0" + SW_MINOR: "0" before_script: @@ -18,7 +12,7 @@ stages: - check - build # - test -# - deploy + - deploy build_job: script: @@ -32,10 +26,11 @@ check_job: - "make check BOARD=stm32f4-discovery" stage: check -#deploy_job: -# script: -# - "make deploy BOARD=stm32f4-discovery" -# stage: deploy +deploy_job: + script: + - "source/scripts/release_number.py" + - "make deploy BOARD=stm32f4-discovery" + stage: deploy #test_job: # script: diff --git a/Makefile b/Makefile index eb9b4bb..415207d 100755 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ include config/make/rules.mk OS_NAME = kosmos MAINFILE = $(EXE_DIR)/lib$(OS_NAME)-$(ARCH)-$(BOARD)$(DBG_EXT)$(LIB_EXT) +DEPLOY_PACKET = lib$(OS_NAME)-$(ARCH)-$(BOARD)-$()$(DBG_EXT).tar.gz INCLUDES += $(SRC_DIR) @@ -29,6 +30,9 @@ ASMSOURCES += $(foreach folder, $(SUB_FOLDER), $(wildcard $(ROOT_DIR)/$(folder)/ all: check $(MAINFILE) deploy: all + echo $(SW_KERNEL) + echo $(SW_MAJOR) + echo $(SW_MINOR) @$(MKDIR) $(EXE_DIR)/include $(SRC_DIR)/scripts/board_interface.py -b "$(SRC_DIR)/firmware/arch/$(CPU)/board/$(BOARD)/include/$(BOARD).h" -o "$(EXE_DIR)/include/board_devices.h" $(SRC_DIR)/scripts/stack_interface.py -i "$(SRC_DIR)/firmware/arch/$(CPU)/include/$(CPU)_stack.h" -o "$(EXE_DIR)/include/stack.h" diff --git a/source/firmware/firmware_version.h b/source/firmware/firmware_version.h deleted file mode 100644 index 2f735a8..0000000 --- a/source/firmware/firmware_version.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * firmware_version.h - * - * Created on: Oct 20, 2015 - * Author: tkl - */ - -#ifndef FIRMWARE_VERSION_H_ -#define FIRMWARE_VERSION_H_ - -#define kernel_version 0 -#define major_number 0 -#define minor_number 0 - -#endif /* FIRMWARE_VERSION_H_ */ diff --git a/source/firmware/version.h b/source/firmware/version.h new file mode 100644 index 0000000..003a627 --- /dev/null +++ b/source/firmware/version.h @@ -0,0 +1,10 @@ +/* Release number include file */ + +#ifndef VERSION_H +#define VERSION_H + +#define KERNEL_VERSION "unknown" +#define MAJOR_VERSION "unknown" +#define MINOR_VERSION "unknown" + +#endif /* VERSION_H */ diff --git a/source/scripts/deploy_container.py b/source/scripts/deploy_container.py new file mode 100755 index 0000000..77a2630 --- /dev/null +++ b/source/scripts/deploy_container.py @@ -0,0 +1,43 @@ +#!/usr/bin/python2 +from sys import argv, exit +from getopt import getopt +from re import match, sub +import os + +def get_current_numbers(): + config = {} + if os.environ.has_key("SW_KERNEL"): + config["sw_kernel"] = os.environ["SW_KERNEL"] + if os.environ.has_key("SW_MAJOR"): + config["sw_major"] = os.environ["SW_MAJOR"] + if os.environ.has_key("SW_MINOR"): + config["sw_minor"] = os.environ["SW_MINOR"] + return config + +def generate_include(numbers): + f = open("../firmware/version.h", "w") + f.write("/* Release number include file */\n\n") + f.write("#ifndef VERSION_H\n") + f.write("#define VERSION_H\n\n") + if numbers.has_key("sw_kernel"): + f.write("#define KERNEL_VERSION\t\"" + numbers["sw_kernel"] + "\"\n") + else: + f.write("#define KERNEL_VERSION\t\"unknown\"\n") + if numbers.has_key("sw_major"): + f.write("#define MAJOR_VERSION\t\"" + numbers["sw_major"] + "\"\n") + else: + f.write("#define MAJOR_VERSION\t\"unknown\"\n") + if numbers.has_key("sw_minor"): + f.write("#define MINOR_VERSION\t\"" + numbers["sw_minor"] + "\"\n") + else: + f.write("#define MINOR_VERSION\t\"unknown\"\n") + f.write("\n#endif /* VERSION_H */\n") + f.close() + +def main(argv): + numbers = get_current_numbers() + generate_include(numbers) + +if __name__ == "__main__": + main(argv[1:]) + diff --git a/source/scripts/release_number.py b/source/scripts/release_number.py new file mode 100755 index 0000000..77a2630 --- /dev/null +++ b/source/scripts/release_number.py @@ -0,0 +1,43 @@ +#!/usr/bin/python2 +from sys import argv, exit +from getopt import getopt +from re import match, sub +import os + +def get_current_numbers(): + config = {} + if os.environ.has_key("SW_KERNEL"): + config["sw_kernel"] = os.environ["SW_KERNEL"] + if os.environ.has_key("SW_MAJOR"): + config["sw_major"] = os.environ["SW_MAJOR"] + if os.environ.has_key("SW_MINOR"): + config["sw_minor"] = os.environ["SW_MINOR"] + return config + +def generate_include(numbers): + f = open("../firmware/version.h", "w") + f.write("/* Release number include file */\n\n") + f.write("#ifndef VERSION_H\n") + f.write("#define VERSION_H\n\n") + if numbers.has_key("sw_kernel"): + f.write("#define KERNEL_VERSION\t\"" + numbers["sw_kernel"] + "\"\n") + else: + f.write("#define KERNEL_VERSION\t\"unknown\"\n") + if numbers.has_key("sw_major"): + f.write("#define MAJOR_VERSION\t\"" + numbers["sw_major"] + "\"\n") + else: + f.write("#define MAJOR_VERSION\t\"unknown\"\n") + if numbers.has_key("sw_minor"): + f.write("#define MINOR_VERSION\t\"" + numbers["sw_minor"] + "\"\n") + else: + f.write("#define MINOR_VERSION\t\"unknown\"\n") + f.write("\n#endif /* VERSION_H */\n") + f.close() + +def main(argv): + numbers = get_current_numbers() + generate_include(numbers) + +if __name__ == "__main__": + main(argv[1:]) + From 09e73017d84f562d5beaade8523834c23e8bbf0e Mon Sep 17 00:00:00 2001 From: tkl Date: Mon, 1 Aug 2016 13:39:10 +0200 Subject: [PATCH 02/10] error - wrong path - corrected --- source/scripts/release_number.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/scripts/release_number.py b/source/scripts/release_number.py index 77a2630..44c235d 100755 --- a/source/scripts/release_number.py +++ b/source/scripts/release_number.py @@ -15,7 +15,7 @@ def get_current_numbers(): return config def generate_include(numbers): - f = open("../firmware/version.h", "w") + f = open("source/firmware/version.h", "w") f.write("/* Release number include file */\n\n") f.write("#ifndef VERSION_H\n") f.write("#define VERSION_H\n\n") From dc3ee9f2b9afdbe5def10c93d7c1394d9c1dc37c Mon Sep 17 00:00:00 2001 From: tkl Date: Mon, 1 Aug 2016 13:44:50 +0200 Subject: [PATCH 03/10] test var's --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c7eda7a..9a9a85d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: SW_KERNEL: "0" SW_MAJOR: "0" - SW_MINOR: "0" + SW_MINOR: "255" before_script: From 99cff149b7dabba760395f45c3f55f05d71211f2 Mon Sep 17 00:00:00 2001 From: tkl Date: Mon, 1 Aug 2016 14:05:39 +0200 Subject: [PATCH 04/10] numbering... --- Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 415207d..1bff59b 100755 --- a/Makefile +++ b/Makefile @@ -1,13 +1,16 @@ -############################################################## -# -############################################################## - include config/make/rules.mk OS_NAME = kosmos -MAINFILE = $(EXE_DIR)/lib$(OS_NAME)-$(ARCH)-$(BOARD)$(DBG_EXT)$(LIB_EXT) -DEPLOY_PACKET = lib$(OS_NAME)-$(ARCH)-$(BOARD)-$()$(DBG_EXT).tar.gz +# version numbering deployed by ci deploy script - no necessary for local build +ifdef $(SW_KERNEL) +VERSION := -$(SW_KERNEL).$(SW_MAJOR).$(SW_MINOR)- +else +VERSION := +endif + +MAINFILE = $(EXE_DIR)/lib$(OS_NAME)-$(ARCH)-$(BOARD)$(VERSION)$(DBG_EXT)$(LIB_EXT) +DEPLOY_PACKET = lib$(OS_NAME)-$(ARCH)-$(BOARD)$(VERSION)$(DBG_EXT).tar.xz INCLUDES += $(SRC_DIR) @@ -30,17 +33,14 @@ ASMSOURCES += $(foreach folder, $(SUB_FOLDER), $(wildcard $(ROOT_DIR)/$(folder)/ all: check $(MAINFILE) deploy: all - echo $(SW_KERNEL) - echo $(SW_MAJOR) - echo $(SW_MINOR) @$(MKDIR) $(EXE_DIR)/include $(SRC_DIR)/scripts/board_interface.py -b "$(SRC_DIR)/firmware/arch/$(CPU)/board/$(BOARD)/include/$(BOARD).h" -o "$(EXE_DIR)/include/board_devices.h" $(SRC_DIR)/scripts/stack_interface.py -i "$(SRC_DIR)/firmware/arch/$(CPU)/include/$(CPU)_stack.h" -o "$(EXE_DIR)/include/stack.h" cp $(SRC_DIR)/firmware/kernel/interface/*.* $(EXE_DIR)/include/ + tar cvJf $(DEPLOY_PACKET) -C $(EXE_DIR) . + echo $(DEPLOY_PACKET) check: - echo $(CHECK_FOLDER) - echo $(CHECKSOURCES) $(CPPCHECK) $(CPPCHECK_FLAGS) $(CHECKSOURCES) From c0dd4782d6cc9bb9ee895dd683c5a19e08f604b2 Mon Sep 17 00:00:00 2001 From: tkl Date: Mon, 1 Aug 2016 14:12:17 +0200 Subject: [PATCH 05/10] error - numbering var's --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1bff59b..266039c 100755 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ include config/make/rules.mk OS_NAME = kosmos # version numbering deployed by ci deploy script - no necessary for local build -ifdef $(SW_KERNEL) +ifdef SW_KERNEL VERSION := -$(SW_KERNEL).$(SW_MAJOR).$(SW_MINOR)- else VERSION := From 28d82dddc4e2af860b62cdfff6853872609325c9 Mon Sep 17 00:00:00 2001 From: tkl Date: Mon, 1 Aug 2016 14:57:32 +0200 Subject: [PATCH 06/10] change var name --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 266039c..345882c 100755 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ OS_NAME = kosmos # version numbering deployed by ci deploy script - no necessary for local build ifdef SW_KERNEL -VERSION := -$(SW_KERNEL).$(SW_MAJOR).$(SW_MINOR)- +VERSION := -$(SW_KERNEL).$(SW_MAJOR).$(SW_MINOR) else VERSION := endif From 022a38921dcae48ad06f1940f19e25650a43767c Mon Sep 17 00:00:00 2001 From: tkl Date: Mon, 1 Aug 2016 14:57:52 +0200 Subject: [PATCH 07/10] deploying artifacts --- .gitlab-ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a9a85d..d72c792 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: SW_KERNEL: "0" SW_MAJOR: "0" - SW_MINOR: "255" + SW_MINOR: "1" before_script: @@ -27,10 +27,18 @@ check_job: stage: check deploy_job: + stage: deploy script: - "source/scripts/release_number.py" - "make deploy BOARD=stm32f4-discovery" - stage: deploy + artifacts: + paths: + - *.xs + only: + - /^release/.*$/ + except: + - tags + #test_job: # script: From 0b7807c7d35d3a950a256f7d56c51e7da5d0e99e Mon Sep 17 00:00:00 2001 From: tkl Date: Mon, 1 Aug 2016 15:17:12 +0200 Subject: [PATCH 08/10] ci deploy... --- .gitlab-ci.yml | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d72c792..8819028 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,39 +35,5 @@ deploy_job: paths: - *.xs only: - - /^release/.*$/ - except: - tags - -#test_job: -# script: -# - "make install APP=test BOARD=stm32f4-discovery" -# stage: test - -#int_release_job: -# script: -# - "cd top_agricola/core" -# - "./generate_ci_makefile.py" -# - "make -f Makefile_ci.gen all" -# - "cd ci" -# - "./deploy_release.py -t rc" -# stage: deploy -# only: -# - /^release/.*$/ -# except: -# - tags - -#ext_release_job: -# script: -# - "cd top_agricola/core" -# - "./generate_ci_makefile.py" -# - "make -f Makefile_ci.gen all" -# - "cd ci" -# - "./deploy_release.py -t r" -# stage: deploy -# only: -# - /^release/174_AG.*$/ -# except: -# - branches - From 5c5061f224d7aa646194a7a0a6f25922fb5a3863 Mon Sep 17 00:00:00 2001 From: tkl Date: Mon, 1 Aug 2016 15:23:54 +0200 Subject: [PATCH 09/10] cleanup makefile --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 345882c..d874baa 100755 --- a/Makefile +++ b/Makefile @@ -38,7 +38,6 @@ deploy: all $(SRC_DIR)/scripts/stack_interface.py -i "$(SRC_DIR)/firmware/arch/$(CPU)/include/$(CPU)_stack.h" -o "$(EXE_DIR)/include/stack.h" cp $(SRC_DIR)/firmware/kernel/interface/*.* $(EXE_DIR)/include/ tar cvJf $(DEPLOY_PACKET) -C $(EXE_DIR) . - echo $(DEPLOY_PACKET) check: $(CPPCHECK) $(CPPCHECK_FLAGS) $(CHECKSOURCES) From d5ebd4b5afb85fe816f33c352109990db051a771 Mon Sep 17 00:00:00 2001 From: tkl Date: Mon, 1 Aug 2016 15:55:35 +0200 Subject: [PATCH 10/10] syntax in deploy script --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8819028..80ffa55 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,6 @@ variables: SW_MAJOR: "0" SW_MINOR: "1" - before_script: - "echo $CI_BUILD_ID" - "echo $CI_BUILD_REF_NAME" @@ -33,7 +32,7 @@ deploy_job: - "make deploy BOARD=stm32f4-discovery" artifacts: paths: - - *.xs + - ./*.xz only: - tags