[infra] Assembles the SDK using GN rather than create_sdk.py

This has a few advantages:
- We can track dependencies more precisely
- ninja can assemble things in parallel as they're ready rather than
  sequentially all at once.
- It is easier to customize SDKs depending on target platform, e.g.
  Fuchsia.

This CL also has a number of cleanups:
- Defining is_fuchsia and is_fuchsia host so we don't always have to check
- Piping through toolchain overrides in more places
- Fixing bugs in copy_tree.py, not using list_files.py, which is broken on Windows

related #29558

R=whesse@google.com

Review-Url: https://codereview.chromium.org/2848943003 .
This commit is contained in:
Zachary Anderson 2017-05-20 23:30:06 -07:00
parent bf15116d0f
commit 81e428fd39
15 changed files with 937 additions and 807 deletions

140
BUILD.gn
View file

@ -4,7 +4,7 @@
# This target will be built if no target is specified when invoking ninja.
group("default") {
if (defined(is_fuchsia) && (is_fuchsia || is_fuchsia_host)) {
if (is_fuchsia || is_fuchsia_host) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
@ -14,7 +14,7 @@ group("default") {
}
group("most") {
if (defined(is_fuchsia) && (is_fuchsia || is_fuchsia_host)) {
if (is_fuchsia || is_fuchsia_host) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
@ -30,7 +30,7 @@ group("most") {
}
group("runtime") {
if (defined(is_fuchsia) && (is_fuchsia || is_fuchsia_host)) {
if (is_fuchsia || is_fuchsia_host) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
@ -46,7 +46,7 @@ group("runtime") {
}
group("runtime_kernel") {
if (defined(is_fuchsia) && (is_fuchsia || is_fuchsia_host)) {
if (is_fuchsia || is_fuchsia_host) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
@ -121,85 +121,83 @@ group("samples") {
# The rules below build a qemu Fuchsia OS image that includes the Dart tree
# under /system/test/dart. Building this image is gated by the GN argument
# 'dart_build_fuchsia_test_image' because building the image is slow.
if (defined(is_fuchsia) && is_fuchsia) {
if (is_fuchsia) {
declare_args() {
dart_build_fuchsia_test_image = false
}
if (dart_build_fuchsia_test_image) {
action("generate_dart_test_manifest") {
testonly = true
action("generate_dart_test_manifest") {
testonly = true
deps = [
"//packages/gn:mkbootfs",
]
deps = [
"//packages/gn:mkbootfs",
]
output_prefix = "$target_gen_dir/dart_test_tree"
outputs = [
"$output_prefix.manifest",
]
output_prefix = "$target_gen_dir/dart_test_tree"
outputs = [
"$output_prefix.manifest",
]
mode = "release"
if (is_debug) {
mode = "debug"
}
mkbootfs_gen = get_label_info("//packages/gn:mkbootfs", "target_gen_dir")
user_manifest = "$mkbootfs_gen/user.bootfs.manifest"
script = "tools/gen_fuchsia_test_manifest.py"
args = [
"-m",
mode,
"-u",
rebase_path(user_manifest),
"-o",
rebase_path(output_prefix),
]
mode = "release"
if (is_debug) {
mode = "debug"
}
action("generate_dart_test_image") {
testonly = true
deps = [
":generate_dart_test_manifest",
"runtime/bin:dart",
"runtime/bin:process_test",
"runtime/bin:run_vm_tests",
]
mkbootfs_gen = get_label_info("//packages/gn:mkbootfs", "target_gen_dir")
user_manifest = "$mkbootfs_gen/user.bootfs.manifest"
# Compute path to magenta bootdata.bin
if (current_cpu == "arm64") {
magenta_bootdata =
"//out/build-magenta/build-magenta-qemu-arm64/bootdata.bin"
} else if (current_cpu == "x64") {
magenta_bootdata =
"//out/build-magenta/build-magenta-pc-x86-64/bootdata.bin"
} else {
assert(false, "unable to determine path to magenta's bootdata.bin")
}
script = "tools/gen_fuchsia_test_manifest.py"
args = [
"-m",
mode,
"-u",
rebase_path(user_manifest),
"-o",
rebase_path(output_prefix),
]
}
input = "$target_gen_dir/dart_test_tree.manifest"
inputs = [
magenta_bootdata,
input,
]
action("generate_dart_test_image") {
testonly = true
deps = [
":generate_dart_test_manifest",
"runtime/bin:dart",
"runtime/bin:process_test",
"runtime/bin:run_vm_tests",
]
output = "$root_out_dir/dart_test_tree.bin"
outputs = [
output,
]
script = "//packages/gn/make_bootfs.py"
args = [
"--manifest",
rebase_path(input),
"--output-file",
rebase_path(output),
"--build-id-map",
rebase_path("$target_gen_dir/build_id_map"),
"--pre-binaries",
rebase_path(magenta_bootdata),
]
# Compute path to magenta bootdata.bin
if (current_cpu == "arm64") {
magenta_bootdata =
"//out/build-magenta/build-magenta-qemu-arm64/bootdata.bin"
} else if (current_cpu == "x64") {
magenta_bootdata =
"//out/build-magenta/build-magenta-pc-x86-64/bootdata.bin"
} else {
assert(false, "unable to determine path to magenta's bootdata.bin")
}
input = "$target_gen_dir/dart_test_tree.manifest"
inputs = [
magenta_bootdata,
input,
]
output = "$root_out_dir/dart_test_tree.bin"
outputs = [
output,
]
script = "//packages/gn/make_bootfs.py"
args = [
"--manifest",
rebase_path(input),
"--output-file",
rebase_path(output),
"--build-id-map",
rebase_path("$target_gen_dir/build_id_map"),
"--pre-binaries",
rebase_path(magenta_bootdata),
]
}
}

View file

@ -153,6 +153,8 @@ declare_args() {
if (current_os == "win") {
is_android = false
is_chromeos = false
is_fuchsia = false
is_fuchsia_host = false
is_ios = false
is_linux = false
is_mac = false
@ -162,6 +164,8 @@ if (current_os == "win") {
} else if (current_os == "mac") {
is_android = false
is_chromeos = false
is_fuchsia = false
is_fuchsia_host = false
is_ios = false
is_linux = false
is_mac = true
@ -171,6 +175,8 @@ if (current_os == "win") {
} else if (current_os == "android") {
is_android = true
is_chromeos = false
is_fuchsia = false
is_fuchsia_host = false
is_ios = false
is_linux = false
is_mac = false
@ -180,6 +186,8 @@ if (current_os == "win") {
} else if (current_os == "linux") {
is_android = false
is_chromeos = false
is_fuchsia = false
is_fuchsia_host = false
is_ios = false
is_linux = true
is_mac = false
@ -227,9 +235,7 @@ if (is_win) {
]
}
if (is_posix) {
_native_compiler_configs += [
"//build/config/gcc:no_exceptions",
]
_native_compiler_configs += [ "//build/config/gcc:no_exceptions" ]
}
if (is_linux) {

View file

@ -73,6 +73,9 @@ config("common_linker_setup") {
# exceeds maximum allowable size (80000000)
# which started happening more regularly after VS2013 Update 4.
"/maxilksize:2147483647",
# Force the creation of a .lib file for all executable() targets.
"/EXPORT:main",
]
# ASLR makes debugging with windbg difficult because Chrome.exe and

57
build/copy_tree.gni Normal file
View file

@ -0,0 +1,57 @@
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
# 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.
_dart_root = rebase_path("..")
# copy_tree() copies a directory tree rooted at `source` to `dest`, which should
# be somewhere under $root_out_dir.
#
# Optional parameters:
# exclude - A comma separated list that is passed to shutil.ignore_patterns()
# in tools/copy_tree.py.
template("copy_tree") {
assert(defined(invoker.source), "copy_tree must define 'source'")
assert(defined(invoker.dest), "copy_tree must define 'dest'")
source = invoker.source
dest = invoker.dest
action(target_name) {
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
deps = []
if (defined(invoker.deps)) {
deps += invoker.deps
}
common_args = [
"--from",
rebase_path(source),
"--to",
rebase_path(dest),
]
if (defined(invoker.exclude)) {
common_args += [
"--exclude",
invoker.exclude,
]
}
dry_run_args = common_args + [ "--dry-run" ]
input_files = exec_script("$_dart_root/tools/copy_tree.py",
dry_run_args,
"list lines")
inputs = input_files
relative_files = rebase_path(input_files, rebase_path(source))
output_files = []
foreach(input, relative_files) {
output_files += [ "$dest/$input" ]
}
outputs = output_files
script = "$_dart_root/tools/copy_tree.py"
args = common_args
}
}

View file

@ -38,8 +38,8 @@ concurrent_links = exec_script("get_concurrent_links.py", [], "value")
# - is_clang
# - strip
# Location of the strip executable. When specified, strip will be run on
# all shared libraries and executables as they are built. The pre-stripped
# artifacts will be put in lib.stripped/ and exe.stripped/.
# all executables as they are built. The stripped artifacts will be put in
# exe.stripped/.
template("gcc_toolchain") {
toolchain(target_name) {
assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
@ -192,17 +192,16 @@ template("gcc_toolchain") {
exename = "{{target_output_name}}{{output_extension}}"
outfile = "{{root_out_dir}}/$exename"
rspfile = "$outfile.rsp"
unstripped_outfile = outfile
if (defined(invoker.strip)) {
unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
stripped_outfile = "{{root_out_dir}}/exe.stripped/$exename"
}
command = "$ld {{ldflags}} -o $unstripped_outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
if (defined(invoker.strip)) {
strip = invoker.strip
strip_command =
"${strip} --strip-unneeded -o $outfile $unstripped_outfile"
"${strip} --strip-unneeded -o $stripped_outfile $outfile"
command += " && " + strip_command
}
if (defined(invoker.postlink)) {
@ -213,8 +212,8 @@ template("gcc_toolchain") {
outputs = [
outfile,
]
if (outfile != unstripped_outfile) {
outputs += [ unstripped_outfile ]
if (defined(invoker.strip)) {
outputs += [ stripped_outfile ]
}
if (defined(invoker.link_outputs)) {
outputs += invoker.link_outputs

View file

@ -34,6 +34,7 @@ gcc_toolchain("arm") {
ld = cxx
readelf = "${prefix}readelf"
nm = "${prefix}nm"
strip = "${prefix}strip"
toolchain_cpu = "arm"
toolchain_os = "linux"
@ -53,6 +54,7 @@ gcc_toolchain("arm64") {
ld = cxx
readelf = "${prefix}readelf"
nm = "${prefix}nm"
strip = "${prefix}strip"
toolchain_cpu = "arm64"
toolchain_os = "linux"
@ -62,12 +64,16 @@ gcc_toolchain("arm64") {
gcc_toolchain("clang_x86") {
prefix = rebase_path("//buildtools/toolchain/clang+llvm-x86_64-linux/bin",
root_build_dir)
cc = "${compiler_prefix}$prefix/clang"
cxx = "${compiler_prefix}$prefix/clang++"
if (toolchain_prefix != "") {
prefix = toolchain_prefix
}
cc = "${compiler_prefix}${prefix}/clang"
cxx = "${compiler_prefix}${prefix}/clang++"
readelf = "readelf"
nm = "nm"
ar = "ar"
nm = "${prefix}/llvm-nm"
ar = "${prefix}/llvm-ar"
ld = cxx
strip = "${prefix}/strip"
toolchain_cpu = "x86"
toolchain_os = "linux"
@ -75,13 +81,18 @@ gcc_toolchain("clang_x86") {
}
gcc_toolchain("x86") {
cc = "${compiler_prefix}gcc"
cxx = "${compiler_prefix}g++"
prefix = ""
if (toolchain_prefix != "") {
prefix = toolchain_prefix
}
cc = "${compiler_prefix}${prefix}gcc"
cxx = "${compiler_prefix}${prefix}g++"
readelf = "readelf"
nm = "nm"
ar = "ar"
readelf = "${prefix}readelf"
nm = "${prefix}nm"
ar = "${prefix}ar"
ld = cxx
strip = "${prefix}strip"
toolchain_cpu = "x86"
toolchain_os = "linux"
@ -91,13 +102,17 @@ gcc_toolchain("x86") {
gcc_toolchain("clang_x64") {
prefix = rebase_path("//buildtools/toolchain/clang+llvm-x86_64-linux/bin",
root_build_dir)
cc = "${compiler_prefix}$prefix/clang"
cxx = "${compiler_prefix}$prefix/clang++"
if (toolchain_prefix != "") {
prefix = toolchain_prefix
}
cc = "${compiler_prefix}${prefix}/clang"
cxx = "${compiler_prefix}${prefix}/clang++"
readelf = "readelf"
nm = "nm"
ar = "ar"
nm = "${prefix}/llvm-nm"
ar = "${prefix}/llvm-ar"
ld = cxx
strip = "${prefix}/strip"
toolchain_cpu = "x64"
toolchain_os = "linux"
@ -105,13 +120,18 @@ gcc_toolchain("clang_x64") {
}
gcc_toolchain("x64") {
cc = "${compiler_prefix}gcc"
cxx = "${compiler_prefix}g++"
prefix = ""
if (toolchain_prefix != "") {
prefix = toolchain_prefix
}
cc = "${compiler_prefix}${prefix}gcc"
cxx = "${compiler_prefix}${prefix}g++"
readelf = "readelf"
nm = "nm"
ar = "ar"
readelf = "${prefix}readelf"
nm = "${prefix}nm"
ar = "${prefix}ar"
ld = cxx
strip = "${prefix}strip"
toolchain_cpu = "x64"
toolchain_os = "linux"
@ -125,6 +145,7 @@ gcc_toolchain("mipsel") {
ld = cxx
readelf = "${toolchain_prefix}readelf"
nm = "${toolchain_prefix}nm"
strip = "${toolchain_prefix}strip"
toolchain_cpu = "${target_cpu}"
toolchain_os = "linux"

View file

@ -171,15 +171,29 @@ template("mac_toolchain") {
}
tool("link") {
outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
exename = "{{target_output_name}}{{output_extension}}"
outfile = "{{root_out_dir}}/$exename"
rspfile = "$outfile.rsp"
if (defined(invoker.strip)) {
stripped_outfile = "{{root_out_dir}}/exe.stripped/$exename"
}
command = "$ld $sysroot_flags $toolchain_flags {{ldflags}} -Xlinker -rpath -Xlinker @executable_path/Frameworks -o $outfile -Wl,-filelist,$rspfile {{solibs}} {{libs}}"
if (defined(invoker.strip)) {
strip = invoker.strip
strip_command = "${strip} -x -o $stripped_outfile $outfile"
command += " && " + strip_command
}
description = "LINK $outfile"
rspfile_content = "{{inputs_newline}}"
outputs = [
outfile,
]
if (defined(invoker.strip)) {
outputs += [ stripped_outfile ]
}
}
tool("stamp") {
@ -216,6 +230,7 @@ mac_toolchain("clang_x64") {
cc = "${goma_prefix}$prefix/clang"
cxx = "${goma_prefix}$prefix/clang++"
ld = cxx
strip = "${prefix}/strip"
is_clang = true
sysroot_flags = "-isysroot $mac_sdk_path -mmacosx-version-min=$mac_sdk_min"
}
@ -229,6 +244,7 @@ mac_toolchain("clang_x86") {
cc = "${goma_prefix}$prefix/clang"
cxx = "${goma_prefix}$prefix/clang++"
ld = cxx
strip = "${prefix}/strip"
is_clang = true
sysroot_flags = "-isysroot $mac_sdk_path -mmacosx-version-min=$mac_sdk_min"
}

View file

@ -165,9 +165,11 @@ template("msvc_toolchain") {
}
tool("link") {
rspfile = "{{output}}.rsp"
binary_output =
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
rspfile = "$binary_output.rsp"
link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe /nologo /OUT:{{output}} /PDB:{{output}}.pdb @$rspfile"
link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe /nologo /OUT:$binary_output /PDB:$binary_output.pdb @$rspfile"
# TODO(brettw) support manifests
#manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.exe -nologo -manifest $manifests -out:{{output}}.manifest"
@ -175,9 +177,10 @@ template("msvc_toolchain") {
command = link_command
default_output_extension = ".exe"
description = "LINK {{output}}"
description = "LINK $binary_output"
outputs = [
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
binary_output,
"{{root_out_dir}}/{{target_output_name}}.lib",
]
# The use of inputs_newline is to work around a fixed per-line buffer

View file

@ -135,7 +135,7 @@ config("dart_config") {
include_dirs += [ "../third_party/tcmalloc/gperftools/src" ]
}
if (defined(is_fuchsia) && is_fuchsia) {
if (is_fuchsia) {
defines += [ "DART_USE_JEMALLOC" ]
include_dirs += [ "//magenta/third_party/ulib/jemalloc/include" ]
}

View file

@ -321,7 +321,7 @@ executable("gen_snapshot") {
]
}
if (defined(is_fuchsia) && is_fuchsia) {
if (is_fuchsia) {
libs = [ "launchpad" ]
}
}
@ -412,7 +412,7 @@ template("dart_io") {
deps += [ "//third_party/boringssl" ]
}
if (defined(is_fuchsia) && is_fuchsia) {
if (is_fuchsia) {
libs = [ "launchpad" ]
}
@ -428,7 +428,7 @@ template("dart_io") {
"log.h",
] + extra_sources
if (is_linux || is_win || (defined(is_fuchsia) && is_fuchsia)) {
if (is_linux || is_win || is_fuchsia) {
if (dart_use_fallback_root_certificates) {
sources += [ "//third_party/root_certificates/root_certificates.cc" ]
} else {
@ -608,7 +608,7 @@ template("dart_executable") {
]
}
if (defined(is_fuchsia) && is_fuchsia) {
if (is_fuchsia) {
libs = [ "launchpad" ]
}
}
@ -692,7 +692,7 @@ dart_executable("dart_bootstrap") {
]
}
if (defined(is_fuchsia) && is_fuchsia) {
if (is_fuchsia) {
hello_fuchsia_source = rebase_path("../tests/vm/dart/hello_fuchsia_test.dart")
copy("hello_fuchsia") {
@ -771,7 +771,7 @@ action("generate_snapshot_test_dat_file") {
}
executable("run_vm_tests") {
if (defined(is_fuchsia) && (is_fuchsia || is_fuchsia_host)) {
if (is_fuchsia || is_fuchsia_host) {
testonly = true
}

View file

@ -27,8 +27,7 @@ declare_args() {
}
# We set this to "" in the Fuchsia build to force building with dart_bootstrap.
if (defined(is_fuchsia) && defined(is_fuchsia_host) &&
(is_fuchsia || is_fuchsia_host)) {
if (is_fuchsia || is_fuchsia_host) {
dart_host_pub_exe = ""
}

View file

@ -9,7 +9,7 @@ import("gypi_contents.gni")
import("../runtime_args.gni")
config("libdart_vm_config") {
if (defined(is_fuchsia) && is_fuchsia) {
if (is_fuchsia) {
libs = [ "magenta" ]
} else if (is_win) {
libs = [

File diff suppressed because it is too large Load diff

View file

@ -1,327 +0,0 @@
#!/usr/bin/env python
#
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
# 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.
#
# A script which will be invoked from gyp to create an SDK.
#
# Usage: create_sdk.py sdk_directory
#
# The SDK will be used either from the command-line or from the editor.
# Top structure is
#
# ..dart-sdk/
# ....bin/
# ......dart or dart.exe (executable)
# ......dart.lib (import library for VM native extensions on Windows)
# ......dartdoc
# ......dartfmt
# ......dart2js
# ......dartanalyzer
# ......dartdevc
# ......pub
# ......snapshots/
# ........analysis_server.dart.snapshot
# ........dart2js.dart.snapshot
# ........dartanalyzer.dart.snapshot
# ........dartdoc.dart.snapshot
# ........dartfmt.dart.snapshot
# ........dartdevc.dart.snapshot
# ........pub.dart.snapshot
# ........utils_wrapper.dart.snapshot
#.........resources/
#...........dartdoc/
#..............packages
#.............resources/
#.............templates/
# ....include/
# ......dart_api.h
# ......dart_mirrors_api.h
# ......dart_native_api.h
# ......dart_tools_api.h
# ....lib/
# ......dart_client.platform
# ......dart_server.platform
# ......dart_shared.platform
# ......_internal/
#.........spec.sum
#.........strong.sum
#.........dev_compiler/
# ......analysis_server/
# ......analyzer/
# ......async/
# ......collection/
# ......convert/
# ......core/
# ......front_end/
# ......html/
# ......internal/
# ......io/
# ......isolate/
# ......js/
# ......js_util/
# ......kernel/
# ......math/
# ......mirrors/
# ......typed_data/
# ......api_readme.md
# ....util/
# ......(more will come here)
import optparse
import os
import re
import sys
import subprocess
import utils
HOST_OS = utils.GuessOS()
# TODO(dgrove): Only import modules following Google style guide.
from os.path import basename, dirname, join, realpath, exists
# TODO(dgrove): Only import modules following Google style guide.
from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move
def GetOptions():
options = optparse.OptionParser(usage='usage: %prog [options]')
options.add_option("--sdk_output_dir",
help='Where to output the sdk')
options.add_option("--snapshot_location",
help='Location of the snapshots.')
return options.parse_args()
def Copy(src, dest):
copyfile(src, dest)
copymode(src, dest)
def CopyShellScript(src_file, dest_dir):
"""Copies a shell/batch script to the given destination directory. Handles
using the appropriate platform-specific file extension."""
file_extension = ''
if HOST_OS == 'win32':
file_extension = '.bat'
# If we're copying an SDK-specific shell script, strip off the suffix.
dest_file = basename(src_file)
if dest_file.endswith('_sdk'):
dest_file = dest_file.replace('_sdk', '')
src = src_file + file_extension
dest = join(dest_dir, dest_file + file_extension)
Copy(src, dest)
def CopyDartScripts(home, sdk_root):
for executable in ['dart2js_sdk', 'dartanalyzer_sdk', 'dartfmt_sdk',
'pub_sdk', 'dartdoc', 'dartdevc_sdk']:
CopyShellScript(os.path.join(home, 'sdk', 'bin', executable),
os.path.join(sdk_root, 'bin'))
def CopySnapshots(snapshots, sdk_root):
for snapshot in ['analysis_server', 'dart2js', 'dartanalyzer', 'dartfmt',
'utils_wrapper', 'pub', 'dartdoc', 'dartdevc']:
snapshot += '.dart.snapshot'
copyfile(join(snapshots, snapshot),
join(sdk_root, 'bin', 'snapshots', snapshot))
def CopyAnalyzerSources(home, lib_dir):
for library in ['analyzer', 'analysis_server', 'front_end', 'kernel']:
copytree(join(home, 'pkg', library), join(lib_dir, library),
ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh',
'.gitignore', 'packages'))
def CopyDartdocResources(home, sdk_root):
RESOURCE_DIR = join(sdk_root, 'bin', 'snapshots', 'resources')
DARTDOC = join(RESOURCE_DIR, 'dartdoc')
copytree(join(home, 'third_party', 'pkg', 'dartdoc', 'lib', 'templates'),
join(DARTDOC, 'templates'))
copytree(join(home, 'third_party', 'pkg', 'dartdoc', 'lib', 'resources'),
join(DARTDOC, 'resources'))
# write the .packages file
PACKAGES_FILE = join(DARTDOC, '.packages')
packages_file = open(PACKAGES_FILE, 'w')
packages_file.write('dartdoc:.')
packages_file.close()
def CopyAnalysisSummaries(snapshots, lib):
copyfile(join(snapshots, 'spec.sum'),
join(lib, '_internal', 'spec.sum'))
copyfile(join(snapshots, 'strong.sum'),
join(lib, '_internal', 'strong.sum'))
def CopyDevCompilerSdk(home, lib):
copyfile(join(home, 'pkg', 'dev_compiler', 'lib', 'sdk', 'ddc_sdk.sum'),
join(lib, '_internal', 'ddc_sdk.sum'))
copytree(join(home, 'pkg', 'dev_compiler', 'lib', 'js'),
join(lib, 'dev_compiler'))
copyfile(join(home, 'third_party', 'requirejs', 'require.js'),
join(lib, 'dev_compiler', 'amd', 'require.js'))
def Main():
# Pull in all of the gypi files which will be munged into the sdk.
HOME = dirname(dirname(realpath(__file__)))
(options, args) = GetOptions()
SDK = options.sdk_output_dir
SDK_tmp = '%s.tmp' % SDK
SNAPSHOT = options.snapshot_location
# TODO(dgrove) - deal with architectures that are not ia32.
if exists(SDK):
rmtree(SDK)
if exists(SDK_tmp):
rmtree(SDK_tmp)
os.makedirs(SDK_tmp)
# Create and populate sdk/bin.
BIN = join(SDK_tmp, 'bin')
os.makedirs(BIN)
os.makedirs(join(BIN, 'snapshots'))
# Copy the Dart VM binary and the Windows Dart VM link library
# into sdk/bin.
#
# TODO(dgrove) - deal with architectures that are not ia32.
build_dir = os.path.dirname(SDK)
dart_file_extension = ''
if HOST_OS == 'win32':
dart_file_extension = '.exe'
dart_import_lib_src = join(HOME, build_dir, 'dart.lib')
dart_import_lib_dest = join(BIN, 'dart.lib')
copyfile(dart_import_lib_src, dart_import_lib_dest)
dart_src_binary = join(HOME, build_dir, 'dart' + dart_file_extension)
dart_dest_binary = join(BIN, 'dart' + dart_file_extension)
copyfile(dart_src_binary, dart_dest_binary)
copymode(dart_src_binary, dart_dest_binary)
# Strip the binaries on platforms where that is supported.
if HOST_OS == 'linux':
subprocess.call(['strip', dart_dest_binary])
elif HOST_OS == 'macos':
subprocess.call(['strip', '-x', dart_dest_binary])
#
# Create and populate sdk/include.
#
INCLUDE = join(SDK_tmp, 'include')
os.makedirs(INCLUDE)
copyfile(join(HOME, 'runtime', 'include', 'dart_api.h'),
join(INCLUDE, 'dart_api.h'))
copyfile(join(HOME, 'runtime', 'include', 'dart_mirrors_api.h'),
join(INCLUDE, 'dart_mirrors_api.h'))
copyfile(join(HOME, 'runtime', 'include', 'dart_native_api.h'),
join(INCLUDE, 'dart_native_api.h'))
copyfile(join(HOME, 'runtime', 'include', 'dart_tools_api.h'),
join(INCLUDE, 'dart_tools_api.h'))
#
# Create and populate sdk/lib.
#
LIB = join(SDK_tmp, 'lib')
os.makedirs(LIB)
#
# Create and populate lib/{async, core, isolate, ...}.
#
os.makedirs(join(LIB, 'html'))
for library in [join('_blink', 'dartium'),
join('_chrome', 'dart2js'), join('_chrome', 'dartium'),
join('_internal', 'js_runtime'),
join('_internal', 'sdk_library_metadata'),
'async', 'collection', 'convert', 'core', 'developer',
'internal', 'io', 'isolate',
join('html', 'dart2js'), join('html', 'dartium'),
join('html', 'html_common'),
join('indexed_db', 'dart2js'), join('indexed_db', 'dartium'),
'js', 'js_util', 'math', 'mirrors', 'profiler', 'typed_data',
join('svg', 'dart2js'), join('svg', 'dartium'),
join('web_audio', 'dart2js'), join('web_audio', 'dartium'),
join('web_gl', 'dart2js'), join('web_gl', 'dartium'),
join('web_sql', 'dart2js'), join('web_sql', 'dartium')]:
copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library),
ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh',
'.gitignore'))
# Copy the platform descriptors.
for file_name in ["dart_client.platform",
"dart_server.platform",
"dart_shared.platform"]:
copyfile(join(HOME, 'sdk', 'lib', file_name), join(LIB, file_name));
# Copy libraries.dart to lib/_internal/libraries.dart for backwards
# compatibility.
#
# TODO(sigmund): stop copying libraries.dart. Old versions (<=0.25.1-alpha.4)
# of the analyzer package do not support the new location of this file. We
# should be able to remove the old file once we release a newer version of
# analyzer and popular frameworks have migrated to use it.
copyfile(join(HOME, 'sdk', 'lib', '_internal',
'sdk_library_metadata', 'lib', 'libraries.dart'),
join(LIB, '_internal', 'libraries.dart'))
# Create and copy tools.
UTIL = join(SDK_tmp, 'util')
os.makedirs(UTIL)
RESOURCE = join(SDK_tmp, 'lib', '_internal', 'pub', 'asset')
os.makedirs(os.path.dirname(RESOURCE))
copytree(join(HOME, 'third_party', 'pkg', 'pub', 'lib', 'src',
'asset'),
join(RESOURCE),
ignore=ignore_patterns('.svn'))
# Copy in 7zip for Windows.
if HOST_OS == 'win32':
copytree(join(HOME, 'third_party', '7zip'),
join(RESOURCE, '7zip'),
ignore=ignore_patterns('.svn'))
# Copy dart2js/pub.
CopyDartScripts(HOME, SDK_tmp)
CopySnapshots(SNAPSHOT, SDK_tmp)
CopyDartdocResources(HOME, SDK_tmp)
CopyAnalyzerSources(HOME, LIB)
CopyAnalysisSummaries(SNAPSHOT, LIB)
CopyDevCompilerSdk(HOME, LIB)
# Write the 'version' file
version = utils.GetVersion()
versionFile = open(os.path.join(SDK_tmp, 'version'), 'w')
versionFile.write(version + '\n')
versionFile.close()
# Write the 'revision' file
revision = utils.GetGitRevision()
if revision is not None:
with open(os.path.join(SDK_tmp, 'revision'), 'w') as f:
f.write('%s\n' % revision)
f.close()
Copy(join(HOME, 'README.dart-sdk'), join(SDK_tmp, 'README'))
Copy(join(HOME, 'LICENSE'), join(SDK_tmp, 'LICENSE'))
Copy(join(HOME, 'sdk', 'api_readme.md'), join(SDK_tmp, 'lib', 'api_readme.md'))
move(SDK_tmp, SDK)
if __name__ == '__main__':
sys.exit(Main())

View file

@ -25,6 +25,8 @@ DART_USE_TSAN = "DART_USE_TSAN" # Use instead of --tsan
DART_USE_WHEEZY = "DART_USE_WHEEZY" # Use instread of --wheezy
DART_USE_TOOLCHAIN = "DART_USE_TOOLCHAIN" # Use instread of --toolchain-prefix
DART_USE_SYSROOT = "DART_USE_SYSROOT" # Use instead of --target-sysroot
# use instead of --platform-sdk
DART_MAKE_PLATFORM_SDK = "DART_MAKE_PLATFORM_SDK"
def UseASAN():
return DART_USE_ASAN in os.environ
@ -54,6 +56,10 @@ def TargetSysroot(args):
return os.environ.get(DART_USE_SYSROOT)
def MakePlatformSDK():
return DART_MAKE_PLATFORM_SDK in os.environ
def GetOutDir(mode, arch, target_os):
return utils.GetBuildRoot(HOST_OS, mode, arch, target_os)
@ -197,6 +203,8 @@ def ToGnArgs(args, mode, arch, target_os):
gn_args['is_msan'] = args.msan and gn_args['is_clang']
gn_args['is_tsan'] = args.tsan and gn_args['is_clang']
gn_args['dart_platform_sdk'] = args.platform_sdk
# Setup the user-defined sysroot.
if gn_args['target_os'] == 'linux' and args.wheezy and not crossbuild:
gn_args['dart_use_wheezy_sysroot'] = True
@ -357,6 +365,10 @@ def parse_args(args):
help='Disable MSAN',
dest='msan',
action='store_false')
other_group.add_argument('--platform-sdk',
help='Directs the create_sdk target to create a smaller "Platform" SDK',
default=MakePlatformSDK(),
action='store_true')
other_group.add_argument('--target-sysroot', '-s',
type=str,
help='Comma-separated list of arch=/path/to/sysroot mappings')