Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Adding absolute paths to build.py and gn.py #59798

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .gitmodules
Empty file.
181 changes: 99 additions & 82 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
# 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("build/config/gclient_args.gni")
targeting_packaging = target_os == "linux_packaged"

if (!targeting_packaging) {
import("build/config/gclient_args.gni")
}
import("sdk_args.gni")

targeting_fuchsia = target_os == "fuchsia"
Expand Down Expand Up @@ -44,19 +48,30 @@ group("runtime") {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}

deps = [
"runtime/bin:dart",
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
"runtime/bin:process_test",
"runtime/bin:run_vm_tests",
"runtime/vm:kernel_platform_files($host_toolchain)",
"samples/embedder:all",
"samples/ffi/http:fake_http",
"utils/dartdev:dartdev",
"utils/kernel-service:kernel-service",
]
if (!targeting_packaging) {
deps = [
"runtime/bin:dart",
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
"runtime/bin:process_test",
"runtime/bin:run_vm_tests",
"runtime/vm:kernel_platform_files($host_toolchain)",
"samples/embedder:all",
"samples/ffi/http:fake_http",
"utils/dartdev:dartdev",
"utils/kernel-service:kernel-service",
]
}
if (targeting_packaging) {
deps = [
"runtime/bin:dart",
"runtime/vm:kernel_platform_files($host_toolchain)",
"samples/embedder:all",
"samples/ffi/http:fake_http",
"utils/dartdev:dartdev",
"utils/kernel-service:kernel-service",
]
}

