blob: c6187ac9c9ce064878d2f1897874eeb1f1a9e545 [file] [log] [blame] [edit]
# Copyright 2016 The Fuchsia Authors. 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/checkout.gni")
import("//build/components.gni")
import("//build/config/clang/clang.gni")
import("//build/config/sysroot.gni")
import("//build/go/go_test.gni")
import("//build/host.gni")
go_git_dir = ""
if (submodules) {
go_git_link_path_list = read_file(".git", "list lines")
go_git_link_path = go_git_link_path_list[0]
go_git_dir_split = string_split(go_git_link_path)
go_git_dir = go_git_dir_split[1]
} else {
go_git_dir = ".git"
}
if (is_host && current_toolchain == toolchain_variant.base) {
_go_root = "$host_tools_dir/goroot"
compiled_action("makeroot") {
visibility = [ ":makefuchsia" ]
depfile = "$target_gen_dir/$target_name.d"
inputs = [
"${go_git_dir}/HEAD",
"${go_git_dir}/index",
".gitignore",
]
_output = "$target_gen_dir/$target_name.stamp"
outputs = [ _output ]
tool = "makeroot"
args = [
"--source-goroot",
rebase_path(".", root_build_dir),
"--target-goroot",
rebase_path(_go_root, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
"--stamp-file",
rebase_path(_output, root_build_dir),
]
}
compiled_action("makefuchsia") {
visibility = [ ":create_go_runtime" ]
deps = [
":makeroot",
"//sdk/lib/fdio",
]
depfile = "$target_gen_dir/$target_name.d"
_output = "$target_gen_dir/$target_name.stamp"
outputs = [ _output ]
tool = "makefuchsia"
args = [
"--cc",
rebase_path("${clang_prefix}/clang", root_build_dir),
"--cxx",
rebase_path("${clang_prefix}/clang++", root_build_dir),
"--gocache",
rebase_path(gocache_dir, root_build_dir),
"--goroot",
rebase_path(_go_root, root_build_dir),
"--goroot-bootstrap",
rebase_path("//prebuilt/third_party/go/${host_platform}", root_build_dir),
"--sysroot",
rebase_path(sysroot, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
"--stamp-file",
rebase_path(_output, root_build_dir),
]
}
group("create_go_runtime") {
public_deps = [ ":makefuchsia(${toolchain_variant.base})" ]
# The host-toolchain target is restricted in visibility to just this redirection target.
visibility = [ ":go_runtime" ]
}
}
if (is_fuchsia) {
# This is the go runtime itself. It's only defined for the fuchsia toolchain(s)
group("go_runtime") {
# The target that creates it is only defined in the host toolchain.
public_deps = [ ":create_go_runtime(${host_toolchain})" ]
}
go_test("go_exec_test") {
gopackages = [ "os/exec" ]
}
go_test("go_net_test") {
gopackages = [ "net" ]
}
go_test("go_os_test") {
gopackages = [ "os" ]
}
go_test("go_pprof_test") {
gopackages = [ "runtime/pprof" ]
}
go_test("go_time_test") {
gopackages = [ "time" ]
}
go_test("go_zx_test") {
gopackages = [ "syscall/zx" ]
}
go_test("go_zxwait_test") {
gopackages = [ "syscall/zx/zxwait" ]
}
fuchsia_component("go-exec-test") {
testonly = true
manifest = "meta/go_exec_test.cml"
deps = [ ":go_exec_test" ]
}
fuchsia_component("go-net-test") {
testonly = true
manifest = "meta/go_net_test.cml"
deps = [ ":go_net_test" ]
}
fuchsia_component("go-os-test") {
testonly = true
manifest = "meta/go_os_test.cml"
deps = [ ":go_os_test" ]
}
fuchsia_component("go-pprof-test") {
testonly = true
manifest = "meta/go_pprof_test.cml"
deps = [ ":go_pprof_test" ]
}
resource("zoneinfo") {
sources = [ rebase_path("lib/time/zoneinfo.zip") ]
outputs = [ "lib/time/{{source_file_part}}" ]
}
resource("time_testdata") {
sources = [
rebase_path("src/time/testdata/2020b_Europe_Berlin"),
rebase_path("src/time/testdata/2021a_America_Nuuk"),
rebase_path("src/time/testdata/2021a_Asia_Gaza"),
rebase_path("src/time/testdata/2021a_Europe_Dublin"),
]
outputs = [ "src/time/testdata/{{source_file_part}}" ]
}
fuchsia_component("go-time-test") {
testonly = true
manifest = "meta/go_time_test.cml"
deps = [
":go_time_test",
":time_testdata",
":zoneinfo",
]
}
fuchsia_component("go-zx-test") {
testonly = true
manifest = "meta/go_zx_test.cml"
deps = [ ":go_zx_test" ]
}
fuchsia_component("go-zxwait-test") {
testonly = true
manifest = "meta/go_zxwait_test.cml"
deps = [ ":go_zxwait_test" ]
}
fuchsia_test_package("go-stdlib-tests") {
test_components = [
":go-exec-test",
":go-net-test",
":go-os-test",
":go-pprof-test",
":go-time-test",
":go-zx-test",
":go-zxwait-test",
]
deps = [ "//src/connectivity/network/netstack:component" ]
test_specs = {
environments = [ emu_env ]
}
}
go_test("go_unsafevalue_test") {
gopackages = [ "syscall/zx/fidl/internal/unsafevalue" ]
}
go_test("go_fidl_test") {
gopackages = [ "syscall/zx/fidl" ]
}
go_test("go_extended_fidl_test") {
# N.B. these tests are not in the fidl package to avoid having to rebuild the
# go toolchain while iterating on them.
gopackages = [ "syscall/zx/fidl/fidl_test" ]
# TODO(pascallouis): Currently, while we take a dependency, the output of
# this FIDL rule is not directly used, rather the generated bindings were
# copied and checked in.
#
# Not being able to depend on automated generation is due to where code is
# placed, and how this relates to the tree structure of the toolchain.
# Disabling while fidlgen table generation is pending.
# Use regen-fidl to generate this file.
# deps = [
# "src/syscall/zx/fidl/internal/bindingstest($go_toolchain)",
# ]
}
fuchsia_component("go-unsafevalue-test") {
testonly = true
manifest = "meta/go_unsafevalue_test.cml"
deps = [ ":go_unsafevalue_test" ]
}
fuchsia_component("go-fidl-test") {
testonly = true
manifest = "meta/go_fidl_test.cml"
deps = [ ":go_fidl_test" ]
}
fuchsia_component("go-extended-fidl-test") {
testonly = true
manifest = "meta/go_extended_fidl_test.cml"
deps = [ ":go_extended_fidl_test" ]
}
fuchsia_test_package("go-fidl-tests") {
test_components = [
":go-unsafevalue-test",
":go-extended-fidl-test",
":go-fidl-test",
]
test_specs = {
environments = [ emu_env ]
}
}
group("fidl-tests") {
testonly = true
deps = [ ":go-fidl-tests" ]
}
}
group("tests") {
testonly = true
deps = [
":fidl-tests",
":go-stdlib-tests",
"makeroot:tests($host_toolchain)",
]
}