X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5148fc8e358a2e0ae5c655b32d5d64c2cfad525e..b7e7242718abab356a303606612be6e34234ea59:/utils/wxPython/distrib/build.py diff --git a/utils/wxPython/distrib/build.py b/utils/wxPython/distrib/build.py index 1f2fd6b8e7..234d5a8cae 100755 --- a/utils/wxPython/distrib/build.py +++ b/utils/wxPython/distrib/build.py @@ -65,7 +65,7 @@ Configuration Files separate namespace which is then used later as a configuration object. This keeps the build script simple in that it doesn't have to parse anything, and the config files can be much more than just names and - values as any pretty much any python code can be executed. The global + values as pretty much any python code can be executed. The global variables set in the config namespace are what are used later as configuation values. @@ -119,7 +119,7 @@ import sys, os, string, getopt # This is really the wxPython version number, and will be placed in the # Makefiles for use with the distribution related targets. -__version__ = '2.1b3' +__version__ = '2.1.12' #---------------------------------------------------------------------------- @@ -163,9 +163,10 @@ def main(args): runClean = runClean, runUninstall = runUninstall) + err = 0 if config.readConfigFiles(args): + config.doFixups() config.makeMakefile() - err = 0 if config.runBuild: cmd = "%s -f %s" % (config.MAKE, config.MAKEFILE) @@ -188,6 +189,7 @@ def main(args): print "Running:", cmd err = os.system(cmd) + return err #---------------------------------------------------------------------------- @@ -219,7 +221,7 @@ class BuildConfig: self.VERSION = __version__ self.MODULE = '' self.SWIGFILES = [] - self.SWIGFLAGS = '-c++ -shadow -python -dnone -I$(WXPSRCDIR)' + self.SWIGFLAGS = '-c++ -shadow -python -keyword -dnone -I$(WXPSRCDIR)' self.SOURCES = [] self.PYFILES = [] self.LFLAGS = '' @@ -229,6 +231,7 @@ class BuildConfig: self.OTHERLIBS = '' self.OTHERTARGETS = '' self.OTHERINSTALLTARGETS = '' + self.OTHERUNINSTALLTARGETS = '' self.OTHERRULES = '' self.DEFAULTRULE = 'default: $(GENCODEDIR) $(TARGET)' self.PYVERSION = sys.version[:3] @@ -240,6 +243,8 @@ class BuildConfig: self.WXUSINGDLL = '1' self.OTHERDEP = '' self.WXPSRCDIR = '$(WXDIR)/utils/wxPython/src' + self.SWIGDEPS = '' + self.OTHERDEPS = '' if sys.platform == 'win32': @@ -256,6 +261,10 @@ class BuildConfig: self.RESFILE = '' self.RESRULE = '' self.OVERRIDEFLAGS = '/GX-' + self.RMCMD = '-erase ' + self.WXPSRCDIR = os.path.normpath(self.WXPSRCDIR) + self.CRTFLAG = '' + else: self.MAKE = 'make' @@ -272,8 +281,9 @@ class BuildConfig: '-I$(WXPSRCDIR)' self.LFLAGS = '-L$(WXPSRCDIR) `wx-config --libs`' self.LIBS = '-l$(HELPERLIB)' + self.RMCMD = '-rm -f ' - # **** what to do when I start supporting Motif, etc.??? + # **** What to do when I start supporting Motif, etc.??? self.GENCODEDIR = 'gtk' self.SWIGTOOLKITFLAG = '-D__WXGTK__' @@ -306,6 +316,18 @@ class BuildConfig: ' ') + #------------------------------------------------------------ + def doFixups(self): + # This is called after the config files have been evaluated + # so we can do some sanity checking... + if sys.platform != 'win32': + if not self.CCC: + print "Warning: C++ compiler not specified (CCC). Assuming c++" + self.CCC = 'c++' + if not self.CC: + print "Warning: C compiler not specified (CC). Assuming cc" + self.CC = 'cc' + #------------------------------------------------------------ def findMFValue(self, mfText, st): # Find line begining with st= and return the value @@ -325,21 +347,34 @@ class BuildConfig: for name in self.SWIGFILES: objects = objects + os.path.splitext(name)[0] + self.OBJEXT + ' ' for name in self.SOURCES: - objects = objects + os.path.splitext(name)[0] + self.OBJEXT + ' ' + obj = os.path.basename(name) + objects = objects + os.path.splitext(obj)[0] + self.OBJEXT + ' ' self.OBJECTS = splitlines(objects) # now build the text for the dependencies depends = "" for name in self.SWIGFILES: - text = '$(GENCODEDIR)/%s.cpp $(GENCODEDIR)/%s.py : %s.i\n' \ + rootname = os.path.splitext(name)[0] + text = '$(GENCODEDIR)/%s.cpp $(GENCODEDIR)/%s.py : %s.i %s\n' \ '$(TARGETDIR)\\%s.py : $(GENCODEDIR)\\%s.py\n' % \ - tuple([os.path.splitext(name)[0]] * 5) + (rootname, rootname, rootname, self.SWIGDEPS, rootname, rootname) depends = depends + text + if self.OTHERDEPS: + text = '%s%s : %s\n' % \ + (os.path.splitext(name)[0], self.OBJEXT, self.OTHERDEPS) + depends = depends + text for name in self.PYFILES: text = '$(TARGETDIR)\\%s.py : %s.py\n' % \ tuple([os.path.splitext(name)[0]] * 2) depends = depends + text + if self.OTHERDEPS: + for name in self.SOURCES: + name = os.path.basename(name) + text = '%s%s : %s\n' % \ + (os.path.splitext(name)[0], self.OBJEXT, self.OTHERDEPS) + depends = depends + text + self.DEPENDS = swapslash(depends) @@ -352,6 +387,14 @@ class BuildConfig: self.PYMODULES = splitlines(swapslash(pymodules)) + # now make a list of the python files that would need uninstalled + pycleanup = "" + for name in self.SWIGFILES: + pycleanup = pycleanup + self.makeCleanupList(name) + for name in self.PYFILES: + pycleanup = pycleanup + self.makeCleanupList(name) + self.PYCLEANUP = swapslash(pycleanup) + # finally, build the makefile if sys.platform == 'win32': @@ -369,6 +412,16 @@ class BuildConfig: print "Makefile created: ", self.MAKEFILE + + #------------------------------------------------------------ + def makeCleanupList(self, name): + st = "" + st = st + '\t%s$(TARGETDIR)\\%s.py\n' % (self.RMCMD, os.path.splitext(name)[0]) + st = st + '\t%s$(TARGETDIR)\\%s.pyc\n' % (self.RMCMD, os.path.splitext(name)[0]) + st = st + '\t%s$(TARGETDIR)\\%s.pyo\n' % (self.RMCMD, os.path.splitext(name)[0]) + return st + + #------------------------------------------------------------ def readConfigFiles(self, args): return self.processFile(self.bldCfg, 1) and \ @@ -419,6 +472,7 @@ class BuildConfig: +#---------------------------------------------------------------------------- #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- @@ -432,8 +486,8 @@ WXDIR = %(WXDIR)s VERSION = %(VERSION)s MODULE = %(MODULE)s SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s -CFLAGS = %(CFLAGS)s %(OTHERCFLAGS)s -LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s +CFLAGS = %(CFLAGS)s +LFLAGS = %(LFLAGS)s PYVERSION = %(PYVERSION)s PYPREFIX = %(PYPREFIX)s EXECPREFIX = %(EXECPREFIX)s @@ -468,12 +522,14 @@ THREAD=-DWXP_USE_THREAD=1 NOPCH=1 -OVERRIDEFLAGS=%(OVERRIDEFLAGS)s %(OTHERCFLAGS)s -EXTRAFLAGS = %(CFLAGS)s +OVERRIDEFLAGS=%(OVERRIDEFLAGS)s +EXTRAFLAGS = $(CFLAGS) %(OTHERCFLAGS)s LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s EXTRALIBS = %(LIBS)s %(OTHERLIBS)s +CRTFLAG=%(CRTFLAG)s + #---------------------------------------------------------------------- !include $(WXDIR)\\src\\makevc.env @@ -500,9 +556,10 @@ clean: -erase $(TARGET) -uninstall: +uninstall: %(OTHERUNINSTALLTARGETS)s -erase $(TARGETDIR)\\$(TARGET) - -erase $(PYMODULES) +%(PYCLEANUP)s + #---------------------------------------------------------------------- # implicit rule for compiling .cpp and .c files @@ -573,6 +630,13 @@ $(GENCODEDIR): #---------------------------------------------------------------------- +showflags: + @echo CPPFLAGS: + @echo $(CPPFLAGS) + @echo LFLAGS: + @echo $(LFLAGS) + + %(OTHERRULES)s ''' @@ -593,7 +657,7 @@ WXDIR = %(WXDIR)s VERSION = %(VERSION)s MODULE = %(MODULE)s SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s -CFLAGS = %(CFLAGS)s %(OTHERCFLAGS)s +CFLAGS = %(CFLAGS)s $(OPT) %(OTHERCFLAGS)s LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s LIBS = %(LIBS)s %(OTHERLIBS)s PYVERSION = %(PYVERSION)s @@ -638,12 +702,12 @@ endif install: $(TARGETDIR) $(TARGETDIR)/$(TARGET) pycfiles %(OTHERINSTALLTARGETS)s clean: - -rm -f *.o *.so *~ + -rm -f *.o *$(SO) *~ -rm -f $(TARGET) -uninstall: +uninstall: %(OTHERUNINSTALLTARGETS)s -rm -f $(TARGETDIR)/$(TARGET) - -rm -f $(PYMODULES) +%(PYCLEANUP)s #---------------------------------------------------------------------- @@ -660,12 +724,15 @@ uninstall: %%.o : $(GENCODEDIR)/%%.c $(CC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $< +ifndef NOSWIG $(GENCODEDIR)/%%.cpp : %%.i swig $(SWIGFLAGS) -c -o $@ $< $(GENCODEDIR)/%%.py : %%.i swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/tmp_wrap.cpp $< rm $(GENCODEDIR)/tmp_wrap.cpp +endif + $(TARGETDIR)/%% : %% cp -f $< $@ @@ -690,7 +757,7 @@ pycfiles : $(PYMODULES) $(TARGETDIR) : - mkdir $(TARGETDIR) + mkdir -p $(TARGETDIR) $(GENCODEDIR): mkdir $(GENCODEDIR) @@ -708,7 +775,8 @@ $(GENCODEDIR): #---------------------------------------------------------------------------- if __name__ == '__main__': - main(sys.argv) + err = main(sys.argv) + sys.exit(err) #----------------------------------------------------------------------------