WriteFileRule: Chunk long content and merge them to result

sbox.textproto files are created when handling genrule. The command
for the genrule and output files are written to this file in the
following format:

commands <
  command: "...."
  copy_after: <
    from: "out/asm-generic/auxvec.h"
    to: "out/soong/.intermediates/kernel/msm-4.19/qti_generate_kernel_headers_arm/gen/asm-generic/auxvec.h"
  >
  copy_after: <
    from: "out/asm-generic/bitsperlong.h"
     to:
     "out/soong/.intermediates/kernel/msm-4.19/qti_generate_kernel_headers_arm/gen/asm-generic/bitsperlong.h"
  >
  ....
>

This file grow by one copy_after entry for each output file.

When generating kenrnel headers where the number of output files are
~1000 we run into problems as the contents of sbox.textproto files
are written to disk by generating a shell script using the following
template: /bin/bash -c 'echo -e "$$0" > $out' $content
If $content is very long as in the case of generating kernel headers we
run into the issue where the command line is so long that the shell
script return E2BIG.

Fix this issue by chuking contents into smaller files and then merge
them as a final step.

Test: Build
Issue: 174444967
Change-Id: I1a74023b4222d19672e4df7edb19810a9cf2136f
This commit is contained in:
Hans Månsson
2020-11-27 12:37:28 +01:00
committed by John Eckerdal
parent 591833471f
commit d3f2bd79e8
3 changed files with 55 additions and 4 deletions

View File

@@ -138,6 +138,8 @@ type WritablePath interface {
// the writablePath method doesn't directly do anything,
// but it allows a struct to distinguish between whether or not it implements the WritablePath interface
writablePath()
ReplaceExtension(ctx PathContext, ext string) OutputPath
}
type genPathProvider interface {
@@ -1249,6 +1251,10 @@ func (p InstallPath) buildDir() string {
return p.config.buildDir
}
func (p InstallPath) ReplaceExtension(ctx PathContext, ext string) OutputPath {
panic("Not implemented")
}
var _ Path = InstallPath{}
var _ WritablePath = InstallPath{}
@@ -1511,6 +1517,10 @@ func (p PhonyPath) buildDir() string {
return p.config.buildDir
}
func (p PhonyPath) ReplaceExtension(ctx PathContext, ext string) OutputPath {
panic("Not implemented")
}
var _ Path = PhonyPath{}
var _ WritablePath = PhonyPath{}