-
Notifications
You must be signed in to change notification settings - Fork 209
/
prebuild.py
34 lines (31 loc) · 1.28 KB
/
prebuild.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
Import("env")
# XXX __file__ does not work here.
dir_path = Dir('.').abspath
src_filter = []
env.Replace(SRC_FILTER=src_filter)
src_defined = False
if 'BUILD_FLAGS' in env:
build_flags = env.ParseFlags(env['BUILD_FLAGS'])
cppdefines = build_flags.get("CPPDEFINES")
if "LIGHT_WS2812_AVR" in cppdefines:
# pure C without arduino
env.Append(SRC_FILTER=["+<light_ws2812_AVR/Light_WS2812/*.c>", "light_ws2812_AVR/Light_WS2812/*.h", "light_ws2812_AVR/*.h"])
# there is no way to change src_dir. without the following, the compiler
# would look for the header files in root directory of the library.
env.Append(CPPPATH=[
os.path.join(dir_path, "light_ws2812_AVR", "Light_WS2812")
])
src_defined = True
elif "LIGHT_APA102_AVR" in cppdefines:
env.Append(SRC_FILTER=["+<light_apa102_AVR/Light_apa102/*.c>", "light_apa102_AVR/Light_apa102/*.h"])
env.Append(CPPPATH=[
os.path.join(dir_path, "light_apa102_AVR", "Light_apa102")
])
src_defined = True
if not src_defined:
# defaults to arduino
env.Append(SRC_FILTER=["+<light_ws2812_Arduino/light_WS2812/*>"])
env.Append(CPPPATH=[
os.path.join(dir_path, "light_ws2812_Arduino", "light_WS2812")
])