diff options
author | Max Kellermann <max@duempel.org> | 2015-11-20 23:47:52 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-11-20 23:47:52 +0100 |
commit | 86486336ecf3183ab7e3444fd2bf2a60d9f71247 (patch) | |
tree | 36678a0f513fff23d53e56036d46b00cdd32d70c | |
parent | ec2a2522aa56d9d7c13bfa0074dcd344068f93ac (diff) | |
download | mpd-86486336ecf3183ab7e3444fd2bf2a60d9f71247.tar.gz mpd-86486336ecf3183ab7e3444fd2bf2a60d9f71247.tar.xz mpd-86486336ecf3183ab7e3444fd2bf2a60d9f71247.zip |
{android,win32}/build.py: add tarball_path and src_path to toolchain class
Reduce dependencies on global variables.
-rwxr-xr-x | android/build.py | 39 | ||||
-rwxr-xr-x | win32/build.py | 40 |
2 files changed, 44 insertions, 35 deletions
diff --git a/android/build.py b/android/build.py index c961a1f82..dc4742b51 100755 --- a/android/build.py +++ b/android/build.py @@ -45,7 +45,12 @@ build_arch = 'linux-x86_64' # set up the NDK toolchain class AndroidNdkToolchain: - def __init__(self, use_cxx, use_clang): + def __init__(self, tarball_path, src_path, build_path, + use_cxx, use_clang): + self.tarball_path = tarball_path + self.src_path = src_path + self.build_path = build_path + self.ndk_arch = 'arm' android_abi = 'armeabi-v7a' ndk_platform = 'android-14' @@ -135,12 +140,11 @@ class Project: self.use_cxx = use_cxx self.use_clang = use_clang - def download(self): - global tarball_path - return download_and_verify(self.url, self.md5, tarball_path) + def download(self, toolchain): + return download_and_verify(self.url, self.md5, toolchain.tarball_path) def is_installed(self, toolchain): - tarball = self.download() + tarball = self.download(toolchain) installed = os.path.join(toolchain.install_prefix, self.installed) tarball_mtime = os.path.getmtime(tarball) try: @@ -148,12 +152,11 @@ class Project: except FileNotFoundError: return False - def unpack(self): - global src_path - return untar(self.download(), src_path, self.base) + def unpack(self, toolchain): + return untar(self.download(toolchain), toolchain.src_path, self.base) - def make_build_path(self): - path = os.path.join(build_path, self.base) + def make_build_path(self, toolchain): + path = os.path.join(toolchain.build_path, self.base) try: shutil.rmtree(path) except FileNotFoundError: @@ -172,14 +175,14 @@ class AutotoolsProject(Project): self.cppflags = cppflags def build(self, toolchain): - src = self.unpack() + src = self.unpack(toolchain) if self.autogen: subprocess.check_call(['/usr/bin/aclocal'], cwd=src) subprocess.check_call(['/usr/bin/automake', '--add-missing', '--force-missing', '--foreign'], cwd=src) subprocess.check_call(['/usr/bin/autoconf'], cwd=src) subprocess.check_call(['/usr/bin/libtoolize', '--force'], cwd=src) - build = self.make_build_path() + build = self.make_build_path(toolchain) configure = [ os.path.join(src, 'configure'), @@ -210,8 +213,8 @@ class FfmpegProject(Project): self.cppflags = cppflags def build(self, toolchain): - src = self.unpack() - build = self.make_build_path() + src = self.unpack(toolchain) + build = self.make_build_path(toolchain) configure = [ os.path.join(src, 'configure'), @@ -244,7 +247,7 @@ class BoostProject(Project): **kwargs) def build(self, toolchain): - src = self.unpack() + src = self.unpack(toolchain) # install the headers manually; don't build any library # (because right now, we only use header-only libraries) @@ -367,12 +370,14 @@ thirdparty_libs = [ # build the third-party libraries for x in thirdparty_libs: - toolchain = AndroidNdkToolchain(use_cxx=x.use_cxx, use_clang=x.use_clang) + toolchain = AndroidNdkToolchain(tarball_path, src_path, build_path, + use_cxx=x.use_cxx, use_clang=x.use_clang) if not x.is_installed(toolchain): x.build(toolchain) # configure and build MPD -toolchain = AndroidNdkToolchain(use_cxx=True, use_clang=True) +toolchain = AndroidNdkToolchain(tarball_path, src_path, build_path, + use_cxx=True, use_clang=True) configure = [ os.path.join(mpd_path, 'configure'), diff --git a/win32/build.py b/win32/build.py index cddd671ec..db92fd7c4 100755 --- a/win32/build.py +++ b/win32/build.py @@ -30,8 +30,12 @@ build_path = os.path.join(arch_path, 'build') root_path = os.path.join(arch_path, 'root') class CrossGccToolchain: - def __init__(self, toolchain_path, arch, install_prefix): + def __init__(self, toolchain_path, arch, + tarball_path, src_path, build_path, install_prefix): self.arch = arch + self.tarball_path = tarball_path + self.src_path = src_path + self.build_path = build_path self.install_prefix = install_prefix toolchain_bin = os.path.join(toolchain_path, 'bin') @@ -80,11 +84,11 @@ class Project: self.md5 = md5 self.installed = installed - def download(self): - return download_and_verify(self.url, self.md5, tarball_path) + def download(self, toolchain): + return download_and_verify(self.url, self.md5, toolchain.tarball_path) def is_installed(self, toolchain): - tarball = self.download() + tarball = self.download(toolchain) installed = os.path.join(toolchain.install_prefix, self.installed) tarball_mtime = os.path.getmtime(tarball) try: @@ -92,16 +96,15 @@ class Project: except FileNotFoundError: return False - def unpack(self, out_of_tree=True): - global src_path, build_path + def unpack(self, toolchain, out_of_tree=True): if out_of_tree: - parent_path = src_path + parent_path = toolchain.src_path else: - parent_path = build_path - return untar(self.download(), parent_path, self.base) + parent_path = toolchain.build_path + return untar(self.download(toolchain), parent_path, self.base) - def make_build_path(self): - path = os.path.join(build_path, self.base) + def make_build_path(self, toolchain): + path = os.path.join(toolchain.build_path, self.base) try: shutil.rmtree(path) except FileNotFoundError: @@ -120,14 +123,14 @@ class AutotoolsProject(Project): self.cppflags = cppflags def build(self, toolchain): - src = self.unpack() + src = self.unpack(toolchain) if self.autogen: subprocess.check_call(['/usr/bin/aclocal'], cwd=src) subprocess.check_call(['/usr/bin/automake', '--add-missing', '--force-missing', '--foreign'], cwd=src) subprocess.check_call(['/usr/bin/autoconf'], cwd=src) subprocess.check_call(['/usr/bin/libtoolize', '--force'], cwd=src) - build = self.make_build_path() + build = self.make_build_path(toolchain) configure = [ os.path.join(src, 'configure'), @@ -157,7 +160,7 @@ class ZlibProject(Project): Project.__init__(self, url, md5, installed, **kwargs) def build(self, toolchain): - src = self.unpack(out_of_tree=False) + src = self.unpack(toolchain, out_of_tree=False) subprocess.check_call(['/usr/bin/make', '--quiet', '-f', 'win32/Makefile.gcc', @@ -179,8 +182,8 @@ class FfmpegProject(Project): self.cppflags = cppflags def build(self, toolchain): - src = self.unpack() - build = self.make_build_path() + src = self.unpack(toolchain) + build = self.make_build_path(toolchain) configure = [ os.path.join(src, 'configure'), @@ -215,7 +218,7 @@ class BoostProject(Project): **kwargs) def build(self, toolchain): - src = self.unpack() + src = self.unpack(toolchain) # install the headers manually; don't build any library # (because right now, we only use header-only libraries) @@ -332,7 +335,8 @@ thirdparty_libs = [ ] # build the third-party libraries -toolchain = CrossGccToolchain('/usr', host_arch, root_path) +toolchain = CrossGccToolchain('/usr', host_arch, + tarball_path, src_path, build_path, root_path) for x in thirdparty_libs: if not x.is_installed(toolchain): |