[PATCH] Allow to set optimization level during configure.
Christian Mauderer
christian.mauderer at embedded-brains.de
Mon Oct 2 07:57:04 UTC 2017
From: Christian Mauderer <Christian.Mauderer at embedded-brains.de>
This allows to set the optimization level for libbsd via a configure
switch. Useful for building with for example no optimization during
debug or with size optimization for space restricted targets.
---
builder.py | 3 +--
libbsd_waf.py | 2 +-
waf_generator.py | 1 +
wscript | 6 ++++++
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/builder.py b/builder.py
index b62f79dc..ae2e6eee 100755
--- a/builder.py
+++ b/builder.py
@@ -156,8 +156,7 @@ class diffRecord:
# This stuff needs to move to libbsd.py.
#
def commonFlags():
- return ['-O2',
- '-g',
+ return ['-g',
'-fno-strict-aliasing',
'-ffreestanding',
'-fno-common']
diff --git a/libbsd_waf.py b/libbsd_waf.py
index a2f581f7..02e87038 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -34,7 +34,7 @@ def configure(conf):
def build(bld):
# C/C++ flags
common_flags = []
- common_flags += ["-O2"]
+ common_flags += ["-O" + bld.env.OPTIMIZATION]
common_flags += ["-g"]
common_flags += ["-fno-strict-aliasing"]
common_flags += ["-ffreestanding"]
diff --git a/waf_generator.py b/waf_generator.py
index a482623a..3a315979 100755
--- a/waf_generator.py
+++ b/waf_generator.py
@@ -371,6 +371,7 @@ class ModuleManager(builder.ModuleManager):
self.add('def build(bld):')
self.add(' # C/C++ flags')
self.add(' common_flags = []')
+ self.add(' common_flags += ["-O%s" % (bld.env.OPTIMIZATION)]')
for f in builder.commonFlags():
self.add(' common_flags += ["%s"]' % (f))
self.add(' if bld.env.WARNINGS:')
diff --git a/wscript b/wscript
index 7088eab3..25a5f85c 100644
--- a/wscript
+++ b/wscript
@@ -68,6 +68,11 @@ def options(opt):
default = "",
dest = "freebsd_options",
help = "Set FreeBSD options (developer option).")
+ opt.add_option("--optimization",
+ action = "store",
+ default = "2",
+ dest = "optimization",
+ help = "Set optimization level (-On compiler flag). Default ist 2.")
libbsd_waf.options(opt)
def bsp_configure(conf, arch_bsp):
@@ -88,6 +93,7 @@ def configure(conf):
conf.env.WARNINGS = conf.options.warnings
conf.env.NET_CONFIG = conf.options.net_config
conf.env.FREEBSD_OPTIONS =conf.options.freebsd_options
+ conf.env.OPTIMIZATION = conf.options.optimization
rtems.configure(conf, bsp_configure)
libbsd_waf.configure(conf)
--
2.12.3
More information about the devel
mailing list