]> git.saurik.com Git - wxWidgets.git/blobdiff - build/tools/build-wxwidgets.py
Dispatch unknown messages immediately in wxMSW YieldFor().
[wxWidgets.git] / build / tools / build-wxwidgets.py
index b2d80884067994bc5bcfe7d5fb057cde7c27411c..a0866e4b2cc02f4547cb546c64a5be4c7ad13caa 100755 (executable)
@@ -55,6 +55,12 @@ def numCPUs():
     return 1 # Default
 
 
+def getXcodePath():
+    p = subprocess.Popen("xcode-select -print-path", shell=True, stdout=subprocess.PIPE)
+    output = p.stdout.read()
+    return output.strip()
+
+
 def exitIfError(code, msg):
     if code != 0:
         print msg
@@ -174,6 +180,7 @@ def main(scriptName, args):
         "mac_framework" : (False, "Install the Mac build as a framework"),
         "mac_framework_prefix" 
                         : (defFwPrefix, "Prefix where the framework should be installed. Default: %s" % defFwPrefix),
+        "cairo"         : (False, "Enable dynamicly loading the Cairo lib for wxGraphicsContext on MSW"),
         "no_config"     : (False, "Turn off configure step on autoconf builds"),
         "config_only"   : (False, "Only run the configure step and then exit"),
         "rebake"        : (False, "Regenerate Bakefile and autoconf files"),
@@ -182,7 +189,6 @@ def main(scriptName, args):
         "cocoa"         : (False, "Build the old Mac Cooca port."),
         "osx_cocoa"     : (False, "Build the new Cocoa port"),
         "shared"        : (False, "Build wx as a dynamic library"),
-        "cairo"         : (False, "Build support for wxCairoContext (always true on GTK+)"),
         "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."),
         "verbose"       : (False, "Print commands as they are run, (to aid with debugging this script)"),
@@ -260,13 +266,21 @@ def main(scriptName, args):
         # developer.  TODO: there should be a command line option to set
         # the SDK...
         if sys.platform.startswith("darwin"):
+            xcodePath = getXcodePath()
+            sdks = [
+                xcodePath+"/SDKs/MacOSX10.5.sdk",
+                xcodePath+"/SDKs/MacOSX10.6.sdk",
+                xcodePath+"/SDKs/MacOSX10.7.sdk",
+            ]
             if not options.osx_cocoa:
-                wxpy_configure_opts.append(
-                    "--with-macosx-sdk=/Developer/SDKs/MacOSX10.4u.sdk")
-            else:
-                wxpy_configure_opts.append(
-                    "--with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk")
-
+                sdks.insert(0, xcodePath+"/SDKs/MacOSX10.4u.sdk")
+            
+            # use the lowest available sdk
+            for sdk in sdks:
+                if os.path.exists(sdk):
+                    wxpy_configure_opts.append(
+                        "--with-macosx-sdk=%s" % sdk)
+                    break
 
         if not options.mac_framework:
             if installDir and not prefixDir:
@@ -306,6 +320,13 @@ def main(scriptName, args):
             # plus the framework specific dir structure.
             prefixDir = getPrefixInFramework(options)
             configure_opts.append("--prefix=" + prefixDir)
+            
+            # the framework build adds symlinks above the installDir + prefixDir folder
+            # so we need to wipe from the framework root instead of inside the prefixDir.
+            frameworkRootDir = os.path.abspath(os.path.join(installDir + prefixDir, "..", ".."))
+            if os.path.exists(frameworkRootDir):
+                if os.path.exists(frameworkRootDir):
+                    shutil.rmtree(frameworkRootDir)
 
         if options.mac_universal_binary: 
             configure_opts.append("--enable-universal_binary")
@@ -336,6 +357,8 @@ def main(scriptName, args):
                 flags["wxUSE_UNICODE_MSLU"] = "1"
     
         if options.cairo:
+            if not os.environ.get("CAIRO_ROOT"):
+                print "WARNING: Expected CAIRO_ROOT set in the environment!"
             flags["wxUSE_CAIRO"] = "1"
     
         if options.wxpython:
@@ -354,7 +377,7 @@ def main(scriptName, args):
 
             if VERSION >= (2,9):
                 flags["wxUSE_UIACTIONSIMULATOR"] = "1"
-                
+
     
         mswIncludeDir = os.path.join(wxRootDir, "include", "wx", "msw")
         setup0File = os.path.join(mswIncludeDir, "setup0.h")
@@ -389,6 +412,14 @@ def main(scriptName, args):
                     args.append("BUILD=release")
                 else:
                     args.append("BUILD=debug")
+                   
+            if options.shared:
+                args.append("SHARED=1")
+
+            if options.cairo:
+                args.append(
+                    "CPPFLAGS=/I%s" %
+                     os.path.join(os.environ.get("CAIRO_ROOT", ""), 'include\\cairo'))
     
             wxBuilder = builder.MSVCBuilder()
             
@@ -409,34 +440,22 @@ def main(scriptName, args):
     
     if options.clean:
         print "Performing cleanup."
