Skip to content

Commit 7facce5

Browse files
committed
GH-9: 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 Forwarded: #2 Signed-off-by: Philippe Coval <[email protected]>
1 parent 637599d commit 7facce5

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

helper.mk

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/usr/bin/make -f
2+
# -*- makefile -*-
3+
# ex: set tabstop=4 noexpandtab:
4+
# -*- coding: utf-8 -*
5+
6+
default: help configure/zpc build/zpc
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+
configure/zpc: CMakeLists.txt
97+
cmake \
98+
-B ${build_dir} \
99+
-DBUILD_AOXPC=OFF \
100+
-DBUILD_CPCD=OFF \
101+
-DBUILD_DEV_GUI=OFF \
102+
-DBUILD_EMD=OFF \
103+
-DBUILD_EPC=OFF \
104+
-DBUILD_GMS=OFF \
105+
-DBUILD_IMAGE_PROVIDER=OFF \
106+
-DBUILD_NAL=OFF \
107+
-DBUILD_OTBR=OFF \
108+
-DBUILD_POSITIONING=OFF \
109+
-DBUILD_TESTING=ON \
110+
-DBUILD_UPTI_CAP=OFF \
111+
-DBUILD_UPTI_CAP=OFF \
112+
-DBUILD_UPTI_WRITER=OFF \
113+
-DBUILD_UPVL=OFF \
114+
-DBUILD_ZIGBEED=OFF \
115+
-DBUILD_ZIGPC=OFF
116+
117+
build/zpc: configure/zpc build
118+
@date -u
119+
120+
test/zpc: ${build_dir}/applications/zpc/components/zwave_command_classes/test/
121+
ctest --test-dir ${<}
122+
123+
test: ${build_dir}
124+
ctest --test-dir ${<}
125+

0 commit comments

Comments
 (0)