From 29fa1dd52289ea3141c251f66b70bf660c7724e1 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Fri, 20 Mar 2015 15:45:32 +0200 Subject: Add support for checking out git repos to subprojects automatically. --- .gitignore | 1 + interpreter.py | 13 +++---- manual tests/1 wrap/subprojects/sqlite.wrap | 2 +- manual tests/2 multiwrap/subprojects/libpng.wrap | 3 +- manual tests/2 multiwrap/subprojects/lua.wrap | 2 +- manual tests/2 multiwrap/subprojects/zlib.wrap | 2 +- manual tests/3 git wrap/meson.build | 8 +++++ manual tests/3 git wrap/prog.c | 6 ++++ .../3 git wrap/subprojects/samplesubproject.wrap | 4 +++ manual tests/3 standalone binaries/Info.plist | 26 -------------- .../3 standalone binaries/build_linux_package.sh | 12 ------- .../3 standalone binaries/build_osx_package.sh | 21 ----------- .../3 standalone binaries/linux_bundler.sh | 7 ---- manual tests/3 standalone binaries/meson.build | 30 ---------------- manual tests/3 standalone binaries/myapp.cpp | 39 --------------------- manual tests/3 standalone binaries/myapp.icns | Bin 1831 -> 0 bytes manual tests/3 standalone binaries/myapp.sh | 10 ------ manual tests/3 standalone binaries/osx_bundler.sh | 6 ---- manual tests/3 standalone binaries/readme.txt | 12 ------- manual tests/3 standalone binaries/template.dmg.gz | Bin 37311 -> 0 bytes manual tests/4 standalone binaries/Info.plist | 26 ++++++++++++++ .../4 standalone binaries/build_linux_package.sh | 12 +++++++ .../4 standalone binaries/build_osx_package.sh | 21 +++++++++++ .../4 standalone binaries/linux_bundler.sh | 7 ++++ manual tests/4 standalone binaries/meson.build | 30 ++++++++++++++++ manual tests/4 standalone binaries/myapp.cpp | 39 +++++++++++++++++++++ manual tests/4 standalone binaries/myapp.icns | Bin 0 -> 1831 bytes manual tests/4 standalone binaries/myapp.sh | 10 ++++++ manual tests/4 standalone binaries/osx_bundler.sh | 6 ++++ manual tests/4 standalone binaries/readme.txt | 12 +++++++ manual tests/4 standalone binaries/template.dmg.gz | Bin 0 -> 37311 bytes wrap.py | 39 ++++++++++++++++++--- 32 files changed, 225 insertions(+), 181 deletions(-) create mode 100644 manual tests/3 git wrap/meson.build create mode 100644 manual tests/3 git wrap/prog.c create mode 100644 manual tests/3 git wrap/subprojects/samplesubproject.wrap delete mode 100644 manual tests/3 standalone binaries/Info.plist delete mode 100755 manual tests/3 standalone binaries/build_linux_package.sh delete mode 100755 manual tests/3 standalone binaries/build_osx_package.sh delete mode 100755 manual tests/3 standalone binaries/linux_bundler.sh delete mode 100644 manual tests/3 standalone binaries/meson.build delete mode 100644 manual tests/3 standalone binaries/myapp.cpp delete mode 100644 manual tests/3 standalone binaries/myapp.icns delete mode 100755 manual tests/3 standalone binaries/myapp.sh delete mode 100755 manual tests/3 standalone binaries/osx_bundler.sh delete mode 100644 manual tests/3 standalone binaries/readme.txt delete mode 100644 manual tests/3 standalone binaries/template.dmg.gz create mode 100644 manual tests/4 standalone binaries/Info.plist create mode 100755 manual tests/4 standalone binaries/build_linux_package.sh create mode 100755 manual tests/4 standalone binaries/build_osx_package.sh create mode 100755 manual tests/4 standalone binaries/linux_bundler.sh create mode 100644 manual tests/4 standalone binaries/meson.build create mode 100644 manual tests/4 standalone binaries/myapp.cpp create mode 100644 manual tests/4 standalone binaries/myapp.icns create mode 100755 manual tests/4 standalone binaries/myapp.sh create mode 100755 manual tests/4 standalone binaries/osx_bundler.sh create mode 100644 manual tests/4 standalone binaries/readme.txt create mode 100644 manual tests/4 standalone binaries/template.dmg.gz 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/3 standalone binaries/Info.plist deleted file mode 100644 index 0f0c90e..0000000 --- a/manual tests/3 standalone binaries/Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleGetInfoString - MyApp - CFBundleExecutable - myapp.sh - CFBundleIdentifier - com.example.me - CFBundleName - myapp - CFBundleIconFile - myapp.icns - CFBundleShortVersionString - 1.0 - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - APPL - IFMajorVersion - 0 - IFMinorVersion - 1 - - diff --git a/manual tests/3 standalone binaries/build_linux_package.sh b/manual tests/3 standalone binaries/build_linux_package.sh deleted file mode 100755 index 806a453..0000000 --- a/manual tests/3 standalone binaries/build_linux_package.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -curdir=`pwd` -rm -rf buildtmp -mkdir buildtmp -LDFLAGS=-static-libstdc++ ~/meson/meson.py buildtmp --buildtype=release --prefix=/tmp/myapp --libdir=lib --strip -ninja -C buildtmp install -rm -rf buildtmp -cd /tmp/ -tar czf myapp.tar.gz myapp -mv myapp.tar.gz "$curdir" -rm -rf myapp diff --git a/manual tests/3 standalone binaries/build_osx_package.sh b/manual tests/3 standalone binaries/build_osx_package.sh deleted file mode 100755 index eca11c6..0000000 --- a/manual tests/3 standalone binaries/build_osx_package.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -rm -rf buildtmp -mkdir buildtmp -~/meson/meson.py buildtmp --buildtype=release --prefix=/tmp/myapp.app --bindir=Contents/MacOS -ninja -C buildtmp install -rm -rf buildtmp -mkdir -p mnttmp -rm -f working.dmg -gunzip < template.dmg.gz > working.dmg -hdiutil attach working.dmg -noautoopen -quiet -mountpoint mnttmp -# NOTE: output of hdiutil changes every now and then. -# Verify that this is still working. -DEV=`hdiutil info|tail -1|awk '{print $1}'` -rm -rf mnttmp/myapp.app -mv /tmp/myapp.app mnttmp -hdiutil detach ${DEV} -rm -rf mnttmp -rm -f myapp.dmg -hdiutil convert working.dmg -quiet -format UDZO -imagekey zlib-level=9 -o myapp.dmg -rm -f working.dmg diff --git a/manual tests/3 standalone binaries/linux_bundler.sh b/manual tests/3 standalone binaries/linux_bundler.sh deleted file mode 100755 index a0e5c12..0000000 --- a/manual tests/3 standalone binaries/linux_bundler.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -libdir="${MESON_INSTALL_PREFIX}/lib" -mkdir -p $libdir -sdlfile=`ldd ${MESON_INSTALL_PREFIX}/bin/myapp | grep libSDL | cut -d ' ' -f 3` -cp $sdlfile "${libdir}" -strip "${libdir}/libSDL"* diff --git a/manual tests/3 standalone binaries/meson.build b/manual tests/3 standalone binaries/meson.build deleted file mode 100644 index e5e6ee0..0000000 --- a/manual tests/3 standalone binaries/meson.build +++ /dev/null @@ -1,30 +0,0 @@ -project('myapp', 'cpp') - -sdl = dependency('sdl2') - -if meson.get_compiler('cpp').get_id() != 'msvc' - add_global_arguments('-std=c++11', language : 'cpp') -endif - -if host.name() == 'darwin' - install_data('myapp.sh', - install_dir : 'Contents/MacOS') - - install_data('myapp.icns', - install_dir : 'Contents/Resources') - - install_data('Info.plist', - install_dir : 'Contents') - - meson.set_install_script('osx_bundler.sh') -endif - -if host.name() == 'linux' - install_data('myapp.sh', install_dir : '.') - meson.set_install_script('linux_bundler.sh') -endif - - -prog = executable('myapp', 'myapp.cpp', -dependencies : sdl, -install : true) diff --git a/manual tests/3 standalone binaries/myapp.cpp b/manual tests/3 standalone binaries/myapp.cpp deleted file mode 100644 index c57fd04..0000000 --- a/manual tests/3 standalone binaries/myapp.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include - -int main(int argc, char **argv) { - SDL_Surface *screenSurface; - SDL_Event e; - int keepGoing = 1; - std::string message; - - if(SDL_Init( SDL_INIT_VIDEO ) < 0) { - printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); - } - atexit(SDL_Quit); - - std::unique_ptr window(SDL_CreateWindow( "My application", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN), SDL_DestroyWindow); - screenSurface = SDL_GetWindowSurface(window.get()); - - // Use iostream to make sure we have not screwed - // up libstdc++ linking. - message = "Window created."; - message += " Starting main loop."; - std::cout << message << std::endl; - - while(keepGoing) { - while(SDL_PollEvent(&e) != 0) { - if(e.type == SDL_QUIT) { - keepGoing = 0; - break; - } - } - SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0x00, 0x00)); - SDL_UpdateWindowSurface(window.get()); - SDL_Delay(100); - } - - return 0; -} diff --git a/manual tests/3 standalone binaries/myapp.icns b/manual tests/3 standalone binaries/myapp.icns deleted file mode 100644 index 6331954..0000000 Binary files a/manual tests/3 standalone binaries/myapp.icns and /dev/null differ diff --git a/manual tests/3 standalone binaries/myapp.sh b/manual tests/3 standalone binaries/myapp.sh deleted file mode 100755 index 3191483..0000000 --- a/manual tests/3 standalone binaries/myapp.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -cd "${0%/*}" - -if [ `uname` == 'Darwin' ]; then - ./myapp -else - export LD_LIBRARY_PATH="`pwd`/lib" - bin/myapp -fi diff --git a/manual tests/3 standalone binaries/osx_bundler.sh b/manual tests/3 standalone binaries/osx_bundler.sh deleted file mode 100755 index f61187f..0000000 --- a/manual tests/3 standalone binaries/osx_bundler.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -mkdir -p ${MESON_INSTALL_PREFIX}/Contents/Frameworks -cp -r /Library/Frameworks/SDL2.framework ${MESON_INSTALL_PREFIX}/Contents/Frameworks - -install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/../Frameworks/SDL2.framework/Versions/A/SDL2 ${MESON_INSTALL_PREFIX}/Contents/MacOS/myapp diff --git a/manual tests/3 standalone binaries/readme.txt b/manual tests/3 standalone binaries/readme.txt deleted file mode 100644 index 6b26c49..0000000 --- a/manual tests/3 standalone binaries/readme.txt +++ /dev/null @@ -1,12 +0,0 @@ -This directory shows how you can build redistributable binaries. On -OSX this menans building an app bundle and a .dmg installer. On Linux -it means building a binary that bundles its dependencies. On Windows -it means probably building an .exe installer or something (not done -yet). - -To build each package you run the corresponding build_ARCH.sh build script. - -On Linux you must build the package on the oldest distribution you -plan to support (Debian stable/oldstable and old CentOS are usually -the choice here). - diff --git a/manual tests/3 standalone binaries/template.dmg.gz b/manual tests/3 standalone binaries/template.dmg.gz deleted file mode 100644 index fcb6d61..0000000 Binary files a/manual tests/3 standalone binaries/template.dmg.gz and /dev/null differ diff --git a/manual tests/4 standalone binaries/Info.plist b/manual tests/4 standalone binaries/Info.plist new file mode 100644 index 0000000..0f0c90e --- /dev/null +++ b/manual tests/4 standalone binaries/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleGetInfoString + MyApp + CFBundleExecutable + myapp.sh + CFBundleIdentifier + com.example.me + CFBundleName + myapp + CFBundleIconFile + myapp.icns + CFBundleShortVersionString + 1.0 + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + IFMajorVersion + 0 + IFMinorVersion + 1 + + diff --git a/manual tests/4 standalone binaries/build_linux_package.sh b/manual tests/4 standalone binaries/build_linux_package.sh new file mode 100755 index 0000000..806a453 --- /dev/null +++ b/manual tests/4 standalone binaries/build_linux_package.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +curdir=`pwd` +rm -rf buildtmp +mkdir buildtmp +LDFLAGS=-static-libstdc++ ~/meson/meson.py buildtmp --buildtype=release --prefix=/tmp/myapp --libdir=lib --strip +ninja -C buildtmp install +rm -rf buildtmp +cd /tmp/ +tar czf myapp.tar.gz myapp +mv myapp.tar.gz "$curdir" +rm -rf myapp diff --git a/manual tests/4 standalone binaries/build_osx_package.sh b/manual tests/4 standalone binaries/build_osx_package.sh new file mode 100755 index 0000000..eca11c6 --- /dev/null +++ b/manual tests/4 standalone binaries/build_osx_package.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +rm -rf buildtmp +mkdir buildtmp +~/meson/meson.py buildtmp --buildtype=release --prefix=/tmp/myapp.app --bindir=Contents/MacOS +ninja -C buildtmp install +rm -rf buildtmp +mkdir -p mnttmp +rm -f working.dmg +gunzip < template.dmg.gz > working.dmg +hdiutil attach working.dmg -noautoopen -quiet -mountpoint mnttmp +# NOTE: output of hdiutil changes every now and then. +# Verify that this is still working. +DEV=`hdiutil info|tail -1|awk '{print $1}'` +rm -rf mnttmp/myapp.app +mv /tmp/myapp.app mnttmp +hdiutil detach ${DEV} +rm -rf mnttmp +rm -f myapp.dmg +hdiutil convert working.dmg -quiet -format UDZO -imagekey zlib-level=9 -o myapp.dmg +rm -f working.dmg diff --git a/manual tests/4 standalone binaries/linux_bundler.sh b/manual tests/4 standalone binaries/linux_bundler.sh new file mode 100755 index 0000000..a0e5c12 --- /dev/null +++ b/manual tests/4 standalone binaries/linux_bundler.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +libdir="${MESON_INSTALL_PREFIX}/lib" +mkdir -p $libdir +sdlfile=`ldd ${MESON_INSTALL_PREFIX}/bin/myapp | grep libSDL | cut -d ' ' -f 3` +cp $sdlfile "${libdir}" +strip "${libdir}/libSDL"* diff --git a/manual tests/4 standalone binaries/meson.build b/manual tests/4 standalone binaries/meson.build new file mode 100644 index 0000000..e5e6ee0 --- /dev/null +++ b/manual tests/4 standalone binaries/meson.build @@ -0,0 +1,30 @@ +project('myapp', 'cpp') + +sdl = dependency('sdl2') + +if meson.get_compiler('cpp').get_id() != 'msvc' + add_global_arguments('-std=c++11', language : 'cpp') +endif + +if host.name() == 'darwin' + install_data('myapp.sh', + install_dir : 'Contents/MacOS') + + install_data('myapp.icns', + install_dir : 'Contents/Resources') + + install_data('Info.plist', + install_dir : 'Contents') + + meson.set_install_script('osx_bundler.sh') +endif + +if host.name() == 'linux' + install_data('myapp.sh', install_dir : '.') + meson.set_install_script('linux_bundler.sh') +endif + + +prog = executable('myapp', 'myapp.cpp', +dependencies : sdl, +install : true) diff --git a/manual tests/4 standalone binaries/myapp.cpp b/manual tests/4 standalone binaries/myapp.cpp new file mode 100644 index 0000000..c57fd04 --- /dev/null +++ b/manual tests/4 standalone binaries/myapp.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +int main(int argc, char **argv) { + SDL_Surface *screenSurface; + SDL_Event e; + int keepGoing = 1; + std::string message; + + if(SDL_Init( SDL_INIT_VIDEO ) < 0) { + printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); + } + atexit(SDL_Quit); + + std::unique_ptr window(SDL_CreateWindow( "My application", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN), SDL_DestroyWindow); + screenSurface = SDL_GetWindowSurface(window.get()); + + // Use iostream to make sure we have not screwed + // up libstdc++ linking. + message = "Window created."; + message += " Starting main loop."; + std::cout << message << std::endl; + + while(keepGoing) { + while(SDL_PollEvent(&e) != 0) { + if(e.type == SDL_QUIT) { + keepGoing = 0; + break; + } + } + SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0x00, 0x00)); + SDL_UpdateWindowSurface(window.get()); + SDL_Delay(100); + } + + return 0; +} diff --git a/manual tests/4 standalone binaries/myapp.icns b/manual tests/4 standalone binaries/myapp.icns new file mode 100644 index 0000000..6331954 Binary files /dev/null and b/manual tests/4 standalone binaries/myapp.icns differ diff --git a/manual tests/4 standalone binaries/myapp.sh b/manual tests/4 standalone binaries/myapp.sh new file mode 100755 index 0000000..3191483 --- /dev/null +++ b/manual tests/4 standalone binaries/myapp.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +cd "${0%/*}" + +if [ `uname` == 'Darwin' ]; then + ./myapp +else + export LD_LIBRARY_PATH="`pwd`/lib" + bin/myapp +fi diff --git a/manual tests/4 standalone binaries/osx_bundler.sh b/manual tests/4 standalone binaries/osx_bundler.sh new file mode 100755 index 0000000..f61187f --- /dev/null +++ b/manual tests/4 standalone binaries/osx_bundler.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +mkdir -p ${MESON_INSTALL_PREFIX}/Contents/Frameworks +cp -r /Library/Frameworks/SDL2.framework ${MESON_INSTALL_PREFIX}/Contents/Frameworks + +install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/../Frameworks/SDL2.framework/Versions/A/SDL2 ${MESON_INSTALL_PREFIX}/Contents/MacOS/myapp diff --git a/manual tests/4 standalone binaries/readme.txt b/manual tests/4 standalone binaries/readme.txt new file mode 100644 index 0000000..6b26c49 --- /dev/null +++ b/manual tests/4 standalone binaries/readme.txt @@ -0,0 +1,12 @@ +This directory shows how you can build redistributable binaries. On +OSX this menans building an app bundle and a .dmg installer. On Linux +it means building a binary that bundles its dependencies. On Windows +it means probably building an .exe installer or something (not done +yet). + +To build each package you run the corresponding build_ARCH.sh build script. + +On Linux you must build the package on the oldest distribution you +plan to support (Debian stable/oldstable and old CentOS are usually +the choice here). + diff --git a/manual tests/4 standalone binaries/template.dmg.gz b/manual tests/4 standalone binaries/template.dmg.gz new file mode 100644 index 0000000..fcb6d61 Binary files /dev/null and b/manual tests/4 standalone binaries/template.dmg.gz 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): -- cgit v1.1