[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] gen-make-modular.patch

From: Brandon Ehle <behle_at_pipedreaminteractive.com>
Date: 2002-12-13 17:16:56 CET

Here's the first patch for the windows project file generation.

* autogen.sh: Pass -c in front of build.conf when running gen-make.py

* gen-make.py, build/gen_make.py: Make gen-make.py modular so that we
  can add the windows project file generation targets.

* build/gen_base.py: Remove obsoleted MSVC stuff

http://fishbowl.digitalbytes.net:81/svn/scripts/patch/gen-make-modular.patch

Index: build/gen_base.py
===================================================================
--- build/gen_base.py (revision 4111)
+++ build/gen_base.py (working copy)
@@ -13,7 +13,7 @@
 import getversion
 
 
-__all__ = ['GeneratorBase', 'MsvcProjectGenerator']
+__all__ = ['GeneratorBase']
 
 
 class GeneratorBase:
@@ -166,22 +166,6 @@
         self.graph.add(DT_OBJECT, objname, include_deps[short][0])
 
 
-class MsvcProjectGenerator(GeneratorBase):
-
- _extension_map = {
- ('exe', 'target'): '.exe',
- ('exe', 'object'): '.obj',
- ('lib', 'target'): '.dll',
- ('lib', 'object'): '.obj',
- }
-
- def __init__(self, fname, oname):
- GeneratorBase.__init__(self, fname)
-
- def write(self):
- raise NotImplementedError
-
-
 class DependencyGraph:
   """Record dependencies between build items.
 
@@ -334,32 +318,6 @@
       else:
         raise GenError('ERROR: unknown file extension on ' + src)
 
- def write_dsp(self):
- ### we should have class attrs for template names, but I don't want
- ### to monkey this too much while somebody else is working on the
- ### .dsp generation stuff...
- if isinstance(self, TargetExe):
- template = open('build/win32/exe-template', 'rb').read()
- elif isinstance(self, TargetLib):
- template = open('build/win32/dll-template', 'rb').read()
- else:
- raise GenError('unknown build type -- cannot generate a .dsp')
-
- dsp = string.replace(template, '@NAME@', self.name)
-
- cfiles = [ ]
- for src in self._sources:
- cfiles.append('# Begin Source File\x0d\x0a'
- '\x0d\x0a'
- 'SOURCE=.\\%s\x0d\x0a'
- '# End Source File\x0d\x0a' % os.path.basename(src))
- dsp = string.replace(dsp, '@CFILES@', string.join(cfiles, ''))
-
- dsp = string.replace(dsp, '@HFILES@', '')
-
- fname = os.path.join(self.path, self.name + '.dsp-test')
- open(fname, 'wb').write(dsp)
-
   def __cmp__(self, ob):
     if isinstance(ob, Target):
       return cmp(self.name, ob.name)
Index: build/gen_make.py
===================================================================
--- build/gen_make.py (revision 4111)
+++ build/gen_make.py (working copy)
@@ -11,6 +11,7 @@
 
 
 __all__ = ['MakefileGenerator']
+generators = {'gcc-makefile':'MakefileGenerator'}
 
 
 class MakefileGenerator(gen_base.GeneratorBase):
@@ -22,9 +23,12 @@
     ('lib', 'object'): '.lo',
     }
 
- def __init__(self, fname, verfname, oname):
+ def __init__(self, fname, verfname, oname=None):
     gen_base.GeneratorBase.__init__(self, fname, verfname)
 
+ if not oname:
+ oname = os.path.splitext(os.path.basename(fname))[0] + '-outputs.mk'
+
     self.ofile = open(oname, 'w')
     self.ofile.write('# DO NOT EDIT -- AUTOMATICALLY GENERATED\n\n')
 
Index: gen-make.py
===================================================================
--- gen-make.py (revision 4111)
+++ gen-make.py (working copy)
@@ -3,49 +3,105 @@
 # gen-make.py -- generate makefiles for building Subversion
 #
 # USAGE:
-# gen-make.py [-s] [BUILD-CONFIG]
+# See ./gen-make.py -h
 #
 
 import os
 import sys
 import getopt
+import traceback
 
 
 sys.path.insert(0, 'build')
 import gen_make
 
-def main(fname, verfname=None, oname=None, skip_depends=0):
- if oname is None:
- oname = os.path.splitext(os.path.basename(fname))[0] + '-outputs.mk'
+default_build_modules = ['gen_make']
+generator_dict = {}
+
+# This doens't truly need to be here, but its possible
+# you don't have all the python modules that project files
+# require, but you don't want to build them anyway.
+def load_build_modules(list):
+ for modname in list:
+ try:
+ # Attempt to import the modules list of targets from generators variable
+ mod = __import__(modname)
+
+ for gendef in mod.generators.items():
+ # Attempt to import the modules actual target classes
+ generator_dict[gendef[0]] = getattr(mod, gendef[1])
+
+ except ImportError:
+ traceback.print_exc()
+ print>>sys.stderr, "warning: Failed to import module 'build/%s.py'." % modname
+ print>>sys.stderr, " Targets from this module will not be available."
+ print>>sys.stderr, " See the backtrace above if you wish to resolve this issue."
+ print>>sys.stderr
+
+def main(fname, targets, verfname=None, skip_depends=0):
   if verfname is None:
     verfname = os.path.join('subversion', 'include', 'svn_version.h')
- generator = gen_make.MakefileGenerator(fname, verfname, oname)
- if not skip_depends:
- generator.compute_hdr_deps()
- generator.write()
 
+ if 'all' in targets:
+ targets = generator_dict.keys()
+
+ for x in targets:
+ sys.stdout.write("Generating %s..." % (x))
+ sys.stdout.flush()
+
+ if not generator_dict.has_key(x):
+ print>>sys.stdout, "gen-make: %s is not a valid target" % (x)
+ sys.exit(1)
+
+ y=generator_dict[x]
+ generator = y(fname, verfname)
 
-def _usage_exit():
+ if not skip_depends:
+ generator.compute_hdr_deps()
+ generator.write()
+
+ sys.stdout.write("done\n")
+ sys.stdout.flush()
+
+
+def show_usage():
   "print usage, exit the script"
- print "usage: gen-make.py [-s] [conf-file]\n"
- sys.exit(0)
+ print "usage: gen-make.py [options] [targets]"
+ print
+ print "options:"
+ print " -h Show this help"
+ print " -s Skip dependencies"
+ print " -c Specify input build configuration file"
+ print
+ print "targets:"
+ print " all"
+ for x in generator_dict:
+ print " %s" % (x)
+ print
+ print "default= gcc-makefile"
 
 if __name__ == '__main__':
- opts, args = getopt.getopt(sys.argv[1:], 's')
- if len(args) > 1:
- _usage_exit()
-
- if args:
- fname = args[0]
- else:
- fname = 'build.conf'
-
- if ('-s', '') in opts:
- skip = 1
- else:
- skip = 0
+ skip = 0
+ fname = 'build.conf'
+ targets = ['gcc-makefile']
+ load_build_modules(default_build_modules)
+
+ opts, args = getopt.getopt(sys.argv[1:], 'shc:')
+
+ for o in opts:
+ a,b=o
+ if a == '-h':
+ show_usage()
+ sys.exit(0)
+ elif a == '-s':
+ skip = 1
+ elif a == '-c':
+ fname = b
+
+ if len(args):
+ targets=args
 
- main(fname, skip_depends=skip)
+ main(fname, targets, skip_depends=skip)
 
 
 ### End of file.
Index: autogen.sh
===================================================================
--- autogen.sh (revision 4111)
+++ autogen.sh (working copy)
@@ -88,10 +88,10 @@
 
 if test "$1" = "-s"; then
   echo "Creating build-outputs.mk (no dependencies)..."
- ./gen-make.py -s build.conf ;
+ ./gen-make.py -s -c build.conf ;
 else
   echo "Creating build-outputs.mk..."
- ./gen-make.py build.conf ;
+ ./gen-make.py -c build.conf ;
 fi
 
 if test "$?" != "0"; then

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Dec 13 17:25:21 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.