Skip to content

Commit 2e06a5f

Browse files
bigbrettdanielinux
authored andcommitted
Refactor Makefiles to allow overriding library dependency paths
1 parent 94c6b78 commit 2e06a5f

File tree

11 files changed

+412
-276
lines changed

11 files changed

+412
-276
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Test External Library Paths
2+
3+
on:
4+
push:
5+
branches: [ 'master', 'main', 'release/**' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test_external_libs:
12+
runs-on: ubuntu-latest
13+
14+
# Matrix to test multiple configurations
15+
strategy:
16+
matrix:
17+
test-config:
18+
- name: "External wolfSSL"
19+
config: "config/examples/sim.config"
20+
21+
- name: "External wolfTPM"
22+
config: "config/examples/sim-tpm.config"
23+
build-tpm-tools: true
24+
25+
- name: "external wolfHSM"
26+
config: "config/examples/sim-wolfHSM-client.config"
27+
28+
- name: "Unit tests"
29+
config: ""
30+
is-unit-test: true
31+
32+
fail-fast: false
33+
34+
steps:
35+
# Checkout wolfBoot with submodules
36+
- uses: actions/checkout@v4
37+
with:
38+
submodules: true
39+
40+
# Move libraries outside the wolfBoot tree
41+
- name: Relocate libraries to external path
42+
run: |
43+
echo "=== Moving libraries outside wolfBoot tree ==="
44+
mv lib ../external-libs
45+
ls -la ../external-libs/
46+
echo "Libraries moved to ../external-libs"
47+
48+
# Select configuration (skip for unit tests)
49+
- name: Select config
50+
if: matrix.test-config.config != ''
51+
run: |
52+
cp ${{ matrix.test-config.config }} .config
53+
echo "=== Selected config: ${{ matrix.test-config.name }} ==="
54+
55+
# Build TPM tools if needed
56+
- name: Build TPM tools with external paths
57+
if: matrix.test-config.build-tpm-tools == true
58+
run: |
59+
echo "=== Building TPM tools with external paths ==="
60+
make tpmtools \
61+
WOLFBOOT_LIB_WOLFSSL=$(realpath ../external-libs/wolfssl) \
62+
WOLFBOOT_LIB_WOLFTPM=$(realpath ../external-libs/wolfTPM)
63+
64+
# Build main target (skip for unit tests)
65+
- name: Build wolfBoot with external library paths
66+
if: matrix.test-config.is-unit-test != true
67+
run: |
68+
echo "=== Building wolfBoot with external paths ==="
69+
make clean
70+
make \
71+
WOLFBOOT_LIB_WOLFSSL="$(realpath ../external-libs/wolfssl)" \
72+
WOLFBOOT_LIB_WOLFTPM="$(realpath ../external-libs/wolfTPM)" \
73+
WOLFBOOT_LIB_WOLFPKCS11="$(realpath ../external-libs/wolfPKCS11)" \
74+
WOLFBOOT_LIB_WOLFHSM="$(realpath ../external-libs/wolfHSM)"
75+
76+
# If building unit tests, install libcheck
77+
- name: install libcheck
78+
if: matrix.test-config.is-unit-test == true
79+
run: sudo apt-get install --no-install-recommends -y -q check
80+
81+
82+
# Build unit tests with external paths
83+
- name: Build unit tests with external library paths
84+
if: matrix.test-config.is-unit-test == true
85+
run: |
86+
echo "=== Building unit tests with external paths ==="
87+
make -C tools/unit-tests \
88+
WOLFBOOT_LIB_WOLFSSL="$(realpath ../external-libs/wolfssl)" \
89+
WOLFBOOT_LIB_WOLFPKCS11="$(realpath ../external-libs/wolfPKCS11)"

Makefile

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ ifneq ("$(NO_LOADER)","1")
5959
OBJS+=./src/loader.o
6060
endif
6161

62+
## Library Path Configuration
63+
# Default paths for wolf* submodules - can be overridden with absolute or relative paths
64+
# Convert all paths to absolute paths for consistent handling across sub-makefiles
65+
WOLFBOOT_LIB_WOLFSSL?=lib/wolfssl
66+
WOLFBOOT_LIB_WOLFTPM?=lib/wolfTPM
67+
WOLFBOOT_LIB_WOLFPKCS11?=lib/wolfPKCS11
68+
WOLFBOOT_LIB_WOLFHSM?=lib/wolfHSM
69+
70+
# Convert to absolute paths using abspath function
71+
WOLFBOOT_LIB_WOLFSSL:=$(abspath $(WOLFBOOT_LIB_WOLFSSL))
72+
WOLFBOOT_LIB_WOLFTPM:=$(abspath $(WOLFBOOT_LIB_WOLFTPM))
73+
WOLFBOOT_LIB_WOLFPKCS11:=$(abspath $(WOLFBOOT_LIB_WOLFPKCS11))
74+
WOLFBOOT_LIB_WOLFHSM:=$(abspath $(WOLFBOOT_LIB_WOLFHSM))
75+
76+
# Export variables so they are available to sub-makefiles
77+
export WOLFBOOT_LIB_WOLFSSL
78+
export WOLFBOOT_LIB_WOLFTPM
79+
export WOLFBOOT_LIB_WOLFPKCS11
80+
export WOLFBOOT_LIB_WOLFHSM
81+
6282
## Architecture/CPU configuration
6383
include arch.mk
6484

@@ -70,7 +90,7 @@ OBJS+=$(PUBLIC_KEY_OBJS)
7090
OBJS+=$(WOLFHSM_OBJS)
7191

7292
CFLAGS+= \
73-
-I"." -I"include/" -I"lib/wolfssl" \
93+
-I"." -I"include/" -I"$(WOLFBOOT_LIB_WOLFSSL)" \
7494
-Wno-array-bounds \
7595
-D"WOLFSSL_USER_SETTINGS" \
7696
-D"WOLFTPM_USER_SETTINGS"
@@ -364,8 +384,8 @@ keys: $(PRIVATE_KEY)
364384

365385
clean:
366386
$(Q)rm -f src/*.o hal/*.o hal/spi/*.o test-app/*.o src/x86/*.o
367-
$(Q)rm -f lib/wolfssl/wolfcrypt/src/*.o lib/wolfTPM/src/*.o lib/wolfTPM/hal/*.o lib/wolfTPM/examples/pcr/*.o
368-
$(Q)rm -f lib/wolfssl/wolfcrypt/src/port/Renesas/*.o
387+
$(Q)rm -f $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/*.o $(WOLFBOOT_LIB_WOLFTPM)/src/*.o $(WOLFBOOT_LIB_WOLFTPM)/hal/*.o $(WOLFBOOT_LIB_WOLFTPM)/examples/pcr/*.o
388+
$(Q)rm -f $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/Renesas/*.o
369389
$(Q)rm -f wolfboot.bin wolfboot.elf wolfboot.map test-update.rom wolfboot.hex
370390
$(Q)rm -f $(MACHINE_OBJ) $(MAIN_TARGET) $(LSCRIPT)
371391
$(Q)rm -f $(OBJS)

0 commit comments

Comments
 (0)