Skip to content

Commit

Permalink
Print deprecation warnings on old style commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Aug 2, 2017
1 parent fa278f3 commit 59a35c4
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def main():
mlog.warning('Please switch to a UTF-8 locale for your platform.')
# Always resolve the command path so Ninja can find it for regen, tests, etc.
launcher = os.path.realpath(sys.argv[0])
return mesonmain.run(launcher, sys.argv[1:])
return mesonmain.run(sys.argv[1:], launcher)

if __name__ == '__main__':
sys.exit(main())
9 changes: 6 additions & 3 deletions mesonbuild/mesonmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
import os.path
from . import environment, interpreter, mesonlib
from . import build
from . import mconf, mintro, mtest, rewriter
import platform
from . import mlog, coredata
from .mesonlib import MesonException
from .wrap import WrapMode
from .wrap import WrapMode, wraptool


parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -262,7 +263,7 @@ def run_script_command(args):
raise MesonException('Unknown internal command {}.'.format(cmdname))
return cmdfunc(cmdargs)

def run(mainfile, args):
def run(args, mainfile=None):
if sys.version_info < (3, 4):
print('Meson works correctly only with python 3.4+.')
print('You have python %s.' % sys.version)
Expand All @@ -276,7 +277,7 @@ def run(mainfile, args):
return mtest.run(remaining_args)
elif cmd_name == 'setup':
args = remaining_args
# FALLTROUGH like it's 1972.
# FALLTHROUGH like it's 1972.
elif cmd_name == 'introspect':
return mintro.run(remaining_args)
elif cmd_name == 'test':
Expand Down Expand Up @@ -324,6 +325,8 @@ def run(mainfile, args):
else:
dir2 = '.'
try:
if mainfile is None:
sys.exit('I iz broken. Sorry.')
app = MesonApp(dir1, dir2, mainfile, handshake, options, sys.argv)
except Exception as e:
# Log directory does not exist, so just print
Expand Down
6 changes: 4 additions & 2 deletions mesonconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from mesonbuild import mconf
from mesonbuild import mesonmain, mlog
import sys

sys.exit(mconf.run(sys.argv[1:]))
if __name__ == '__main__':
mlog.warning('This executable is deprecated, use "meson configure" instead.')
sys.exit(mesonmain.run(['configure'] + sys.argv[1:]))
6 changes: 4 additions & 2 deletions mesonintrospect.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from mesonbuild import mintro
from mesonbuild import mesonmain, mlog
import sys

sys.exit(mintro.run(sys.argv[1:]))
if __name__ == '__main__':
mlog.warning('This executable is deprecated. Use "meson introspect" instead.')
sys.exit(mesonmain.run(['introspect'] + sys.argv[1:]))
5 changes: 3 additions & 2 deletions mesonrewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
# - move targets
# - reindent?

from mesonbuild import rewriter
from mesonbuild import mesonmain, mlog
import sys

if __name__ == '__main__':
sys.exit(rewriter.run(sys.argv[1:]))
mlog.warning('This program is deprecated, use "meson rewrite" instead')
sys.exit(mesonmain.run(['rewrite'] + sys.argv[1:]))

5 changes: 2 additions & 3 deletions mesontest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

# A tool to run tests in many different ways.

from mesonbuild import mesonmain
from mesonbuild import mesonmain, mlog
import sys

if __name__ == '__main__':
print('Warning: This executable is deprecated. Use "meson test" instead.',
file=sys.stderr)
mlog.warning('This executable is deprecated, use "meson test" instead.')
sys.exit(mesonmain.run(['test'] + sys.argv[1:]))
2 changes: 1 addition & 1 deletion run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def run_configure_inprocess(commandlist):
old_stderr = sys.stderr
sys.stderr = mystderr = StringIO()
try:
returncode = mesonmain.run(commandlist[0], commandlist[1:])
returncode = mesonmain.run(commandlist[1:], commandlist[0])
finally:
sys.stdout = old_stdout
sys.stderr = old_stderr
Expand Down
4 changes: 2 additions & 2 deletions run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ def setUp(self):
self.backend = getattr(Backend, os.environ.get('MESON_UNIT_TEST_BACKEND', 'ninja'))
self.meson_args = [os.path.join(src_root, 'meson.py'), '--backend=' + self.backend.name]
self.meson_command = [sys.executable] + self.meson_args
self.mconf_command = [sys.executable, os.path.join(src_root, 'mesonconf.py')]
self.mintro_command = [sys.executable, os.path.join(src_root, 'mesonintrospect.py')]
self.mconf_command = [sys.executable, os.path.join(src_root, 'meson.py'), 'configure']
self.mintro_command = [sys.executable, os.path.join(src_root, 'meson.py'), 'introspect']
self.mtest_command = [sys.executable, os.path.join(src_root, 'mesontest.py'), '-C', self.builddir]
# Backend-specific build commands
self.build_command, self.clean_command, self.test_command, self.install_command, \
Expand Down

0 comments on commit 59a35c4

Please sign in to comment.