Add support for checking out git repos to subprojects automatically.

pull/57/head
Jussi Pakkanen 10 years ago
parent df357211a8
commit 29fa1dd522
  1. 1
      .gitignore
  2. 13
      interpreter.py
  3. 2
      manual tests/1 wrap/subprojects/sqlite.wrap
  4. 3
      manual tests/2 multiwrap/subprojects/libpng.wrap
  5. 2
      manual tests/2 multiwrap/subprojects/lua.wrap
  6. 2
      manual tests/2 multiwrap/subprojects/zlib.wrap
  7. 8
      manual tests/3 git wrap/meson.build
  8. 6
      manual tests/3 git wrap/prog.c
  9. 4
      manual tests/3 git wrap/subprojects/samplesubproject.wrap
  10. 0
      manual tests/4 standalone binaries/Info.plist
  11. 0
      manual tests/4 standalone binaries/build_linux_package.sh
  12. 0
      manual tests/4 standalone binaries/build_osx_package.sh
  13. 0
      manual tests/4 standalone binaries/linux_bundler.sh
  14. 0
      manual tests/4 standalone binaries/meson.build
  15. 0
      manual tests/4 standalone binaries/myapp.cpp
  16. 0
      manual tests/4 standalone binaries/myapp.icns
  17. 0
      manual tests/4 standalone binaries/myapp.sh
  18. 0
      manual tests/4 standalone binaries/osx_bundler.sh
  19. 0
      manual tests/4 standalone binaries/readme.txt
  20. 0
      manual tests/4 standalone binaries/template.dmg.gz
  21. 39
      wrap.py

1
.gitignore vendored

@ -9,3 +9,4 @@ __pycache__
.DS_Store
*~
packagecache

@ -1015,14 +1015,11 @@ class Interpreter():
if dirname == self.subprojects:
return self.subprojects[dirname]
subdir = os.path.join('subprojects', dirname)
abs_subdir = os.path.join(self.build.environment.get_source_dir(), subdir)
if not os.path.isdir(abs_subdir):
r = wrap.Resolver(os.path.join(self.build.environment.get_source_dir(), 'subprojects'))
resolved = r.resolve(dirname)
if resolved is None:
raise InterpreterException('Subproject directory does not exist and can not be downloaded.')
subdir = os.path.join('subprojects', resolved)
abs_subdir = os.path.join(self.build.environment.get_source_dir(), 'subprojects', subdir)
r = wrap.Resolver(os.path.join(self.build.environment.get_source_dir(), 'subprojects'))
resolved = r.resolve(dirname)
if resolved is None:
raise InterpreterException('Subproject directory does not exist and can not be downloaded.')
subdir = os.path.join('subprojects', resolved)
os.makedirs(os.path.join(self.build.environment.get_build_dir(), subdir), exist_ok=True)
self.global_args_frozen = True
mlog.log('\nExecuting subproject ', mlog.bold(dirname), '.\n', sep='')

@ -1,4 +1,4 @@
[mesonwrap]
[wrap-file]
directory = sqlite-amalgamation-3080802
source_url = http://sqlite.com/2015/sqlite-amalgamation-3080802.zip

@ -1,5 +1,4 @@
[mesonwrap]
[wrap-file]
directory = libpng-1.6.16
source_url = ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.16.tar.gz

@ -1,4 +1,4 @@
[mesonwrap]
[wrap-file]
directory = lua-5.3.0
source_url = http://www.lua.org/ftp/lua-5.3.0.tar.gz

@ -1,4 +1,4 @@
[mesonwrap]
[wrap-file]
directory = zlib-1.2.8
source_url = http://zlib.net/zlib-1.2.8.tar.gz

@ -0,0 +1,8 @@
project('git outcheckker', 'c')
sp = subproject('samplesubproject')
exe = executable('gitprog', 'prog.c',
include_directories : sp.get_variable('subproj_inc'),
link_with : sp.get_variable('subproj_lib'),
)

@ -0,0 +1,6 @@
#include"subproj.h"
int main(int argc, char **argv) {
subproj_function();
return 0;
}

@ -0,0 +1,4 @@
[wrap-git]
directory=samplesubproject
url=https://github.com/jpakkane/samplesubproject.git
revision=head

@ -14,13 +14,19 @@
import mlog
import urllib.request, os, hashlib, shutil
import subprocess
class PackageDefinition:
def __init__(self, fname):
self.values = {}
ifile = open(fname)
first = ifile.readline().strip()
if first != '[mesonwrap]':
if first == '[wrap-file]':
self.type = 'file'
elif first == '[wrap-git]':
self.type = 'git'
else:
raise RuntimeError('Invalid format of package file')
for line in ifile:
line = line.strip()
@ -45,12 +51,35 @@ class Resolver:
def resolve(self, packagename):
fname = os.path.join(self.subdir_root, packagename + '.wrap')
if not os.path.isfile(fname):
if os.path.isdir(dirname):
# No wrap file but dir exists -> user put it there manually.
return packagename
return None
if not os.path.isdir(self.cachedir):
os.mkdir(self.cachedir)
p = PackageDefinition(fname)
self.download(p, packagename)
self.extract_package(p)
if p.type == 'file':
if not os.path.isdir(self.cachedir):
os.mkdir(self.cachedir)
self.download(p, packagename)
self.extract_package(p)
elif p.type == 'git':
checkoutdir = os.path.join(self.subdir_root, p.get('directory'))
revno = p.get('revision')
is_there = os.path.isdir(checkoutdir)
if is_there:
if revno.lower() == 'head':
subprocess.check_call(['git', 'pull'], cwd=checkoutdir)
else:
subprocess.check_call(['git', 'fetch'], cwd=checkoutdir)
subprocess.check_call(['git', 'checkout', revno],
cwd=checkoutdir)
else:
subprocess.check_call(['git', 'clone', p.get('url'), p.get('directory')],
cwd=self.subdir_root)
if revno.lower() != 'head':
subprocess.check_call(['git', 'checkout', revno],
cwd=checkoutdir)
else:
raise RuntimeError('Unreachable code.')
return p.get('directory')
def get_data(self, url):

Loading…
Cancel
Save