Determine location of scripts properly.

pull/15/head
Jussi Pakkanen 12 years ago
parent 2438953b8e
commit 816752f51a
  1. 11
      environment.py
  2. 12
      generators.py

@ -227,6 +227,7 @@ header_suffixes = ['h', 'hh', 'hpp', 'hxx', 'H']
class Environment():
def __init__(self, source_dir, build_dir, builder_script_file, options):
assert(builder_script_file[0] == '/')
self.source_dir = source_dir
self.build_dir = build_dir
self.builder_script_file = builder_script_file
@ -244,6 +245,16 @@ class Environment():
self.static_lib_suffix = 'a'
self.static_lib_prefix = 'lib'
self.object_suffix = 'o'
def get_script_dir(self):
fullfile = self.builder_script_file
while os.path.islink(fullfile):
resolved = os.readlink(fullfile)
if resolved[0] != '/':
fullfile = os.path.join(os.path.dirname(fullfile), resolved)
else:
fullfile = resolved
return os.path.dirname(fullfile)
def get_builder_command(self):
return self.builder_script_file

@ -58,12 +58,6 @@ class Generator():
self.build_to_src = os.path.relpath(self.environment.get_source_dir(),
self.environment.get_build_dir())
def get_script_root(self):
# The path to wherever our internal scripts are.
# /usr/share/../ when installed, local path
# when running from source directory.
return '..' # FIXME
def get_compiler_for_source(self, src):
for i in self.build.compilers:
if i.can_compile(src):
@ -214,10 +208,10 @@ class NinjaGenerator(Generator):
print('Warning: coverage requested but neither gcovr nor lcov/genhtml found.')
def generate_install(self, outfile):
script_root = self.get_script_root()
script_root = self.environment.get_script_dir()
install_script = os.path.join(script_root, 'builder_install.py')
install_data_file = os.path.join(self.environment.get_scratch_dir(), 'install.dat')
depfixer = os.path.join(self.get_script_root(), 'depfixer.py')
depfixer = os.path.join(script_root, 'depfixer.py')
d = InstallData(self.environment.get_prefix(), depfixer, './') # Fixme
outfile.write('build install: CUSTOM_COMMAND | all\n')
@ -279,7 +273,7 @@ class NinjaGenerator(Generator):
d.data.append(i)
def generate_tests(self, outfile):
script_root = self.get_script_root()
script_root = self.environment.get_script_dir()
test_script = os.path.join(script_root, 'builder_test.py')
test_data = os.path.join(self.environment.get_scratch_dir(), 'builder_test_setup.dat')
outfile.write('build test: CUSTOM_COMMAND\n')

Loading…
Cancel
Save