complexity is valuable in its own right.
"""
-import os.path
-import sys
-
-import TestCmd
import TestSCons
test = TestSCons.TestSCons()
###
experimenttop = r"%s"
-
import os
-import os.path
-import string
import Mylib
BStaticLibMerge = Builder(generator = Mylib.Gen_StaticLibMerge)
e["EXPORT_LIB"] = os.path.join(experimenttop, "export", "lib")
e["INSTALL_BIN"] = os.path.join(experimenttop, "install", "bin")
-build_dir = os.path.join(experimenttop, "tmp-bld-dir")
+variant_dir = os.path.join(experimenttop, "tmp-bld-dir")
src_dir = os.path.join(experimenttop, "src")
env.Append(CPPPATH = [e["EXPORT_INCLUDE"]])
test.write('Mylib.py', """\
import os
-import string
import re
def Subdirs(env, dirlist):
env.SConscript(file, "env")
def _subconf_list(dirlist):
- return map(lambda x: os.path.join(x, "SConscript"), string.split(dirlist))
+ return [os.path.join(x, "SConscript") for x in dirlist.split()]
def StaticLibMergeMembers(local_env, libname, hackpath, files):
- for file in string.split(files):
+ for file in files.split():
# QQQ Fix limits in grok'ed regexp
tmp = re.sub(".c$", ".o", file)
objname = re.sub(".cpp", ".o", tmp)
return [["ar", "cq"] + target + srclist, ["ranlib"] + target]
def StaticLibrary(env, target, source):
- env.StaticLibrary(target, string.split(source))
+ env.StaticLibrary(target, source.split())
def SharedLibrary(env, target, source):
- env.SharedLibrary(target, string.split(source))
+ env.SharedLibrary(target, source.split())
def ExportHeader(env, headers):
- env.Install(dir = env["EXPORT_INCLUDE"], source = string.split(headers))
+ env.Install(dir = env["EXPORT_INCLUDE"], source = headers.split())
def ExportLib(env, libs):
- env.Install(dir = env["EXPORT_LIB"], source = string.split(libs))
+ env.Install(dir = env["EXPORT_LIB"], source = libs.split())
def InstallBin(env, bins):
- env.Install(dir = env["INSTALL_BIN"], source = string.split(bins))
+ env.Install(dir = env["INSTALL_BIN"], source = bins.split())
def Program(env, target, source):
- env.Program(target, string.split(source))
+ env.Program(target, source.split())
def AddCFlags(env, str):
env.Append(CPPFLAGS = " " + str)
# AddCFlags(env, str)
def AddIncludeDirs(env, str):
- env.Append(CPPPATH = string.split(str))
+ env.Append(CPPPATH = str.split())
def AddLibs(env, str):
- env.Append(LIBS = string.split(str))
+ env.Append(LIBS = str.split())
def AddLibDirs(env, str):
- env.Append(LIBPATH = string.split(str))
+ env.Append(LIBPATH = str.split())
""")
test.write(['src', 'lib_geng', 'SConscript'], """\
# --- Begin SConscript boilerplate ---
-import string
import sys
import Mylib
Import("env")
except SCons.Errors.UserError:
pass
todict["CFLAGS"] = fromdict["CPPFLAGS"] + " " + \
- string.join(map(lambda x: "-I" + x, env["CPPPATH"])) + " " + \
- string.join(map(lambda x: "-L" + x, env["LIBPATH"]))
+ ' '.join(["-I" + x for x in env["CPPPATH"]]) + " " + \
+ ' '.join(["-L" + x for x in env["LIBPATH"]])
todict["CXXFLAGS"] = todict["CFLAGS"]
generated_hdrs = "libg_gx.h libg_gy.h libg_gz.h"
exported_hdrs = static_hdrs
lib_name = "g"
lib_fullname = env.subst("${LIBPREFIX}g${LIBSUFFIX}")
-lib_srcs = string.split("libg_1.c libg_2.c libg_3.c")
+lib_srcs = "libg_1.c libg_2.c libg_3.c".split()
import re
-lib_objs = map(lambda x: re.sub("\.c$", ".o", x), lib_srcs)
+lib_objs = [re.sub("\.c$", ".o", x) for x in lib_srcs]
Mylib.ExportHeader(env, exported_hdrs)
Mylib.ExportLib(env, lib_fullname)
#
# SCons bug??
-env.Command(string.split(generated_hdrs),
+env.Command(generated_hdrs.split(),
["MAKE-HEADER.py"],
cmd_generated)
recurse_env.Command([lib_fullname] + lib_objs,
- lib_srcs + string.split(generated_hdrs + " " + static_hdrs),
+ lib_srcs + (generated_hdrs + " " + static_hdrs).split(),
cmd_justlib)
""")
Scanned = {}
def write_out(file, dict):
- keys = dict.keys()
- keys.sort()
f = open(file, 'wb')
- for k in keys:
+ for k in sorted(dict.keys()):
file = os.path.split(k)[1]
f.write(file + ": " + str(dict[k]) + "\\n")
f.close()
-orig_function = CScan.scan
+orig_function = CScan.__call__
-def MyCScan(node, paths, orig_function=orig_function):
- deps = orig_function(node, paths)
+def MyCScan(node, paths, cwd, orig_function=orig_function):
+ deps = orig_function(node, paths, cwd)
global Scanned
n = str(node)
return deps
-CScan.scan = MyCScan
+CScan.__call__ = MyCScan
env = Environment(CPPPATH = ".")
l = env.StaticLibrary("g", Split("libg_1.c libg_2.c libg_3.c"))
test.run(stderr=TestSCons.noisy_ar,
match=TestSCons.match_re_dotall)
-# XXX Note that the generated .h files still get scanned twice,
-# once before they're generated and once after. That's the
-# next thing to fix here.
-
test.must_match("MyCScan.out", """\
libg_1.c: 1
libg_2.c: 1
""")
test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: