Skip to content

Commit 12942e0

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 <philippe.coval@silabs.com>
1 parent 637599d commit 12942e0

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+
setup/debian: docker/target_dependencies.apt
41+
cat /etc/debian_version
42+
-${sudo} apt update
43+
${sudo} apt install -y $(shell cat $<)
44+
${sudo} apt install -y ${packages}
45+
@echo "$@: TODO: Support debian stable rustc=1.63 https://tracker.debian.org/pkg/rustc"
46+
47+
setup/rust:
48+
@echo "$@: TODO: Support https://tracker.debian.org/pkg/rustup"
49+
curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain ${RUST_VERSION}
50+
cat $${HOME}/.cargo/env
51+
@echo '$@: info: You might like to add ". $${HOME}/.cargo/env" to "$${HOME}/.bashrc"'
52+
-which rustc
53+
rustc --version
54+
cargo --version
55+
@echo "$@: TODO: Support stable version from https://releases.rs/ or older"
56+
57+
setup/python:
58+
@echo "$@: TODO: https://github.com/wbond/pybars3/issues/82"
59+
pip3 --version || echo "warning: Please install pip"
60+
pip3 install --break-system-packages pybars3
61+
62+
setup/debian/12: setup/debian setup/rust setup/python
63+
date -u
64+
65+
setup: setup/debian/12
66+
date -u
67+
68+
git: .git/lfs
69+
git lfs version || echo "$@: warning: Please install git-lfs"
70+
git lfs status --porcelain || git lfs install
71+
time git lfs pull
72+
git lfs update || git lfs update --force
73+
git lfs status --porcelain
74+
75+
configure: ${build_dir}/CMakeCache.txt
76+
file -E $<
77+
78+
${build_dir}/CMakeCache.txt: CMakeLists.txt ${build_pre_list}
79+
cmake -B ${build_dir}
80+
81+
build: ${build_dir}/CMakeCache.txt
82+
cmake --build ${<D} \
83+
|| cat ${build_dir}/CMakeFiles/CMakeOutput.log
84+
cmake --build ${<D}
85+
.PHONY: build
86+
87+
${build_dir}/%: build
88+
file -E "$<"
89+
90+
${exe}: build
91+
file -E $<
92+
93+
all: ${exes}
94+
file -E $<
95+
96+
test: ${build_dir}
97+
ctest --test-dir ${<}
98+
99+
all/default: configure build test
100+
@date -u
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)