-        wxBuilder.clean()
-        
-        if options.wxpython:
-            exitIfError(wxBuilder.clean(os.path.join(contribDir, "gizmos")), "Error building gizmos")
-            exitIfError(wxBuilder.clean(os.path.join(contribDir, "stc")), "Error building stc")
+        wxBuilder.clean(dir=buildDir, options=args)
         
         sys.exit(0)
 
     if options.extra_make:
         args.append(options.extra_make)
      
-    args.append("--jobs=" + options.jobs)
+    if not sys.platform.startswith("win"):
+        args.append("--jobs=" + options.jobs)
     exitIfError(wxBuilder.build(dir=buildDir, options=args), "Error building")
-    
-    if options.wxpython and os.path.exists(contribDir):
-        exitIfError(wxBuilder.build(os.path.join(contribDir, "gizmos"), options=args), "Error building gizmos")
-        exitIfError(wxBuilder.build(os.path.join(contribDir, "stc"),options=args), "Error building stc")
         
     if options.install:
         extra=None
         if installDir:
             extra = ['DESTDIR='+installDir]
-        wxBuilder.install(dir=buildDir, options=extra) 
-        
-        if options.wxpython and os.path.exists(contribDir):
-            exitIfError(wxBuilder.install(os.path.join(contribDir, "gizmos"), options=extra), "Error building gizmos")
-            exitIfError(wxBuilder.install(os.path.join(contribDir, "stc"), options=extra), "Error building stc")
-            
+        wxBuilder.install(dir=buildDir, options=extra)             
             
     if options.install and options.mac_framework:
     
@@ -464,17 +483,33 @@ def main(scriptName, args):
 
         fwname = getFrameworkName(options)
         version = commands.getoutput("bin/wx-config --release")
+        version_full = commands.getoutput("bin/wx-config --version")
         basename = commands.getoutput("bin/wx-config --basename")
         configname = commands.getoutput("bin/wx-config --selected-config")
-
-        run("ln -s -f bin Resources")
+        
+        os.makedirs("Resources")
+        wxplist = dict(
+            CFBundleDevelopmentRegion="English",
+            CFBundleIdentifier='org.wxwidgets.wxosxcocoa',
+            CFBundleName=fwname,
+            CFBundleVersion=version_full,
+            CFBundleExecutable=fwname,
+            CFBundleGetInfoString="%s %s" % (fwname, version_full),
+            CFBundlePackageType="FMWK",
+            CFBundleSignature="WXCO",
+            CFBundleShortVersionString=version_full,
+            CFBundleInfoDictionaryVersion="6.0",
+        )
+        
+        import plistlib
+        plistlib.writePlist(wxplist, os.path.join(frameworkRootDir, "Resources", "Info.plist"))
         
         # 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
         renameLibrary("lib/lib%s-%s.dylib" % (basename, version), fwname)
         run("ln -s -f lib/%s.dylib %s" % (fwname, fwname))
         
-        run("ln -s -f include/wx Headers")
+        run("ln -s -f include Headers")
         
         for lib in ["GL", "STC", "Gizmos", "Gizmos_xrc"]:  
             libfile = "lib/lib%s_%s-%s.dylib" % (basename, lib.lower(), version)
@@ -504,17 +539,19 @@ def main(scriptName, args):
         headers = ""
         header_dir = "wx-%s/wx" % version
         for include in glob.glob(header_dir + "/*.h"):
-            headers += "wx/" + os.path.basename(include) + "\n"
+            headers += "#include <wx/" + os.path.basename(include) + ">\n"
             
-        framework_header = open("wx.h", "w")
+        framework_header = open("%s.h" % fwname, "w")
         framework_header.write(header_template % headers)
         framework_header.close()
         
         run("ln -s -f %s wx" % header_dir)
-        run("ln -s -f ../../../lib/wx/include/%s/wx/setup.h wx/setup.h" % configname)
+        os.chdir("wx-%s/wx" % version)
+        run("ln -s -f ../../../lib/wx/include/%s/wx/setup.h setup.h" % configname)
         
-        os.chdir(os.path.join(frameworkRootDir, "..", ".."))
-        run("ln -s -f %s Versions/Current" % getWxRelease())
+        os.chdir(os.path.join(frameworkRootDir, ".."))
+        run("ln -s -f %s Current" % getWxRelease())
+        os.chdir("..")
         run("ln -s -f Versions/Current/Headers Headers")
         run("ln -s -f Versions/Current/Resources Resources")
         run("ln -s -f Versions/Current/%s %s" % (fwname, fwname))
@@ -562,7 +599,7 @@ def main(scriptName, args):
         os.makedirs(packagedir)
         basename = os.path.basename(prefixDir.split(".")[0])
         packageName = basename + "-" + getWxRelease()
-        packageMakerPath = "/Developer/usr/bin/packagemaker "
+        packageMakerPath = getXcodePath()+"/usr/bin/packagemaker "
         args = []
         args.append("--root %s" % options.installdir)
         args.append("--id org.wxwidgets.%s" % basename.lower())
@@ -579,8 +616,6 @@ def main(scriptName, args):
         
         shutil.rmtree(packagedir)
         
-        
-        
 if __name__ == '__main__':
     exitWithException = False  # use sys.exit instead
     main(sys.argv[0], sys.argv[1:])