aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-05-22 12:10:30 -0400
committerJack Lloyd <[email protected]>2019-05-22 12:10:30 -0400
commitfc342d791d387af408bb3a008fa89e2eb662da35 (patch)
treec34eff3ff64e2a262d959dd3a09964e80b72f451
parent7be91937f8f276071189f9bae3520f13a1c34e2b (diff)
parentd49da8b0abc8fedf8dbc0d58ca391a3d5a7f6791 (diff)
Merge GH #1960 Add option for setting arbitrary macros during build
-rwxr-xr-xconfigure.py8
-rw-r--r--doc/manual/building.rst7
-rw-r--r--src/build-data/cc/msvc.txt1
3 files changed, 16 insertions, 0 deletions
diff --git a/configure.py b/configure.py
index e38144ad9..0bd487845 100755
--- a/configure.py
+++ b/configure.py
@@ -420,6 +420,9 @@ def process_command_line(args): # pylint: disable=too-many-locals,too-many-state
build_group.add_option('--with-external-libdir', metavar='DIR', default=[],
help='use DIR for external libs', action='append')
+ build_group.add_option('--define-build-macro', metavar='DEFINE', default=[],
+ help='set compile-time pre-processor definition like KEY[=VALUE]', action='append')
+
build_group.add_option('--with-sysroot-dir', metavar='DIR', default='',
help='use DIR for system root while cross-compiling')
@@ -1086,6 +1089,7 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
'output_to_exe': '-o ',
'add_include_dir_option': '-I',
'add_lib_dir_option': '-L',
+ 'add_compile_definition_option': '-D',
'add_sysroot_option': '',
'add_lib_option': '-l',
'add_framework_option': '-framework ',
@@ -1112,6 +1116,7 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
self.add_include_dir_option = lex.add_include_dir_option
self.add_lib_dir_option = lex.add_lib_dir_option
self.add_lib_option = lex.add_lib_option
+ self.add_compile_definition_option = lex.add_compile_definition_option
self.add_sysroot_option = lex.add_sysroot_option
self.ar_command = lex.ar_command
self.ar_options = lex.ar_options
@@ -1354,6 +1359,9 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
if options.extra_cxxflags:
yield options.extra_cxxflags
+ for definition in options.define_build_macro:
+ yield self.add_compile_definition_option + definition
+
return (' '.join(gen_flags(with_debug_info, enable_optimizations))).strip()
@staticmethod
diff --git a/doc/manual/building.rst b/doc/manual/building.rst
index 23c3f72c5..6ae9b9af5 100644
--- a/doc/manual/building.rst
+++ b/doc/manual/building.rst
@@ -728,6 +728,13 @@ define multiple additional include directories.
Add DIR to the link path. Provide this parameter multiple times to define
multiple additional library link directories.
+--define-build-macro
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Set a compile-time pre-processor definition (i.e. add a -D... to the compiler
+invocations). Provide this parameter multiple times to add multiple compile-time
+definitions. Both KEY=VALUE and KEY (without specific value) are supported.
+
--with-sysroot-dir=DIR
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/build-data/cc/msvc.txt b/src/build-data/cc/msvc.txt
index cb2ef304e..2306a4485 100644
--- a/src/build-data/cc/msvc.txt
+++ b/src/build-data/cc/msvc.txt
@@ -8,6 +8,7 @@ output_to_exe "/OUT:"
add_include_dir_option "/I"
add_lib_dir_option "/LIBPATH:"
+add_compile_definition_option "/D"
add_lib_option ""
compile_flags "/nologo /c"