pass meson source and build dirs as env variables for postconf scripts

pull/431/head
Nicolas Schneider 9 years ago
parent 5498f16fb3
commit 749aeefe0c
  1. 10
      mesonbuild/backend/backends.py
  2. 4
      test cases/common/107 postconf/postconf.py
  3. 4
      test cases/common/108 postconf with args/postconf.py

@ -438,6 +438,12 @@ class Backend():
return (srcs, ofilenames, cmd)
def run_postconf_scripts(self):
env = {'MESON_SOURCE_ROOT' : self.environment.get_source_dir(),
'MESON_BUILD_ROOT' : self.environment.get_build_dir()
}
child_env = os.environ.copy()
child_env.update(env)
for s in self.build.postconf_scripts:
cmd = s['exe'].get_command() + [self.environment.get_source_dir(), self.environment.get_build_dir()] + s['args']
subprocess.check_call(cmd)
cmd = s['exe'].get_command() + s['args']
subprocess.check_call(cmd, env=child_env)

@ -7,5 +7,5 @@ template = '''#pragma once
#define THE_NUMBER {}
'''
data = open(os.path.join(sys.argv[1], 'raw.dat')).readline().strip()
open(os.path.join(sys.argv[2], 'generated.h'), 'w').write(template.format(data))
data = open(os.path.join(os.environ['MESON_SOURCE_ROOT'], 'raw.dat')).readline().strip()
open(os.path.join(os.environ['MESON_BUILD_ROOT'], 'generated.h'), 'w').write(template.format(data))

@ -9,5 +9,5 @@ template = '''#pragma once
#define THE_ARG2 {}
'''
data = open(os.path.join(sys.argv[1], 'raw.dat')).readline().strip()
open(os.path.join(sys.argv[2], 'generated.h'), 'w').write(template.format(data, sys.argv[3], sys.argv[4]))
data = open(os.path.join(os.environ['MESON_SOURCE_ROOT'], 'raw.dat')).readline().strip()
open(os.path.join(os.environ['MESON_BUILD_ROOT'], 'generated.h'), 'w').write(template.format(data, sys.argv[1], sys.argv[2]))

Loading…
Cancel
Save