diff options
-rw-r--r-- | docs/markdown/Release-notes-for-0.41.0.md | 15 | ||||
-rw-r--r-- | mesonbuild/scripts/dist.py | 2 | ||||
-rwxr-xr-x | run_unittests.py | 42 |
3 files changed, 58 insertions, 1 deletions
diff --git a/docs/markdown/Release-notes-for-0.41.0.md b/docs/markdown/Release-notes-for-0.41.0.md index 8a7f263..c93fee8 100644 --- a/docs/markdown/Release-notes-for-0.41.0.md +++ b/docs/markdown/Release-notes-for-0.41.0.md @@ -38,3 +38,18 @@ pkg.generate(libraries : libs, description : 'A simple demo library.', variables : ['datadir=${prefix}/data']) ``` + +## A target for creating tarballs + +Creating distribution tarballs is simple: + + ninja dist + +This will create a `.tar.xz` archive of the source code including +submodules without any revision control information. This command also +verifies that the resulting archive can be built, tested and +installed. This is roughly equivalent to the `distcheck` target in +other build systems. Currently this only works for projects using Git +and only with the Ninja backend. + + diff --git a/mesonbuild/scripts/dist.py b/mesonbuild/scripts/dist.py index 622277a..ba6df7d 100644 --- a/mesonbuild/scripts/dist.py +++ b/mesonbuild/scripts/dist.py @@ -98,7 +98,7 @@ def check_dist(packagename, meson_command): tf = tarfile.open(packagename) tf.extractall(unpackdir) srcdir = glob(os.path.join(unpackdir, '*'))[0] - if subprocess.call(meson_command + [srcdir, builddir]) != 0: + if subprocess.call(meson_command + ['--backend=ninja', srcdir, builddir]) != 0: print('Running Meson on distribution package failed') return 1 if subprocess.call([ninja_bin], cwd=builddir) != 0: diff --git a/run_unittests.py b/run_unittests.py index 86e5a98..ec9d53b 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -331,6 +331,7 @@ class BasePlatformTests(unittest.TestCase): self.prefix = '/usr' self.libdir = os.path.join(self.prefix, 'lib') self.installdir = os.path.join(self.builddir, 'install') + self.distdir = os.path.join(self.builddir, 'meson-dist') # Get the backend # FIXME: Extract this from argv? self.backend = getattr(Backend, os.environ.get('MESON_UNIT_TEST_BACKEND', 'ninja')) @@ -1065,6 +1066,47 @@ class AllPlatformTests(BasePlatformTests): self.build() self.run_tests() + def test_dist(self): + if not shutil.which('git'): + raise unittest.SkipTest('Git not found') + try: + self.dist_impl() + except PermissionError: + # When run under Windows CI, something (virus scanner?) + # holds on to the git files so cleaning up the dir + # fails sometimes. + pass + + def dist_impl(self): + # Create this on the fly because having rogue .git directories inside + # the source tree leads to all kinds of trouble. + with tempfile.TemporaryDirectory() as project_dir: + with open(os.path.join(project_dir, 'meson.build'), 'w') as ofile: + ofile.write('''project('disttest', 'c', version : '1.4.3') +e = executable('distexe', 'distexe.c') +test('dist test', e) +''') + with open(os.path.join(project_dir, 'distexe.c'), 'w') as ofile: + ofile.write('''#include<stdio.h> + +int main(int argc, char **argv) { + printf("I am a distribution test.\\n"); + return 0; +} +''') + subprocess.check_call(['git', 'init'], cwd=project_dir) + subprocess.check_call(['git', 'config', + 'user.name', 'Author Person'], cwd=project_dir) + subprocess.check_call(['git', 'config', + 'user.email', 'teh_coderz@example.com'], cwd=project_dir) + subprocess.check_call(['git', 'add', 'meson.build', 'distexe.c'], cwd=project_dir) + subprocess.check_call(['git', 'commit', '-a', '-m', 'I am a project'], cwd=project_dir) + self.init(project_dir) + self.build('dist') + distfile = os.path.join(self.distdir, 'disttest-1.4.3.tar.xz') + checksumfile = distfile + '.sha256sum' + self.assertTrue(os.path.exists(distfile)) + self.assertTrue(os.path.exists(checksumfile)) class WindowsTests(BasePlatformTests): ''' |