| # Copyright 2018 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/components/fuchsia_test_package.gni") |
| import("//build/dart/dart_library.gni") |
| import("//build/dart/dart_test_component.gni") |
| import("//build/python/python_binary.gni") |
| |
| _zircon_pkg_root = "$target_gen_dir/zircon" |
| _zircon_lib_dir = "$_zircon_pkg_root/lib" |
| |
| python_binary("extract_zircon_constants_bin") { |
| main_source = "extract_zircon_constants.py" |
| } |
| |
| action("generate_zircon_constants") { |
| inputs = [ |
| "//zircon/system/public/zircon/errors.h", |
| "//zircon/system/public/zircon/rights.h", |
| "//zircon/system/public/zircon/types.h", |
| prebuilt_dart, |
| ] |
| _output = "$_zircon_lib_dir/src/constants.dart" |
| outputs = [ _output ] |
| deps = [ ":extract_zircon_constants_bin" ] |
| |
| _bin_outputs = get_target_outputs(":extract_zircon_constants_bin") |
| assert(_bin_outputs == [ _bin_outputs[0] ], |
| "python_binary produced more than 1 outputs") |
| script = _bin_outputs[0] |
| args = [ |
| "--errors", |
| rebase_path("//zircon/system/public/zircon/errors.h", root_build_dir), |
| "--rights", |
| rebase_path("//zircon/system/public/zircon/rights.h", root_build_dir), |
| "--types", |
| rebase_path("//zircon/system/public/zircon/types.h", root_build_dir), |
| "--dart", |
| rebase_path(prebuilt_dart, root_build_dir), |
| "--dart-constants", |
| rebase_path(_output, root_build_dir), |
| ] |
| } |
| |
| # dart_library wants sources to be in the same dir, so copy sources to where |
| # constants.dart is generated in the build output directory. |
| copy("copy_lib_sources") { |
| sources = [ |
| "lib/src/channel.dart", |
| "lib/src/channel_reader.dart", |
| "lib/src/errors.dart", |
| "lib/src/eventpair.dart", |
| "lib/src/fakes/handle.dart", |
| "lib/src/fakes/handle_disposition.dart", |
| "lib/src/fakes/handle_waiter.dart", |
| "lib/src/fakes/system.dart", |
| "lib/src/fakes/zircon_fakes.dart", |
| "lib/src/handle_wrapper.dart", |
| "lib/src/socket.dart", |
| "lib/src/socket_reader.dart", |
| "lib/src/vmo.dart", |
| "lib/zircon.dart", |
| ] |
| outputs = [ "$_zircon_pkg_root/{{source_target_relative}}" ] |
| } |
| |
| # Copy pubspec.yaml to package root as well, because Flutter dependents expect |
| # it to exist there. |
| copy("copy_pubspec_yaml") { |
| sources = [ "pubspec.yaml" ] |
| outputs = [ "$_zircon_pkg_root/pubspec.yaml" ] |
| } |
| |
| dart_library("zircon") { |
| package_name = "zircon" |
| null_safe = true |
| |
| sdk_category = "partner" |
| |
| package_root = _zircon_pkg_root |
| |
| abs_sources = get_target_outputs(":copy_lib_sources") + |
| get_target_outputs(":generate_zircon_constants") |
| |
| # dart_library expects sources to be relative to lib dir, which defaults to |
| # $_pkg_root/lib. |
| sources = rebase_path(abs_sources, _zircon_lib_dir) |
| |
| # TODO(https://fxbug.dev/63133): Using `deps` makes dart_library think these |
| # are SDK dependencies (while they are not), and causes gn gen to fail. So |
| # listing these as `non_dart_deps` until `deps` is fixed to support this. |
| non_dart_deps = [ |
| ":copy_lib_sources", |
| ":copy_pubspec_yaml", |
| ":generate_zircon_constants", |
| ] |
| } |
| |
| dart_test_component("unittests_component") { |
| component_name = "zircon_unittests" |
| manifest = "meta/zircon_unittests.cmx" |
| sources = [ |
| "channel_test.dart", |
| "clock_test.dart", |
| "eventpair_test.dart", |
| "handle_disposition_test.dart", |
| "handle_test.dart", |
| "socket_test.dart", |
| "vmo_test.dart", |
| ] |
| deps = [ |
| ":zircon", |
| "//third_party/dart-pkg/pub/test", |
| ] |
| } |
| |
| fuchsia_test_package("zircon_unittests") { |
| test_components = [ ":unittests_component" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ ":zircon_unittests" ] |
| } |