Skip to content

Commit

Permalink
Made dist a top level command.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Jul 23, 2019
1 parent 3811101 commit 7ce2a24
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
6 changes: 1 addition & 5 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2645,11 +2645,7 @@ def get_user_option_args(self):
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
Expand Down
23 changes: 11 additions & 12 deletions mesonbuild/scripts/dist.py → mesonbuild/mdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
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'
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion mesonbuild/mesonmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

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
Expand All @@ -44,6 +44,8 @@ def __init__(self):
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,
Expand Down

0 comments on commit 7ce2a24

Please sign in to comment.