"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "build/gen-build.py" between
apr-1.6.5.tar.bz2 and apr-1.7.0.tar.bz2

About: APR (Apache Portable Runtime) project offers software libraries that provide a predictable and consistent interface to underlying platform-specific implementations (APR core library).

gen-build.py  (apr-1.6.5.tar.bz2):gen-build.py  (apr-1.7.0.tar.bz2)
skipping to change at line 12 skipping to change at line 12
# #
# USAGE: gen-build.py TYPE # USAGE: gen-build.py TYPE
# #
# where TYPE is one of: make, dsp, vcproj # where TYPE is one of: make, dsp, vcproj
# #
# It reads build.conf from the current directory, and produces its output # It reads build.conf from the current directory, and produces its output
# into the current directory. # into the current directory.
# #
import os import os
import ConfigParser try:
import configparser
except ImportError:
import ConfigParser as configparser
import codecs
import getopt import getopt
import string import string
import glob import glob
import re import re
#import ezt #import ezt
# #
# legal platforms: aix, beos, netware, os2, os390, unix, win32 # legal platforms: aix, beos, netware, os2, os390, unix, win32
# 'make' users: aix, beos, os2, os390, unix, win32 (mingw) # 'make' users: aix, beos, os2, os390, unix, win32 (mingw)
skipping to change at line 37 skipping to change at line 41
('aix', 'unix'), ('aix', 'unix'),
('beos', 'unix'), ('beos', 'unix'),
('os2', 'unix'), ('os2', 'unix'),
('os390', 'unix'), ('os390', 'unix'),
('win32', 'unix'), ('win32', 'unix'),
] ]
# note: MAKE_PLATFORMS is an ordered set. we want to generate unix symbols # note: MAKE_PLATFORMS is an ordered set. we want to generate unix symbols
# first, so that the later platforms can reference them. # first, so that the later platforms can reference them.
def main(): def main():
parser = ConfigParser.ConfigParser() parser = configparser.ConfigParser()
parser.read('build.conf') parser.read('build.conf')
if parser.has_option('options', 'dsp'): if parser.has_option('options', 'dsp'):
dsp_file = parser.get('options', 'dsp') dsp_file = parser.get('options', 'dsp')
else: else:
dsp_file = None dsp_file = None
headers = get_files(parser.get('options', 'headers')) headers = get_files(parser.get('options', 'headers'))
# compute the relevant headers, along with the implied includes # compute the relevant headers, along with the implied includes
skipping to change at line 63 skipping to change at line 67
for fname in headers: for fname in headers:
h_deps[os.path.basename(fname)] = extract_deps(fname, legal_deps) h_deps[os.path.basename(fname)] = extract_deps(fname, legal_deps)
resolve_deps(h_deps) resolve_deps(h_deps)
f = open('build-outputs.mk', 'w') f = open('build-outputs.mk', 'w')
f.write('# DO NOT EDIT. AUTOMATICALLY GENERATED.\n\n') f.write('# DO NOT EDIT. AUTOMATICALLY GENERATED.\n\n')
# write out the platform-independent files # write out the platform-independent files
files = get_files(parser.get('options', 'paths')) files = get_files(parser.get('options', 'paths'))
objects, dirs = write_objects(f, legal_deps, h_deps, files) objects, dirs = write_objects(f, legal_deps, h_deps, files)
f.write('\nOBJECTS_all = %s\n\n' % string.join(objects)) f.write('\nOBJECTS_all = %s\n\n' % " ".join(objects))
# for each platform and each subdirectory holding platform-specific files, # for each platform and each subdirectory holding platform-specific files,
# write out their compilation rules, and an OBJECT_<subdir>_<plat> symbol. # write out their compilation rules, and an OBJECT_<subdir>_<plat> symbol.
for platform, parent in MAKE_PLATFORMS: for platform, parent in MAKE_PLATFORMS:
# record the object symbols to build for each platform # record the object symbols to build for each platform
group = [ '$(OBJECTS_all)' ] group = [ '$(OBJECTS_all)' ]
# If we're doing win32, we're going to look in the libapr.dsp file # If we're doing win32, we're going to look in the libapr.dsp file
# for those files that we have to manually add to our list. # for those files that we have to manually add to our list.
skipping to change at line 87 skipping to change at line 91
if line[:7] != 'SOURCE=': if line[:7] != 'SOURCE=':
continue continue
if line[7:].find('unix') != -1: if line[7:].find('unix') != -1:
# skip the leading .\ and split it out # skip the leading .\ and split it out
inherit_files = line[9:].strip().split('\\') inherit_files = line[9:].strip().split('\\')
# change the .c to .lo # change the .c to .lo
assert inherit_files[-1][-2:] == '.c' assert inherit_files[-1][-2:] == '.c'
inherit_files[-1] = inherit_files[-1][:-2] + '.lo' inherit_files[-1] = inherit_files[-1][:-2] + '.lo'
# replace the \\'s with /'s # replace the \\'s with /'s
inherit_line = '/'.join(inherit_files) inherit_line = '/'.join(inherit_files)
if not inherit_parent.has_key(inherit_files[0]): if inherit_files[0] not in inherit_parent:
inherit_parent[inherit_files[0]] = [] inherit_parent[inherit_files[0]] = []
inherit_parent[inherit_files[0]].append(inherit_line) inherit_parent[inherit_files[0]].append(inherit_line)
for subdir in string.split(parser.get('options', 'platform_dirs')): for subdir in parser.get('options', 'platform_dirs').split():
path = '%s/%s' % (subdir, platform) path = '%s/%s' % (subdir, platform)
if not os.path.exists(path): if not os.path.exists(path):
# this subdir doesn't have a subdir for this platform, so we'll # this subdir doesn't have a subdir for this platform, so we'll
# use the parent-platform's set of symbols # use the parent-platform's set of symbols
if parent: if parent:
group.append('$(OBJECTS_%s_%s)' % (subdir, parent)) group.append('$(OBJECTS_%s_%s)' % (subdir, parent))
continue continue
# remember that this directory has files/objects # remember that this directory has files/objects
dirs[path] = None dirs[path] = None
# write out the compilation lines for this subdir # write out the compilation lines for this subdir
files = get_files(path + '/*.c') files = get_files(path + '/*.c')
objects, _unused = write_objects(f, legal_deps, h_deps, files) objects, _unused = write_objects(f, legal_deps, h_deps, files)
if inherit_parent.has_key(subdir): if subdir in inherit_parent:
objects = objects + inherit_parent[subdir] objects = objects + inherit_parent[subdir]
symname = 'OBJECTS_%s_%s' % (subdir, platform) symname = 'OBJECTS_%s_%s' % (subdir, platform)
objects.sort() objects.sort()
# and write the symbol for the whole group # and write the symbol for the whole group
f.write('\n%s = %s\n\n' % (symname, string.join(objects))) f.write('\n%s = %s\n\n' % (symname, " ".join(objects)))
# and include that symbol in the group # and include that symbol in the group
group.append('$(%s)' % symname) group.append('$(%s)' % symname)
group.sort() group.sort()
# write out a symbol which contains the necessary files # write out a symbol which contains the necessary files
f.write('OBJECTS_%s = %s\n\n' % (platform, string.join(group))) f.write('OBJECTS_%s = %s\n\n' % (platform, " ".join(group)))
f.write('HEADERS = $(top_srcdir)/%s\n\n' % string.join(headers, ' $(top_srcdir f.write('HEADERS = $(top_srcdir)/%s\n\n' % ' $(top_srcdir)/'.join(headers))
)/')) f.write('SOURCE_DIRS = %s $(EXTRA_SOURCE_DIRS)\n\n' % " ".join(dirs.keys()))
f.write('SOURCE_DIRS = %s $(EXTRA_SOURCE_DIRS)\n\n' % string.join(dirs.keys())
)
if parser.has_option('options', 'modules'): if parser.has_option('options', 'modules'):
modules = parser.get('options', 'modules') modules = parser.get('options', 'modules')
for mod in string.split(modules): for mod in modules.split():
files = get_files(parser.get(mod, 'paths')) files = get_files(parser.get(mod, 'paths'))
objects, _unused = write_objects(f, legal_deps, h_deps, files) objects, _unused = write_objects(f, legal_deps, h_deps, files)
flat_objects = string.join(objects) flat_objects = " ".join(objects)
f.write('OBJECTS_%s = %s\n' % (mod, flat_objects)) f.write('OBJECTS_%s = %s\n' % (mod, flat_objects))
if parser.has_option(mod, 'target'): if parser.has_option(mod, 'target'):
target = parser.get(mod, 'target') target = parser.get(mod, 'target')
f.write('MODULE_%s = %s\n' % (mod, target)) f.write('MODULE_%s = %s\n' % (mod, target))
f.write('%s: %s\n' % (target, flat_objects)) f.write('%s: %s\n' % (target, flat_objects))
f.write('\t$(LINK_MODULE) -o $@ $(OBJECTS_%s) $(LDADD_%s)\n' % (mod, mod )) f.write('\t$(LINK_MODULE) -o $@ $(OBJECTS_%s) $(LDADD_%s)\n' % (mod, mod ))
f.write('\n') f.write('\n')
# Build a list of all necessary directories in build tree # Build a list of all necessary directories in build tree
alldirs = { } alldirs = { }
for dir in dirs.keys(): for dir in dirs.keys():
d = dir d = dir
while d: while d:
alldirs[d] = None alldirs[d] = None
d = os.path.dirname(d) d = os.path.dirname(d)
# Sort so 'foo' is before 'foo/bar' # Sort so 'foo' is before 'foo/bar'
keys = alldirs.keys() keys = list(alldirs.keys())
keys.sort() keys.sort()
f.write('BUILD_DIRS = %s\n\n' % string.join(keys)) f.write('BUILD_DIRS = %s\n\n' % " ".join(keys))
f.write('.make.dirs: $(srcdir)/build-outputs.mk\n' \ f.write('.make.dirs: $(srcdir)/build-outputs.mk\n' \
'\t@for d in $(BUILD_DIRS); do test -d $$d || mkdir $$d; done\n' \ '\t@for d in $(BUILD_DIRS); do test -d $$d || mkdir $$d; done\n' \
'\t@echo timestamp > $@\n') '\t@echo timestamp > $@\n')
def write_objects(f, legal_deps, h_deps, files): def write_objects(f, legal_deps, h_deps, files):
dirs = { } dirs = { }
objects = [ ] objects = [ ]
for file in files: for file in files:
if file[-10:] == '/apr_app.c': if file[-10:] == '/apr_app.c':
continue continue
assert file[-2:] == '.c' assert file[-2:] == '.c'
obj = file[:-2] + '.lo' obj = file[:-2] + '.lo'
objects.append(obj) objects.append(obj)
dirs[os.path.dirname(file)] = None dirs[os.path.dirname(file)] = None
# what headers does this file include, along with the implied headers # what headers does this file include, along with the implied headers
deps = extract_deps(file, legal_deps) deps = extract_deps(file, legal_deps)
for hdr in deps.keys(): for hdr in list(deps.keys()):
deps.update(h_deps.get(hdr, {})) deps.update(h_deps.get(hdr, {}))
vals = deps.values() vals = list(deps.values())
vals.sort() vals.sort()
f.write('%s: %s .make.dirs %s\n' % (obj, file, string.join(vals))) f.write('%s: %s .make.dirs %s\n' % (obj, file, " ".join(vals)))
objects.sort() objects.sort()
return objects, dirs return objects, dirs
def extract_deps(fname, legal_deps): def extract_deps(fname, legal_deps):
"Extract the headers this file includes." "Extract the headers this file includes."
deps = { } deps = { }
for line in open(fname).readlines(): for line in codecs.open(fname, 'r', 'utf-8').readlines():
if line[:8] != '#include': if line[:8] != '#include':
continue continue
inc = _re_include.match(line).group(1) inc = _re_include.match(line).group(1)
if inc in legal_deps.keys(): if inc in legal_deps.keys():
deps[inc] = legal_deps[inc] deps[inc] = legal_deps[inc]
return deps return deps
_re_include = re.compile('#include *["<](.*)[">]') _re_include = re.compile('#include *["<](.*)[">]')
def resolve_deps(header_deps): def resolve_deps(header_deps):
"Alter the provided dictionary to flatten includes-of-includes." "Alter the provided dictionary to flatten includes-of-includes."
altered = 1 altered = 1
while altered: while altered:
altered = 0 altered = 0
for hdr, deps in header_deps.items(): for hdr, deps in header_deps.items():
# print hdr, deps # print hdr, deps
start = len(deps) start = len(deps)
for dep in deps.keys(): for dep in list(deps.keys()):
deps.update(header_deps.get(dep, {})) deps.update(header_deps.get(dep, {}))
if len(deps) != start: if len(deps) != start:
altered = 1 altered = 1
def clean_path(path): def clean_path(path):
return path.replace("\\", "/") return path.replace("\\", "/")
def get_files(patterns): def get_files(patterns):
files = [ ] files = [ ]
for pat in string.split(patterns): for pat in patterns.split():
files.extend(map(clean_path, glob.glob(pat))) files.extend(map(clean_path, glob.glob(pat)))
files.sort() files.sort()
return files return files
if __name__ == '__main__': if __name__ == '__main__':
main() main()
 End of changes. 19 change blocks. 
22 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)