aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--interpreter.py13
-rw-r--r--manual tests/1 wrap/subprojects/sqlite.wrap2
-rw-r--r--manual tests/2 multiwrap/subprojects/libpng.wrap3
-rw-r--r--manual tests/2 multiwrap/subprojects/lua.wrap2
-rw-r--r--manual tests/2 multiwrap/subprojects/zlib.wrap2
-rw-r--r--manual tests/3 git wrap/meson.build8
-rw-r--r--manual tests/3 git wrap/prog.c6
-rw-r--r--manual tests/3 git wrap/subprojects/samplesubproject.wrap4
-rw-r--r--manual tests/4 standalone binaries/Info.plist (renamed from manual tests/3 standalone binaries/Info.plist)0
-rwxr-xr-xmanual tests/4 standalone binaries/build_linux_package.sh (renamed from manual tests/3 standalone binaries/build_linux_package.sh)0
-rwxr-xr-xmanual tests/4 standalone binaries/build_osx_package.sh (renamed from manual tests/3 standalone binaries/build_osx_package.sh)0
-rwxr-xr-xmanual tests/4 standalone binaries/linux_bundler.sh (renamed from manual tests/3 standalone binaries/linux_bundler.sh)0
-rw-r--r--manual tests/4 standalone binaries/meson.build (renamed from manual tests/3 standalone binaries/meson.build)0
-rw-r--r--manual tests/4 standalone binaries/myapp.cpp (renamed from manual tests/3 standalone binaries/myapp.cpp)0
-rw-r--r--manual tests/4 standalone binaries/myapp.icns (renamed from manual tests/3 standalone binaries/myapp.icns)bin1831 -> 1831 bytes
-rwxr-xr-xmanual tests/4 standalone binaries/myapp.sh (renamed from manual tests/3 standalone binaries/myapp.sh)0
-rwxr-xr-xmanual tests/4 standalone binaries/osx_bundler.sh (renamed from manual tests/3 standalone binaries/osx_bundler.sh)0
-rw-r--r--manual tests/4 standalone binaries/readme.txt (renamed from manual tests/3 standalone binaries/readme.txt)0
-rw-r--r--manual tests/4 standalone binaries/template.dmg.gz (renamed from manual tests/3 standalone binaries/template.dmg.gz)bin37311 -> 37311 bytes
-rw-r--r--wrap.py39
21 files changed, 62 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore
index 886f7de..e09cfa0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ __pycache__
.DS_Store
*~
+packagecache
diff --git a/interpreter.py b/interpreter.py
index dfb42e6..98875ce 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -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='')
diff --git a/manual tests/1 wrap/subprojects/sqlite.wrap b/manual tests/1 wrap/subprojects/sqlite.wrap
index 879a170..b56e7e2 100644
--- a/manual tests/1 wrap/subprojects/sqlite.wrap
+++ b/manual tests/1 wrap/subprojects/sqlite.wrap
@@ -1,4 +1,4 @@
-[mesonwrap]
+[wrap-file]
directory = sqlite-amalgamation-3080802
source_url = http://sqlite.com/2015/sqlite-amalgamation-3080802.zip
diff --git a/manual tests/2 multiwrap/subprojects/libpng.wrap b/manual tests/2 multiwrap/subprojects/libpng.wrap
index bd65080..d7cb93e 100644
--- a/manual tests/2 multiwrap/subprojects/libpng.wrap
+++ b/manual tests/2 multiwrap/subprojects/libpng.wrap
@@ -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
diff --git a/manual tests/2 multiwrap/subprojects/lua.wrap b/manual tests/2 multiwrap/subprojects/lua.wrap
index da2ca14..8f19d15 100644
--- a/manual tests/2 multiwrap/subprojects/lua.wrap
+++ b/manual tests/2 multiwrap/subprojects/lua.wrap
@@ -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
diff --git a/manual tests/2 multiwrap/subprojects/zlib.wrap b/manual tests/2 multiwrap/subprojects/zlib.wrap
index 7ea3354..37202f8 100644
--- a/manual tests/2 multiwrap/subprojects/zlib.wrap
+++ b/manual tests/2 multiwrap/subprojects/zlib.wrap
@@ -1,4 +1,4 @@
-[mesonwrap]
+[wrap-file]
directory = zlib-1.2.8
source_url = http://zlib.net/zlib-1.2.8.tar.gz
diff --git a/manual tests/3 git wrap/meson.build b/manual tests/3 git wrap/meson.build
new file mode 100644
index 0000000..f3cce00
--- /dev/null
+++ b/manual tests/3 git wrap/meson.build
@@ -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'),
+)
diff --git a/manual tests/3 git wrap/prog.c b/manual tests/3 git wrap/prog.c
new file mode 100644
index 0000000..df38000
--- /dev/null
+++ b/manual tests/3 git wrap/prog.c
@@ -0,0 +1,6 @@
+#include"subproj.h"
+
+int main(int argc, char **argv) {
+ subproj_function();
+ return 0;
+}
diff --git a/manual tests/3 git wrap/subprojects/samplesubproject.wrap b/manual tests/3 git wrap/subprojects/samplesubproject.wrap
new file mode 100644
index 0000000..f52190b
--- /dev/null
+++ b/manual tests/3 git wrap/subprojects/samplesubproject.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+directory=samplesubproject
+url=https://github.com/jpakkane/samplesubproject.git
+revision=head
diff --git a/manual tests/3 standalone binaries/Info.plist b/manual tests/4 standalone binaries/Info.plist
index 0f0c90e..0f0c90e 100644
--- a/manual tests/3 standalone binaries/Info.plist
+++ b/manual tests/4 standalone binaries/Info.plist
diff --git a/manual tests/3 standalone binaries/build_linux_package.sh b/manual tests/4 standalone binaries/build_linux_package.sh
index 806a453..806a453 100755
--- a/manual tests/3 standalone binaries/build_linux_package.sh
+++ b/manual tests/4 standalone binaries/build_linux_package.sh
diff --git a/manual tests/3 standalone binaries/build_osx_package.sh b/manual tests/4 standalone binaries/build_osx_package.sh
index eca11c6..eca11c6 100755
--- a/manual tests/3 standalone binaries/build_osx_package.sh
+++ b/manual tests/4 standalone binaries/build_osx_package.sh
diff --git a/manual tests/3 standalone binaries/linux_bundler.sh b/manual tests/4 standalone binaries/linux_bundler.sh
index a0e5c12..a0e5c12 100755
--- a/manual tests/3 standalone binaries/linux_bundler.sh
+++ b/manual tests/4 standalone binaries/linux_bundler.sh
diff --git a/manual tests/3 standalone binaries/meson.build b/manual tests/4 standalone binaries/meson.build
index e5e6ee0..e5e6ee0 100644
--- a/manual tests/3 standalone binaries/meson.build
+++ b/manual tests/4 standalone binaries/meson.build
diff --git a/manual tests/3 standalone binaries/myapp.cpp b/manual tests/4 standalone binaries/myapp.cpp
index c57fd04..c57fd04 100644
--- a/manual tests/3 standalone binaries/myapp.cpp
+++ b/manual tests/4 standalone binaries/myapp.cpp
diff --git a/manual tests/3 standalone binaries/myapp.icns b/manual tests/4 standalone binaries/myapp.icns
index 6331954..6331954 100644
--- a/manual tests/3 standalone binaries/myapp.icns
+++ b/manual tests/4 standalone binaries/myapp.icns
Binary files differ
diff --git a/manual tests/3 standalone binaries/myapp.sh b/manual tests/4 standalone binaries/myapp.sh
index 3191483..3191483 100755
--- a/manual tests/3 standalone binaries/myapp.sh
+++ b/manual tests/4 standalone binaries/myapp.sh
diff --git a/manual tests/3 standalone binaries/osx_bundler.sh b/manual tests/4 standalone binaries/osx_bundler.sh
index f61187f..f61187f 100755
--- a/manual tests/3 standalone binaries/osx_bundler.sh
+++ b/manual tests/4 standalone binaries/osx_bundler.sh
diff --git a/manual tests/3 standalone binaries/readme.txt b/manual tests/4 standalone binaries/readme.txt
index 6b26c49..6b26c49 100644
--- a/manual tests/3 standalone binaries/readme.txt
+++ b/manual tests/4 standalone binaries/readme.txt
diff --git a/manual tests/3 standalone binaries/template.dmg.gz b/manual tests/4 standalone binaries/template.dmg.gz
index fcb6d61..fcb6d61 100644
--- a/manual tests/3 standalone binaries/template.dmg.gz
+++ b/manual tests/4 standalone binaries/template.dmg.gz
Binary files differ
diff --git a/wrap.py b/wrap.py
index af2b213..9c88403 100644
--- a/wrap.py
+++ b/wrap.py
@@ -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):