Files
2021-01-19 20:27:42 +01:00

309 lines
12 KiB
Diff

From 201228c52908bf445d450c39e1e2630533da2878 Mon Sep 17 00:00:00 2001
From: Robin Dunn <robin@alldunn.com>
Date: Tue, 1 Dec 2020 16:18:14 -0800
Subject: [PATCH 1/2] Improve code to use the same CC and CXX as wxWidgets,
including flags that may be added on to wx's CC/CXX.
---
buildtools/config.py | 107 ++++++++++++++++++++++++++++---------------
wscript | 30 ++++++------
2 files changed, 86 insertions(+), 51 deletions(-)
diff --git a/buildtools/config.py b/buildtools/config.py
index c837e5d36..99a1a2258 100644
--- a/buildtools/config.py
+++ b/buildtools/config.py
@@ -15,6 +15,7 @@
import os
import glob
import fnmatch
+import shlex
import re
import shutil
import subprocess
@@ -195,6 +196,7 @@ def finishSetup(self, wx_config=None, debug=None):
'/EHsc',
# '/GX-' # workaround for internal compiler error in MSVC on some machines
]
+ self.cxxflags = self.cflags[:]
self.lflags = None
# These confuse WAF, but since it already reliably picks the correct
@@ -206,6 +208,7 @@ def finishSetup(self, wx_config=None, debug=None):
# Other MSVC flags...
# Uncomment these to have debug info for all kinds of builds
#self.cflags += ['/Od', '/Z7']
+ #self.cxxflags += ['/Od', '/Z7']
#self.lflags = ['/DEBUG', ]
@@ -219,13 +222,15 @@ def finishSetup(self, wx_config=None, debug=None):
self.libdirs = []
self.libs = []
- self.cflags = self.getWxConfigValue('--cxxflags')
- self.cflags = self.cflags.split()
+ self.cflags = self.getWxConfigValue('--cflags').split()
+ self.cxxflags = self.getWxConfigValue('--cxxflags').split()
if self.debug:
- self.cflags.append('-ggdb')
- self.cflags.append('-O0')
+ for lst in [self.cflags, self.cxxflags]:
+ lst.append('-ggdb')
+ lst.append('-O0')
else:
- self.cflags.append('-O3')
+ for lst in [self.cflags, self.cxxflags]:
+ lst.append('-O3')
lflags = self.getWxConfigValue('--libs')
self.MONOLITHIC = (lflags.find("_xrc") == -1)
@@ -235,9 +240,47 @@ def finishSetup(self, wx_config=None, debug=None):
self.WXRELEASE = self.getWxConfigValue('--release')
self.WXPREFIX = self.getWxConfigValue('--prefix')
+ # Set CC, CXX and maybe LDSHARED based on what was configured for
+ # wxWidgets, but not if those values are in the environment.
self.CC = self.CXX = self.LDSHARED = None
-
- # wxMac settings
+ if not os.environ.get('CC'):
+ compiler, flags = self.unpackCompilerCommand(self.getWxConfigValue('--cc'))
+ self.CC = os.environ["CC"] = compiler
+ for flag in flags:
+ if flag not in self.cflags:
+ self.cflags.insert(0, flag)
+
+ if not os.environ.get('CXX'):
+ compiler, flags = self.unpackCompilerCommand(self.getWxConfigValue('--cxx'))
+ self.CXX = os.environ["CXX"] = compiler
+ for flag in flags:
+ if flag not in self.cxxflags:
+ self.cxxflags.insert(0, flag)
+
+ if sys.platform[:6] == "darwin" and not os.environ.get('LDSHARED'):
+ # We want to use the linker command from wx to make sure
+ # we get the right sysroot, but we also need to ensure that
+ # the other linker flags that distutils wants to use are
+ # included as well.
+ LDSHARED = distutils.sysconfig.get_config_var('LDSHARED').split()
+ # remove the compiler command
+ del LDSHARED[0]
+ # remove any -sysroot flags and their arg
+ while True:
+ try:
+ index = LDSHARED.index('-isysroot')
+ # Strip this argument and the next one:
+ del LDSHARED[index:index+2]
+ except ValueError:
+ break
+ LDSHARED = ' '.join(LDSHARED)
+ # Combine with wx's ld command and stash it in the env
+ # where distutils will get it later.
+ LDSHARED = self.getWxConfigValue('--ld').replace(' -o', '') + ' ' + LDSHARED
+ self.LDSHARED = os.environ["LDSHARED"] = LDSHARED
+
+
+ # Other wxMac-only settings
if sys.platform[:6] == "darwin":
self.WXPLAT = '__WXMAC__'
@@ -247,41 +290,16 @@ def finishSetup(self, wx_config=None, debug=None):
else:
self.WXPLAT2 = '__WXOSX_COCOA__'
- self.libs = ['stdc++']
if not self.ARCH == "":
for arch in self.ARCH.split(','):
- self.cflags.append("-arch")
- self.cflags.append(arch)
+ for lst in [self.cflags, self.cxxflags]:
+ lst.append("-arch")
+ lst.append(arch)
self.lflags.append("-arch")
self.lflags.append(arch)
- if not os.environ.get('CC') or not os.environ.get('CXX'):
- self.CC = os.environ["CC"] = self.getWxConfigValue('--cc')
- self.CXX = os.environ["CXX"] = self.getWxConfigValue('--cxx')
-
- # We want to use the linker command from wx to make sure
- # we get the right sysroot, but we also need to ensure that
- # the other linker flags that distutils wants to use are
- # included as well.
- LDSHARED = distutils.sysconfig.get_config_var('LDSHARED').split()
- # remove the compiler command
- del LDSHARED[0]
- # remove any -sysroot flags and their arg
- while 1:
- try:
- index = LDSHARED.index('-isysroot')
- # Strip this argument and the next one:
- del LDSHARED[index:index+2]
- except ValueError:
- break
- LDSHARED = ' '.join(LDSHARED)
- # Combine with wx's ld command and stash it in the env
- # where distutils will get it later.
- LDSHARED = self.getWxConfigValue('--ld').replace(' -o', '') + ' ' + LDSHARED
- self.LDSHARED = os.environ["LDSHARED"] = LDSHARED
-
-
- # wxGTK settings
+
+ # wxGTK-only settings
else:
# Set flags for other Unix type platforms
if self.WXPORT == 'gtk':
@@ -296,7 +314,7 @@ def finishSetup(self, wx_config=None, debug=None):
self.WXPLAT = '__WXGTK__'
portcfg = os.popen('pkg-config gtk+-3.0 --cflags', 'r').read()[:-1]
elif self.WXPORT == 'x11':
- msg("WARNING: The wxX11 port is no supported")
+ msg("WARNING: The wxX11 port is not supported")
self.WXPLAT = '__WXX11__'
portcfg = ''
self.BUILD_BASE = self.BUILD_BASE + '-' + self.WXPORT
@@ -307,6 +325,7 @@ def finishSetup(self, wx_config=None, debug=None):
raise SystemExit("Unknown WXPORT value: " + self.WXPORT)
self.cflags += portcfg.split()
+ self.cxxflags += portcfg.split()
# Some distros (e.g. Mandrake) put libGLU in /usr/X11R6/lib, but
# wx-config doesn't output that for some reason. For now, just
@@ -318,9 +337,11 @@ def finishSetup(self, wx_config=None, debug=None):
# Move the various -I, -D, etc. flags we got from the config scripts
# into the distutils lists.
self.cflags = self.adjustCFLAGS(self.cflags, self.defines, self.includes)
+ self.cxxflags = self.adjustCFLAGS(self.cxxflags, self.defines, self.includes)
self.lflags = self.adjustLFLAGS(self.lflags, self.libdirs, self.libs)
self.cflags.insert(0, '-UNDEBUG')
+ self.cxxflags.insert(0, '-UNDEBUG')
if self.debug and self.WXPORT == 'msw' and self.COMPILER != 'mingw32':
self.defines.append( ('_DEBUG', None) )
@@ -430,6 +451,16 @@ def getWxConfigValue(self, flag):
return value
+ def unpackCompilerCommand(self, cmd):
+ """
+ It's possible for the CC and CXX values coming from wx-config to have
+ some extra parameters tacked on. Let's split them apart.
+ """
+ cmd = shlex.split(cmd)
+ compiler = cmd[0]
+ flags = cmd[1:]
+ return compiler, flags
+
def build_locale_dir(self, destdir, verbose=1):
"""Build a locale dir under the wxPython package."""
diff --git a/wscript b/wscript
index 2eea2600a..1e143be67 100644
--- a/wscript
+++ b/wscript
@@ -125,8 +125,10 @@ def configure(conf):
conf.env.INCLUDES_WX = cfg.includes
conf.env.DEFINES_WX = cfg.wafDefines
- conf.env.CFLAGS_WX = cfg.cflags
- conf.env.CXXFLAGS_WX = cfg.cflags
+ conf.env.CFLAGS = cfg.cflags
+ conf.env.CXXFLAGS = cfg.cxxflags
+ conf.env.CFLAGS_WX = list()
+ conf.env.CXXFLAGS_WX = list()
conf.env.LIBPATH_WX = cfg.libdirs
conf.env.LIB_WX = cfg.libs
conf.env.LIBFLAGS_WX = cfg.lflags
@@ -192,20 +194,22 @@ def configure(conf):
conf.env['LIB_PYEXT'][0] += '_d'
- else:
+ else: # not isWindows
# 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()
- conf.env.CFLAGS_WXPY = list()
- conf.env.CXXFLAGS_WXPY = list()
-
- # finish configuring the Config object
+ # First finish configuring the Config object
conf.env.wx_config = conf.options.wx_config
cfg.finishSetup(conf.env.wx_config, conf.env.debug)
+ conf.env.CFLAGS = cfg.cflags[:]
+ conf.env.CXXFLAGS = cfg.cxxflags[:]
+ conf.env.CFLAGS_WX = list()
+ conf.env.CXXFLAGS_WX = list()
+ conf.env.CFLAGS_WXPY = list()
+ conf.env.CXXFLAGS_WXPY = list()
+
# Check wx-config exists and fetch some values from it
rpath = ' --no-rpath' if not conf.options.no_magic else ''
conf.check_cfg(path=conf.options.wx_config, package='',
@@ -364,14 +368,14 @@ def configure(conf):
# Some Mac-specific stuff
if isDarwin:
- conf.env.MACOSX_DEPLOYMENT_TARGET = "10.6"
+ conf.env.MACOSX_DEPLOYMENT_TARGET = "10.10"
if conf.options.mac_arch:
conf.env.ARCH_WXPY = conf.options.mac_arch.split(',')
- #import pprint
- #pprint.pprint( [(k, conf.env[k]) for k in conf.env.keys()] )
-
+ # import pprint
+ # pprint.pprint( [(k, conf.env[k]) for k in conf.env.keys()] )
+ # sys.exit(0)
#
From 800e0dee756cbcd603db96d9aae431616e65844d Mon Sep 17 00:00:00 2001
From: Robin Dunn <robin@alldunn.com>
Date: Tue, 1 Dec 2020 17:46:46 -0800
Subject: [PATCH 2/2] Add changelog note
---
CHANGES.rst | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/CHANGES.rst b/CHANGES.rst
index c062f6112..0582ae31e 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -8,6 +8,24 @@
wxPython Changelog
==================
+4.1.2
+-----
+* (unreleased)
+
+PyPI: https://pypi.python.org/pypi/wxPython/4.1.2
+Extras: https://extras.wxPython.org/wxPython4/extras/
+Pip: ``pip install wxPython==4.1.2``
+
+New and improved in this release:
+
+* Tweaked the build scripts a bit to ensure that on non-Windows platforms that
+ the complier and flags used by default match those used by wxWidgets, (with
+ the flags needed by Python added on.) The compiler commands can be overridden
+ by setting CC and CXX in the environment if needed. (#1247)
+
+
+
+
4.1.1 "An attitude of gratitude"
--------------------------------
* 21-Nov-2020