summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2018-06-27 11:41:30 +0000
committerJoe Orton <jorton@apache.org>2018-06-27 11:41:30 +0000
commitbbf93347820c477188a7651d5aff6f303bedfa98 (patch)
treea9720c6744c8cfe74d203e3ac69d701209f7b2a4 /build
parent71507ba0ae1389f199ea5f0705915c4b078f0e25 (diff)
downloadapr-bbf93347820c477188a7651d5aff6f303bedfa98.tar.gz
* build/buildcheck.sh, buildconf: Detect and run under Python 3 or 2,
and respect $PYTHON. * build/gen-build.py: Fix various Python 3 compatibility issues. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1834494 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'build')
-rwxr-xr-xbuild/buildcheck.sh4
-rwxr-xr-xbuild/gen-build.py45
2 files changed, 26 insertions, 23 deletions
diff --git a/build/buildcheck.sh b/build/buildcheck.sh
index ab5df445c..76ff8cef2 100755
--- a/build/buildcheck.sh
+++ b/build/buildcheck.sh
@@ -4,14 +4,14 @@ echo "buildconf: checking installation..."
res=0
# any python
-python=`build/PrintPath python`
+python=${PYTHON-`build/PrintPath python3 python2 python`}
if test -z "$python"; then
echo "buildconf: python not found."
echo " You need python installed"
echo " to build APR from SVN."
res=1
else
- py_version=`python -c 'import sys; print sys.version' 2>&1|sed 's/ .*//;q'`
+ py_version=`$python -c 'import sys; print(sys.version)' 2>&1|sed 's/ .*//;q'`
echo "buildconf: python version $py_version (ok)"
fi
diff --git a/build/gen-build.py b/build/gen-build.py
index 054422abc..4874f0eb4 100755
--- a/build/gen-build.py
+++ b/build/gen-build.py
@@ -10,7 +10,10 @@
import os
-import ConfigParser
+try:
+ import configparser
+except ImportError:
+ import ConfigParser as configparser
import getopt
import string
import glob
@@ -36,7 +39,7 @@ MAKE_PLATFORMS = [
def main():
- parser = ConfigParser.ConfigParser()
+ parser = configparser.ConfigParser()
parser.read('build.conf')
if parser.has_option('options', 'dsp'):
@@ -62,7 +65,7 @@ def main():
# write out the platform-independent files
files = get_files(parser.get('options', 'paths'))
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,
# write out their compilation rules, and an OBJECT_<subdir>_<plat> symbol.
@@ -86,11 +89,11 @@ def main():
inherit_files[-1] = inherit_files[-1][:-2] + '.lo'
# replace the \\'s with /'s
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]].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)
if not os.path.exists(path):
# this subdir doesn't have a subdir for this platform, so we'll
@@ -106,7 +109,7 @@ def main():
files = get_files(path + '/*.c')
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]
symname = 'OBJECTS_%s_%s' % (subdir, platform)
@@ -114,7 +117,7 @@ def main():
objects.sort()
# 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
group.append('$(%s)' % symname)
@@ -122,18 +125,18 @@ def main():
group.sort()
# 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('SOURCE_DIRS = %s $(EXTRA_SOURCE_DIRS)\n\n' % string.join(dirs.keys()))
+ 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()))
if parser.has_option('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'))
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))
if parser.has_option(mod, 'target'):
@@ -147,10 +150,10 @@ def main():
if parser.has_option('options', 'libraries'):
libs = parser.get('options', 'libraries')
- for lib in string.split(libs):
+ for lib in libs.split():
files = get_files(parser.get(lib, 'paths'))
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' % (lib, flat_objects))
if parser.has_option(lib, 'target'):
@@ -170,9 +173,9 @@ def main():
d = os.path.dirname(d)
# Sort so 'foo' is before 'foo/bar'
- keys = alldirs.keys()
+ keys = list(alldirs.keys())
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' \
'\t@for d in $(BUILD_DIRS); do test -d $$d || mkdir $$d; done\n' \
@@ -194,12 +197,12 @@ def write_objects(f, legal_deps, h_deps, files):
# what headers does this file include, along with the implied headers
deps = extract_deps(file, legal_deps)
- for hdr in deps.keys():
+ for hdr in list(deps.keys()):
deps.update(h_deps.get(hdr, {}))
- vals = deps.values()
+ vals = list(deps.values())
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()
@@ -227,7 +230,7 @@ def resolve_deps(header_deps):
for hdr, deps in header_deps.items():
# print hdr, deps
start = len(deps)
- for dep in deps.keys():
+ for dep in list(deps.keys()):
deps.update(header_deps.get(dep, {}))
if len(deps) != start:
altered = 1
@@ -237,7 +240,7 @@ def clean_path(path):
def get_files(patterns):
files = [ ]
- for pat in string.split(patterns):
+ for pat in patterns.split():
files.extend(map(clean_path, glob.glob(pat)))
files.sort()
return files