Skip to content

Commit 062ccf0

Browse files
committed
GH-14: build: Add helper.mk to setup system
It has been tested on debian but might work elsewhere (ie: WSL2 users) Testing on cloud should be enabled in separate commit Bug-SiliconLabs: UIC-3082 Bug-GitHub: #3 Forwarded: SiliconLabs#14 Signed-off-by: Philippe Coval <[email protected]>
1 parent 637599d commit 062ccf0

File tree

1 file changed

+130
-0
lines changed

1 file changed

+130
-0
lines changed

helper.mk

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/make -f
2+
# -*- makefile -*-
3+
# ex: set tabstop=4 noexpandtab:
4+
# -*- coding: utf-8 -*
5+
6+
default: help zpc/default
7+
@echo "$@: TODO: Support more than $^ by default"
8+
@date -u
9+
10+
SELF?=${CURDIR}/helper.mk
11+
12+
CMAKE_GENERATOR?=Ninja
13+
export CMAKE_GENERATOR
14+
15+
build_dir?=build
16+
sudo?=sudo
17+
18+
packages?=cmake ninja-build build-essential python3-full ruby clang
19+
packages+=git-lfs unp time file
20+
packages+=nlohmann-json3-dev
21+
# TODO: remove for offline build
22+
packages+=curl wget python3-pip
23+
24+
RUST_VERSION?=1.64.0
25+
export PATH := ${HOME}/.cargo/bin:${PATH}
26+
27+
zpc_exe?=${build_dir}/applications/zpc/zpc
28+
exes+=${zpc_exe}
29+
30+
help: README.md
31+
@cat $<
32+
@echo ""
33+
@echo "# Available rules at your own risk:"
34+
@grep -o '^[^ ]*:' ${SELF} | grep -v '\$$' | grep -v '^#' | grep -v '^\.'
35+
@echo ""
36+
@echo "# Environment:"
37+
@echo "# PATH=${PATH}"
38+
@echo ""
39+
40+
default/all: configure build test
41+
@date -u
42+
43+
setup/debian: docker/target_dependencies.apt
44+
cat /etc/debian_version
45+
-${sudo} apt update
46+
${sudo} apt install -y $(shell cat $<)
47+
${sudo} apt install -y ${packages}
48+
@echo "$@: TODO: Support debian stable rustc=1.63 https://tracker.debian.org/pkg/rustc"
49+
50+
setup/rust:
51+
@echo "$@: TODO: Support https://tracker.debian.org/pkg/rustup"
52+
curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain ${RUST_VERSION}
53+
cat $${HOME}/.cargo/env
54+
@echo '$@: info: You might like to add ". $${HOME}/.cargo/env" to "$${HOME}/.bashrc"'
55+
-which rustc
56+
rustc --version
57+
cargo --version
58+
@echo "$@: TODO: Support stable version from https://releases.rs/ or older"
59+
60+
setup/python:
61+
@echo "$@: TODO: https://github.com/wbond/pybars3/issues/82"
62+
pip3 --version || echo "warning: Please install pip"
63+
pip3 install --break-system-packages pybars3
64+
65+
setup/debian/12: setup/debian setup/rust setup/python
66+
date -u
67+
68+
setup: setup/debian/12
69+
date -u
70+
71+
git: .git/lfs
72+
git lfs version || echo "$@: warning: Please install git-lfs"
73+
git lfs status --porcelain || git lfs install
74+
time git lfs pull
75+
git lfs update || git lfs update --force
76+
git lfs status --porcelain
77+
78+
configure: ${build_dir}/CMakeCache.txt
79+
file -E $<
80+
81+
${build_dir}/CMakeCache.txt: CMakeLists.txt ${build_pre_list}
82+
cmake -B ${build_dir}
83+
84+
build: ${build_dir}/CMakeCache.txt
85+
cmake --build ${<D} \
86+
|| cat ${build_dir}/CMakeFiles/CMakeOutput.log
87+
cmake --build ${<D}
88+
.PHONY: build
89+
90+
${build_dir}/%: build
91+
file -E "$<"
92+
93+
${exe}: build
94+
file -E $<
95+
96+
all: ${exes}
97+
file -E $<
98+
99+
test: ${build_dir}
100+
ctest --test-dir ${<}
101+
102+
zpc/configure: CMakeLists.txt
103+
cmake \
104+
-B ${build_dir} \
105+
-DBUILD_AOXPC=OFF \
106+
-DBUILD_CPCD=OFF \
107+
-DBUILD_DEV_GUI=OFF \
108+
-DBUILD_EMD=OFF \
109+
-DBUILD_EPC=OFF \
110+
-DBUILD_GMS=OFF \
111+
-DBUILD_IMAGE_PROVIDER=OFF \
112+
-DBUILD_NAL=OFF \
113+
-DBUILD_OTBR=OFF \
114+
-DBUILD_POSITIONING=OFF \
115+
-DBUILD_TESTING=ON \
116+
-DBUILD_UPTI_CAP=OFF \
117+
-DBUILD_UPTI_CAP=OFF \
118+
-DBUILD_UPTI_WRITER=OFF \
119+
-DBUILD_UPVL=OFF \
120+
-DBUILD_ZIGBEED=OFF \
121+
-DBUILD_ZIGPC=OFF
122+
123+
zpc/build: zpc/configure build
124+
@date -u
125+
126+
zpc/test: ${build_dir}/applications/zpc/components/zwave_command_classes/test/
127+
ctest --test-dir ${<}
128+
129+
zpc/default: zpc/configure zpc/build
130+
@date -u

0 commit comments

Comments
 (0)