From 7ce2a24f42ce546ad7b26594b3c9b3f087d83f94 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 21 Jul 2019 16:51:12 +0300 Subject: [PATCH] Made dist a top level command. --- mesonbuild/backend/ninjabackend.py | 6 +----- mesonbuild/{scripts/dist.py => mdist.py} | 23 +++++++++++------------ mesonbuild/mesonmain.py | 4 +++- 3 files changed, 15 insertions(+), 18 deletions(-) rename mesonbuild/{scripts/dist.py => mdist.py} (94%) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index cc601d8b2..570a153c5 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2645,11 +2645,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) def generate_dist(self): elem = NinjaBuildElement(self.all_outputs, 'meson-dist', 'CUSTOM_COMMAND', 'PHONY') elem.add_item('DESC', 'Creating source packages') - elem.add_item('COMMAND', self.environment.get_build_command() + [ - '--internal', 'dist', - self.environment.source_dir, - self.environment.build_dir, - ] + self.environment.get_build_command()) + elem.add_item('COMMAND', self.environment.get_build_command() + ['dist']) elem.add_item('pool', 'console') self.add_build(elem) # Alias that runs the target defined above diff --git a/mesonbuild/scripts/dist.py b/mesonbuild/mdist.py similarity index 94% rename from mesonbuild/scripts/dist.py rename to mesonbuild/mdist.py index e69789067..d1dee1bdc 100644 --- a/mesonbuild/scripts/dist.py +++ b/mesonbuild/mdist.py @@ -24,7 +24,7 @@ import tarfile, zipfile from glob import glob from mesonbuild.environment import detect_ninja from mesonbuild.mesonlib import windows_proof_rmtree -from mesonbuild import mlog +from mesonbuild import mlog, build def create_hash(fname): hashname = fname + '.sha256sum' @@ -178,24 +178,23 @@ def check_dist(packagename, meson_command, privdir): print('Distribution package %s tested' % packagename) return 0 -def run(args): - src_root = args[0] - bld_root = args[1] - meson_command = args[2:] +def run(opts): + b = build.load('.') + # This import must be load delayed, otherwise it will get the default + # value of None. + from mesonbuild.mesonlib import meson_command + src_root = b.environment.source_dir + bld_root = b.environment.build_dir priv_dir = os.path.join(bld_root, 'meson-private') dist_sub = os.path.join(bld_root, 'meson-dist') - buildfile = os.path.join(priv_dir, 'build.dat') - - build = pickle.load(open(buildfile, 'rb')) - - dist_name = build.project_name + '-' + build.project_version + dist_name = b.project_name + '-' + b.project_version _git = os.path.join(src_root, '.git') if os.path.isdir(_git) or os.path.isfile(_git): - names = create_dist_git(dist_name, src_root, bld_root, dist_sub, build.dist_scripts) + names = create_dist_git(dist_name, src_root, bld_root, dist_sub, b.dist_scripts) elif os.path.isdir(os.path.join(src_root, '.hg')): - names = create_dist_hg(dist_name, src_root, bld_root, dist_sub, build.dist_scripts) + names = create_dist_hg(dist_name, src_root, bld_root, dist_sub, b.dist_scripts) else: print('Dist currently only works with Git or Mercurial repos') return 1 diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index c94f1bf9d..c89465cf8 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -22,7 +22,7 @@ import shutil from . import mesonlib from . import mlog -from . import mconf, minit, minstall, mintro, msetup, mtest, rewriter, msubprojects, munstable_coredata +from . import mconf, mdist, minit, minstall, mintro, msetup, mtest, rewriter, msubprojects, munstable_coredata from .mesonlib import MesonException from .environment import detect_msys2_arch from .wrap import wraptool @@ -44,6 +44,8 @@ class CommandLineParser: help_msg='Configure the project') self.add_command('configure', mconf.add_arguments, mconf.run, help_msg='Change project options',) + self.add_command('dist', mconf.add_arguments, mdist.run, + help_msg='Generate release archive',) self.add_command('install', minstall.add_arguments, minstall.run, help_msg='Install the project') self.add_command('introspect', mintro.add_arguments, mintro.run,