summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
da9eee8)
Signed-off-by: Thomas Nagy <tnagy@waf.io>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
'''substiture @VAR@ style variables in a file'''
env = task.env
'''substiture @VAR@ style variables in a file'''
env = task.env
- src = task.inputs[0].srcpath(env)
- tgt = task.outputs[0].bldpath(env)
+ s = task.inputs[0].read()
- f = open(src, 'r')
- s = f.read()
- f.close()
# split on the vars
a = re.split('(@\w+@)', s)
out = []
# split on the vars
a = re.split('(@\w+@)', s)
out = []
v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
out.append(v)
contents = ''.join(out)
v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
out.append(v)
contents = ''.join(out)
- f = open(tgt, 'w')
- s = f.write(contents)
- f.close()
+ task.outputs[0].write(contents)
return 0
def CONFIGURE_FILE(bld, in_file, **kwargs):
return 0
def CONFIGURE_FILE(bld, in_file, **kwargs):
def subst_at_vars(task):
'''substiture @VAR@ style variables in a file'''
def subst_at_vars(task):
'''substiture @VAR@ style variables in a file'''
- src = task.inputs[0].srcpath(task.env)
- tgt = task.outputs[0].bldpath(task.env)
- f = open(src, 'r')
- s = f.read()
- f.close()
+ s = task.inputs[0].read()
# split on the vars
a = re.split('(@\w+@)', s)
out = []
# split on the vars
a = re.split('(@\w+@)', s)
out = []
break
out.append(v)
contents = ''.join(out)
break
out.append(v)
contents = ''.join(out)
- f = open(tgt, 'w')
- s = f.write(contents)
- f.close()
+ task.outputs[0].write(contents)
def abi_process_file(fname, version, symmap):
'''process one ABI file, adding new symbols to the symmap'''
def abi_process_file(fname, version, symmap):
'''process one ABI file, adding new symbols to the symmap'''
- f = open(fname, mode='r')
- for line in f:
+ for line in Utils.readf(fname).splitlines():
symname = line.split(":")[0]
if not symname in symmap:
symmap[symname] = version
symname = line.split(":")[0]
if not symname in symmap:
symmap[symname] = version
def abi_write_vscript(f, libname, current_version, versions, symmap, abi_match):
def abi_write_vscript(f, libname, current_version, versions, symmap, abi_match):
- dest = open(os.path.join(subdir, 'liblc1.c'), 'w')
- dest.write('#include <stdio.h>\nint lib_func(void) { FILE *f = fopen("foo", "r");}\n')
- dest.close()
+ Utils.writef(os.path.join(subdir, 'liblc1.c'), '#include <stdio.h>\nint lib_func(void) { FILE *f = fopen("foo", "r");}\n')
bld = Build.BuildContext()
bld.log = conf.log
bld = Build.BuildContext()
bld.log = conf.log
- dest = open(os.path.join(subdir, 'lib1.c'), 'w')
- dest.write('int lib_func(void) { return 42; }\n')
- dest.close()
-
- dest = open(os.path.join(dir, 'main.c'), 'w')
- dest.write('int main(void) {return !(lib_func() == 42);}\n')
- dest.close()
+ Utils.writef(os.path.join(subdir, 'lib1.c'), 'int lib_func(void) { return 42; }\n')
+ Utils.writef(os.path.join(dir, 'main.c'), 'int main(void) {return !(lib_func() == 42);}\n')
bld = Build.BuildContext()
bld.log = conf.log
bld = Build.BuildContext()
bld.log = conf.log
ldflags = []
if version_script:
ldflags.append("-Wl,--version-script=%s/vscript" % bld.path.abspath())
ldflags = []
if version_script:
ldflags.append("-Wl,--version-script=%s/vscript" % bld.path.abspath())
- dest = open(os.path.join(dir,'vscript'), 'w')
- dest.write('TEST_1.0A2 { global: *; };\n')
- dest.close()
+ Utils.writef(os.path.join(dir,'vscript'), 'TEST_1.0A2 { global: *; };\n')
bld(features='cc cshlib',
source='libdir/lib1.c',
bld(features='cc cshlib',
source='libdir/lib1.c',
if not os.path.exists(bdir):
os.makedirs(bdir)
if not os.path.exists(bdir):
os.makedirs(bdir)
- dest = open(os.path.join(bdir, 'Makefile.PL'), 'w')
- dest.write("""
+ Utils.writef(os.path.join(bdir, 'Makefile.PL'), """
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'WafTest',
'EXE_FILES' => [ 'WafTest' ]
);
""")
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'WafTest',
'EXE_FILES' => [ 'WafTest' ]
);
""")
back = os.path.abspath('.')
os.chdir(bdir)
proc = Utils.pproc.Popen(['perl', 'Makefile.PL'],
back = os.path.abspath('.')
os.chdir(bdir)
proc = Utils.pproc.Popen(['perl', 'Makefile.PL'],
- f = open(os.path.join(bdir,'Makefile'), 'r')
- man = f.read()
- f.close()
+ man = Utils.readf(os.path.join(bdir,'Makefile'))
m = re.search('MAN%sEXT\s+=\s+(\w+)' % section, man)
if not m:
conf.check_message_2('not found', color='YELLOW')
m = re.search('MAN%sEXT\s+=\s+(\w+)' % section, man)
if not m:
conf.check_message_2('not found', color='YELLOW')
def write_version_header(task):
'''print version.h contents'''
src = task.inputs[0].srcpath(task.env)
def write_version_header(task):
'''print version.h contents'''
src = task.inputs[0].srcpath(task.env)
- tgt = task.outputs[0].bldpath(task.env)
version = samba_version_file(src, task.env.srcdir, env=task.env, is_install=task.env.is_install)
string = str(version)
version = samba_version_file(src, task.env.srcdir, env=task.env, is_install=task.env.is_install)
string = str(version)
- f = open(tgt, 'w')
- s = f.write(string)
- f.close()
+ task.outputs[0].write(string)
def distversion_version_summary(path):
#get version from .distversion file
def distversion_version_summary(path):
#get version from .distversion file
- f = open(path + '/.distversion', 'r')
suffix = None
fields = {}
suffix = None
fields = {}
- for line in f:
- line = line.strip()
+ for line in Utils.readf(path + '/.distversion').splitlines():
if line == '':
continue
if line.startswith("#"):
if line == '':
continue
if line.startswith("#"):
except:
print("Failed to parse line %s from .distversion file." % (line))
raise
except:
print("Failed to parse line %s from .distversion file." % (line))
raise
if "COMMIT_TIME" in fields:
fields["COMMIT_TIME"] = int(fields["COMMIT_TIME"])
if "COMMIT_TIME" in fields:
fields["COMMIT_TIME"] = int(fields["COMMIT_TIME"])
def generate_empty_file(task):
def generate_empty_file(task):
- target_fname = installed_location=task.outputs[0].bldpath(task.env)
- target_file = open(installed_location, 'w')
- target_file.close()
+ task.outputs[0].write('')
return 0
#################################################################
return 0
#################################################################
t += "]>\n"
t += "<section>\n"
for article in articles:
t += "]>\n"
t += "<section>\n"
for article in articles:
- f = open(article.abspath(task.env), 'r')
- t += f.read()
- f.close()
t += "</section>\n"
save_file(parameter_all, t , create_dir=True)
t += "</section>\n"
save_file(parameter_all, t , create_dir=True)