Meson compile command (ninja) also need a proper environment.

The ninja command may relaunch meson if meson files have changed.
As we need a proper environment (PKG_CONFIG_PATH, PATH) to let meson
configure properly, we also need to pass the environment to ninja.
This commit is contained in:
Matthieu Gautier 2017-01-03 11:50:18 +01:00
parent c60040e92c
commit ea725d0951
1 changed files with 20 additions and 8 deletions

View File

@ -282,11 +282,7 @@ class MesonMixin(MakeMixin):
def build_path(self): def build_path(self):
return pj(self.source_path, 'build') return pj(self.source_path, 'build')
@command("configure", autoskip=True) def _gen_env(self, options):
def _configure(self, options, log):
if os.path.exists(self.build_path):
shutil.rmtree(self.build_path)
os.makedirs(self.build_path)
env = Defaultdict(str, os.environ) env = Defaultdict(str, os.environ)
env['PKG_CONFIG_PATH'] = (env['PKG_CONFIG_PATH'] + ':' + pj(options.install_dir, options.libprefix, 'pkgconfig') env['PKG_CONFIG_PATH'] = (env['PKG_CONFIG_PATH'] + ':' + pj(options.install_dir, options.libprefix, 'pkgconfig')
if env['PKG_CONFIG_PATH'] if env['PKG_CONFIG_PATH']
@ -295,6 +291,15 @@ class MesonMixin(MakeMixin):
env['PATH'] = ':'.join([pj(options.install_dir, 'bin'), env['PATH']]) env['PATH'] = ':'.join([pj(options.install_dir, 'bin'), env['PATH']])
if options.build_static: if options.build_static:
env['LDFLAGS'] = env['LDFLAGS'] + " -static-libstdc++ --static" env['LDFLAGS'] = env['LDFLAGS'] + " -static-libstdc++ --static"
return env
@command("configure", autoskip=True)
def _configure(self, options, log):
if os.path.exists(self.build_path):
shutil.rmtree(self.build_path)
os.makedirs(self.build_path)
env = self._gen_env(options)
if options.build_static:
library_type = 'static' library_type = 'static'
else: else:
library_type = 'shared' library_type = 'shared'
@ -307,15 +312,22 @@ class MesonMixin(MakeMixin):
run_command(command, self.source_path, log, env=env) run_command(command, self.source_path, log, env=env)
@command("compile") @command("compile")
def _compile(self, log): def _compile(self, options, log):
env = self._gen_env(options)
command = "{} -v".format(self.ninja_command) command = "{} -v".format(self.ninja_command)
run_command(command, self.build_path, log) run_command(command, self.build_path, log, env=env)
@command("install") @command("install")
def _install(self, log): def _install(self, options, log):
env = self._gen_env(options)
command = "{} -v install".format(self.ninja_command) command = "{} -v install".format(self.ninja_command)
run_command(command, self.build_path, log) run_command(command, self.build_path, log)
def build(self, options):
self._configure(options)
self._compile(options)
self._install(options)
# ************************************* # *************************************
# Missing dependencies # Missing dependencies