Skip to content

Commit b865569

Browse files
committed
setup: better deal with compiler flags
- honor environment variable PYXMLSEC_OPTIMIZE_SIZE to switch between speed and size optimization - enabled by default for backward compatibility - better deal with compiler flags for different platforms Signed-off-by: Konstantin Demin <rockdrilla@gmail.com>
1 parent 1563947 commit b865569

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

setup.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def run(self):
8686
ext = self.ext_map['xmlsec']
8787
self.debug = os.environ.get('PYXMLSEC_ENABLE_DEBUG', False)
8888
self.static = os.environ.get('PYXMLSEC_STATIC_DEPS', False)
89+
self.size_opt = os.environ.get('PYXMLSEC_OPTIMIZE_SIZE', True)
8990

9091
if self.static or sys.platform == 'win32':
9192
self.info('starting static build on {}'.format(sys.platform))
@@ -153,11 +154,18 @@ def run(self):
153154
)
154155

155156
if self.debug:
156-
ext.extra_compile_args.append('-Wall')
157-
ext.extra_compile_args.append('-O0')
158157
ext.define_macros.append(('PYXMLSEC_ENABLE_DEBUG', '1'))
158+
if sys.platform == 'win32':
159+
ext.extra_compile_args.append('/Od')
160+
else:
161+
ext.extra_compile_args.append('-Wall')
162+
ext.extra_compile_args.append('-O0')
159163
else:
160-
ext.extra_compile_args.append('-Os')
164+
if self.size_opt:
165+
if sys.platform == 'win32':
166+
ext.extra_compile_args.append('/Os')
167+
else:
168+
ext.extra_compile_args.append('-Os')
161169

162170
super(build_ext, self).run()
163171

0 commit comments

Comments
 (0)