# The following dependencies allow dartdev to start the resident frontend
# server.
Expand Down Expand Up @@ -386,82 +401,84 @@ if (is_fuchsia) {

test_deps = []
test_resources = []
foreach(test_source, test_sources) {
label = string_replace(test_source, "/", "_")

application_snapshot(label) {
dart_snapshot_kind = "kernel"
main_dart = test_source
training_args = [] # Not used
output = "$target_gen_dir/$test_source.dill"
if (!targeting_packaging) {
foreach(test_source, test_sources) {
label = string_replace(test_source, "/", "_")

application_snapshot(label) {
dart_snapshot_kind = "kernel"
main_dart = test_source
training_args = [] # Not used
output = "$target_gen_dir/$test_source.dill"
}

test_deps += [ ":$label" ]
test_resources += [
{
path = rebase_path("$target_gen_dir/$test_source.dill")
dest = "data/$test_source"
},
]
}

test_deps += [ ":$label" ]
test_resources += [
{
path = rebase_path("$target_gen_dir/$test_source.dill")
dest = "data/$test_source"
},
test_binaries = [
"dart",
"dartaotruntime",
"run_vm_tests",
]
}

test_binaries = [
"dart",
"dartaotruntime",
"run_vm_tests",
]

foreach(binary, test_binaries) {
fuchsia_component("${binary}_test_component") {
testonly = true
manifest = "runtime/bin/${binary}_test_component.cml"
data_deps = [
"runtime/bin:${binary}",
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
]
library_files = [
"libffi_test_dynamic_library.so",
"libffi_test_functions.so",
]
resource_files = [
".dart_tool/package_config.json",
"tools/addlatexhash.dart",
]
resources = []
foreach(file, library_files) {
resources += [
{
path = root_out_dir + "/" + file
dest = "lib/" + file
},
foreach(binary, test_binaries) {
fuchsia_component("${binary}_test_component") {
testonly = true
manifest = "runtime/bin/${binary}_test_component.cml"
data_deps = [
"runtime/bin:${binary}",
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
]
}
foreach(file, resource_files) {
resources += [
{
path = file
dest = "data/" + file
},
library_files = [
"libffi_test_dynamic_library.so",
"libffi_test_functions.so",
]
resource_files = [
".dart_tool/package_config.json",
"tools/addlatexhash.dart",
]
resources = []
foreach(file, library_files) {
resources += [
{
path = root_out_dir + "/" + file
dest = "lib/" + file
},
]
}
foreach(file, resource_files) {
resources += [
{
path = file
dest = "data/" + file
},
]
}
deps = test_deps
resources += test_resources
}
deps = test_deps
resources += test_resources
}
}

fuchsia_package("fuchsia_test_package") {
testonly = true
if (is_debug) {
package_name = "dart_test_debug"
} else if (is_release) {
package_name = "dart_test_release"
} else if (is_product) {
package_name = "dart_test_product"
}
deps = []
foreach(binary, test_binaries) {
deps += [ ":${binary}_test_component" ]
fuchsia_package("fuchsia_test_package") {
testonly = true
if (is_debug) {
package_name = "dart_test_debug"
} else if (is_release) {
package_name = "dart_test_release"
} else if (is_product) {
package_name = "dart_test_product"
}
deps = []
foreach(binary, test_binaries) {
deps += [ ":${binary}_test_component" ]
}
}
}
}
}
16 changes: 14 additions & 2 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ def BuildOneConfig(options, targets, target_os, mode, arch, sanitizer, env):
build_config = utils.GetBuildConf(mode, arch, target_os, sanitizer)
out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os, sanitizer)
using_rbe = False
command = ['buildtools/ninja/ninja', '-C', out_dir]
if os.path.isfile('buildtools/ninja/ninja'):
command = ['buildtools/ninja/ninja', '-C', out_dir]
elif os.path.isfile(os.path.join('/usr', 'bin', 'ninja')):
command = [os.path.join('/usr', 'bin', 'ninja'), '-C', out_dir]
if options.verbose:
command += ['-v']
if UseRBE(out_dir):
Expand Down Expand Up @@ -213,7 +216,16 @@ def CheckCleanBuild(build_config, args, env):


def SanitizerEnvironmentVariables():
with io.open('tools/bots/test_matrix.json', encoding='utf-8') as fd:
if os.path.isfile('tools/bots/test_matrix.json'):
_test_matrix_path = 'tools/bots/test_matrix.json'
else:
if os.path.isfile(os.path.join(DART_ROOT, 'tools/bots/test_matrix.json')):
_test_matrix_path = os.path.join(DART_ROOT, 'tools/bots/test_matrix.json')
else:
_test_matrix_path = os.path.join(
os.path.join(os.getcwd(), 'tools/bots/test_matrix.json')
)
with io.open(_test_matrix_path, encoding='utf-8') as fd:
config = json.loads(fd.read())
env = dict()
for k, v in config['sanitizer_options'].items():
Expand Down
17 changes: 12 additions & 5 deletions tools/gn.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def ParseStringMap(key, string_map):

def UseSysroot(args, gn_args):
# Don't try to use a Linux sysroot if we aren't on Linux.
if gn_args['target_os'] != 'linux' and HOST_OS != 'linux':
if gn_args['target_os'] != 'linux' and HOST_OS != 'linux' or gn_args['target_os'] != 'linux_packaged' and HOST_OS != 'linux':
return False
# Don't use the sysroot if we're given another sysroot.
if TargetSysroot(args):
Expand Down Expand Up @@ -225,9 +225,11 @@ def ToGnArgs(args, mode, arch, target_os, sanitizer, verify_sdk_hash,
# We only want the fallback root certs in the standalone VM on
# Linux and Windows.
if gn_args['target_os'] in ['linux', 'win']:
# This condition also covers the case of 'linux_packaged', which is a special case to cater for
# the needs of Linux distributions, which do not accept packages with prebuilt binary contents
gn_args['dart_use_fallback_root_certificates'] = True

if gn_args['target_os'] == 'linux':
if gn_args['target_os'] == 'linux' or gn_args['target_os'] == 'linux_packaged':
if gn_args['target_cpu'] == 'arm':
# Default to -mfloat-abi=hard and -mfpu=neon for arm on Linux as we're
# specifying a gnueabihf compiler in //build/toolchain/linux/BUILD.gn.
Expand Down Expand Up @@ -354,7 +356,7 @@ def ProcessOptions(args):
for os_name in oses:
if not os_name in [
'android', 'freebsd', 'linux', 'macos', 'win32', 'fuchsia',
'ios', 'ios_simulator'
'ios', 'ios_simulator', 'linux_packaged'
]:
print("Unknown os %s" % os_name)
return False
Expand Down Expand Up @@ -561,7 +563,7 @@ def AddCommonConfigurationArgs(parser):
parser.add_argument('--os',
type=str,
help='Target OSs (comma-separated).',
metavar='[all,host,android,fuchsia,ios,ios_simulator]',
metavar='[all,host,android,fuchsia,ios,ios_simulator,linux_packaged]',
default='host')
parser.add_argument('--sanitizer',
type=str,
Expand Down Expand Up @@ -635,7 +637,12 @@ def BuildGnCommand(args, mode, arch, target_os, sanitizer, out_dir):
if utils.IsWindows():
gn = os.path.join(DART_ROOT, 'buildtools', 'win', 'gn.exe')
else:
gn = os.path.join(DART_ROOT, 'buildtools', 'gn')
_gn = os.path.join(DART_ROOT, 'buildtools', 'gn')
if os.path.isfile(_gn):
gn = os.path.join(DART_ROOT, 'buildtools', 'gn')
else:
gn = os.path.join('/usr', 'bin', 'gn')
del _gn
if not os.path.isfile(gn):
raise Exception("Couldn't find the gn binary at path: " + gn)

Expand Down