Fix popen2 deprecation warning.

Fix binary name inside the framework to be the same as the framework name.
Inject a bit of info about the framework into wx-config, so it can output framework flags/names instead of lib flags/names.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67650 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2011-04-29 20:03:45 +00:00
parent 783d8c1131
commit b4f28d1ef6
2 changed files with 40 additions and 9 deletions

View File

@@ -15,6 +15,7 @@ import optparse
import platform import platform
import shutil import shutil
import types import types
import subprocess
# builder object # builder object
wxBuilder = None wxBuilder = None
@@ -43,7 +44,9 @@ def numCPUs():
if isinstance(ncpus, int) and ncpus > 0: if isinstance(ncpus, int) and ncpus > 0:
return ncpus return ncpus
else: # OSX: else: # OSX:
return int(os.popen2("sysctl -n hw.ncpu")[1].read()) p = subprocess.Popen("sysctl -n hw.ncpu", shell=True, stdout=subprocess.PIPE)
return p.stdout.read()
# Windows: # Windows:
if os.environ.has_key("NUMBER_OF_PROCESSORS"): if os.environ.has_key("NUMBER_OF_PROCESSORS"):
ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]); ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]);
@@ -182,6 +185,7 @@ def main(scriptName, args):
"cairo" : (False, "Build support for wxCairoContext (always true on GTK+)"), "cairo" : (False, "Build support for wxCairoContext (always true on GTK+)"),
"extra_make" : ("", "Extra args to pass on [n]make's command line."), "extra_make" : ("", "Extra args to pass on [n]make's command line."),
"features" : ("", "A comma-separated list of wxUSE_XYZ defines on Win, or a list of configure flags on unix."), "features" : ("", "A comma-separated list of wxUSE_XYZ defines on Win, or a list of configure flags on unix."),
"verbose" : (False, "Print commands as they are run, (to aid with debugging this script)"),
} }
parser = optparse.OptionParser(usage="usage: %prog [options]", version="%prog 1.0") parser = optparse.OptionParser(usage="usage: %prog [options]", version="%prog 1.0")
@@ -197,7 +201,11 @@ def main(scriptName, args):
help=option_dict[opt][1]) help=option_dict[opt][1])
options, arguments = parser.parse_args(args=args) options, arguments = parser.parse_args(args=args)
global verbose
if options.verbose:
verbose = True
# compiler / build system specific args # compiler / build system specific args
buildDir = options.builddir buildDir = options.builddir
args = [] args = []
@@ -454,6 +462,7 @@ def main(scriptName, args):
if options.debug: if options.debug:
build_string = "d" build_string = "d"
fwname = getFrameworkName(options)
version = commands.getoutput("bin/wx-config --release") version = commands.getoutput("bin/wx-config --release")
basename = commands.getoutput("bin/wx-config --basename") basename = commands.getoutput("bin/wx-config --basename")
configname = commands.getoutput("bin/wx-config --selected-config") configname = commands.getoutput("bin/wx-config --selected-config")
@@ -462,8 +471,8 @@ def main(scriptName, args):
# we make wx the "actual" library file and link to it from libwhatever.dylib # we make wx the "actual" library file and link to it from libwhatever.dylib
# so that things can link to wx and survive minor version changes # so that things can link to wx and survive minor version changes
renameLibrary("lib/lib%s-%s.dylib" % (basename, version), "wx") renameLibrary("lib/lib%s-%s.dylib" % (basename, version), fwname)
run("ln -s -f lib/wx.dylib wx") run("ln -s -f lib/%s.dylib %s" % (fwname, fwname))
run("ln -s -f include/wx Headers") run("ln -s -f include/wx Headers")
@@ -481,7 +490,7 @@ def main(scriptName, args):
corelibname = "lib/lib%s-%s.0.dylib" % (basename, version) corelibname = "lib/lib%s-%s.0.dylib" % (basename, version)
run("install_name_tool -id %s %s" % (os.path.join(prefixDir, lib), lib)) run("install_name_tool -id %s %s" % (os.path.join(prefixDir, lib), lib))
run("install_name_tool -change %s %s %s" % (os.path.join(frameworkRootDir, corelibname), os.path.join(prefixDir, corelibname), lib)) run("install_name_tool -change %s %s %s" % (os.path.join(frameworkRootDir, corelibname), os.path.join(prefixDir, corelibname), lib))
os.chdir("include") os.chdir("include")
header_template = """ header_template = """
@@ -508,16 +517,26 @@ def main(scriptName, args):
run("ln -s -f %s Versions/Current" % getWxRelease()) run("ln -s -f %s Versions/Current" % getWxRelease())
run("ln -s -f Versions/Current/Headers Headers") run("ln -s -f Versions/Current/Headers Headers")
run("ln -s -f Versions/Current/Resources Resources") run("ln -s -f Versions/Current/Resources Resources")
run("ln -s -f Versions/Current/wx wx") run("ln -s -f Versions/Current/%s %s" % (fwname, fwname))
# sanity check to ensure the symlink works # sanity check to ensure the symlink works
os.chdir("Versions/Current") os.chdir("Versions/Current")
os.chdir("../..")
# put info about the framework into wx-config
os.chdir(frameworkRootDir)
text = file('lib/wx/config/%s' % configname).read()
text = text.replace("MAC_FRAMEWORK=", "MAC_FRAMEWORK=%s" % getFrameworkName(options))
if options.mac_framework_prefix not in ['/Library/Frameworks',
'/System/Library/Frameworks']:
text = text.replace("MAC_FRAMEWORK_PREFIX=",
"MAC_FRAMEWORK_PREFIX=%s" % options.mac_framework_prefix)
file('lib/wx/config/%s' % configname, 'w').write(text)
# The framework is finished!
print "wxWidgets framework created at: " + \ print "wxWidgets framework created at: " + \
os.path.join( installDir, os.path.join( installDir,
options.mac_framework_prefix, options.mac_framework_prefix,
'%s.framework' % getFrameworkName(options)) '%s.framework' % fwname)
# adjust the install_name if needed # adjust the install_name if needed

View File

@@ -245,6 +245,9 @@ check_yesno_option()
} }
MAC_FRAMEWORK=
MAC_FRAMEWORK_PREFIX=
# Now we are ready to find out what the user wants from us. # Now we are ready to find out what the user wants from us.
# -------------------------------------------------------------- # --------------------------------------------------------------
@@ -1263,6 +1266,15 @@ if [ -n "$output_option_libs" ]; then
[ "x$libdir" = "x/usr/lib" ] || [ "x$libdir" = "x/usr/lib" ] ||
_ldflags="-L$libdir" _ldflags="-L$libdir"
if [ -n "$MAC_FRAMEWORK" ]; then
wx_libs="-framework $MAC_FRAMEWORK"
if [ -n "$MAC_FRAMEWORK_PREFIX" ]; then
_ldflags="-F$MAC_FRAMEWORK_PREFIX"
else
_ldflags=""
fi
fi
is_installed || [ -n "$flag_option_no_rpath" ] || _rpath="@WXCONFIG_RPATH@" is_installed || [ -n "$flag_option_no_rpath" ] || _rpath="@WXCONFIG_RPATH@"
echo $_ldflags "@WXCONFIG_LDFLAGS@" $_rpath $wx_libs "@DMALLOC_LIBS@" echo $_ldflags "@WXCONFIG_LDFLAGS@" $_rpath $wx_libs "@DMALLOC_LIBS@"