summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--system/gd/packet/parser/packetgen.gni180
1 files changed, 79 insertions, 101 deletions
diff --git a/system/gd/packet/parser/packetgen.gni b/system/gd/packet/parser/packetgen.gni
index 8b22f5dafb..5156a4d983 100644
--- a/system/gd/packet/parser/packetgen.gni
+++ b/system/gd/packet/parser/packetgen.gni
@@ -24,14 +24,14 @@
# Default = 0. Max = 10.
template("packetgen_py") {
action_name = "${target_name}_gen"
- action_foreach(action_name) {
- forward_variables_from(invoker,
- [
- "sources",
- "include",
- "shards",
- "source_root",
- ])
+
+ all_dependent_config_name = "_${target_name}_all_dependent_config"
+ config(all_dependent_config_name) {
+ include_dirs = [ "${root_gen_dir}" ]
+ }
+
+ action(action_name) {
+ forward_variables_from(invoker, [ "sources", "include", "shards", "source_root" ])
assert(defined(sources), "sources must be set")
assert(defined(include), "include must be set")
assert(defined(source_root), "source root must be set")
@@ -41,34 +41,28 @@ template("packetgen_py") {
# Set shards cmd
shards_cmd = ""
- outputs = [ "${outdir}/{{source_name_part}}_python3.cc" ]
+ outputs = []
+ source_args = []
if (defined(shards)) {
- shards_cmd = "--num_shards=${shards}"
-
- # TODO - GN reference doesn't explain how to programatically create
- # a range (i.e. range(shards)) so we use a fixed list and foreach loop to
- # work around it.
- assert(shards <= 10, "Maximum supported shards is 10.")
- shards_list = [
- "0",
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- "8",
- "9",
- ]
- index = 0
- foreach(num, shards_list) {
- if (index < shards) {
- outputs +=
- [ "${outdir}/{{source_name_part}}_python3_shard_${num}.cc" ]
+ shards_list = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ foreach (source, sources) {
+ rel_source = rebase_path(source, ".")
+ source_args += [ rebase_path(source, source_root) ]
+ shards_cmd = "--num_shards=${shards}"
+
+ # TODO - GN reference doesn't explain how to programatically create
+ # a range (i.e. range(shards)) so we use a fixed list and foreach loop to
+ # work around it.
+ assert(shards <= 10, "Maximum supported shards is 10.")
+ index = 0
+ outputs += [ string_replace("${outdir}/${rel_source}_python3.cc", ".pdl", "") ]
+ foreach(num, shards_list) {
+ if (index < shards) {
+ outputs += [ string_replace("${outdir}/${rel_source}_python3_shard_${num}.cc", ".pdl", "") ]
+ }
+
+ index = index + 1
}
-
- index = index + 1
}
}
@@ -80,28 +74,21 @@ template("packetgen_py") {
"--out=${outdir}",
"--source_root=${source_root}",
shards_cmd,
- "{{source_root_relative_dir}}/{{source_file_part}}",
- ]
+ ] + source_args
}
- all_dependent_config_name = "_${target_name}_all_dependent_config"
- config(all_dependent_config_name) {
- include_dirs = [ "${root_gen_dir}" ]
- }
-
- source_set(target_name) {
- sources = get_target_outputs(":${action_name}")
- deps = [ ":${action_name}" ]
-
- all_dependent_configs = [ ":${all_dependent_config_name}" ]
- if (defined(invoker.all_dependent_configs)) {
- all_dependent_configs += invoker.all_dependent_configs
- }
-
- if (defined(invoker.configs)) {
- configs += invoker.configs
- }
- }
+ # TODO: Make building with python-dev work.
+ # source_set(target_name) {
+ # sources = get_target_outputs(":${action_name}")
+ # deps = [":${action_name}"]
+ # all_dependent_configs = [":${all_dependent_config_name}"]
+ # if (defined(invoker.all_dependent_configs)) {
+ # all_dependent_configs += invoker.all_dependent_configs
+ # }
+ # if (defined(invoker.configs)) {
+ # configs += invoker.configs
+ # }
+ # }
}
# Generate single c++ headers for each pdl
@@ -111,14 +98,13 @@ template("packetgen_py") {
# source_root: Root of source relative to current BUILD.gn
# sources: PDL files to use for generation.
template("packetgen_headers") {
- action_name = "${target_name}_gen"
- action_foreach(action_name) {
- forward_variables_from(invoker,
- [
- "include",
- "sources",
- "source_root",
- ])
+ all_dependent_config_name = "_${target_name}_all_dependent_config"
+ config(all_dependent_config_name) {
+ include_dirs = [ "${root_gen_dir}" ]
+ }
+
+ action(target_name) {
+ forward_variables_from(invoker, [ "include", "sources", "source_root" ])
assert(defined(sources), "sources must be set")
assert(defined(include), "include must be set")
assert(defined(source_root), "source root must be set")
@@ -126,8 +112,6 @@ template("packetgen_headers") {
outdir = rebase_path(root_gen_dir)
source_root = rebase_path(source_root)
- outputs = [ "${outdir}/{{source_name_part}}.h" ]
-
script = "//common-mk/file_generator_wrapper.py"
binfile = "${root_out_dir}/bluetooth_packetgen"
args = [
@@ -135,18 +119,14 @@ template("packetgen_headers") {
"--include=${include}",
"--out=${outdir}",
"--source_root=${source_root}",
- "{{source_root_relative_dir}}/{{source_file_part}}",
]
- }
-
- all_dependent_config_name = "_${target_name}_all_dependent_config"
- config(all_dependent_config_name) {
- include_dirs = [ "${root_gen_dir}" ]
- }
- source_set(target_name) {
- sources = get_target_outputs(":${action_name}")
- deps = [ ":${action_name}" ]
+ outputs = []
+ foreach (source, sources) {
+ rel_source = rebase_path(source, ".")
+ args += [ rebase_path(source, source_root) ]
+ outputs += [ string_replace("${outdir}/${rel_source}.h", ".pdl", "") ]
+ }
all_dependent_configs = [ ":${all_dependent_config_name}" ]
if (defined(invoker.all_dependent_configs)) {
@@ -167,13 +147,13 @@ template("packetgen_headers") {
# sources: PDL files to use for generation.
template("packetgen_rust") {
action_name = "${target_name}_gen"
- action_foreach(action_name) {
- forward_variables_from(invoker,
- [
- "include",
- "sources",
- "source_root",
- ])
+ all_dependent_config_name = "_${target_name}_all_dependent_config"
+ config(all_dependent_config_name) {
+ include_dirs = [ "${root_gen_dir}" ]
+ }
+
+ action(action_name) {
+ forward_variables_from(invoker, [ "include", "sources", "source_root" ])
assert(defined(sources), "sources must be set")
assert(defined(include), "include must be set")
assert(defined(source_root), "source root must be set")
@@ -181,8 +161,6 @@ template("packetgen_rust") {
outdir = rebase_path(root_gen_dir)
source_root = rebase_path(source_root)
- outputs = [ "${outdir}/{{source_name_part}}.rs" ]
-
script = "//common-mk/file_generator_wrapper.py"
binfile = "${root_out_dir}/bluetooth_packetgen"
args = [
@@ -191,26 +169,26 @@ template("packetgen_rust") {
"--out=${outdir}",
"--source_root=${source_root}",
"--rust",
- "{{source_root_relative_dir}}/{{source_file_part}}",
]
- }
- all_dependent_config_name = "_${target_name}_all_dependent_config"
- config(all_dependent_config_name) {
- include_dirs = [ "${root_gen_dir}" ]
- }
-
- source_set(target_name) {
- sources = get_target_outputs(":${action_name}")
- deps = [ ":${action_name}" ]
-
- all_dependent_configs = [ ":${all_dependent_config_name}" ]
- if (defined(invoker.all_dependent_configs)) {
- all_dependent_configs += invoker.all_dependent_configs
- }
-
- if (defined(invoker.configs)) {
- configs += invoker.configs
+ outputs = []
+ foreach (source, sources) {
+ rel_source = rebase_path(source, ".")
+ args += [ rebase_path(source, source_root) ]
+ outputs += [ string_replace("${outdir}/${rel_source}.rs", ".pdl", "") ]
}
}
+
+ # TODO: Rust source_set is not supported by gn.
+ # source_set(target_name) {
+ # sources = get_target_outputs(":${action_name}")
+ # deps = [ ":${action_name}" ]
+ # all_dependent_configs = [":${all_dependent_config_name}"]
+ # if (defined(invoker.all_dependent_configs)) {
+ # all_dependent_configs += invoker.all_dependent_configs
+ # }
+ # if (defined(invoker.configs)) {
+ # configs += invoker.configs
+ # }
+ # }
}