Generate configure files in Ninja backend. Now it passes all unit tests.

pull/15/head
Jussi Pakkanen 12 years ago
parent e0b6c68a4e
commit 7a19918024
  1. 25
      generators.py
  2. 12
      run_tests.py

@ -141,6 +141,17 @@ class Generator():
args.append(fname)
return args
def generate_configure_files(self):
for cf in self.build.get_configure_files():
infile = os.path.join(self.environment.get_source_dir(),
cf.get_subdir(),
cf.get_source_name())
outdir = os.path.join(self.environment.get_build_dir(),
cf.get_subdir())
os.makedirs(outdir, exist_ok=True)
outfile = os.path.join(outdir, cf.get_target_name())
do_conf_file(infile, outfile, self.interpreter.get_variables())
class NinjaGenerator(Generator):
def __init__(self, build, interp):
@ -150,6 +161,7 @@ class NinjaGenerator(Generator):
def generate(self):
outfilename = os.path.join(self.environment.get_build_dir(), self.ninja_filename)
outfile = open(outfilename, 'w')
self.generate_configure_files()
outfile.write('# This is the build file for project "%s"\n' % self.build.get_project())
outfile.write('# It is autogenerated. Do not edit by hand.\n\n')
self.generate_rules(outfile)
@ -324,7 +336,7 @@ class NinjaGenerator(Generator):
build = 'build %s: %s %s %s\n' % \
(ninja_quote(abs_obj), compiler_name, ninja_quote(abs_src),
pch_dep)
flags = ' FLAGS = %s\n\n' % ' '.join([ninja_quote(t) for t in commands])
flags = ' FLAGS = %s\n\n' % ' '.join(["'" + ninja_quote(t) + "'" for t in commands])
outfile.write(build)
outfile.write(flags)
return abs_obj
@ -460,17 +472,6 @@ echo Run compile.sh before this or bad things will happen.
cpcommand = ' '.join(shell_quote(cpcommand)) + ' || exit\n'
outfile.write(cpcommand)
def generate_configure_files(self):
for cf in self.build.get_configure_files():
infile = os.path.join(self.environment.get_source_dir(),
cf.get_subdir(),
cf.get_source_name())
outdir = os.path.join(self.environment.get_build_dir(),
cf.get_subdir())
os.makedirs(outdir, exist_ok=True)
outfile = os.path.join(outdir, cf.get_target_name())
do_conf_file(infile, outfile, self.interpreter.get_variables())
def generate_data_install(self, outfile):
prefix = self.environment.get_prefix()
dataroot = os.path.join(prefix, self.environment.get_datadir())

@ -20,9 +20,9 @@ import os, subprocess, shutil
test_build_dir = 'work area'
install_dir = os.path.join(os.path.split(os.path.abspath(__file__))[0], 'install dir')
builder_command = './builder.py'
compile_commands = [os.path.join(test_build_dir, 'compile.sh')]
test_commands = [os.path.join(test_build_dir, 'run_tests.sh')]
install_commands = [os.path.join(test_build_dir, 'install.sh')]
compile_commands = ['compile.sh']
test_commands = ['run_tests.sh']
install_commands = ['install.sh']
def run_test(testdir):
shutil.rmtree(test_build_dir)
@ -34,15 +34,15 @@ def run_test(testdir):
p.wait()
if p.returncode != 0:
raise RuntimeError('Generating the build system failed.')
pc = subprocess.Popen(compile_commands)
pc = subprocess.Popen(compile_commands, cwd=test_build_dir)
pc.wait()
if pc.returncode != 0:
raise RuntimeError('Compiling source code failed.')
pt = subprocess.Popen(test_commands)
pt = subprocess.Popen(test_commands, cwd=test_build_dir)
pt.wait()
if pt.returncode != 0:
raise RuntimeError('Running unit tests failed.')
pi = subprocess.Popen(install_commands)
pi = subprocess.Popen(install_commands, cwd=test_build_dir)
pi.wait()
if pi.returncode != 0:
raise RuntimeError('Running install failed.')

Loading…
Cancel
Save