2011-10-05 05:34:19 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
2012-11-12 12:55:02 +00:00
|
|
|
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
2011-10-05 05:34:19 +00:00
|
|
|
# for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
# BSD-style license that can be found in the LICENSE file.
|
|
|
|
#
|
|
|
|
|
|
|
|
import optparse
|
|
|
|
import os
|
2013-04-08 12:37:41 +00:00
|
|
|
import re
|
2011-10-05 05:34:19 +00:00
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2014-04-03 11:09:02 +00:00
|
|
|
import time
|
2011-10-05 05:34:19 +00:00
|
|
|
import utils
|
|
|
|
|
|
|
|
HOST_OS = utils.GuessOS()
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
HOST_ARCH = utils.GuessArchitecture()
|
2011-10-05 05:34:19 +00:00
|
|
|
HOST_CPUS = utils.GuessCpus()
|
2012-08-29 20:42:28 +00:00
|
|
|
SCRIPT_DIR = os.path.dirname(sys.argv[0])
|
|
|
|
DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
|
|
|
|
THIRD_PARTY_ROOT = os.path.join(DART_ROOT, 'third_party')
|
2011-10-05 05:34:19 +00:00
|
|
|
|
2013-04-19 18:05:44 +00:00
|
|
|
arm_cc_error = """
|
|
|
|
Couldn't find the arm cross compiler.
|
|
|
|
To make sure that you have the arm cross compilation tools installed, run:
|
|
|
|
|
|
|
|
$ wget http://src.chromium.org/chrome/trunk/src/build/install-build-deps.sh
|
|
|
|
OR
|
|
|
|
$ svn co http://src.chromium.org/chrome/trunk/src/build; cd build
|
|
|
|
Then,
|
|
|
|
$ chmod u+x install-build-deps.sh
|
|
|
|
$ ./install-build-deps.sh --arm --no-chromeos-fonts
|
|
|
|
"""
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
DEFAULT_ARM_CROSS_COMPILER_PATH = '/usr/bin'
|
|
|
|
|
2013-04-19 18:05:44 +00:00
|
|
|
|
2011-10-05 05:34:19 +00:00
|
|
|
def BuildOptions():
|
|
|
|
result = optparse.OptionParser()
|
|
|
|
result.add_option("-m", "--mode",
|
|
|
|
help='Build variants (comma-separated).',
|
|
|
|
metavar='[all,debug,release]',
|
|
|
|
default='debug')
|
|
|
|
result.add_option("-v", "--verbose",
|
|
|
|
help='Verbose output.',
|
|
|
|
default=False, action="store_true")
|
2012-11-12 12:55:02 +00:00
|
|
|
result.add_option("-a", "--arch",
|
2011-10-05 05:34:19 +00:00
|
|
|
help='Target architectures (comma-separated).',
|
2014-05-27 18:05:20 +00:00
|
|
|
metavar='[all,ia32,x64,simarm,arm,simmips,mips,simarm64,arm64,]',
|
2011-10-05 05:34:19 +00:00
|
|
|
default=utils.GuessArchitecture())
|
2012-08-29 20:42:28 +00:00
|
|
|
result.add_option("--os",
|
|
|
|
help='Target OSs (comma-separated).',
|
|
|
|
metavar='[all,host,android]',
|
|
|
|
default='host')
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
result.add_option("-t", "--toolchain",
|
|
|
|
help='Cross-compiler toolchain path',
|
|
|
|
default=None)
|
2011-10-05 05:34:19 +00:00
|
|
|
result.add_option("-j",
|
|
|
|
help='The number of parallel jobs to run.',
|
|
|
|
metavar=HOST_CPUS,
|
|
|
|
default=str(HOST_CPUS))
|
2013-02-20 03:58:19 +00:00
|
|
|
(vs_directory, vs_executable) = utils.GuessVisualStudioPath()
|
2011-10-05 05:34:19 +00:00
|
|
|
result.add_option("--devenv",
|
|
|
|
help='Path containing devenv.com on Windows',
|
2013-02-20 03:58:19 +00:00
|
|
|
default=vs_directory)
|
2012-10-16 21:28:18 +00:00
|
|
|
result.add_option("--executable",
|
|
|
|
help='Name of the devenv.com/msbuild executable on Windows (varies for '
|
2013-02-20 03:58:19 +00:00
|
|
|
'different versions of Visual Studio)',
|
|
|
|
default=vs_executable)
|
2011-10-05 05:34:19 +00:00
|
|
|
return result
|
|
|
|
|
|
|
|
|
2012-08-29 20:42:28 +00:00
|
|
|
def ProcessOsOption(os):
|
|
|
|
if os == 'host':
|
|
|
|
return HOST_OS
|
|
|
|
return os
|
|
|
|
|
|
|
|
|
|
|
|
def ProcessOptions(options, args):
|
2011-10-05 05:34:19 +00:00
|
|
|
if options.arch == 'all':
|
2014-04-02 17:39:32 +00:00
|
|
|
options.arch = 'ia32,x64,simarm,simmips,simarm64'
|
2011-10-05 05:34:19 +00:00
|
|
|
if options.mode == 'all':
|
2011-12-01 12:58:53 +00:00
|
|
|
options.mode = 'release,debug'
|
2012-08-29 20:42:28 +00:00
|
|
|
if options.os == 'all':
|
|
|
|
options.os = 'host,android'
|
2011-10-05 05:34:19 +00:00
|
|
|
options.mode = options.mode.split(',')
|
|
|
|
options.arch = options.arch.split(',')
|
2012-08-29 20:42:28 +00:00
|
|
|
options.os = options.os.split(',')
|
2011-10-05 05:34:19 +00:00
|
|
|
for mode in options.mode:
|
|
|
|
if not mode in ['debug', 'release']:
|
|
|
|
print "Unknown mode %s" % mode
|
|
|
|
return False
|
|
|
|
for arch in options.arch:
|
2014-05-27 18:05:20 +00:00
|
|
|
archs = ['ia32', 'x64', 'simarm', 'arm', 'simmips', 'mips',
|
|
|
|
'simarm64', 'arm64',]
|
2014-04-02 17:39:32 +00:00
|
|
|
if not arch in archs:
|
2011-10-05 05:34:19 +00:00
|
|
|
print "Unknown arch %s" % arch
|
|
|
|
return False
|
2012-08-29 20:42:28 +00:00
|
|
|
options.os = [ProcessOsOption(os) for os in options.os]
|
|
|
|
for os in options.os:
|
|
|
|
if not os in ['android', 'freebsd', 'linux', 'macos', 'win32']:
|
|
|
|
print "Unknown os %s" % os
|
|
|
|
return False
|
|
|
|
if os != HOST_OS:
|
|
|
|
if os != 'android':
|
|
|
|
print "Unsupported target os %s" % os
|
|
|
|
return False
|
|
|
|
if not HOST_OS in ['linux']:
|
|
|
|
print ("Cross-compilation to %s is not supported on host os %s."
|
|
|
|
% (os, HOST_OS))
|
|
|
|
return False
|
2014-03-10 12:00:06 +00:00
|
|
|
if not arch in ['ia32', 'arm', 'mips']:
|
2012-08-29 20:42:28 +00:00
|
|
|
print ("Cross-compilation to %s is not supported for architecture %s."
|
|
|
|
% (os, arch))
|
|
|
|
return False
|
|
|
|
# We have not yet tweaked the v8 dart build to work with the Android
|
|
|
|
# NDK/SDK, so don't try to build it.
|
|
|
|
if args == []:
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
print "For android builds you must specify a target, such as 'runtime'."
|
2012-08-29 20:42:28 +00:00
|
|
|
return False
|
2011-10-05 05:34:19 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
def GetToolchainPrefix(target_os, arch, options):
|
|
|
|
if options.toolchain != None:
|
|
|
|
return options.toolchain
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
if target_os == 'android':
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
android_toolchain = GetAndroidToolchainDir(HOST_OS, arch)
|
|
|
|
if arch == 'arm':
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
return os.path.join(android_toolchain, 'arm-linux-androideabi')
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
if arch == 'ia32':
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
return os.path.join(android_toolchain, 'i686-linux-android')
|
|
|
|
|
|
|
|
# If no cross compiler is specified, only try to figure one out on Linux.
|
|
|
|
if not HOST_OS in ['linux']:
|
2014-07-22 15:01:05 +00:00
|
|
|
raise Exception('Unless --toolchain is used cross-building is only '
|
|
|
|
'supported on Linux.')
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
|
|
|
|
# For ARM Linux, by default use the Linux distribution's cross-compiler.
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
if arch == 'arm':
|
|
|
|
# To use a non-hf compiler, specify on the command line with --toolchain.
|
|
|
|
return (DEFAULT_ARM_CROSS_COMPILER_PATH + "/arm-linux-gnueabihf")
|
|
|
|
|
|
|
|
# TODO(zra): Find default MIPS and ARM64 Linux cross-compilers.
|
|
|
|
|
|
|
|
return None
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
|
|
|
|
def SetTools(arch, target_os, options):
|
|
|
|
toolsOverride = None
|
|
|
|
|
|
|
|
toolchainprefix = GetToolchainPrefix(target_os, arch, options)
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
|
|
|
|
# Override the Android toolchain's linker to handle some complexity in the
|
|
|
|
# linker arguments that gyp has trouble with.
|
|
|
|
linker = ""
|
|
|
|
if target_os == 'android':
|
|
|
|
linker = os.path.join(DART_ROOT, 'tools', 'android_link.py')
|
|
|
|
elif toolchainprefix:
|
|
|
|
linker = toolchainprefix + "-g++"
|
|
|
|
|
2012-08-29 20:42:28 +00:00
|
|
|
if toolchainprefix:
|
2011-10-05 05:34:19 +00:00
|
|
|
toolsOverride = {
|
2013-04-19 18:05:44 +00:00
|
|
|
"CC.target" : toolchainprefix + "-gcc",
|
|
|
|
"CXX.target" : toolchainprefix + "-g++",
|
|
|
|
"AR.target" : toolchainprefix + "-ar",
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
"LINK.target": linker,
|
2013-04-19 18:05:44 +00:00
|
|
|
"NM.target" : toolchainprefix + "-nm",
|
2011-10-05 05:34:19 +00:00
|
|
|
}
|
2012-08-29 20:42:28 +00:00
|
|
|
return toolsOverride
|
|
|
|
|
|
|
|
|
|
|
|
def CheckDirExists(path, docstring):
|
|
|
|
if not os.path.isdir(path):
|
|
|
|
raise Exception('Could not find %s directory %s'
|
|
|
|
% (docstring, path))
|
|
|
|
|
|
|
|
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
def GetAndroidToolchainDir(host_os, target_arch):
|
2012-08-29 20:42:28 +00:00
|
|
|
global THIRD_PARTY_ROOT
|
|
|
|
if host_os not in ['linux']:
|
|
|
|
raise Exception('Unsupported host os %s' % host_os)
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
if target_arch not in ['ia32', 'arm']:
|
2012-08-29 20:42:28 +00:00
|
|
|
raise Exception('Unsupported target architecture %s' % target_arch)
|
|
|
|
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
# Set up path to the Android NDK.
|
2012-08-29 20:42:28 +00:00
|
|
|
CheckDirExists(THIRD_PARTY_ROOT, 'third party tools');
|
|
|
|
android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools')
|
|
|
|
CheckDirExists(android_tools, 'Android tools')
|
|
|
|
android_ndk_root = os.path.join(android_tools, 'ndk')
|
|
|
|
CheckDirExists(android_ndk_root, 'Android NDK')
|
|
|
|
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
# Set up the directory of the Android NDK cross-compiler toolchain.
|
|
|
|
toolchain_arch = 'arm-linux-androideabi-4.6'
|
|
|
|
if target_arch == 'ia32':
|
|
|
|
toolchain_arch = 'x86-4.6'
|
2013-12-20 22:23:49 +00:00
|
|
|
toolchain_dir = 'linux-x86_64'
|
2012-08-29 20:42:28 +00:00
|
|
|
android_toolchain = os.path.join(android_ndk_root,
|
|
|
|
'toolchains', toolchain_arch,
|
|
|
|
'prebuilt', toolchain_dir, 'bin')
|
|
|
|
CheckDirExists(android_toolchain, 'Android toolchain')
|
|
|
|
|
Simplifies standalone VM Android build.
This change also avoids the need to
do another 'gclient runhooks' when switching
between Android and Linux builds, and between
IA32 and ARM Android builds.
gyp does not allow 'libraries' sections inside of
configurations. Therefore, since some architecture
specific paths, libraries, etc. must be specified
on the Android NDK's linker command line, to avoid
re-gyping when switching between Android IA32 and ARM,
this change moves the architecture specific linker
flags to a script, android_link.py.
To avoid re-gyping when swtiching between Linux and
Android, this change creates new configurations
that specify the target OS as well as the the target
architecture, e.g. ReleaseLinuxARM or ReleaseAndroidARM
instead of ReleaseARM.
This change also adds a --toolchain flag to build.py,
and removes obsoleted logic for setting up the Android
build.
R=iposva@google.com
Review URL: https://codereview.chromium.org//105223002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31340 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-20 17:51:34 +00:00
|
|
|
return android_toolchain
|
2011-10-05 05:34:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
def Execute(args):
|
|
|
|
process = subprocess.Popen(args)
|
|
|
|
process.wait()
|
|
|
|
if process.returncode != 0:
|
2014-01-15 14:57:58 +00:00
|
|
|
raise Exception(args[0] + " failed")
|
2012-08-29 20:42:28 +00:00
|
|
|
|
|
|
|
|
2011-10-05 05:34:19 +00:00
|
|
|
def CurrentDirectoryBaseName():
|
|
|
|
"""Returns the name of the current directory"""
|
|
|
|
return os.path.relpath(os.curdir, start=os.pardir)
|
|
|
|
|
2012-08-29 20:42:28 +00:00
|
|
|
|
2013-04-05 15:46:36 +00:00
|
|
|
def FilterEmptyXcodebuildSections(process):
|
|
|
|
"""
|
|
|
|
Filter output from xcodebuild so empty sections are less verbose.
|
|
|
|
|
|
|
|
The output from xcodebuild looks like this:
|
|
|
|
|
|
|
|
Build settings from command line:
|
|
|
|
SYMROOT = .../xcodebuild
|
|
|
|
|
2014-01-15 14:57:58 +00:00
|
|
|
=== BUILD TARGET samples OF PROJECT dart WITH CONFIGURATION ...
|
2013-04-05 15:46:36 +00:00
|
|
|
|
2014-01-15 14:57:58 +00:00
|
|
|
Check dependencies
|
2013-04-05 15:46:36 +00:00
|
|
|
|
|
|
|
=== BUILD AGGREGATE TARGET upload_sdk OF PROJECT dart WITH CONFIGURATION ...
|
2014-01-15 14:57:58 +00:00
|
|
|
|
2013-04-05 15:46:36 +00:00
|
|
|
Check dependencies
|
|
|
|
|
|
|
|
PhaseScriptExecution "Action \"upload_sdk_py\"" xcodebuild/dart.build/...
|
|
|
|
cd ...
|
|
|
|
/bin/sh -c .../xcodebuild/dart.build/ReleaseIA32/upload_sdk.build/...
|
|
|
|
|
|
|
|
|
|
|
|
** BUILD SUCCEEDED **
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def is_empty_chunk(chunk):
|
2014-01-15 14:57:58 +00:00
|
|
|
empty_chunk = ['', 'Check dependencies', '']
|
2013-04-05 15:46:36 +00:00
|
|
|
return not chunk or (len(chunk) == 4 and chunk[1:] == empty_chunk)
|
|
|
|
|
|
|
|
def unbuffered(callable):
|
|
|
|
# Use iter to disable buffering in for-in.
|
|
|
|
return iter(callable, '')
|
|
|
|
|
|
|
|
section = None
|
|
|
|
chunk = []
|
2013-04-05 18:02:21 +00:00
|
|
|
# Is stdout a terminal which supports colors?
|
|
|
|
is_fancy_tty = False
|
|
|
|
clr_eol = None
|
|
|
|
if sys.stdout.isatty():
|
|
|
|
term = os.getenv('TERM', 'dumb')
|
|
|
|
# The capability "clr_eol" means clear the line from cursor to end
|
|
|
|
# of line. See man pages for tput and terminfo.
|
2013-04-05 18:15:39 +00:00
|
|
|
try:
|
2013-04-08 12:56:43 +00:00
|
|
|
with open('/dev/null', 'a') as dev_null:
|
|
|
|
clr_eol = subprocess.check_output(['tput', '-T' + term, 'el'],
|
|
|
|
stderr=dev_null)
|
2013-04-05 18:15:39 +00:00
|
|
|
if clr_eol:
|
|
|
|
is_fancy_tty = True
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
is_fancy_tty = False
|
2013-04-11 20:14:21 +00:00
|
|
|
except AttributeError:
|
|
|
|
is_fancy_tty = False
|
2014-01-15 14:57:58 +00:00
|
|
|
pattern = re.compile(r'=== BUILD.* TARGET (.*) OF PROJECT (.*) WITH ' +
|
2013-04-08 12:37:41 +00:00
|
|
|
r'CONFIGURATION (.*) ===')
|
2013-04-08 12:26:22 +00:00
|
|
|
has_interesting_info = False
|
2013-04-05 15:46:36 +00:00
|
|
|
for line in unbuffered(process.stdout.readline):
|
|
|
|
line = line.rstrip()
|
|
|
|
if line.startswith('=== BUILD ') or line.startswith('** BUILD '):
|
2013-04-08 12:26:22 +00:00
|
|
|
has_interesting_info = False
|
2013-04-05 15:46:36 +00:00
|
|
|
section = line
|
2013-04-05 18:02:21 +00:00
|
|
|
if is_fancy_tty:
|
2013-04-08 12:37:41 +00:00
|
|
|
match = re.match(pattern, section)
|
|
|
|
if match:
|
|
|
|
section = '%s/%s/%s' % (
|
|
|
|
match.group(3), match.group(2), match.group(1))
|
|
|
|
# Truncate to avoid extending beyond 80 columns.
|
|
|
|
section = section[:80]
|
2013-04-05 18:02:21 +00:00
|
|
|
# If stdout is a terminal, emit "progress" information. The
|
|
|
|
# progress information is the first line of the current chunk.
|
|
|
|
# After printing the line, move the cursor back to the
|
|
|
|
# beginning of the line. This has two effects: First, if the
|
|
|
|
# chunk isn't empty, the first line will be overwritten
|
|
|
|
# (avoiding duplication). Second, the next segment line will
|
|
|
|
# overwrite it too avoid long scrollback. clr_eol ensures
|
|
|
|
# that there is no trailing garbage when a shorter line
|
|
|
|
# overwrites a longer line.
|
|
|
|
print '%s%s\r' % (clr_eol, section),
|
2013-04-05 15:46:36 +00:00
|
|
|
chunk = []
|
2013-04-08 12:26:22 +00:00
|
|
|
if not section or has_interesting_info:
|
2013-04-05 15:46:36 +00:00
|
|
|
print line
|
|
|
|
else:
|
2013-04-08 12:26:22 +00:00
|
|
|
length = len(chunk)
|
2014-01-15 14:57:58 +00:00
|
|
|
if length == 2 and line != 'Check dependencies':
|
2013-04-08 12:26:22 +00:00
|
|
|
has_interesting_info = True
|
2014-01-15 14:57:58 +00:00
|
|
|
elif (length == 1 or length == 3) and line:
|
2013-04-08 12:26:22 +00:00
|
|
|
has_interesting_info = True
|
2014-01-15 17:05:05 +00:00
|
|
|
elif length > 3:
|
|
|
|
has_interesting_info = True
|
2013-04-08 12:26:22 +00:00
|
|
|
if has_interesting_info:
|
|
|
|
print '\n'.join(chunk)
|
|
|
|
chunk = []
|
|
|
|
else:
|
|
|
|
chunk.append(line)
|
2013-04-05 15:46:36 +00:00
|
|
|
if not is_empty_chunk(chunk):
|
|
|
|
print '\n'.join(chunk)
|
|
|
|
|
|
|
|
|
2014-04-03 11:09:02 +00:00
|
|
|
def NotifyBuildDone(build_config, success, start):
|
2014-04-01 12:11:45 +00:00
|
|
|
if not success:
|
|
|
|
print "BUILD FAILED"
|
|
|
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
2014-04-03 11:09:02 +00:00
|
|
|
# Display a notification if build time exceeded DART_BUILD_NOTIFICATION_DELAY.
|
|
|
|
notification_delay = float(
|
|
|
|
os.getenv('DART_BUILD_NOTIFICATION_DELAY', default=sys.float_info.max))
|
|
|
|
if (time.time() - start) < notification_delay:
|
|
|
|
return
|
|
|
|
|
2014-04-01 12:11:45 +00:00
|
|
|
if success:
|
|
|
|
message = 'Build succeeded.'
|
|
|
|
else:
|
|
|
|
message = 'Build failed.'
|
|
|
|
title = build_config
|
|
|
|
|
|
|
|
command = None
|
|
|
|
if HOST_OS == 'macos':
|
|
|
|
# Use AppleScript to display a UI non-modal notification.
|
|
|
|
script = 'display notification "%s" with title "%s" sound name "Glass"' % (
|
|
|
|
message, title)
|
|
|
|
command = "osascript -e '%s' &" % script
|
|
|
|
elif HOST_OS == 'linux':
|
|
|
|
if success:
|
|
|
|
icon = 'dialog-information'
|
|
|
|
else:
|
|
|
|
icon = 'dialog-error'
|
|
|
|
command = "notify-send -i '%s' '%s' '%s' &" % (icon, message, title)
|
2014-05-15 01:02:04 +00:00
|
|
|
elif HOST_OS == 'win32':
|
|
|
|
if success:
|
|
|
|
icon = 'info'
|
|
|
|
else:
|
|
|
|
icon = 'error'
|
|
|
|
command = ("powershell -command \""
|
|
|
|
"[reflection.assembly]::loadwithpartialname('System.Windows.Forms')"
|
|
|
|
"| Out-Null;"
|
|
|
|
"[reflection.assembly]::loadwithpartialname('System.Drawing')"
|
|
|
|
"| Out-Null;"
|
|
|
|
"$n = new-object system.windows.forms.notifyicon;"
|
|
|
|
"$n.icon = [system.drawing.systemicons]::information;"
|
|
|
|
"$n.visible = $true;"
|
|
|
|
"$n.showballoontip(%d, '%s', '%s', "
|
|
|
|
"[system.windows.forms.tooltipicon]::%s);\"") % (
|
|
|
|
5000, # Notification stays on for this many milliseconds
|
|
|
|
message, title, icon)
|
2014-04-01 12:11:45 +00:00
|
|
|
|
|
|
|
if command:
|
|
|
|
# Ignore return code, if this command fails, it doesn't matter.
|
|
|
|
os.system(command)
|
|
|
|
|
|
|
|
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
filter_xcodebuild_output = False
|
2014-07-22 15:01:05 +00:00
|
|
|
def BuildOneConfig(options, target, target_os, mode, arch, override_tools):
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
global filter_xcodebuild_output
|
|
|
|
start_time = time.time()
|
|
|
|
os.environ['DART_BUILD_MODE'] = mode
|
|
|
|
build_config = utils.GetBuildConf(mode, arch, target_os)
|
|
|
|
if HOST_OS == 'macos':
|
|
|
|
filter_xcodebuild_output = True
|
|
|
|
project_file = 'dart.xcodeproj'
|
|
|
|
if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
|
|
|
|
project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName()
|
|
|
|
args = ['xcodebuild',
|
|
|
|
'-project',
|
|
|
|
project_file,
|
|
|
|
'-target',
|
|
|
|
target,
|
|
|
|
'-configuration',
|
|
|
|
build_config,
|
|
|
|
'SYMROOT=%s' % os.path.abspath('xcodebuild')
|
|
|
|
]
|
|
|
|
elif HOST_OS == 'win32':
|
|
|
|
project_file = 'dart.sln'
|
|
|
|
if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
|
|
|
|
project_file = 'dart-%s.sln' % CurrentDirectoryBaseName()
|
|
|
|
# Select a platform suffix to pass to devenv.
|
|
|
|
if arch == 'ia32':
|
|
|
|
platform_suffix = 'Win32'
|
|
|
|
elif arch == 'x64':
|
|
|
|
platform_suffix = 'x64'
|
|
|
|
else:
|
|
|
|
print 'Unsupported arch for MSVC build: %s' % arch
|
|
|
|
return 1
|
|
|
|
config_name = '%s|%s' % (build_config, platform_suffix)
|
|
|
|
if target == 'all':
|
|
|
|
args = [options.devenv + os.sep + options.executable,
|
|
|
|
'/build',
|
|
|
|
config_name,
|
|
|
|
project_file
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
args = [options.devenv + os.sep + options.executable,
|
|
|
|
'/build',
|
|
|
|
config_name,
|
|
|
|
'/project',
|
|
|
|
target,
|
|
|
|
project_file
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
make = 'make'
|
|
|
|
if HOST_OS == 'freebsd':
|
|
|
|
make = 'gmake'
|
|
|
|
# work around lack of flock
|
|
|
|
os.environ['LINK'] = '$(CXX)'
|
|
|
|
args = [make,
|
|
|
|
'-j',
|
|
|
|
options.j,
|
|
|
|
'BUILDTYPE=' + build_config,
|
|
|
|
]
|
|
|
|
if target_os != HOST_OS:
|
|
|
|
args += ['builddir_name=' + utils.GetBuildDir(HOST_OS, target_os)]
|
|
|
|
if options.verbose:
|
|
|
|
args += ['V=1']
|
|
|
|
|
|
|
|
args += [target]
|
|
|
|
|
|
|
|
toolsOverride = None
|
|
|
|
if override_tools:
|
|
|
|
toolsOverride = SetTools(arch, target_os, options)
|
|
|
|
if toolsOverride:
|
|
|
|
for k, v in toolsOverride.iteritems():
|
|
|
|
args.append( k + "=" + v)
|
|
|
|
if options.verbose:
|
|
|
|
print k + " = " + v
|
|
|
|
if not os.path.isfile(toolsOverride['CC.target']):
|
|
|
|
if arch == 'arm':
|
|
|
|
print arm_cc_error
|
|
|
|
else:
|
|
|
|
print "Couldn't find compiler: %s" % toolsOverride['CC.target']
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
print ' '.join(args)
|
|
|
|
process = None
|
|
|
|
if filter_xcodebuild_output:
|
|
|
|
process = subprocess.Popen(args,
|
|
|
|
stdin=None,
|
|
|
|
bufsize=1, # Line buffered.
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT)
|
|
|
|
FilterEmptyXcodebuildSections(process)
|
|
|
|
else:
|
|
|
|
process = subprocess.Popen(args, stdin=None)
|
|
|
|
process.wait()
|
|
|
|
if process.returncode != 0:
|
|
|
|
NotifyBuildDone(build_config, success=False, start=start_time)
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
NotifyBuildDone(build_config, success=True, start=start_time)
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def BuildCrossSdk(options, target_os, mode, arch):
|
|
|
|
# First build 'create_sdk' for the host. Do not override the host toolchain.
|
|
|
|
if BuildOneConfig(options, 'create_sdk', HOST_OS,
|
|
|
|
mode, HOST_ARCH, False) != 0:
|
|
|
|
return 1
|
|
|
|
|
|
|
|
# Then, build the runtime for the target arch.
|
2014-07-22 15:01:05 +00:00
|
|
|
if BuildOneConfig(options, 'runtime', target_os, mode, arch, True) != 0:
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
return 1
|
|
|
|
|
|
|
|
# TODO(zra): verify that no platform specific details leak into the snapshots
|
|
|
|
# created for pub, dart2js, etc.
|
|
|
|
|
|
|
|
# Copy dart-sdk from the host build products dir to the target build
|
|
|
|
# products dir, and copy the dart binary for target to the sdk bin/ dir.
|
|
|
|
src = os.path.join(
|
|
|
|
utils.GetBuildRoot(HOST_OS, mode, HOST_ARCH, HOST_OS), 'dart-sdk')
|
|
|
|
dst = os.path.join(
|
|
|
|
utils.GetBuildRoot(HOST_OS, mode, arch, target_os), 'dart-sdk')
|
|
|
|
shutil.rmtree(dst, ignore_errors=True)
|
|
|
|
shutil.copytree(src, dst)
|
|
|
|
|
|
|
|
dart = os.path.join(
|
|
|
|
utils.GetBuildRoot(HOST_OS, mode, arch, target_os), 'dart')
|
|
|
|
bin = os.path.join(dst, 'bin')
|
|
|
|
shutil.copy(dart, bin)
|
|
|
|
|
|
|
|
# Strip the dart binary
|
|
|
|
toolchainprefix = GetToolchainPrefix(target_os, arch, options)
|
|
|
|
if toolchainprefix == None:
|
|
|
|
print "Couldn't figure out the cross-toolchain"
|
|
|
|
return 1
|
|
|
|
strip = toolchainprefix + '-strip'
|
|
|
|
subprocess.call([strip, os.path.join(bin, 'dart')])
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
2011-10-05 05:34:19 +00:00
|
|
|
def Main():
|
|
|
|
utils.ConfigureJava()
|
|
|
|
# Parse the options.
|
|
|
|
parser = BuildOptions()
|
|
|
|
(options, args) = parser.parse_args()
|
2012-08-29 20:42:28 +00:00
|
|
|
if not ProcessOptions(options, args):
|
2011-10-05 05:34:19 +00:00
|
|
|
parser.print_help()
|
|
|
|
return 1
|
|
|
|
# Determine which targets to build. By default we build the "all" target.
|
|
|
|
if len(args) == 0:
|
2013-04-08 13:58:16 +00:00
|
|
|
if HOST_OS == 'macos':
|
2013-06-21 08:37:25 +00:00
|
|
|
targets = ['All']
|
2013-04-08 13:58:16 +00:00
|
|
|
else:
|
2013-06-21 08:37:25 +00:00
|
|
|
targets = ['all']
|
2011-10-05 05:34:19 +00:00
|
|
|
else:
|
2013-06-21 08:37:25 +00:00
|
|
|
targets = args
|
2012-08-29 20:42:28 +00:00
|
|
|
|
2013-06-21 08:37:25 +00:00
|
|
|
# Build all targets for each requested configuration.
|
|
|
|
for target in targets:
|
|
|
|
for target_os in options.os:
|
|
|
|
for mode in options.mode:
|
|
|
|
for arch in options.arch:
|
2014-07-22 15:01:05 +00:00
|
|
|
cross_build = utils.IsCrossBuild(target_os, arch)
|
|
|
|
if target in ['create_sdk'] and cross_build:
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
if BuildCrossSdk(options, target_os, mode, arch) != 0:
|
2014-06-06 12:14:15 +00:00
|
|
|
return 1
|
2012-08-29 20:42:28 +00:00
|
|
|
else:
|
2014-07-22 15:01:05 +00:00
|
|
|
if BuildOneConfig(options, target, target_os, mode, arch, cross_build) != 0:
|
2013-06-21 08:37:25 +00:00
|
|
|
return 1
|
|
|
|
|
2011-10-05 05:34:19 +00:00
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(Main())
|