Loading genrule/allowlists.go +0 −2 Original line number Diff line number Diff line Loading @@ -47,7 +47,6 @@ var ( } SandboxingDenyModuleList = []string{ "framework-javastream-protos", "RsBalls-rscript", "CtsRsBlasTestCases-rscript", "pvmfw_fdt_template_rs", Loading Loading @@ -88,7 +87,6 @@ var ( "vm-tests-tf-lib", "hidl_cpp_impl_test_gen-headers", "pandora_experimental-python-gen-src", "framework-cppstream-protos", "Refocus-rscript", "RSTest_v11-rscript", "RSTest_v16-rscript", Loading genrule/genrule.go +50 −28 Original line number Diff line number Diff line Loading @@ -209,6 +209,7 @@ type generateTask struct { copyTo android.WritablePaths // For gensrcs to set on gensrcsMerge rule. genDir android.WritablePath extraTools android.Paths // dependencies on tools used by the generator extraInputs map[string][]string cmd string // For gensrsc sharding. Loading Loading @@ -402,11 +403,13 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { addLocationLabel(toolFile, toolLocation{paths}) } addLabelsForInputs := func(propName string, include, exclude []string) android.Paths { includeDirInPaths := ctx.DeviceConfig().BuildBrokenInputDir(g.Name()) var srcFiles android.Paths for _, in := range g.properties.Srcs { for _, in := range include { paths, missingDeps := android.PathsAndMissingDepsRelativeToModuleSourceDir(android.SourceInput{ Context: ctx, Paths: []string{in}, ExcludePaths: g.properties.Exclude_srcs, IncludeDirs: includeDirInPaths, Context: ctx, Paths: []string{in}, ExcludePaths: exclude, IncludeDirs: includeDirInPaths, }) if len(missingDeps) > 0 { if !ctx.Config().AllowMissingDependencies() { Loading @@ -420,12 +423,15 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { // The command that uses this placeholder file will never be executed because the rule will be // replaced with an android.Error rule reporting the missing dependencies. ctx.AddMissingDependencies(missingDeps) addLocationLabel(in, errorLocation{"***missing srcs " + in + "***"}) addLocationLabel(in, errorLocation{"***missing " + propName + " " + in + "***"}) } else { srcFiles = append(srcFiles, paths...) addLocationLabel(in, inputLocation{paths}) } } return srcFiles } srcFiles := addLabelsForInputs("srcs", g.properties.Srcs, g.properties.Exclude_srcs) var copyFrom android.Paths var outputFiles android.WritablePaths Loading @@ -437,12 +443,20 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { } // Generate tasks, either from genrule or gensrcs. for _, task := range g.taskGenerator(ctx, cmd, srcFiles) { for i, task := range g.taskGenerator(ctx, cmd, srcFiles) { if len(task.out) == 0 { ctx.ModuleErrorf("must have at least one output file") return } var extraInputs android.Paths // Only handle extra inputs once as these currently are the same across all tasks if i == 0 { for name, values := range task.extraInputs { extraInputs = append(extraInputs, addLabelsForInputs(name, values, []string{})...) } } // Pick a unique path outside the task.genDir for the sbox manifest textproto, // a unique rule name, and the user-visible description. manifestName := "genrule.sbox.textproto" Loading Loading @@ -551,6 +565,8 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { g.rawCommands = append(g.rawCommands, rawCommand) cmd.Text(rawCommand) cmd.Implicits(srcFiles) // need to be able to reference other srcs cmd.Implicits(extraInputs) cmd.ImplicitOutputs(task.out) cmd.Implicits(task.in) cmd.ImplicitTools(tools) Loading Loading @@ -820,6 +836,9 @@ func NewGenSrcs() *Module { shard: i, shards: len(shards), extraTools: extraTools, extraInputs: map[string][]string{ "data": properties.Data, }, }) } Loading @@ -844,6 +863,9 @@ type genSrcsProperties struct { // maximum number of files that will be passed on a single command line. Shard_size *int64 // Additional files needed for build that are not tooling related. Data []string `android:"path"` } type bazelGensrcsAttributes struct { Loading genrule/genrule_test.go +24 −0 Original line number Diff line number Diff line Loading @@ -604,6 +604,30 @@ func TestGenSrcs(t *testing.T) { "out/soong/.intermediates/gen/gen/gensrcs/in3.h", }, }, { name: "data", prop: ` tools: ["tool"], srcs: ["in1.txt", "in2.txt", "in3.txt"], cmd: "$(location) $(in) --extra_input=$(location baz.txt) > $(out)", data: ["baz.txt"], shard_size: 2, `, cmds: []string{ "bash -c '__SBOX_SANDBOX_DIR__/tools/out/bin/tool in1.txt --extra_input=baz.txt > __SBOX_SANDBOX_DIR__/out/in1.h' && bash -c '__SBOX_SANDBOX_DIR__/tools/out/bin/tool in2.txt --extra_input=baz.txt > __SBOX_SANDBOX_DIR__/out/in2.h'", "bash -c '__SBOX_SANDBOX_DIR__/tools/out/bin/tool in3.txt --extra_input=baz.txt > __SBOX_SANDBOX_DIR__/out/in3.h'", }, deps: []string{ "out/soong/.intermediates/gen/gen/gensrcs/in1.h", "out/soong/.intermediates/gen/gen/gensrcs/in2.h", "out/soong/.intermediates/gen/gen/gensrcs/in3.h", }, files: []string{ "out/soong/.intermediates/gen/gen/gensrcs/in1.h", "out/soong/.intermediates/gen/gen/gensrcs/in2.h", "out/soong/.intermediates/gen/gen/gensrcs/in3.h", }, }, } for _, test := range testcases { Loading Loading
genrule/allowlists.go +0 −2 Original line number Diff line number Diff line Loading @@ -47,7 +47,6 @@ var ( } SandboxingDenyModuleList = []string{ "framework-javastream-protos", "RsBalls-rscript", "CtsRsBlasTestCases-rscript", "pvmfw_fdt_template_rs", Loading Loading @@ -88,7 +87,6 @@ var ( "vm-tests-tf-lib", "hidl_cpp_impl_test_gen-headers", "pandora_experimental-python-gen-src", "framework-cppstream-protos", "Refocus-rscript", "RSTest_v11-rscript", "RSTest_v16-rscript", Loading
genrule/genrule.go +50 −28 Original line number Diff line number Diff line Loading @@ -209,6 +209,7 @@ type generateTask struct { copyTo android.WritablePaths // For gensrcs to set on gensrcsMerge rule. genDir android.WritablePath extraTools android.Paths // dependencies on tools used by the generator extraInputs map[string][]string cmd string // For gensrsc sharding. Loading Loading @@ -402,11 +403,13 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { addLocationLabel(toolFile, toolLocation{paths}) } addLabelsForInputs := func(propName string, include, exclude []string) android.Paths { includeDirInPaths := ctx.DeviceConfig().BuildBrokenInputDir(g.Name()) var srcFiles android.Paths for _, in := range g.properties.Srcs { for _, in := range include { paths, missingDeps := android.PathsAndMissingDepsRelativeToModuleSourceDir(android.SourceInput{ Context: ctx, Paths: []string{in}, ExcludePaths: g.properties.Exclude_srcs, IncludeDirs: includeDirInPaths, Context: ctx, Paths: []string{in}, ExcludePaths: exclude, IncludeDirs: includeDirInPaths, }) if len(missingDeps) > 0 { if !ctx.Config().AllowMissingDependencies() { Loading @@ -420,12 +423,15 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { // The command that uses this placeholder file will never be executed because the rule will be // replaced with an android.Error rule reporting the missing dependencies. ctx.AddMissingDependencies(missingDeps) addLocationLabel(in, errorLocation{"***missing srcs " + in + "***"}) addLocationLabel(in, errorLocation{"***missing " + propName + " " + in + "***"}) } else { srcFiles = append(srcFiles, paths...) addLocationLabel(in, inputLocation{paths}) } } return srcFiles } srcFiles := addLabelsForInputs("srcs", g.properties.Srcs, g.properties.Exclude_srcs) var copyFrom android.Paths var outputFiles android.WritablePaths Loading @@ -437,12 +443,20 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { } // Generate tasks, either from genrule or gensrcs. for _, task := range g.taskGenerator(ctx, cmd, srcFiles) { for i, task := range g.taskGenerator(ctx, cmd, srcFiles) { if len(task.out) == 0 { ctx.ModuleErrorf("must have at least one output file") return } var extraInputs android.Paths // Only handle extra inputs once as these currently are the same across all tasks if i == 0 { for name, values := range task.extraInputs { extraInputs = append(extraInputs, addLabelsForInputs(name, values, []string{})...) } } // Pick a unique path outside the task.genDir for the sbox manifest textproto, // a unique rule name, and the user-visible description. manifestName := "genrule.sbox.textproto" Loading Loading @@ -551,6 +565,8 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { g.rawCommands = append(g.rawCommands, rawCommand) cmd.Text(rawCommand) cmd.Implicits(srcFiles) // need to be able to reference other srcs cmd.Implicits(extraInputs) cmd.ImplicitOutputs(task.out) cmd.Implicits(task.in) cmd.ImplicitTools(tools) Loading Loading @@ -820,6 +836,9 @@ func NewGenSrcs() *Module { shard: i, shards: len(shards), extraTools: extraTools, extraInputs: map[string][]string{ "data": properties.Data, }, }) } Loading @@ -844,6 +863,9 @@ type genSrcsProperties struct { // maximum number of files that will be passed on a single command line. Shard_size *int64 // Additional files needed for build that are not tooling related. Data []string `android:"path"` } type bazelGensrcsAttributes struct { Loading
genrule/genrule_test.go +24 −0 Original line number Diff line number Diff line Loading @@ -604,6 +604,30 @@ func TestGenSrcs(t *testing.T) { "out/soong/.intermediates/gen/gen/gensrcs/in3.h", }, }, { name: "data", prop: ` tools: ["tool"], srcs: ["in1.txt", "in2.txt", "in3.txt"], cmd: "$(location) $(in) --extra_input=$(location baz.txt) > $(out)", data: ["baz.txt"], shard_size: 2, `, cmds: []string{ "bash -c '__SBOX_SANDBOX_DIR__/tools/out/bin/tool in1.txt --extra_input=baz.txt > __SBOX_SANDBOX_DIR__/out/in1.h' && bash -c '__SBOX_SANDBOX_DIR__/tools/out/bin/tool in2.txt --extra_input=baz.txt > __SBOX_SANDBOX_DIR__/out/in2.h'", "bash -c '__SBOX_SANDBOX_DIR__/tools/out/bin/tool in3.txt --extra_input=baz.txt > __SBOX_SANDBOX_DIR__/out/in3.h'", }, deps: []string{ "out/soong/.intermediates/gen/gen/gensrcs/in1.h", "out/soong/.intermediates/gen/gen/gensrcs/in2.h", "out/soong/.intermediates/gen/gen/gensrcs/in3.h", }, files: []string{ "out/soong/.intermediates/gen/gen/gensrcs/in1.h", "out/soong/.intermediates/gen/gen/gensrcs/in2.h", "out/soong/.intermediates/gen/gen/gensrcs/in3.h", }, }, } for _, test := range testcases { Loading