bp2build to convert $(genDir) to $(RULEDIR) in genrule's cmd
`statslog.cpp` with cmd `"$(location stats-log-api-gen) --cpp $(genDir)/statslog.cpp"` produces `out/.intermediates/frameworks/proto_logging/stats/stats_log_api_gen/statslog.cpp/gen/statslog.cpp`. Hence, $(genDir) is equivalent to `<package-dir>/<module-name>/gen`. Currently, bp2buld converts `$(genDir)` to `$(GENDIR)`. In Bazel, `$(GENDIR)` is only the base of the generated code (e.g. `bazel-bin`). ``` genrule( name = "statslog.cpp", cmd = "$(location :stats-log-api-gen) --cpp $(GENDIR)/statslog.cpp", outs = ["statslog.cpp"], tools = [":stats-log-api-gen"], ) ``` produces `bazel-bin/statslog.cpp` but expects to have `bazel-bin/frameworks/proto_logging/stats/stats_log_api_gen/statslog.cpp`. By converting to `$(RULEDIR)` which is `bazel-bin/frameworks/proto_logging/stats/stats_log_api_gen`. There had not been any genrule module allowlisted with genDir yet. So this should not cause any issue with modules converted before this CL. Bug: 247536535 Test: go tests Test: presubmit builds and tests Change-Id: I65c6aafadab6b180b7ef700427e041547ae7e98a
This commit is contained in:
parent
94a0373f1e
commit
f19b658803
3 changed files with 13 additions and 12 deletions
|
@ -439,6 +439,8 @@ var (
|
|||
"philox_random",
|
||||
"philox_random_headers",
|
||||
"server_configurable_flags",
|
||||
"statslog_neuralnetworks.cpp",
|
||||
"statslog_neuralnetworks.h",
|
||||
"tensorflow_headers",
|
||||
|
||||
"libgui_headers",
|
||||
|
@ -660,14 +662,12 @@ var (
|
|||
"libstatslog_art", // depends on unconverted modules: statslog_art.cpp, statslog_art.h
|
||||
"linker_reloc_bench_main", // depends on unconverted modules: liblinker_reloc_bench_*
|
||||
"pbtombstone", "crash_dump", // depends on libdebuggerd, libunwindstack
|
||||
"robolectric-sqlite4java-0.282", // depends on unconverted modules: robolectric-sqlite4java-import, robolectric-sqlite4java-native
|
||||
"static_crasher", // depends on unconverted modules: libdebuggerd_handler
|
||||
"statslog.cpp", "statslog.h", "statslog.rs", // depends on unconverted modules: stats-log-api-gen
|
||||
"statslog_art.cpp", "statslog_art.h", "statslog_header.rs", // depends on unconverted modules: stats-log-api-gen
|
||||
"test_fips", // depends on unconverted modules: adb
|
||||
"timezone-host", // depends on unconverted modules: art.module.api.annotations
|
||||
"truth-host-prebuilt", // depends on unconverted modules: truth-prebuilt
|
||||
"truth-prebuilt", // depends on unconverted modules: asm-7.0, guava
|
||||
"robolectric-sqlite4java-0.282", // depends on unconverted modules: robolectric-sqlite4java-import, robolectric-sqlite4java-native
|
||||
"static_crasher", // depends on unconverted modules: libdebuggerd_handler
|
||||
"test_fips", // depends on unconverted modules: adb
|
||||
"timezone-host", // depends on unconverted modules: art.module.api.annotations
|
||||
"truth-host-prebuilt", // depends on unconverted modules: truth-prebuilt
|
||||
"truth-prebuilt", // depends on unconverted modules: asm-7.0, guava
|
||||
|
||||
// '//bionic/libc:libc_bp2build_cc_library_static' is duplicated in the 'deps' attribute of rule
|
||||
"toybox-static",
|
||||
|
|
|
@ -61,7 +61,7 @@ func TestGenruleCliVariableReplacement(t *testing.T) {
|
|||
{
|
||||
moduleType: "genrule",
|
||||
factory: genrule.GenRuleFactory,
|
||||
genDir: "$(GENDIR)",
|
||||
genDir: "$(RULEDIR)",
|
||||
},
|
||||
{
|
||||
moduleType: "cc_genrule",
|
||||
|
|
|
@ -910,10 +910,11 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||
cmd = strings.Replace(cmd, "$(out)", "$(OUTS)", -1)
|
||||
}
|
||||
|
||||
genDir := "$(GENDIR)"
|
||||
if t := ctx.ModuleType(); t == "cc_genrule" || t == "java_genrule" || t == "java_genrule_host" {
|
||||
genDir = "$(RULEDIR)"
|
||||
genDir := "$(RULEDIR)"
|
||||
if ctx.ModuleType() == "gensrcs" {
|
||||
genDir = "$(GENDIR)"
|
||||
}
|
||||
|
||||
cmd = strings.Replace(cmd, "$(genDir)", genDir, -1)
|
||||
if len(tools.Value.Includes) > 0 {
|
||||
cmd = strings.Replace(cmd, "$(location)", fmt.Sprintf("$(location %s)", tools.Value.Includes[0].Label), -1)
|
||||
|
|
Loading…
Reference in a new issue