From 7da04766a392dbe6700fcd8a2a29fc59b8e3d0d8 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 25 Sep 2016 23:57:43 +0200 Subject: [PATCH] docs +xcode6 bugfix: do not merge env variables of type dictionary into PROJ_SETTINGS config --- playground/xcode6/src/test.cpp | 6 +++++- playground/xcode6/wscript | 12 +++++++++++- waflib/extras/xcode6.py | 12 ++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/playground/xcode6/src/test.cpp b/playground/xcode6/src/test.cpp index 35ae7eac..44c057f3 100644 --- a/playground/xcode6/src/test.cpp +++ b/playground/xcode6/src/test.cpp @@ -1,9 +1,13 @@ #include #include "MyLib/TestClass.h" +#include "config.h" int main(int argc, char const *argv[]) { TestClass a; - std::cout << a.message(); + std::cout << a.message() << std::endl; + std::cout << "Number should be 10: " << NUMBER << std::endl; + + return 0; } \ No newline at end of file diff --git a/playground/xcode6/wscript b/playground/xcode6/wscript index d6a3cac9..11db85eb 100644 --- a/playground/xcode6/wscript +++ b/playground/xcode6/wscript @@ -12,15 +12,24 @@ This demo will create an XCode project containing an App bundle target, a dynamic library target, a static library target and an executable target. The generated XCode project can then be opened -and XCode can build those targets. +and XCode can then build those targets. Tested in XCode 6 & 7. """ def configure(conf): + + # Use environment variables to set default project configuration + # settings conf.env.FRAMEWORK_VERSION = '1.0' conf.env.ARCHS = 'x86_64' conf.env.INSTALL_PATH = '/my/install/path' + # The xcode6 tool will also pick up any c config files generated by + # the c_config tool, and it'll be added to your project's include path + conf.load('c_config') + conf.define('NUMBER', 10) + conf.write_config_header('config.h') + # This must be called at the end of configure() conf.load('xcode6') @@ -53,6 +62,7 @@ def build(bld): uselib='SDL2', cxxflags='-O3', framework='Cocoa', + # Override default setting in a target settings={"Debug": {"CONFIG_NAME": 'Debug'}} ) diff --git a/waflib/extras/xcode6.py b/waflib/extras/xcode6.py index b1516492..79cc129b 100644 --- a/waflib/extras/xcode6.py +++ b/waflib/extras/xcode6.py @@ -124,6 +124,13 @@ TARGET_TYPES = { 'exe' :TARGET_TYPE_EXECUTABLE, } +def delete_invalid_values(dct): + """ Deletes entries that are dictionaries or sets """ + for k, v in list(dct.items()): + if isinstance(v, dict) or isinstance(v, set): + del dct[k] + return dct + """ Configuration of the global project settings. Sets an environment variable 'PROJ_CONFIGURATION' which is a dictionary of configuration name and buildsettings pair. @@ -151,9 +158,10 @@ def configure(self): # Create default project configuration? if 'PROJ_CONFIGURATION' not in self.env: + defaults = delete_invalid_values(self.env.get_merged_dict()) self.env.PROJ_CONFIGURATION = { - "Debug": self.env.get_merged_dict(), - "Release": self.env.get_merged_dict(), + "Debug": defaults, + "Release": defaults, } # Some build settings are required to be present by XCode. We will supply default values