mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:19:49 +00:00
Allows building debian packages for ARM.
This change adds arm as a possible architecture to the create_debian_packages.py script and additionally adds a toolchain flag so that arm packages can be built using different cross-compilers that target different ARM versions. The specified cross-compiler is passed on to the debian/rules file through an environment variable. R=ricow@google.com, sgjesse@google.com Review URL: https://codereview.chromium.org//396123003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39291 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
ee5635056f
commit
12e83bbd84
|
@ -8,6 +8,7 @@
|
|||
import optparse
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
# binary packages.
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import sys
|
||||
import tarfile
|
||||
import subprocess
|
||||
|
@ -31,23 +32,29 @@ def BuildOptions():
|
|||
help="Where to put the packages.")
|
||||
result.add_option("-a", "--arch",
|
||||
help='Target architectures (comma-separated).',
|
||||
metavar='[all,ia32,x64]',
|
||||
metavar='[all,ia32,x64,armel,armhf]',
|
||||
default='x64')
|
||||
result.add_option("-t", "--toolchain",
|
||||
help='Cross-compilation toolchain prefix',
|
||||
default=None)
|
||||
|
||||
return result
|
||||
|
||||
def RunBuildPackage(opt, cwd):
|
||||
def RunBuildPackage(opt, cwd, toolchain=None):
|
||||
env = os.environ.copy()
|
||||
if toolchain != None:
|
||||
env["TOOLCHAIN"] = '--toolchain=' + toolchain
|
||||
cmd = ['dpkg-buildpackage', '-j%d' % HOST_CPUS]
|
||||
cmd.extend(opt)
|
||||
process = subprocess.Popen(cmd,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
cwd=cwd)
|
||||
cwd=cwd, env=env)
|
||||
(stdout, stderr) = process.communicate()
|
||||
if process.returncode != 0:
|
||||
raise Exception('Command \'%s\' failed: %s\nSTDOUT: %s' %
|
||||
(' '.join(cmd), stderr, stdout))
|
||||
|
||||
def BuildDebianPackage(tarball, out_dir, arch):
|
||||
def BuildDebianPackage(tarball, out_dir, arch, toolchain):
|
||||
version = utils.GetVersion()
|
||||
tarroot = 'dart-%s' % version
|
||||
origtarname = 'dart_%s.orig.tar.gz' % version
|
||||
|
@ -77,6 +84,18 @@ def BuildDebianPackage(tarball, out_dir, arch):
|
|||
print "Building amd64 package"
|
||||
RunBuildPackage(['-B', '-aamd64', '-us', '-uc'], join(temp_dir, tarroot))
|
||||
|
||||
# Build armhf binary package.
|
||||
if 'armhf' in arch:
|
||||
print "Building armhf package"
|
||||
RunBuildPackage(
|
||||
['-B', '-aarmhf', '-us', '-uc'], join(temp_dir, tarroot), toolchain)
|
||||
|
||||
# Build armel binary package.
|
||||
if 'armel' in arch:
|
||||
print "Building armel package"
|
||||
RunBuildPackage(
|
||||
['-B', '-aarmel', '-us', '-uc'], join(temp_dir, tarroot), toolchain)
|
||||
|
||||
# Copy the Debian package files to the build directory.
|
||||
debbase = 'dart_%s' % version
|
||||
source_package = [
|
||||
|
@ -90,6 +109,12 @@ def BuildDebianPackage(tarball, out_dir, arch):
|
|||
amd64_package = [
|
||||
'%s-1_amd64.deb' % debbase
|
||||
]
|
||||
armhf_package = [
|
||||
'%s-1_armhf.deb' % debbase
|
||||
]
|
||||
armel_package = [
|
||||
'%s-1_armel.deb' % debbase
|
||||
]
|
||||
|
||||
for name in source_package:
|
||||
copyfile(join(temp_dir, name), join(out_dir, name))
|
||||
|
@ -99,6 +124,13 @@ def BuildDebianPackage(tarball, out_dir, arch):
|
|||
if 'x64' in arch:
|
||||
for name in amd64_package:
|
||||
copyfile(join(temp_dir, name), join(out_dir, name))
|
||||
if ('armhf' in arch):
|
||||
for name in armhf_package:
|
||||
copyfile(join(temp_dir, name), join(out_dir, name))
|
||||
if ('armel' in arch):
|
||||
for name in armel_package:
|
||||
copyfile(join(temp_dir, name), join(out_dir, name))
|
||||
|
||||
|
||||
def Main():
|
||||
if HOST_OS != 'linux':
|
||||
|
@ -109,7 +141,7 @@ def Main():
|
|||
out_dir = options.out_dir
|
||||
tar_filename = options.tar_filename
|
||||
if options.arch == 'all':
|
||||
options.arch = 'ia32,x64'
|
||||
options.arch = 'ia32,x64,armhf'
|
||||
arch = options.arch.split(',')
|
||||
|
||||
if not options.out_dir:
|
||||
|
@ -120,7 +152,7 @@ def Main():
|
|||
utils.GetBuildDir(HOST_OS),
|
||||
'dart-%s.tar.gz' % utils.GetVersion())
|
||||
|
||||
BuildDebianPackage(tar_filename, out_dir, arch)
|
||||
BuildDebianPackage(tar_filename, out_dir, arch, options.toolchain)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(Main())
|
||||
|
|
|
@ -8,7 +8,7 @@ Build-Depends: debhelper (>= 9),
|
|||
openjdk-6-jdk
|
||||
|
||||
Package: dart
|
||||
Architecture: amd64 i386
|
||||
Architecture: amd64 i386 armhf armel
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: Dart SDK
|
||||
|
||||
|
|
|
@ -9,14 +9,24 @@ else
|
|||
PARALLEL_JOBS := 1
|
||||
endif
|
||||
|
||||
DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
|
||||
ifeq (amd64,$(DEB_HOST_ARCH_CPU))
|
||||
BUILD_TYPE += ReleaseX64
|
||||
ARCH += x64
|
||||
else
|
||||
ifeq (i386,$(DEB_HOST_ARCH_CPU))
|
||||
BUILD_TYPE += ReleaseIA32
|
||||
ARCH += ia32
|
||||
else
|
||||
$(warning unsupported target arch $(DEB_HOST_ARCH_CPU) - continuing anyway)
|
||||
ifeq (arm,$(DEB_HOST_ARCH_CPU))
|
||||
ifeq ($(DEB_BUILD_ARCH_CPU),$(DEB_HOST_ARCH_CPU))
|
||||
BUILD_TYPE += ReleaseARM
|
||||
else
|
||||
BUILD_TYPE += ReleaseXARM
|
||||
endif
|
||||
ARCH += arm
|
||||
else
|
||||
$(error unsupported target arch '$(DEB_HOST_ARCH_CPU)')
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -40,12 +50,18 @@ override_dh_auto_configure:
|
|||
GYP_GENERATORS=make python dart/tools/gyp_dart.py all
|
||||
|
||||
override_dh_auto_build:
|
||||
make -C dart -j$(PARALLEL_JOBS) \
|
||||
BUILDTYPE=$(BUILD_TYPE) $(BUILD_ARGS) create_sdk
|
||||
cd dart; \
|
||||
python tools/build.py -v -m release -a $(ARCH) $(TOOLCHAIN) create_sdk; \
|
||||
cd ..
|
||||
|
||||
# Building the Dart SDK will already strip all binaries.
|
||||
override_dh_strip:
|
||||
|
||||
# This override allows us to ignore spurious missing library errors when
|
||||
# cross-compiling.
|
||||
override_dh_shlibdeps:
|
||||
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
|
||||
|
||||
override_dh_auto_install:
|
||||
mkdir -p debian/tmp/out
|
||||
cp -R dart/out/$(BUILD_TYPE)/dart-sdk debian/tmp/out
|
||||
|
|
Loading…
Reference in a new issue