forked from OpenAstroTech/OpenAstroTracker-Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre_script_custom_defines.py
37 lines (32 loc) · 1.37 KB
/
pre_script_custom_defines.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
35
36
37
Import("env")
import platform
extra_macros = {
# PP indirection needed
'DO_PRAGMA_(x)': '_Pragma(#x)',
'DO_PRAGMA(x)': 'DO_PRAGMA_(x)',
# Useful for disabling warnings on system headers that we don't care about
'PUSH_NO_WARNINGS': ''.join([
'DO_PRAGMA(GCC diagnostic push);',
'DO_PRAGMA(GCC diagnostic ignored "-Wconversion");',
'DO_PRAGMA(GCC diagnostic ignored "-Wdouble-promotion");',
'DO_PRAGMA(GCC diagnostic ignored "-Wshadow");',
'DO_PRAGMA(GCC diagnostic ignored "-Wsign-conversion");',
'DO_PRAGMA(GCC diagnostic ignored "-Wsign-compare");',
'DO_PRAGMA(GCC diagnostic ignored "-Wignored-qualifiers");',
'DO_PRAGMA(GCC diagnostic ignored "-Wuseless-cast");',
'DO_PRAGMA(GCC diagnostic ignored "-Wunknown-pragmas");',
'DO_PRAGMA(GCC diagnostic ignored "-Wall");',
'DO_PRAGMA(GCC diagnostic ignored "-Wextra");',
'DO_PRAGMA(GCC diagnostic ignored "-Wpedantic");',
]),
'POP_NO_WARNINGS': 'DO_PRAGMA(GCC diagnostic pop);'
}
def escape_str(s):
if 'windows' not in platform.system().lower():
# This stuff breaks windows builds
if ' ' not in s:
s = s.replace('(', '\\(')
s = s.replace(')', '\\)')
s = s.replace('"', '\\"')
return s
env.Append(CPPDEFINES={escape_str(k): escape_str(v) for k, v in extra_macros.items()})