diff options
author | Greg Stein <gstein@apache.org> | 2004-02-05 10:16:25 +0000 |
---|---|---|
committer | Greg Stein <gstein@apache.org> | 2004-02-05 10:16:25 +0000 |
commit | 7f5b352d208fc156d060afc3d4d9bd6dd02472dc (patch) | |
tree | cfa5a711c027d72cc924b6fe5e6451b8d81fbe2c /build/gen-build.py | |
parent | 4ee50c35aa2cd7184e3e6ec836f469f08bd003f5 (diff) | |
download | apr-7f5b352d208fc156d060afc3d4d9bd6dd02472dc.tar.gz |
First whack at switching to a single top-level make. This adds a dependency
upon Python at packaging time, but not at end-user config/build time. As far
as I can tell, the build continues to function properly. (out-of-dir
config/make not tested, and apr-iconv prolly needs some work)
The buildconf scripts now generate a build-outputs.mk file which is included
by the root's Makefile (via the build/gen-build.py script). bulid-outputs.mk
specifies all of the various files present in the distribution.
The top-level Makefiles were simplified to use an $(OBJECTS) symbol rather
than 'find'ing them. Similarly, a $(HEADERS) symbol is used for the exports.
The corresponding delete-* targets were eliminated since we have a precise
set of inputs.
The subdirs' Makefiles were removed since they are no longer called/used.
The apr-util/uri Makefile was responsible for compiling a C program to
generate the uri_delims.h file. That process was replaced by a Python script
to generate the header (called by buildconf). The .c and .dsp were left for
the Windows build to continue, but that should be revamped.
build/apr_rules.mk was revamped somewhat to avoid recursion, but a lot of
cleanup is still needed. Much of the recursive/local/x- logic is no longer
needed and can be elimianated. rules.mk was created for inclusion by N
makefiles, but that isn't really true any more, so it could probably be
tossed (caveat: test/Makefile). Saved for a phase 2.
Some additional work was added to properly clean up files in */build/,
rather than relying on a makefile in there.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@64891 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'build/gen-build.py')
-rwxr-xr-x | build/gen-build.py | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/build/gen-build.py b/build/gen-build.py new file mode 100755 index 000000000..6c6b07471 --- /dev/null +++ b/build/gen-build.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +# +# USAGE: gen-build.py TYPE +# +# where TYPE is one of: make, dsp, vcproj +# +# It reads build.conf from the current directory, and produces its output +# into the current directory. +# + + +import os +import ConfigParser +import getopt +import string +import glob +import re + +#import ezt + + +def main(): + parser = ConfigParser.ConfigParser() + parser.read('build.conf') + + dirs = { } + files = get_files(parser.get('options', 'paths')) + headers = get_files(parser.get('options', 'headers')) + + # compute the relevant headers, along with the implied includes + legal_deps = map(os.path.basename, headers) + h_deps = { } + for fname in headers: + h_deps[os.path.basename(fname)] = extract_deps(fname, legal_deps) + resolve_deps(h_deps) + + f = open('build-outputs.mk', 'w') + f.write('# DO NOT EDIT. AUTOMATICALLY GENERATED.\n\n') + + objects = [ ] + for file in files: + assert file[-2:] == '.c' + obj = file[:-2] + '.lo' + objects.append(obj) + + dirs[os.path.dirname(file)] = None + + # what headers does this file include, along with the implied headers + deps = extract_deps(file, legal_deps) + for hdr in deps.keys(): + deps.update(h_deps.get(hdr, {})) + + f.write('%s: %s %s\n' % (obj, file, string.join(deps.keys(), ' '))) + + f.write('\nOBJECTS = %s\n\n' % string.join(objects)) + f.write('HEADERS = %s\n\n' % string.join(headers)) + f.write('SOURCE_DIRS = %s\n\n' % string.join(dirs.keys())) + + +def extract_deps(fname, legal_deps): + "Extract the headers this file includes." + deps = { } + for line in open(fname).readlines(): + if line[:8] != '#include': + continue + inc = _re_include.match(line).group(1) + if inc in legal_deps: + deps[inc] = None + return deps +_re_include = re.compile('#include *["<](.*)[">]') + + +def resolve_deps(header_deps): + "Alter the provided dictionary to flatten includes-of-includes." + altered = 1 + while altered: + altered = 0 + for hdr, deps in header_deps.items(): + print hdr, deps + start = len(deps) + for dep in deps.keys(): + deps.update(header_deps.get(dep, {})) + if len(deps) != start: + altered = 1 + + +def get_files(patterns): + patterns = string.replace(patterns, '{platform}', get_platform()) + patterns = string.split(string.strip(patterns)) + files = [ ] + for pat in patterns: + files.extend(glob.glob(pat)) + return files + +def get_platform(): + return 'unix' + + +if __name__ == '__main__': + main() |