|
|
|
# Copyright 2015-2016 The Meson development team
|
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
import sys, os
|
|
|
|
import pickle, subprocess
|
|
|
|
|
|
|
|
# This could also be used for XCode.
|
|
|
|
|
|
|
|
def need_regen(regeninfo, regen_timestamp):
|
|
|
|
for i in regeninfo.depfiles:
|
|
|
|
curfile = os.path.join(regeninfo.build_dir, i)
|
|
|
|
curtime = os.stat(curfile).st_mtime
|
|
|
|
if curtime > regen_timestamp:
|
|
|
|
return True
|
|
|
|
# The timestamp file gets automatically deleted by MSBuild during a 'Clean' build.
|
|
|
|
# We must make sure to recreate it, even if we do not regenerate the solution.
|
|
|
|
# Otherwise, Visual Studio will always consider the REGEN project out of date.
|
|
|
|
print("Everything is up-to-date, regeneration of build files is not needed.")
|
|
|
|
from ..backend.vs2010backend import Vs2010Backend
|
|
|
|
Vs2010Backend.touch_regen_timestamp(regeninfo.build_dir)
|
|
|
|
return False
|
|
|
|
|
Set the meson command to use when we know what it is
Instead of using fragile guessing to figure out how to invoke meson,
set the value when meson is run. Also rework how we pass of
meson_script_launcher to regenchecker.py -- it wasn't even being used
With this change, we only need to guess the meson path when running
the tests, and in that case:
1. If MESON_EXE is set in the env, we know how to run meson
for project tests.
2. MESON_EXE is not set, which means we run the configure in-process
for project tests and need to guess what meson to run, so either
- meson.py is found next to run_tests.py, or
- meson, meson.py, or meson.exe is in PATH
Otherwise, you can invoke meson in the following ways:
1. meson is installed, and mesonbuild is available in PYTHONPATH:
- meson, meson.py, meson.exe from PATH
- python3 -m mesonbuild.mesonmain
- python3 /path/to/meson.py
- meson is a shell wrapper to meson.real
2. meson is not installed, and is run from git:
- Absolute path to meson.py
- Relative path to meson.py
- Symlink to meson.py
All these are tested in test_meson_commands.py, except meson.exe since
that involves building the meson msi and installing it.
7 years ago
|
|
|
def regen(regeninfo, meson_command, backend):
|
|
|
|
cmd = meson_command + ['--internal',
|
|
|
|
'regenerate',
|
|
|
|
regeninfo.build_dir,
|
|
|
|
regeninfo.source_dir,
|
|
|
|
'--backend=' + backend]
|
|
|
|
subprocess.check_call(cmd)
|
|
|
|
|
|
|
|
def run(args):
|
|
|
|
private_dir = args[0]
|
|
|
|
dumpfile = os.path.join(private_dir, 'regeninfo.dump')
|
|
|
|
coredata = os.path.join(private_dir, 'coredata.dat')
|
|
|
|
with open(dumpfile, 'rb') as f:
|
|
|
|
regeninfo = pickle.load(f)
|
|
|
|
with open(coredata, 'rb') as f:
|
|
|
|
coredata = pickle.load(f)
|
|
|
|
backend = coredata.get_builtin_option('backend')
|
|
|
|
regen_timestamp = os.stat(dumpfile).st_mtime
|
|
|
|
if need_regen(regeninfo, regen_timestamp):
|
Set the meson command to use when we know what it is
Instead of using fragile guessing to figure out how to invoke meson,
set the value when meson is run. Also rework how we pass of
meson_script_launcher to regenchecker.py -- it wasn't even being used
With this change, we only need to guess the meson path when running
the tests, and in that case:
1. If MESON_EXE is set in the env, we know how to run meson
for project tests.
2. MESON_EXE is not set, which means we run the configure in-process
for project tests and need to guess what meson to run, so either
- meson.py is found next to run_tests.py, or
- meson, meson.py, or meson.exe is in PATH
Otherwise, you can invoke meson in the following ways:
1. meson is installed, and mesonbuild is available in PYTHONPATH:
- meson, meson.py, meson.exe from PATH
- python3 -m mesonbuild.mesonmain
- python3 /path/to/meson.py
- meson is a shell wrapper to meson.real
2. meson is not installed, and is run from git:
- Absolute path to meson.py
- Relative path to meson.py
- Symlink to meson.py
All these are tested in test_meson_commands.py, except meson.exe since
that involves building the meson msi and installing it.
7 years ago
|
|
|
regen(regeninfo, coredata.meson_command, backend)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
run(sys.argv[1:])
|