blob: c49ea0e8a4d7b0b6ff403044c3a56982c32cf95f [file] [log] [blame]
# Copyright 2017 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.
declare_args() {
fidlc_union_not_simple = false
fidlc_deprecate_c_unions = false
}
config("fidlc_config") {
defines = []
if (defined(fidlc_deprecate_c_unions) && fidlc_deprecate_c_unions) {
defines += [ "FIDLC_DEPRECATE_C_UNIONS" ]
}
}
if (defined(zx)) {
zx_library("fidl") {
host = true
sources = [
"lib/attributes.cc",
"lib/c_generator.cc",
"lib/coded_types_generator.cc",
"lib/error_reporter.cc",
"lib/experimental_flags.cc",
"lib/findings_json.cc",
"lib/flat_ast.cc",
"lib/formatter.cc",
"lib/json_generator.cc",
"lib/lexer.cc",
"lib/library_zx.cc",
"lib/linter.cc",
"lib/linting_tree_callbacks.cc",
"lib/names.cc",
"lib/ordinals.cc",
"lib/parser.cc",
"lib/raw_ast.cc",
"lib/source_file.cc",
"lib/source_manager.cc",
"lib/source_span.cc",
"lib/tables_generator.cc",
"lib/template_string.cc",
"lib/tree_visitor.cc",
"lib/type_shape.cc",
"lib/utils.cc",
"lib/virtual_source_file.cc",
]
public_deps = [
"$zx/system/ulib/cmdline:headers",
"$zx/system/ulib/fit:headers",
"$zx/third_party/ulib/safemath",
]
deps = [
":json_schema",
"$zx/system/ulib/cmdline",
"$zx/system/ulib/fit",
"$zx/third_party/ulib/uboringssl",
]
configs += [ ":fidlc_config" ]
public_configs = [ "$zx/public/gn/config:Wno-unused-function" ]
}
source_set("json_schema") {
visibility = [ ":*" ]
sources = [ "$target_gen_dir/json_schema.cc" ]
deps = [
":gen-json-schema",
":headers",
]
}
action("gen-json-schema") {
visibility = [ ":json_schema" ]
outputs = [ "$target_gen_dir/json_schema.cc" ]
sources = [ "schema.json" ]
script = "gen-json-schema.sh"
args = rebase_path(outputs, root_build_dir) +
rebase_path(sources, root_build_dir)
}
group("tools") {
deps = [
":fidl-format",
":fidl-lint",
":fidlc",
]
}
zx_host_tool("fidlc") {
sources = [ "compiler/main.cc" ]
deps = [ ":fidl" ]
}
zx_host_tool("fidl-format") {
sources = [ "formatter/main.cc" ]
deps = [ ":fidl" ]
}
zx_host_tool("fidl-lint") {
sources = [
"linter/command_line_options.cc",
"linter/main.cc",
]
deps = [ ":fidl" ]
}
action("fidlgen_llcpp") {
assert(current_os != "fuchsia")
gopath = rebase_path("//../garnet/go")
go = rebase_path("//../prebuilt/third_party/go/${host_platform}/bin/go")
if (current_os == "mac") {
goos = "darwin"
} else {
goos = current_os
}
if (current_cpu == "x64") {
goarch = "amd64"
} else {
goarch = current_cpu
}
output_name = "$target_out_dir/fidlgen_llcpp"
script = "/usr/bin/env"
args = [
"GOPATH=$gopath",
"GOOS=$goos",
"GOARCH=$goarch",
go,
"build",
"-o",
rebase_path(output_name),
"fidl/compiler/llcpp_backend",
]
# Taken from ./host_x64/exe.unstripped/fidlgen_llcpp.d in the Fuchsia build:
inputs = [
"$zx/../garnet/go/src/fidl/compiler/backend/common/names.go",
"$zx/../garnet/go/src/fidl/compiler/backend/common/strings.go",
"$zx/../garnet/go/src/fidl/compiler/backend/cpp/ir/ir.go",
"$zx/../garnet/go/src/fidl/compiler/backend/types/config.go",
"$zx/../garnet/go/src/fidl/compiler/backend/types/only_for_ordinal_migration.go",
"$zx/../garnet/go/src/fidl/compiler/backend/types/only_for_xunion_migration.go",
"$zx/../garnet/go/src/fidl/compiler/backend/types/types.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/generator.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/main.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/files/header.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/files/source.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/bits.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/const.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/enum.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/helpers.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/interface.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/reply_c_flavor.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/reply_caller_allocate.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/reply_in_place.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/send_event_c_flavor.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/send_event_caller_allocate.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/send_event_in_place.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/service.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/struct.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/sync_event_handler.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/sync_request_caller_allocate.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/sync_request_in_place.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/sync_request_managed.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/sync_server.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/table.tmpl.go",
"$zx/../garnet/go/src/fidl/compiler/llcpp_backend/templates/fragments/xunion.tmpl.go",
]
outputs = [ output_name ]
# See host_tool_action().
metadata = {
# Dependencies come before the "--".
host_tool_rspfile = rebase_path(inputs, root_build_dir)
host_tool_rspfile += [ "--" ]
# The command line to run comes after the "--".
host_tool_rspfile += [ rebase_path(output_name, root_build_dir) ]
}
}
} else {
# TODO(BLD-353): Referenced by //garnet/public/lib/fidl/fuzz:compiler.
config("fidl_config") {
visibility = [ ":*" ]
include_dirs = [ "include" ]
}
source_set("compiler") {
public_configs = [ ":fidl_config" ]
sources = [
"lib/attributes.cc",
"lib/c_generator.cc",
"lib/error_reporter.cc",
"lib/findings_json.cc",
"lib/flat_ast.cc",
"lib/formatter.cc",
"lib/json_generator.cc",
"lib/lexer.cc",
"lib/library_zx.cc",
"lib/linter.cc",
"lib/names.cc",
"lib/parser.cc",
"lib/raw_ast.cc",
"lib/source_file.cc",
"lib/source_manager.cc",
"lib/source_span.cc",
"lib/tables_generator.cc",
"lib/tree_visitor.cc",
"lib/type_shape.cc",
]
}
}