3 import sys, glob, os.path, datetime, pwd, time, fnmatch
4 sys.path.append('senfscons')
7 ###########################################################################
9 def updateRevision(target, source, env):
10 rev = env['ENV']['REVISION'][1:]
13 print "Working copy not clean. Run 'svn update'"
16 if 'm' in rev and not ARGUMENTS.get('force_deb'):
18 print "Working copy contains local changes. Commit first"
25 changelog = file('debian/changelog.template').read() % {
27 'user': pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0].strip(),
28 'date': time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) }
29 file('debian/changelog','w').write(changelog)
32 try: return os.stat(f).st_size > 0
33 except OSError: return False
35 def checkLocalConf(target, source, env):
36 if nonemptyFile('SConfig') or nonemptyFile('Doxyfile.local'):
38 print "You have made local modifications to 'SConfig' and/or 'Doxyfile.local'."
39 print "Building a debian package would remove those files."
41 print "To continue, remove the offending file(s) and try again. Alternatively,"
42 print "build a source package using 'scons debsrc' and may then build debian"
43 print "binary packages from this source-package without disrupting your print local"
44 print "configuration."
48 ###########################################################################
49 # Load utilities and setup libraries and configure build
52 SENFSCons.UseSTLPort()
53 env = SENFSCons.MakeEnvironment()
56 Additional top-level build targets:
58 all_tests Build and run unit tests for all modules
59 all_docs Build documentation for all modules
61 install_all Install SENF into $PREFIX
62 deb Build debian source and binary package
63 debsrc Build debian source package
64 debbin Build debian binary package
67 if os.environ.get('debian_build'):
68 rev = os.popen("dpkg-parsechangelog | awk '/^Version:/{print $2}'").read().strip()
70 rev = 'r' + os.popen("svnversion").read().strip().lower()
72 logname = os.environ.get('LOGNAME')
74 logname = pwd.getpwuid(os.getuid()).pw_name
78 LIBS = [ 'iberty', '$BOOSTREGEXLIB' ],
79 DOXY_XREF_TYPES = [ 'bug', 'fixme', 'todo', 'idea' ],
80 DOXY_HTML_XSL = '#/doclib/html-munge.xsl',
81 ENV = { 'TODAY' : str(datetime.date.today()),
83 'LOGNAME' : logname, # needed by the debian build scripts
84 'CONCURRENCY_LEVEL' : env.GetOption('num_jobs') or "1"
86 CLEAN_PATTERNS = [ '*.pyc', 'semantic.cache', '.sconsign', '.sconsign.dblite' ],
87 BUILDPACKAGE_COMMAND = "dpkg-buildpackage -us -uc -rfakeroot -I.svn -IDoxyfile.local -ISConfig",
92 # Create Doxyfile.local if not cleaning and the file does not exist
93 # otherwise doxygen will barf on this non-existent file
94 if not env.GetOption('clean') and not os.path.exists("Doxyfile.local"):
95 Execute(Touch("Doxyfile.local"))
98 file("config.h","w").write(
101 // This looks stupid. However, we need this since the debian packaged Version
102 // of SENF is installed in a 'senf' subdirectory which the source Version is not
103 #define SENF_ABSOLUTE_INCLUDE_PATH(senf_relative_include_file_path) <%s/senf_relative_include_file_path>
105 """ % env.Dir('#').abspath)
107 ###########################################################################
108 # Define build targets
110 SConscript(glob.glob("*/SConscript"))
112 SENFSCons.StandardTargets(env)
113 SENFSCons.GlobalTargets(env)
114 SENFSCons.Doxygen(env)
115 SENFSCons.DoxyXRef(env,
116 HTML_HEADER = '#/doclib/doxy-header-overview.html',
117 HTML_FOOTER = '#/doclib/doxy-footer.html')
119 # Build combined library 'libsenf'
120 libsenf = env.Library(
121 SENFSCons.LibPath('senf'),
122 Flatten([ env.File(SENFSCons.LibPath(lib)).sources for lib in env['ALLLIBS'] ]))
124 env.Alias('install_all', env.Install('$LIBINSTALLDIR', libsenf))
127 env.Alias('deb', [], [ checkLocalConf,
129 "$BUILDPACKAGE_COMMAND" ]))
132 env.Alias('debsrc', [], [ updateRevision,
133 "$BUILDPACKAGE_COMMAND -S" ]))
136 env.Alias('debbin', [], [ checkLocalConf,
138 "$BUILDPACKAGE_COMMAND -nc" ]))
140 env.Clean('all', [ os.path.join(path,f)
141 for path, subdirs, files in os.walk('.')
142 for pattern in env['CLEAN_PATTERNS']
143 for f in fnmatch.filter(files,pattern) ])
145 env.Clean('all', 'config.h')