| 1 |
From: YOKOTA Hiroshi <[email protected]> |
| 2 |
Date: Sat, 23 Nov 2019 17:48:46 +0900 |
| 3 |
Subject: Hardening Qt code |
| 4 |
|
| 5 |
Forwarded: not-needed |
| 6 |
|
| 7 |
Allow hardening flags from debhelper. |
| 8 |
--- |
| 9 |
setup/build.py | 13 +++++++++++++ |
| 10 |
1 file changed, 13 insertions(+) |
| 11 |
|
| 12 |
diff --git a/setup/build.py b/setup/build.py |
| 13 |
index 486249d..3d43f02 100644 |
| 14 |
--- a/setup/build.py |
| 15 |
+++ b/setup/build.py |
| 16 |
@@ -267,6 +267,10 @@ def init_env(debug=False, sanitize=False, compiling_for='native'): |
| 17 |
base_cflags = shlex.split(os.environ.get('CFLAGS', '')) |
| 18 |
base_cxxflags = shlex.split(os.environ.get('CXXFLAGS', '')) |
| 19 |
base_ldflags = shlex.split(os.environ.get('LDFLAGS', '')) |
| 20 |
+ |
| 21 |
+ base_cflags += shlex.split(os.environ.get('CPPFLAGS', '')) |
| 22 |
+ base_cxxflags += shlex.split(os.environ.get('CPPFLAGS', '')) |
| 23 |
+ |
| 24 |
cflags += base_cflags |
| 25 |
ldflags += base_ldflags |
| 26 |
cflags += ['-fvisibility=hidden'] |
| 27 |
@@ -773,6 +777,15 @@ sip-file = {os.path.basename(sipf)!r} |
| 28 |
cwd = os.getcwd() |
| 29 |
try: |
| 30 |
os.chdir(os.path.join(src_dir, 'build')) |
| 31 |
+ for q in walk('.'): |
| 32 |
+ if os.path.basename(q) in ('Makefile',): |
| 33 |
+ with open(q, 'r+') as f: |
| 34 |
+ raw = f.read() |
| 35 |
+ raw = raw.replace('CFLAGS =', 'CFLAGS = ' + os.environ.get('CFLAGS', '') + ' ' + os.environ.get('CPPFLAGS', '')) |
| 36 |
+ raw = raw.replace('CXXFLAGS =', 'CXXFLAGS = ' + os.environ.get('CXXFLAGS', '') + ' ' + os.environ.get('CPPFLAGS', '')) |
| 37 |
+ raw = raw.replace('LFLAGS =', 'LFLAGS = ' + os.environ.get('LDFLAGS', '')) |
| 38 |
+ f.seek(0), f.truncate() |
| 39 |
+ f.write(raw) |
| 40 |
env = os.environ.copy() |
| 41 |
if is_macos_universal_build: |
| 42 |
env['ARCHS'] = 'x86_64 arm64' |