Merge "bp2build conversion for rscript srcs in cc modules"
This commit is contained in:
@@ -131,6 +131,7 @@ var (
|
|||||||
"external/brotli": Bp2BuildDefaultTrue,
|
"external/brotli": Bp2BuildDefaultTrue,
|
||||||
"external/bsdiff": Bp2BuildDefaultTrueRecursively,
|
"external/bsdiff": Bp2BuildDefaultTrueRecursively,
|
||||||
"external/bzip2": Bp2BuildDefaultTrueRecursively,
|
"external/bzip2": Bp2BuildDefaultTrueRecursively,
|
||||||
|
"external/clang/lib": Bp2BuildDefaultTrue,
|
||||||
"external/conscrypt": Bp2BuildDefaultTrue,
|
"external/conscrypt": Bp2BuildDefaultTrue,
|
||||||
"external/e2fsprogs": Bp2BuildDefaultTrueRecursively,
|
"external/e2fsprogs": Bp2BuildDefaultTrueRecursively,
|
||||||
"external/eigen": Bp2BuildDefaultTrueRecursively,
|
"external/eigen": Bp2BuildDefaultTrueRecursively,
|
||||||
@@ -796,6 +797,13 @@ var (
|
|||||||
|
|
||||||
// for platform_compat_config
|
// for platform_compat_config
|
||||||
"process-compat-config",
|
"process-compat-config",
|
||||||
|
|
||||||
|
// cc_* modules with rscript srcs
|
||||||
|
"rstest-latency",
|
||||||
|
"libRScpp_static",
|
||||||
|
"rs-headers",
|
||||||
|
"rs_script_api",
|
||||||
|
"libRSDispatch",
|
||||||
}
|
}
|
||||||
|
|
||||||
Bp2buildModuleTypeAlwaysConvertList = []string{
|
Bp2buildModuleTypeAlwaysConvertList = []string{
|
||||||
|
@@ -1182,3 +1182,35 @@ cc_binary {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCCBinaryRscriptSrc(t *testing.T) {
|
||||||
|
runCcBinaryTests(t, ccBinaryBp2buildTestCase{
|
||||||
|
description: `cc_binary with rscript files in sources`,
|
||||||
|
blueprint: `
|
||||||
|
{rule_name} {
|
||||||
|
name : "foo",
|
||||||
|
srcs : [
|
||||||
|
"ccSrc.cc",
|
||||||
|
"rsSrc.rscript",
|
||||||
|
],
|
||||||
|
include_build_directory: false,
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
targets: []testBazelTarget{
|
||||||
|
{"rscript_to_cpp", "foo_renderscript", AttrNameToString{
|
||||||
|
"srcs": `["rsSrc.rscript"]`,
|
||||||
|
}},
|
||||||
|
{"cc_binary", "foo", AttrNameToString{
|
||||||
|
"absolute_includes": `[
|
||||||
|
"frameworks/rs",
|
||||||
|
"frameworks/rs/cpp",
|
||||||
|
]`,
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
"srcs": `[
|
||||||
|
"ccSrc.cc",
|
||||||
|
"foo_renderscript",
|
||||||
|
]`,
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@@ -1555,3 +1555,33 @@ cc_library_shared {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCCLibrarySharedRscriptSrc(t *testing.T) {
|
||||||
|
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: ``,
|
||||||
|
Blueprint: `
|
||||||
|
cc_library_shared{
|
||||||
|
name : "foo",
|
||||||
|
srcs : [
|
||||||
|
"ccSrc.cc",
|
||||||
|
"rsSrc.rscript",
|
||||||
|
],
|
||||||
|
include_build_directory: false,
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("rscript_to_cpp", "foo_renderscript", AttrNameToString{
|
||||||
|
"srcs": `["rsSrc.rscript"]`,
|
||||||
|
}),
|
||||||
|
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||||
|
"absolute_includes": `[
|
||||||
|
"frameworks/rs",
|
||||||
|
"frameworks/rs/cpp",
|
||||||
|
]`,
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
"srcs": `[
|
||||||
|
"ccSrc.cc",
|
||||||
|
"foo_renderscript",
|
||||||
|
]`,
|
||||||
|
})}})
|
||||||
|
}
|
||||||
|
@@ -2185,3 +2185,33 @@ cc_library_static {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCCLibraryStaticRscriptSrc(t *testing.T) {
|
||||||
|
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: `cc_library_static with rscript files in sources`,
|
||||||
|
Blueprint: `
|
||||||
|
cc_library_static{
|
||||||
|
name : "foo",
|
||||||
|
srcs : [
|
||||||
|
"ccSrc.cc",
|
||||||
|
"rsSrc.rscript",
|
||||||
|
],
|
||||||
|
include_build_directory: false,
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("rscript_to_cpp", "foo_renderscript", AttrNameToString{
|
||||||
|
"srcs": `["rsSrc.rscript"]`,
|
||||||
|
}),
|
||||||
|
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
|
||||||
|
"absolute_includes": `[
|
||||||
|
"frameworks/rs",
|
||||||
|
"frameworks/rs/cpp",
|
||||||
|
]`,
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
"srcs": `[
|
||||||
|
"ccSrc.cc",
|
||||||
|
"foo_renderscript",
|
||||||
|
]`,
|
||||||
|
})}})
|
||||||
|
}
|
||||||
|
@@ -38,7 +38,10 @@ const (
|
|||||||
protoSrcPartition = "proto"
|
protoSrcPartition = "proto"
|
||||||
aidlSrcPartition = "aidl"
|
aidlSrcPartition = "aidl"
|
||||||
syspropSrcPartition = "sysprop"
|
syspropSrcPartition = "sysprop"
|
||||||
yaccSrcPartition = "yacc"
|
|
||||||
|
yaccSrcPartition = "yacc"
|
||||||
|
|
||||||
|
rScriptSrcPartition = "renderScript"
|
||||||
|
|
||||||
stubsSuffix = "_stub_libs_current"
|
stubsSuffix = "_stub_libs_current"
|
||||||
)
|
)
|
||||||
@@ -149,8 +152,9 @@ func groupSrcsByExtension(ctx android.BazelConversionPathContext, srcs bazel.Lab
|
|||||||
// contains .l or .ll files we will need to find a way to add a
|
// contains .l or .ll files we will need to find a way to add a
|
||||||
// LabelMapper for these that identifies these filegroups and
|
// LabelMapper for these that identifies these filegroups and
|
||||||
// converts them appropriately
|
// converts them appropriately
|
||||||
lSrcPartition: bazel.LabelPartition{Extensions: []string{".l"}},
|
lSrcPartition: bazel.LabelPartition{Extensions: []string{".l"}},
|
||||||
llSrcPartition: bazel.LabelPartition{Extensions: []string{".ll"}},
|
llSrcPartition: bazel.LabelPartition{Extensions: []string{".ll"}},
|
||||||
|
rScriptSrcPartition: bazel.LabelPartition{Extensions: []string{".fs", ".rscript"}},
|
||||||
// C++ is the "catch-all" group, and comprises generated sources because we don't
|
// C++ is the "catch-all" group, and comprises generated sources because we don't
|
||||||
// know the language of these sources until the genrule is executed.
|
// know the language of these sources until the genrule is executed.
|
||||||
cppSrcPartition: bazel.LabelPartition{Extensions: []string{".cpp", ".cc", ".cxx", ".mm"}, LabelMapper: addSuffixForFilegroup("_cpp_srcs"), Keep_remainder: true},
|
cppSrcPartition: bazel.LabelPartition{Extensions: []string{".cpp", ".cc", ".cxx", ".mm"}, LabelMapper: addSuffixForFilegroup("_cpp_srcs"), Keep_remainder: true},
|
||||||
@@ -412,6 +416,8 @@ type compilerAttributes struct {
|
|||||||
yaccGenLocationHeader bazel.BoolAttribute
|
yaccGenLocationHeader bazel.BoolAttribute
|
||||||
yaccGenPositionHeader bazel.BoolAttribute
|
yaccGenPositionHeader bazel.BoolAttribute
|
||||||
|
|
||||||
|
rsSrcs bazel.LabelListAttribute
|
||||||
|
|
||||||
hdrs bazel.LabelListAttribute
|
hdrs bazel.LabelListAttribute
|
||||||
|
|
||||||
rtti bazel.BoolAttribute
|
rtti bazel.BoolAttribute
|
||||||
@@ -426,8 +432,9 @@ type compilerAttributes struct {
|
|||||||
|
|
||||||
includes BazelIncludes
|
includes BazelIncludes
|
||||||
|
|
||||||
protoSrcs bazel.LabelListAttribute
|
protoSrcs bazel.LabelListAttribute
|
||||||
aidlSrcs bazel.LabelListAttribute
|
aidlSrcs bazel.LabelListAttribute
|
||||||
|
rscriptSrcs bazel.LabelListAttribute
|
||||||
|
|
||||||
stubsSymbolFile *string
|
stubsSymbolFile *string
|
||||||
stubsVersions bazel.StringListAttribute
|
stubsVersions bazel.StringListAttribute
|
||||||
@@ -582,6 +589,7 @@ func (ca *compilerAttributes) finalize(ctx android.BazelConversionPathContext, i
|
|||||||
ca.yaccSrc = bazel.MakeLabelAttribute(yacc.Value.Includes[0].Label)
|
ca.yaccSrc = bazel.MakeLabelAttribute(yacc.Value.Includes[0].Label)
|
||||||
}
|
}
|
||||||
ca.syspropSrcs = partitionedSrcs[syspropSrcPartition]
|
ca.syspropSrcs = partitionedSrcs[syspropSrcPartition]
|
||||||
|
ca.rscriptSrcs = partitionedSrcs[rScriptSrcPartition]
|
||||||
|
|
||||||
ca.absoluteIncludes.DeduplicateAxesFromBase()
|
ca.absoluteIncludes.DeduplicateAxesFromBase()
|
||||||
ca.localIncludes.DeduplicateAxesFromBase()
|
ca.localIncludes.DeduplicateAxesFromBase()
|
||||||
@@ -903,6 +911,12 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module)
|
|||||||
compilerAttrs.absoluteIncludes.Prepend = true
|
compilerAttrs.absoluteIncludes.Prepend = true
|
||||||
compilerAttrs.hdrs.Prepend = true
|
compilerAttrs.hdrs.Prepend = true
|
||||||
|
|
||||||
|
convertedRsSrcs, rsAbsIncludes, rsLocalIncludes := bp2buildRScript(ctx, module, compilerAttrs)
|
||||||
|
(&compilerAttrs).srcs.Add(&convertedRsSrcs)
|
||||||
|
(&compilerAttrs).absoluteIncludes.Append(rsAbsIncludes)
|
||||||
|
(&compilerAttrs).localIncludes.Append(rsLocalIncludes)
|
||||||
|
(&compilerAttrs).localIncludes.Value = android.FirstUniqueStrings(compilerAttrs.localIncludes.Value)
|
||||||
|
|
||||||
features := compilerAttrs.features.Clone().Append(linkerAttrs.features).Append(bp2buildSanitizerFeatures(ctx, module))
|
features := compilerAttrs.features.Clone().Append(linkerAttrs.features).Append(bp2buildSanitizerFeatures(ctx, module))
|
||||||
features = features.Append(bp2buildLtoFeatures(ctx, module))
|
features = features.Append(bp2buildLtoFeatures(ctx, module))
|
||||||
features = features.Append(convertHiddenVisibilityToFeatureBase(ctx, module))
|
features = features.Append(convertHiddenVisibilityToFeatureBase(ctx, module))
|
||||||
|
@@ -448,11 +448,12 @@ func init() {
|
|||||||
pctx.StaticVariable("RSLLVMPrebuiltsPath", "${RSClangBase}/${HostPrebuiltTag}/${RSClangVersion}/bin")
|
pctx.StaticVariable("RSLLVMPrebuiltsPath", "${RSClangBase}/${HostPrebuiltTag}/${RSClangVersion}/bin")
|
||||||
pctx.StaticVariable("RSIncludePath", "${RSLLVMPrebuiltsPath}/../lib64/clang/${RSReleaseVersion}/include")
|
pctx.StaticVariable("RSIncludePath", "${RSLLVMPrebuiltsPath}/../lib64/clang/${RSReleaseVersion}/include")
|
||||||
|
|
||||||
pctx.PrefixedExistentPathsForSourcesVariable("RsGlobalIncludes", "-I",
|
rsGlobalIncludes := []string{
|
||||||
[]string{
|
"external/clang/lib/Headers",
|
||||||
"external/clang/lib/Headers",
|
"frameworks/rs/script_api/include",
|
||||||
"frameworks/rs/script_api/include",
|
}
|
||||||
})
|
pctx.PrefixedExistentPathsForSourcesVariable("RsGlobalIncludes", "-I", rsGlobalIncludes)
|
||||||
|
exportedVars.ExportStringList("RsGlobalIncludes", rsGlobalIncludes)
|
||||||
|
|
||||||
pctx.VariableFunc("CcWrapper", func(ctx android.PackageVarContext) string {
|
pctx.VariableFunc("CcWrapper", func(ctx android.PackageVarContext) string {
|
||||||
if override := ctx.Config().Getenv("CC_WRAPPER"); override != "" {
|
if override := ctx.Config().Getenv("CC_WRAPPER"); override != "" {
|
||||||
|
35
cc/rs.go
35
cc/rs.go
@@ -15,11 +15,12 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
|
"android/soong/bazel"
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -132,3 +133,35 @@ func rsFlags(ctx ModuleContext, flags Flags, properties *BaseCompilerProperties)
|
|||||||
|
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type rscriptAttributes struct {
|
||||||
|
// Renderscript source files
|
||||||
|
Srcs bazel.LabelListAttribute
|
||||||
|
}
|
||||||
|
|
||||||
|
func bp2buildRScript(ctx android.Bp2buildMutatorContext, m *Module, ca compilerAttributes) (bazel.LabelAttribute, bazel.StringListAttribute, bazel.StringListAttribute) {
|
||||||
|
var rscriptAttrs rscriptAttributes
|
||||||
|
var rsAbsIncludes bazel.StringListAttribute
|
||||||
|
var localIncludes bazel.StringListAttribute
|
||||||
|
var rsModuleName string
|
||||||
|
var convertedRsSrcsLabel bazel.LabelAttribute
|
||||||
|
|
||||||
|
if !ca.rscriptSrcs.IsEmpty() {
|
||||||
|
rscriptAttrs.Srcs = ca.rscriptSrcs
|
||||||
|
rsModuleName = m.Name() + "_renderscript"
|
||||||
|
|
||||||
|
localIncludes.Value = []string{"."}
|
||||||
|
rsAbsIncludes.Value = []string{"frameworks/rs", "frameworks/rs/cpp"}
|
||||||
|
convertedRsSrcsLabel = bazel.LabelAttribute{Value: &bazel.Label{Label: rsModuleName}}
|
||||||
|
|
||||||
|
ctx.CreateBazelTargetModule(
|
||||||
|
bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "rscript_to_cpp",
|
||||||
|
Bzl_load_location: "//build/bazel/rules/cc:rscript_to_cpp.bzl",
|
||||||
|
},
|
||||||
|
android.CommonAttributes{Name: rsModuleName},
|
||||||
|
&rscriptAttrs)
|
||||||
|
}
|
||||||
|
|
||||||
|
return convertedRsSrcsLabel, rsAbsIncludes, localIncludes
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user