diff --git a/.github/workflows/run.yaml b/.github/workflows/run.yaml index b49ac5a..fa75f90 100644 --- a/.github/workflows/run.yaml +++ b/.github/workflows/run.yaml @@ -11,6 +11,6 @@ jobs: submodules: true - name: install dependencies run: sudo apt install gcc-arm-none-eabi qemu-system - - name: Make all + - name: Make all and run run: | make -j$(nproc) run \ No newline at end of file diff --git a/.github/workflows/standalone.yaml b/.github/workflows/standalone.yaml new file mode 100644 index 0000000..d4ec5d9 --- /dev/null +++ b/.github/workflows/standalone.yaml @@ -0,0 +1,19 @@ +name: Package standalone artifacts and build +on: + pull_request: + branches: [ "main" ] +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: install dependencies + run: sudo apt install gcc-arm-none-eabi qemu-system + - name: Package standalone artificats + run: | + make -j$(nproc) standalone + - name: Make sure all standalone artifacts build + run: | + for standlone in standalone/*; do make -C $standalone; done \ No newline at end of file diff --git a/.gitignore b/.gitignore index 954f187..a0c61b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ **/build/ **/*.elf +standalone diff --git a/Makefile b/Makefile index fcd689d..d9a678e 100644 --- a/Makefile +++ b/Makefile @@ -3,16 +3,18 @@ include tests/ntt_dilithium/ntt_dilithium.mk include tests/ntt_kyber/ntt_kyber.mk totestname = $(shell echo $(1) | tr '[a-z]' '[A-Z]') -totestsources = $(addprefix ../../tests/$(1)/,$($(call totestname,$(1))_SOURCES)) -totestasm = $(addprefix ../../tests/$(1)/,$($(call totestname,$(1))_ASMS)) +totestsources = $(addprefix $(2),$(addprefix tests/$(1)/,$($(call totestname,$(1))_SOURCES))) +totestasm = $(addprefix $(2),$(addprefix tests/$(1)/,$($(call totestname,$(1))_ASMS))) +totestother = $(addprefix $(2),$(addprefix tests/$(1)/,$($(call totestname,$(1))_OTHER))) toplatform = $(addsuffix --$(1),$($(call totestname,$(1))_PLATFORMS)) toelfname = $(addsuffix -test.elf,$(1)) platformtests := $(foreach test,$(TESTS), $(call toplatform,$(test))) -builds := $(addprefix build-, $(platformtests)) -runs := $(addprefix run-, $(platformtests)) -cleans := $(addprefix clean-, $(platformtests)) +builds := $(addprefix build-, $(platformtests)) +runs := $(addprefix run-, $(platformtests)) +cleans := $(addprefix clean-, $(platformtests)) +standalones := $(addprefix standalone-, $(platformtests)) .PHONY: all all: ${builds} @@ -20,21 +22,31 @@ all: ${builds} platform = $(firstword $(subst --, ,$*)) test = $(lastword $(subst --, ,$*)) - .PHONY: ${builds} ${builds}: build-%: - make -j$(shell nproc) -C envs/$(platform) build SOURCES='$(call totestsources,$(test))' ASMS='$(call totestasm,$(test))' TARGET=$(call toelfname,$(test)) + make -j$(shell nproc) -C envs/$(platform) build SOURCES='$(call totestsources,$(test),../../)' ASMS='$(call totestasm,$(test),../../)' TARGET=$(call toelfname,$(test)) .PHONY: ${runs} ${runs}: run-%: - make -C envs/$(platform) run SOURCES='$(call totestsources,$(test))' ASMS='$(call totestasm,$(test))' TARGET=$(call toelfname,$(test)) + make -C envs/$(platform) run SOURCES='$(call totestsources,$(test),../../)' ASMS='$(call totestasm,$(test),../../)' TARGET=$(call toelfname,$(test)) .PHONY: run run: ${runs} +.PHONY: ${standalones} +${standalones}: standalone-%: + make -C envs/$(platform) clean + mkdir -p standalone/$@/test_src/ + cp -rL envs/$(platform)/* standalone/$@/ + cp -rL $(call totestsources,$(test),./) $(call totestasm,$(test),./) $(call totestother,$(test),./) standalone/$@/test_src/ + +.PHONY: standalone +standalone: ${standalones} + .PHONY: ${cleans} ${cleans}: clean-%: make -C envs/$(platform) clean .PHONY: clean clean: ${cleans} + rm -rf standalone diff --git a/envs/m55-an547/Makefile b/envs/m55-an547/Makefile index 8478183..0d2110a 100644 --- a/envs/m55-an547/Makefile +++ b/envs/m55-an547/Makefile @@ -1,12 +1,17 @@ # Makefile for images for AN547 +# default values (when not called from the root Makefile - used in standalone artifacts) +TARGET ?= test.elf +SOURCES ?= $(wildcard test_src/*.c) +ASMS ?= $(wildcard test_src/*.s) + CC = arm-none-eabi-gcc LD := $(CC) SRC_DIR=./src BUILD_DIR=./build -COMMON_INC=../common/inc/ +COMMON_INC=common/inc/ ENV_INC=./inc/ SYSROOT := $(shell $(CC) --print-sysroot) @@ -49,7 +54,7 @@ LDFLAGS += \ all: $(TARGET) -HAL_SOURCES = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*/*.c) $(wildcard ../common/src/*.c) +HAL_SOURCES = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*/*.c) $(wildcard common/src/*.c) OBJECTS_HAL = $(patsubst %.c, $(BUILD_DIR)/%.c.o, $(abspath $(HAL_SOURCES))) OBJECTS_SOURCES=$(patsubst %.c, $(BUILD_DIR)/%.c.o, $(abspath $(SOURCES))) OBJECTS_C = $(OBJECTS_SOURCES) $(OBJECTS_HAL) diff --git a/envs/m55-an547/common b/envs/m55-an547/common new file mode 120000 index 0000000..60d3b0a --- /dev/null +++ b/envs/m55-an547/common @@ -0,0 +1 @@ +../common \ No newline at end of file diff --git a/envs/m85-an555/Makefile b/envs/m85-an555/Makefile index 6f4c6cf..b4adaa1 100644 --- a/envs/m85-an555/Makefile +++ b/envs/m85-an555/Makefile @@ -1,12 +1,17 @@ # Makefile for images for AN555 +# default values (when not called from the root Makefile - used in standalone artifacts) +TARGET ?= test.elf +SOURCES ?= $(wildcard test_src/*.c) +ASMS ?= $(wildcard test_src/*.s) + CC = arm-none-eabi-gcc LD := $(CC) SRC_DIR=./src BUILD_DIR=./build -COMMON_INC=../common/inc/ +COMMON_INC=common/inc/ ENV_INC=./inc/ SYSROOT := $(shell $(CC) --print-sysroot) @@ -49,7 +54,7 @@ LDFLAGS += \ all: $(TARGET) -HAL_SOURCES = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*/*.c) $(wildcard ../common/src/*.c) +HAL_SOURCES = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*/*.c) $(wildcard common/src/*.c) OBJECTS_HAL = $(patsubst %.c, $(BUILD_DIR)/%.c.o, $(abspath $(HAL_SOURCES))) OBJECTS_SOURCES=$(patsubst %.c, $(BUILD_DIR)/%.c.o, $(abspath $(SOURCES))) OBJECTS_C = $(OBJECTS_SOURCES) $(OBJECTS_HAL) diff --git a/envs/m85-an555/common b/envs/m85-an555/common new file mode 120000 index 0000000..8332399 --- /dev/null +++ b/envs/m85-an555/common @@ -0,0 +1 @@ +../common/ \ No newline at end of file diff --git a/tests/ntt_dilithium/ntt_dilithium.mk b/tests/ntt_dilithium/ntt_dilithium.mk index fd3261f..e3702ec 100644 --- a/tests/ntt_dilithium/ntt_dilithium.mk +++ b/tests/ntt_dilithium/ntt_dilithium.mk @@ -1,10 +1,16 @@ +# Test name - needs to match the directory name TESTS += ntt_dilithium +# All further variables must be prefixed with the capitalized test name + +# Platforms this test should run on (matching the directory name in envs/) NTT_DILITHIUM_PLATFORMS += m55-an547 NTT_DILITHIUM_PLATFORMS += m85-an555 +# C sources required for this test NTT_DILITHIUM_SOURCES += main.c +# Assembly sources required for this test NTT_DILITHIUM_ASM_DIR = ../../asm/manual/ntt_dilithium NTT_DILITHIUM_ASMS += $(NTT_DILITHIUM_ASM_DIR)/ntt_dilithium_12_34_56_78_no_trans_vld4_opt_m55.s NTT_DILITHIUM_ASMS += $(NTT_DILITHIUM_ASM_DIR)/ntt_dilithium_12_34_56_78_no_trans_vld4_opt_m85.s @@ -14,4 +20,8 @@ NTT_DILITHIUM_ASMS += $(NTT_DILITHIUM_ASM_DIR)/ntt_dilithium_12_34_56_78_opt_m85 NTT_DILITHIUM_ASMS += $(NTT_DILITHIUM_ASM_DIR)/ntt_dilithium_12_34_56_78.s NTT_DILITHIUM_ASMS += $(NTT_DILITHIUM_ASM_DIR)/ntt_dilithium_123_456_78_opt_size_m55.s NTT_DILITHIUM_ASMS += $(NTT_DILITHIUM_ASM_DIR)/ntt_dilithium_123_456_78_opt_size_m85.s -NTT_DILITHIUM_ASMS += $(NTT_DILITHIUM_ASM_DIR)/ntt_dilithium_123_456_78.s \ No newline at end of file +NTT_DILITHIUM_ASMS += $(NTT_DILITHIUM_ASM_DIR)/ntt_dilithium_123_456_78.s + +# Additional required files (needed for packaging a standalone artifact) +NTT_DILITHIUM_OTHER += $(NTT_DILITHIUM_ASM_DIR)/ntt_dilithium_12_34_56_78_twiddles.s +NTT_DILITHIUM_OTHER += $(NTT_DILITHIUM_ASM_DIR)/ntt_dilithium_123_456_78_twiddles.s diff --git a/tests/ntt_kyber/ntt_kyber.mk b/tests/ntt_kyber/ntt_kyber.mk index 14af270..f9f32e8 100644 --- a/tests/ntt_kyber/ntt_kyber.mk +++ b/tests/ntt_kyber/ntt_kyber.mk @@ -1,10 +1,16 @@ +# Test name - needs to match the directory name TESTS += ntt_kyber +# All further variables must be prefixed with the capitalized test name + +# Platforms this test should run on (matching the directory name in envs/) NTT_KYBER_PLATFORMS += m55-an547 NTT_KYBER_PLATFORMS += m85-an555 +# C sources required for this test NTT_KYBER_SOURCES += main.c +# Assembly sources required for this test NTT_KYBER_ASM_DIR=../../asm/manual/ntt_kyber NTT_KYBER_ASMS += $(NTT_KYBER_ASM_DIR)/ntt_kyber_1_23_45_67_no_trans_opt_m55.s NTT_KYBER_ASMS += $(NTT_KYBER_ASM_DIR)/ntt_kyber_1_23_45_67_no_trans_opt_m85.s @@ -14,4 +20,8 @@ NTT_KYBER_ASMS += $(NTT_KYBER_ASM_DIR)/ntt_kyber_1_23_45_67_no_trans_vld4.s NTT_KYBER_ASMS += $(NTT_KYBER_ASM_DIR)/ntt_kyber_1_23_45_67_no_trans.s NTT_KYBER_ASMS += $(NTT_KYBER_ASM_DIR)/ntt_kyber_12_345_67_opt_size_m55.s NTT_KYBER_ASMS += $(NTT_KYBER_ASM_DIR)/ntt_kyber_12_345_67_opt_size_m85.s -NTT_KYBER_ASMS += $(NTT_KYBER_ASM_DIR)/ntt_kyber_12_345_67.s \ No newline at end of file +NTT_KYBER_ASMS += $(NTT_KYBER_ASM_DIR)/ntt_kyber_12_345_67.s + +# Additional required files (needed for packaging a standalone artifact) +NTT_KYBER_OTHER += $(NTT_KYBER_ASM_DIR)/ntt_kyber_1_23_45_67_twiddles.s +NTT_KYBER_OTHER += $(NTT_KYBER_ASM_DIR)/ntt_kyber_12_345_67_twiddles.s