From e35c48442cda73a4db9ee9fe072b9533bc54bb33 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 16 Apr 2019 20:04:16 -0700 Subject: [PATCH 1/3] Unset CC and CXX in MSVC builds, if set --- buildtools/config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/buildtools/config.py b/buildtools/config.py index 8b872343..35b1e4ca 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -195,6 +195,12 @@ class Configuration(object): ] self.lflags = None + # These confuse WAF, but since it already reliably picks the correct + # MSVC it shouldn't hurt to get rid of them. + for name in ['CC', 'CXX']: + if os.environ.get(name): + os.environ.pop(name) + # Other MSVC flags... # Uncomment these to have debug info for all kinds of builds #self.cflags += ['/Od', '/Z7'] From 229e4db424b87722b6c92ccb25033ea7c39c324f Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 16 Apr 2019 20:32:45 -0700 Subject: [PATCH 2/3] Use the custom check_python_headers on Darwin too --- wscript | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wscript b/wscript index a50904d1..3575c4f2 100644 --- a/wscript +++ b/wscript @@ -92,9 +92,11 @@ def configure(conf): conf.env.PYTHON = conf.options.python conf.load('python') conf.check_python_version(minver=(2,7,0)) - if isWindows: + if isWindows or isDarwin: # Search for the Python headers without doing some stuff that could - # incorrectly fail on Windows. See my_check_python_headers below. + # incorrectly fail on Windows. Seems to help on Darwin too. See + # my_check_python_headers below. + # TODO: Check if it can/should be used on other platforms too. conf.my_check_python_headers() else: conf.check_python_headers() From e9b2b6ef0a3dc82bdd96e87b6452c06b6c37f9fb Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 16 Apr 2019 21:35:08 -0700 Subject: [PATCH 3/3] Enable wxPython's build to check results of wxWidgets configuration --- CHANGES.rst | 4 ++++ buildtools/config.py | 28 ++++++++++++++++++++++++++++ wscript | 9 ++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index ce3fb3c9..a14fb627 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -36,6 +36,10 @@ Changes in this release include the following: * Updated sip to version 4.19.16. +* Added helper functions to check results of wxWidgets configure during the + build of wxPython. Currently used to determine if the wx webview library + should be added to the link command. (#1138) + diff --git a/buildtools/config.py b/buildtools/config.py index 35b1e4ca..7066e8d1 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -576,6 +576,34 @@ class Configuration(object): return newLFLAGS + def checkSetup(self, build_dir, flag): + """ + Find the setup.h generated by wxWidgets and return True if the given + flag (eg. "wxUSE_WEBKIT") is enabled. + """ + def _find_setup(): + for dirpath, dirnames, filenames in os.walk(build_dir): + for name in filenames: + if name == 'setup.h': + return opj(dirpath, name) + return None + + setup = _find_setup() + with open(setup, 'rt') as f: + for line in f: + if flag in line: + return '1' in line.split() + return False + + + def findWxConfigDir(self, wx_config): + output = runcmd(wx_config + " --cflags", getOutput=True, echoCmd=False) + # We expect that the first -I flag is the path we're looking for here + configDir = output.split()[0] + assert configDir.startswith('-I') + configDir = configDir[2:] + return configDir + # We'll use a factory function so we can use the Configuration class as a singleton _config = None diff --git a/wscript b/wscript index 3575c4f2..89961a3a 100644 --- a/wscript +++ b/wscript @@ -183,6 +183,9 @@ def configure(conf): else: + # TODO: Double-check that this works when using an installed wxWidgets + wxConfigDir = cfg.findWxConfigDir(conf.options.wx_config) + # Configuration stuff for non-Windows ports using wx-config conf.env.CFLAGS_WX = list() conf.env.CXXFLAGS_WX = list() @@ -223,8 +226,12 @@ def configure(conf): uselib_store='WXGL', mandatory=True, msg='Finding libs for WXGL') + if cfg.checkSetup(wxConfigDir, 'wxUSE_WEBVIEW'): + wv_libs = '--libs webview,core,net' + else: + wv_libs = '--libs core,net' conf.check_cfg(path=conf.options.wx_config, package='', - args='--cxxflags --libs webview,core,net' + rpath, + args='--cxxflags ' + wv_libs + rpath, uselib_store='WXWEBVIEW', mandatory=True, msg='Finding libs for WXWEBVIEW')