{android,win32}/build.py: add toolchain classes
This commit is contained in:
parent
3079aa1f9d
commit
2daa3eb61f
204
android/build.py
204
android/build.py
|
@ -23,14 +23,7 @@ if not os.path.isdir(ndk_path):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# select the NDK target
|
# select the NDK target
|
||||||
ndk_arch = 'arm'
|
arch = 'arm-linux-androideabi'
|
||||||
host_arch = 'arm-linux-androideabi'
|
|
||||||
android_abi = 'armeabi-v7a'
|
|
||||||
ndk_platform = 'android-14'
|
|
||||||
|
|
||||||
# select the NDK compiler
|
|
||||||
gcc_version = '4.9'
|
|
||||||
llvm_version = '3.6'
|
|
||||||
|
|
||||||
# the path to the MPD sources
|
# the path to the MPD sources
|
||||||
mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
|
mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
|
||||||
|
@ -44,55 +37,74 @@ if 'MPD_SHARED_LIB' in os.environ:
|
||||||
tarball_path = os.path.join(shared_path, 'download')
|
tarball_path = os.path.join(shared_path, 'download')
|
||||||
src_path = os.path.join(shared_path, 'src')
|
src_path = os.path.join(shared_path, 'src')
|
||||||
|
|
||||||
arch_path = os.path.join(lib_path, host_arch)
|
arch_path = os.path.join(lib_path, arch)
|
||||||
build_path = os.path.join(arch_path, 'build')
|
build_path = os.path.join(arch_path, 'build')
|
||||||
root_path = os.path.join(arch_path, 'root')
|
|
||||||
|
|
||||||
# build host configuration
|
# build host configuration
|
||||||
build_arch = 'linux-x86_64'
|
build_arch = 'linux-x86_64'
|
||||||
|
|
||||||
# redirect pkg-config to use our root directory instead of the default
|
|
||||||
# one on the build host
|
|
||||||
os.environ['PKG_CONFIG_LIBDIR'] = os.path.join(root_path, 'lib/pkgconfig')
|
|
||||||
|
|
||||||
# set up the NDK toolchain
|
# set up the NDK toolchain
|
||||||
|
|
||||||
gcc_toolchain = os.path.join(ndk_path, 'toolchains', host_arch + '-' + gcc_version, 'prebuilt', build_arch)
|
class AndroidNdkToolchain:
|
||||||
llvm_toolchain = os.path.join(ndk_path, 'toolchains', 'llvm-' + llvm_version, 'prebuilt', build_arch)
|
def __init__(self, use_cxx, use_clang):
|
||||||
ndk_platform_path = os.path.join(ndk_path, 'platforms', ndk_platform)
|
self.ndk_arch = 'arm'
|
||||||
target_root = os.path.join(ndk_platform_path, 'arch-' + ndk_arch)
|
android_abi = 'armeabi-v7a'
|
||||||
|
ndk_platform = 'android-14'
|
||||||
|
|
||||||
llvm_triple = 'armv7-none-linux-androideabi'
|
# select the NDK compiler
|
||||||
|
gcc_version = '4.9'
|
||||||
|
llvm_version = '3.6'
|
||||||
|
|
||||||
def select_toolchain(use_cxx, use_clang):
|
ndk_platform_path = os.path.join(ndk_path, 'platforms', ndk_platform)
|
||||||
global cc, cxx, ar, strip, cflags, cxxflags, cppflags, ldflags, libs
|
sysroot = os.path.join(ndk_platform_path, 'arch-' + self.ndk_arch)
|
||||||
|
|
||||||
target_arch = '-march=armv7-a -mfloat-abi=softfp'
|
install_prefix = os.path.join(arch_path, 'root')
|
||||||
if use_clang:
|
|
||||||
cc = os.path.join(llvm_toolchain, 'bin/clang')
|
|
||||||
cxx = os.path.join(llvm_toolchain, 'bin/clang++')
|
|
||||||
target_arch += ' -target ' + llvm_triple + ' -integrated-as -gcc-toolchain ' + gcc_toolchain
|
|
||||||
else:
|
|
||||||
cc = os.path.join(gcc_toolchain, 'bin', host_arch + '-gcc')
|
|
||||||
cxx = os.path.join(gcc_toolchain, 'bin', host_arch + '-g++')
|
|
||||||
ar = os.path.join(gcc_toolchain, 'bin', host_arch + '-ar')
|
|
||||||
strip = os.path.join(gcc_toolchain, 'bin', host_arch + '-strip')
|
|
||||||
|
|
||||||
libstdcxx_path = os.path.join(ndk_path, 'sources/cxx-stl/gnu-libstdc++', gcc_version)
|
self.arch = arch
|
||||||
libstdcxx_cppflags = '-isystem ' + os.path.join(libstdcxx_path, 'include') + ' -isystem ' + os.path.join(libstdcxx_path, 'libs', android_abi, 'include')
|
self.install_prefix = install_prefix
|
||||||
if use_clang:
|
self.sysroot = sysroot
|
||||||
libstdcxx_cppflags += ' -D__STRICT_ANSI__'
|
|
||||||
libstdcxx_ldadd = os.path.join(libstdcxx_path, 'libs', android_abi, 'libgnustl_static.a')
|
|
||||||
|
|
||||||
cflags = '-Os -g ' + target_arch
|
toolchain_path = os.path.join(ndk_path, 'toolchains', arch + '-' + gcc_version, 'prebuilt', build_arch)
|
||||||
cxxflags = '-Os -g ' + target_arch
|
llvm_path = os.path.join(ndk_path, 'toolchains', 'llvm-' + llvm_version, 'prebuilt', build_arch)
|
||||||
cppflags = '--sysroot=' + target_root + ' -I' + root_path + '/include'
|
llvm_triple = 'armv7-none-linux-androideabi'
|
||||||
ldflags = '--sysroot=' + target_root + ' -L' + root_path + '/lib'
|
|
||||||
libs = ''
|
|
||||||
|
|
||||||
if use_cxx:
|
common_flags = '-march=armv7-a -mfloat-abi=softfp'
|
||||||
libs += ' ' + libstdcxx_ldadd
|
|
||||||
cppflags += ' ' + libstdcxx_cppflags
|
toolchain_bin = os.path.join(toolchain_path, 'bin')
|
||||||
|
if use_clang:
|
||||||
|
llvm_bin = os.path.join(llvm_path, 'bin')
|
||||||
|
self.cc = os.path.join(llvm_bin, 'clang')
|
||||||
|
self.cxx = os.path.join(llvm_bin, 'clang++')
|
||||||
|
common_flags += ' -target ' + llvm_triple + ' -integrated-as -gcc-toolchain ' + toolchain_path
|
||||||
|
else:
|
||||||
|
self.cc = os.path.join(toolchain_bin, arch + '-gcc')
|
||||||
|
self.cxx = os.path.join(toolchain_bin, arch + '-g++')
|
||||||
|
|
||||||
|
self.ar = os.path.join(toolchain_bin, arch + '-ar')
|
||||||
|
self.nm = os.path.join(toolchain_bin, arch + '-nm')
|
||||||
|
self.strip = os.path.join(toolchain_bin, arch + '-strip')
|
||||||
|
|
||||||
|
self.cflags = '-Os -g ' + common_flags
|
||||||
|
self.cxxflags = '-Os -g ' + common_flags
|
||||||
|
self.cppflags = '--sysroot=' + self.sysroot + ' -isystem ' + os.path.join(install_prefix, 'include')
|
||||||
|
self.ldflags = '--sysroot=' + self.sysroot + ' -L' + os.path.join(root_path, 'lib')
|
||||||
|
self.libs = ''
|
||||||
|
|
||||||
|
libstdcxx_path = os.path.join(ndk_path, 'sources/cxx-stl/gnu-libstdc++', gcc_version)
|
||||||
|
libstdcxx_cppflags = '-isystem ' + os.path.join(libstdcxx_path, 'include') + ' -isystem ' + os.path.join(libstdcxx_path, 'libs', android_abi, 'include')
|
||||||
|
if use_clang:
|
||||||
|
libstdcxx_cppflags += ' -D__STRICT_ANSI__'
|
||||||
|
libstdcxx_ldadd = os.path.join(libstdcxx_path, 'libs', android_abi, 'libgnustl_static.a')
|
||||||
|
|
||||||
|
if use_cxx:
|
||||||
|
self.libs += ' ' + libstdcxx_ldadd
|
||||||
|
self.cppflags += ' ' + libstdcxx_cppflags
|
||||||
|
|
||||||
|
self.env = dict(os.environ)
|
||||||
|
|
||||||
|
# redirect pkg-config to use our root directory instead of the
|
||||||
|
# default one on the build host
|
||||||
|
self.env['PKG_CONFIG_LIBDIR'] = os.path.join(install_prefix, 'lib/pkgconfig')
|
||||||
|
|
||||||
def file_md5(path):
|
def file_md5(path):
|
||||||
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
|
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
|
||||||
|
@ -162,10 +174,9 @@ class Project:
|
||||||
def download(self):
|
def download(self):
|
||||||
return download_tarball(self.url, self.md5)
|
return download_tarball(self.url, self.md5)
|
||||||
|
|
||||||
def is_installed(self):
|
def is_installed(self, toolchain):
|
||||||
global root_path
|
|
||||||
tarball = self.download()
|
tarball = self.download()
|
||||||
installed = os.path.join(root_path, self.installed)
|
installed = os.path.join(toolchain.install_prefix, self.installed)
|
||||||
tarball_mtime = os.path.getmtime(tarball)
|
tarball_mtime = os.path.getmtime(tarball)
|
||||||
try:
|
try:
|
||||||
return os.path.getmtime(installed) >= tarball_mtime
|
return os.path.getmtime(installed) >= tarball_mtime
|
||||||
|
@ -203,7 +214,7 @@ class AutotoolsProject(Project):
|
||||||
self.autogen = autogen
|
self.autogen = autogen
|
||||||
self.cppflags = cppflags
|
self.cppflags = cppflags
|
||||||
|
|
||||||
def build(self):
|
def build(self, toolchain):
|
||||||
src = self.unpack()
|
src = self.unpack()
|
||||||
if self.autogen:
|
if self.autogen:
|
||||||
subprocess.check_call(['/usr/bin/aclocal'], cwd=src)
|
subprocess.check_call(['/usr/bin/aclocal'], cwd=src)
|
||||||
|
@ -213,27 +224,25 @@ class AutotoolsProject(Project):
|
||||||
|
|
||||||
build = self.make_build_path()
|
build = self.make_build_path()
|
||||||
|
|
||||||
select_toolchain(use_cxx=self.use_cxx, use_clang=self.use_clang)
|
|
||||||
configure = [
|
configure = [
|
||||||
os.path.join(src, 'configure'),
|
os.path.join(src, 'configure'),
|
||||||
'CC=' + cc,
|
'CC=' + toolchain.cc,
|
||||||
'CXX=' + cxx,
|
'CXX=' + toolchain.cxx,
|
||||||
'CFLAGS=' + cflags,
|
'CFLAGS=' + toolchain.cflags,
|
||||||
'CXXFLAGS=' + cxxflags,
|
'CXXFLAGS=' + toolchain.cxxflags,
|
||||||
'CPPFLAGS=' + cppflags + ' ' + self.cppflags,
|
'CPPFLAGS=' + toolchain.cppflags + ' ' + self.cppflags,
|
||||||
'LDFLAGS=' + ldflags,
|
'LDFLAGS=' + toolchain.ldflags,
|
||||||
'LIBS=' + libs,
|
'LIBS=' + toolchain.libs,
|
||||||
'AR=' + ar,
|
'AR=' + toolchain.ar,
|
||||||
'STRIP=' + strip,
|
'STRIP=' + toolchain.strip,
|
||||||
'--host=' + host_arch,
|
'--host=' + toolchain.arch,
|
||||||
'--prefix=' + root_path,
|
'--prefix=' + toolchain.install_prefix,
|
||||||
'--with-sysroot=' + target_root,
|
|
||||||
'--enable-silent-rules',
|
'--enable-silent-rules',
|
||||||
] + self.configure_args
|
] + self.configure_args
|
||||||
|
|
||||||
subprocess.check_call(configure, cwd=build)
|
subprocess.check_call(configure, cwd=build, env=toolchain.env)
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], cwd=build)
|
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], cwd=build, env=toolchain.env)
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', 'install'], cwd=build)
|
subprocess.check_call(['/usr/bin/make', '--quiet', 'install'], cwd=build, env=toolchain.env)
|
||||||
|
|
||||||
class FfmpegProject(Project):
|
class FfmpegProject(Project):
|
||||||
def __init__(self, url, md5, installed, configure_args=[],
|
def __init__(self, url, md5, installed, configure_args=[],
|
||||||
|
@ -243,30 +252,30 @@ class FfmpegProject(Project):
|
||||||
self.configure_args = configure_args
|
self.configure_args = configure_args
|
||||||
self.cppflags = cppflags
|
self.cppflags = cppflags
|
||||||
|
|
||||||
def build(self):
|
def build(self, toolchain):
|
||||||
src = self.unpack()
|
src = self.unpack()
|
||||||
build = self.make_build_path()
|
build = self.make_build_path()
|
||||||
|
|
||||||
select_toolchain(use_cxx=self.use_cxx, use_clang=self.use_clang)
|
|
||||||
configure = [
|
configure = [
|
||||||
os.path.join(src, 'configure'),
|
os.path.join(src, 'configure'),
|
||||||
'--cc=' + cc,
|
'--cc=' + toolchain.cc,
|
||||||
'--cxx=' + cxx,
|
'--cxx=' + toolchain.cxx,
|
||||||
'--extra-cflags=' + cflags + ' ' + cppflags + ' ' + self.cppflags,
|
'--nm=' + toolchain.nm,
|
||||||
'--extra-cxxflags=' + cxxflags + ' ' + cppflags + ' ' + self.cppflags,
|
'--extra-cflags=' + toolchain.cflags + ' ' + toolchain.cppflags + ' ' + self.cppflags,
|
||||||
'--extra-ldflags=' + ldflags,
|
'--extra-cxxflags=' + toolchain.cxxflags + ' ' + toolchain.cppflags + ' ' + self.cppflags,
|
||||||
'--extra-libs=' + libs,
|
'--extra-ldflags=' + toolchain.ldflags,
|
||||||
'--ar=' + ar,
|
'--extra-libs=' + toolchain.libs,
|
||||||
|
'--ar=' + toolchain.ar,
|
||||||
'--enable-cross-compile',
|
'--enable-cross-compile',
|
||||||
'--target-os=linux',
|
'--target-os=linux',
|
||||||
'--arch=' + ndk_arch,
|
'--arch=' + toolchain.ndk_arch,
|
||||||
'--cpu=cortex-a8',
|
'--cpu=cortex-a8',
|
||||||
'--prefix=' + root_path,
|
'--prefix=' + toolchain.install_prefix,
|
||||||
] + self.configure_args
|
] + self.configure_args
|
||||||
|
|
||||||
subprocess.check_call(configure, cwd=build)
|
subprocess.check_call(configure, cwd=build, env=toolchain.env)
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], cwd=build)
|
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], cwd=build, env=toolchain.env)
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', 'install'], cwd=build)
|
subprocess.check_call(['/usr/bin/make', '--quiet', 'install'], cwd=build, env=toolchain.env)
|
||||||
|
|
||||||
class BoostProject(Project):
|
class BoostProject(Project):
|
||||||
def __init__(self, url, md5, installed,
|
def __init__(self, url, md5, installed,
|
||||||
|
@ -277,12 +286,12 @@ class BoostProject(Project):
|
||||||
name='boost', version=version,
|
name='boost', version=version,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
def build(self):
|
def build(self, toolchain):
|
||||||
src = self.unpack()
|
src = self.unpack()
|
||||||
|
|
||||||
# install the headers manually; don't build any library
|
# install the headers manually; don't build any library
|
||||||
# (because right now, we only use header-only libraries)
|
# (because right now, we only use header-only libraries)
|
||||||
includedir = os.path.join(root_path, 'include')
|
includedir = os.path.join(toolchain.install_prefix, 'include')
|
||||||
for dirpath, dirnames, filenames in os.walk(os.path.join(src, 'boost')):
|
for dirpath, dirnames, filenames in os.walk(os.path.join(src, 'boost')):
|
||||||
relpath = dirpath[len(src)+1:]
|
relpath = dirpath[len(src)+1:]
|
||||||
destdir = os.path.join(includedir, relpath)
|
destdir = os.path.join(includedir, relpath)
|
||||||
|
@ -401,26 +410,27 @@ thirdparty_libs = [
|
||||||
|
|
||||||
# build the third-party libraries
|
# build the third-party libraries
|
||||||
for x in thirdparty_libs:
|
for x in thirdparty_libs:
|
||||||
if not x.is_installed():
|
toolchain = AndroidNdkToolchain(use_cxx=x.use_cxx, use_clang=x.use_clang)
|
||||||
x.build()
|
if not x.is_installed(toolchain):
|
||||||
|
x.build(toolchain)
|
||||||
|
|
||||||
# configure and build MPD
|
# configure and build MPD
|
||||||
select_toolchain(use_cxx=True, use_clang=True)
|
toolchain = AndroidNdkToolchain(use_cxx=True, use_clang=True)
|
||||||
|
|
||||||
configure = [
|
configure = [
|
||||||
os.path.join(mpd_path, 'configure'),
|
os.path.join(mpd_path, 'configure'),
|
||||||
'CC=' + cc,
|
'CC=' + toolchain.cc,
|
||||||
'CXX=' + cxx,
|
'CXX=' + toolchain.cxx,
|
||||||
'CFLAGS=' + cflags,
|
'CFLAGS=' + toolchain.cflags,
|
||||||
'CXXFLAGS=' + cxxflags,
|
'CXXFLAGS=' + toolchain.cxxflags,
|
||||||
'CPPFLAGS=' + cppflags,
|
'CPPFLAGS=' + toolchain.cppflags,
|
||||||
'LDFLAGS=' + ldflags,
|
'LDFLAGS=' + toolchain.ldflags,
|
||||||
'LIBS=' + libs,
|
'LIBS=' + toolchain.libs,
|
||||||
'AR=' + ar,
|
'AR=' + toolchain.ar,
|
||||||
'STRIP=' + strip,
|
'STRIP=' + toolchain.strip,
|
||||||
'--host=' + host_arch,
|
'--host=' + toolchain.arch,
|
||||||
'--prefix=' + root_path,
|
'--prefix=' + toolchain.install_prefix,
|
||||||
'--with-sysroot=' + target_root,
|
'--with-sysroot=' + toolchain.sysroot,
|
||||||
'--with-android-sdk=' + sdk_path,
|
'--with-android-sdk=' + sdk_path,
|
||||||
|
|
||||||
'--enable-silent-rules',
|
'--enable-silent-rules',
|
||||||
|
@ -429,5 +439,5 @@ configure = [
|
||||||
|
|
||||||
] + configure_args
|
] + configure_args
|
||||||
|
|
||||||
subprocess.check_call(configure)
|
subprocess.check_call(configure, env=toolchain.env)
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'])
|
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], env=toolchain.env)
|
||||||
|
|
152
win32/build.py
152
win32/build.py
|
@ -30,27 +30,30 @@ arch_path = os.path.join(lib_path, host_arch)
|
||||||
build_path = os.path.join(arch_path, 'build')
|
build_path = os.path.join(arch_path, 'build')
|
||||||
root_path = os.path.join(arch_path, 'root')
|
root_path = os.path.join(arch_path, 'root')
|
||||||
|
|
||||||
# redirect pkg-config to use our root directory instead of the default
|
class CrossGccToolchain:
|
||||||
# one on the build host
|
def __init__(self, toolchain_path, arch, install_prefix):
|
||||||
os.environ['PKG_CONFIG_LIBDIR'] = os.path.join(root_path, 'lib/pkgconfig')
|
self.arch = arch
|
||||||
|
self.install_prefix = install_prefix
|
||||||
|
|
||||||
gcc_toolchain = '/usr'
|
toolchain_bin = os.path.join(toolchain_path, 'bin')
|
||||||
|
self.cc = os.path.join(toolchain_bin, arch + '-gcc')
|
||||||
|
self.cxx = os.path.join(toolchain_bin, arch + '-g++')
|
||||||
|
self.ar = os.path.join(toolchain_bin, arch + '-ar')
|
||||||
|
self.nm = os.path.join(toolchain_bin, arch + '-nm')
|
||||||
|
self.strip = os.path.join(toolchain_bin, arch + '-strip')
|
||||||
|
|
||||||
def select_toolchain():
|
common_flags = ''
|
||||||
global cc, cxx, ar, nm, strip, cflags, cxxflags, cppflags, ldflags, libs
|
self.cflags = '-O2 -g ' + common_flags
|
||||||
|
self.cxxflags = '-O2 -g ' + common_flags
|
||||||
|
self.cppflags = '-isystem ' + os.path.join(install_prefix, 'include')
|
||||||
|
self.ldflags = '-L' + os.path.join(root_path, 'lib')
|
||||||
|
self.libs = ''
|
||||||
|
|
||||||
target_arch = ''
|
self.env = dict(os.environ)
|
||||||
cc = os.path.join(gcc_toolchain, 'bin', host_arch + '-gcc')
|
|
||||||
cxx = os.path.join(gcc_toolchain, 'bin', host_arch + '-g++')
|
|
||||||
ar = os.path.join(gcc_toolchain, 'bin', host_arch + '-ar')
|
|
||||||
nm = os.path.join(gcc_toolchain, 'bin', host_arch + '-nm')
|
|
||||||
strip = os.path.join(gcc_toolchain, 'bin', host_arch + '-strip')
|
|
||||||
|
|
||||||
cflags = '-O2 -g ' + target_arch
|
# redirect pkg-config to use our root directory instead of the
|
||||||
cxxflags = '-O2 -g ' + target_arch
|
# default one on the build host
|
||||||
cppflags = '-I' + root_path + '/include'
|
self.env['PKG_CONFIG_LIBDIR'] = os.path.join(install_prefix, 'lib/pkgconfig')
|
||||||
ldflags = '-L' + root_path + '/lib'
|
|
||||||
libs = ''
|
|
||||||
|
|
||||||
def file_md5(path):
|
def file_md5(path):
|
||||||
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
|
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
|
||||||
|
@ -116,10 +119,9 @@ class Project:
|
||||||
def download(self):
|
def download(self):
|
||||||
return download_tarball(self.url, self.md5)
|
return download_tarball(self.url, self.md5)
|
||||||
|
|
||||||
def is_installed(self):
|
def is_installed(self, toolchain):
|
||||||
global root_path
|
|
||||||
tarball = self.download()
|
tarball = self.download()
|
||||||
installed = os.path.join(root_path, self.installed)
|
installed = os.path.join(toolchain.install_prefix, self.installed)
|
||||||
tarball_mtime = os.path.getmtime(tarball)
|
tarball_mtime = os.path.getmtime(tarball)
|
||||||
try:
|
try:
|
||||||
return os.path.getmtime(installed) >= tarball_mtime
|
return os.path.getmtime(installed) >= tarball_mtime
|
||||||
|
@ -161,7 +163,7 @@ class AutotoolsProject(Project):
|
||||||
self.autogen = autogen
|
self.autogen = autogen
|
||||||
self.cppflags = cppflags
|
self.cppflags = cppflags
|
||||||
|
|
||||||
def build(self):
|
def build(self, toolchain):
|
||||||
src = self.unpack()
|
src = self.unpack()
|
||||||
if self.autogen:
|
if self.autogen:
|
||||||
subprocess.check_call(['/usr/bin/aclocal'], cwd=src)
|
subprocess.check_call(['/usr/bin/aclocal'], cwd=src)
|
||||||
|
@ -171,46 +173,46 @@ class AutotoolsProject(Project):
|
||||||
|
|
||||||
build = self.make_build_path()
|
build = self.make_build_path()
|
||||||
|
|
||||||
select_toolchain()
|
|
||||||
configure = [
|
configure = [
|
||||||
os.path.join(src, 'configure'),
|
os.path.join(src, 'configure'),
|
||||||
'CC=' + cc,
|
'CC=' + toolchain.cc,
|
||||||
'CXX=' + cxx,
|
'CXX=' + toolchain.cxx,
|
||||||
'CFLAGS=' + cflags,
|
'CFLAGS=' + toolchain.cflags,
|
||||||
'CXXFLAGS=' + cxxflags,
|
'CXXFLAGS=' + toolchain.cxxflags,
|
||||||
'CPPFLAGS=' + cppflags + ' ' + self.cppflags,
|
'CPPFLAGS=' + toolchain.cppflags + ' ' + self.cppflags,
|
||||||
'LDFLAGS=' + ldflags,
|
'LDFLAGS=' + toolchain.ldflags,
|
||||||
'LIBS=' + libs,
|
'LIBS=' + toolchain.libs,
|
||||||
'AR=' + ar,
|
'AR=' + toolchain.ar,
|
||||||
'STRIP=' + strip,
|
'STRIP=' + toolchain.strip,
|
||||||
'--host=' + host_arch,
|
'--host=' + toolchain.arch,
|
||||||
'--prefix=' + root_path,
|
'--prefix=' + toolchain.install_prefix,
|
||||||
'--enable-silent-rules',
|
'--enable-silent-rules',
|
||||||
] + self.configure_args
|
] + self.configure_args
|
||||||
|
|
||||||
subprocess.check_call(configure, cwd=build)
|
subprocess.check_call(configure, cwd=build, env=toolchain.env)
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], cwd=build)
|
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'],
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', 'install'], cwd=build)
|
cwd=build, env=toolchain.env)
|
||||||
|
subprocess.check_call(['/usr/bin/make', '--quiet', 'install'],
|
||||||
|
cwd=build, env=toolchain.env)
|
||||||
|
|
||||||
class ZlibProject(Project):
|
class ZlibProject(Project):
|
||||||
def __init__(self, url, md5, installed,
|
def __init__(self, url, md5, installed,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
Project.__init__(self, url, md5, installed, **kwargs)
|
Project.__init__(self, url, md5, installed, **kwargs)
|
||||||
|
|
||||||
def build(self):
|
def build(self, toolchain):
|
||||||
src = self.unpack(out_of_tree=False)
|
src = self.unpack(out_of_tree=False)
|
||||||
|
|
||||||
select_toolchain()
|
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet',
|
subprocess.check_call(['/usr/bin/make', '--quiet',
|
||||||
'-f', 'win32/Makefile.gcc',
|
'-f', 'win32/Makefile.gcc',
|
||||||
'PREFIX=' + host_arch + '-',
|
'PREFIX=' + toolchain.arch + '-',
|
||||||
'-j12',
|
'-j12',
|
||||||
'install',
|
'install',
|
||||||
'DESTDIR=' + root_path + '/',
|
'DESTDIR=' + toolchain.install_prefix + '/',
|
||||||
'INCLUDE_PATH=include',
|
'INCLUDE_PATH=include',
|
||||||
'LIBRARY_PATH=lib',
|
'LIBRARY_PATH=lib',
|
||||||
'BINARY_PATH=bin', 'SHARED_MODE=1'],
|
'BINARY_PATH=bin', 'SHARED_MODE=1'],
|
||||||
cwd=src)
|
cwd=src, env=toolchain.env)
|
||||||
|
|
||||||
class FfmpegProject(Project):
|
class FfmpegProject(Project):
|
||||||
def __init__(self, url, md5, installed, configure_args=[],
|
def __init__(self, url, md5, installed, configure_args=[],
|
||||||
|
@ -220,31 +222,32 @@ class FfmpegProject(Project):
|
||||||
self.configure_args = configure_args
|
self.configure_args = configure_args
|
||||||
self.cppflags = cppflags
|
self.cppflags = cppflags
|
||||||
|
|
||||||
def build(self):
|
def build(self, toolchain):
|
||||||
src = self.unpack()
|
src = self.unpack()
|
||||||
build = self.make_build_path()
|
build = self.make_build_path()
|
||||||
|
|
||||||
select_toolchain()
|
|
||||||
configure = [
|
configure = [
|
||||||
os.path.join(src, 'configure'),
|
os.path.join(src, 'configure'),
|
||||||
'--cc=' + cc,
|
'--cc=' + toolchain.cc,
|
||||||
'--cxx=' + cxx,
|
'--cxx=' + toolchain.cxx,
|
||||||
'--nm=' + nm,
|
'--nm=' + toolchain.nm,
|
||||||
'--extra-cflags=' + cflags + ' ' + cppflags + ' ' + self.cppflags,
|
'--extra-cflags=' + toolchain.cflags + ' ' + toolchain.cppflags + ' ' + self.cppflags,
|
||||||
'--extra-cxxflags=' + cxxflags + ' ' + cppflags + ' ' + self.cppflags,
|
'--extra-cxxflags=' + toolchain.cxxflags + ' ' + toolchain.cppflags + ' ' + self.cppflags,
|
||||||
'--extra-ldflags=' + ldflags,
|
'--extra-ldflags=' + toolchain.ldflags,
|
||||||
'--extra-libs=' + libs,
|
'--extra-libs=' + toolchain.libs,
|
||||||
'--ar=' + ar,
|
'--ar=' + toolchain.ar,
|
||||||
'--enable-cross-compile',
|
'--enable-cross-compile',
|
||||||
'--arch=x86',
|
'--arch=x86',
|
||||||
'--target-os=mingw32',
|
'--target-os=mingw32',
|
||||||
'--cross-prefix=' + host_arch + '-',
|
'--cross-prefix=' + toolchain.arch + '-',
|
||||||
'--prefix=' + root_path,
|
'--prefix=' + toolchain.install_prefix,
|
||||||
] + self.configure_args
|
] + self.configure_args
|
||||||
|
|
||||||
subprocess.check_call(configure, cwd=build)
|
subprocess.check_call(configure, cwd=build, env=toolchain.env)
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], cwd=build)
|
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'],
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', 'install'], cwd=build)
|
cwd=build, env=toolchain.env)
|
||||||
|
subprocess.check_call(['/usr/bin/make', '--quiet', 'install'],
|
||||||
|
cwd=build, env=toolchain.env)
|
||||||
|
|
||||||
class BoostProject(Project):
|
class BoostProject(Project):
|
||||||
def __init__(self, url, md5, installed,
|
def __init__(self, url, md5, installed,
|
||||||
|
@ -255,12 +258,12 @@ class BoostProject(Project):
|
||||||
name='boost', version=version,
|
name='boost', version=version,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
def build(self):
|
def build(self, toolchain):
|
||||||
src = self.unpack()
|
src = self.unpack()
|
||||||
|
|
||||||
# install the headers manually; don't build any library
|
# install the headers manually; don't build any library
|
||||||
# (because right now, we only use header-only libraries)
|
# (because right now, we only use header-only libraries)
|
||||||
includedir = os.path.join(root_path, 'include')
|
includedir = os.path.join(toolchain.install_prefix, 'include')
|
||||||
for dirpath, dirnames, filenames in os.walk(os.path.join(src, 'boost')):
|
for dirpath, dirnames, filenames in os.walk(os.path.join(src, 'boost')):
|
||||||
relpath = dirpath[len(src)+1:]
|
relpath = dirpath[len(src)+1:]
|
||||||
destdir = os.path.join(includedir, relpath)
|
destdir = os.path.join(includedir, relpath)
|
||||||
|
@ -373,26 +376,27 @@ thirdparty_libs = [
|
||||||
]
|
]
|
||||||
|
|
||||||
# build the third-party libraries
|
# build the third-party libraries
|
||||||
|
toolchain = CrossGccToolchain('/usr', host_arch, root_path)
|
||||||
|
|
||||||
for x in thirdparty_libs:
|
for x in thirdparty_libs:
|
||||||
if not x.is_installed():
|
if not x.is_installed(toolchain):
|
||||||
x.build()
|
x.build(toolchain)
|
||||||
|
|
||||||
# configure and build MPD
|
# configure and build MPD
|
||||||
select_toolchain()
|
|
||||||
|
|
||||||
configure = [
|
configure = [
|
||||||
os.path.join(mpd_path, 'configure'),
|
os.path.join(mpd_path, 'configure'),
|
||||||
'CC=' + cc,
|
'CC=' + toolchain.cc,
|
||||||
'CXX=' + cxx,
|
'CXX=' + toolchain.cxx,
|
||||||
'CFLAGS=' + cflags,
|
'CFLAGS=' + toolchain.cflags,
|
||||||
'CXXFLAGS=' + cxxflags,
|
'CXXFLAGS=' + toolchain.cxxflags,
|
||||||
'CPPFLAGS=' + cppflags,
|
'CPPFLAGS=' + toolchain.cppflags,
|
||||||
'LDFLAGS=' + ldflags + ' -static',
|
'LDFLAGS=' + toolchain.ldflags + ' -static',
|
||||||
'LIBS=' + libs,
|
'LIBS=' + toolchain.libs,
|
||||||
'AR=' + ar,
|
'AR=' + toolchain.ar,
|
||||||
'STRIP=' + strip,
|
'STRIP=' + toolchain.strip,
|
||||||
'--host=' + host_arch,
|
'--host=' + toolchain.arch,
|
||||||
'--prefix=' + root_path,
|
'--prefix=' + toolchain.install_prefix,
|
||||||
|
|
||||||
'--enable-silent-rules',
|
'--enable-silent-rules',
|
||||||
|
|
||||||
|
@ -400,5 +404,5 @@ configure = [
|
||||||
|
|
||||||
] + configure_args
|
] + configure_args
|
||||||
|
|
||||||
subprocess.check_call(configure)
|
subprocess.check_call(configure, env=toolchain.env)
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'])
|
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], env=toolchain.env)
|
||||||
|
|
Loading…
Reference in New Issue