Merge changes Ieaff757f,I5bdbba8d
* changes:
pom2mk: Fix unlisted dependency types
pom2mk: Add a flag to specify a specific version of artifacts
diff --git a/README.md b/README.md
index bc019ae..3d24e75 100644
--- a/README.md
+++ b/README.md
@@ -61,6 +61,7 @@
first assignment, and properties statically by the module type. The supported
types are:
* Bool (`true` or `false`)
+* Integers (`int`)
* Strings (`"string"`)
* Lists of strings (`["string1", "string2"]`)
* Maps (`{key1: "value1", key2: ["value2"]}`)
@@ -71,8 +72,9 @@
### Operators
Strings, lists of strings, and maps can be appended using the `+` operator.
-Appending a map produces the union of keys in both maps, appending the values
-of any keys that are present in both maps.
+Integers can be summed up using the `+` operator. Appending a map produces the
+union of keys in both maps, appending the values of any keys that are present
+in both maps.
### Defaults modules
diff --git a/android/arch.go b/android/arch.go
index f8317bb..5ea9759 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -973,8 +973,6 @@
return []archConfig{
{"arm", "armv5te", "", []string{"armeabi"}},
{"arm64", "armv8-a", "", []string{"arm64-v8a"}},
- {"mips", "mips32-fp", "", []string{"mips"}},
- {"mips64", "mips64r6", "", []string{"mips64"}},
{"x86", "", "", []string{"x86"}},
{"x86_64", "", "", []string{"x86_64"}},
}
diff --git a/cc/cc.go b/cc/cc.go
index 02aaf19..60c8f41 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -159,10 +159,6 @@
// Minimum sdk version supported when compiling against the ndk
Sdk_version string
- // don't insert default compiler flags into asflags, cflags,
- // cppflags, conlyflags, ldflags, or include_dirs
- No_default_compiler_flags *bool
-
AndroidMkSharedLibs []string `blueprint:"mutated"`
HideFromMake bool `blueprint:"mutated"`
PreventInstall bool `blueprint:"mutated"`
@@ -199,7 +195,6 @@
staticBinary() bool
clang() bool
toolchain() config.Toolchain
- noDefaultCompilerFlags() bool
useSdk() bool
sdkVersion() string
useVndk() bool
@@ -452,10 +447,6 @@
return false
}
-func (ctx *moduleContextImpl) noDefaultCompilerFlags() bool {
- return Bool(ctx.mod.Properties.No_default_compiler_flags)
-}
-
func (ctx *moduleContextImpl) useSdk() bool {
if ctx.ctx.Device() && !ctx.useVndk() {
return ctx.mod.Properties.Sdk_version != ""
diff --git a/cc/compiler.go b/cc/compiler.go
index 0a2d7bd..c40e179 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -232,16 +232,14 @@
flags.YasmFlags = append(flags.YasmFlags, f)
}
- if !ctx.noDefaultCompilerFlags() {
- flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String())
- flags.YasmFlags = append(flags.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String())
+ flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String())
+ flags.YasmFlags = append(flags.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String())
- if !(ctx.useSdk() || ctx.useVndk()) || ctx.Host() {
- flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
- "${config.CommonGlobalIncludes}",
- tc.IncludeFlags(),
- "${config.CommonNativehelperInclude}")
- }
+ if !(ctx.useSdk() || ctx.useVndk()) || ctx.Host() {
+ flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
+ "${config.CommonGlobalIncludes}",
+ tc.IncludeFlags(),
+ "${config.CommonNativehelperInclude}")
}
if ctx.useSdk() {
@@ -318,48 +316,46 @@
hod = "Device"
}
- if !ctx.noDefaultCompilerFlags() {
- flags.GlobalFlags = append(flags.GlobalFlags, instructionSetFlags)
- flags.ConlyFlags = append([]string{"${config.CommonGlobalConlyflags}"}, flags.ConlyFlags...)
+ flags.GlobalFlags = append(flags.GlobalFlags, instructionSetFlags)
+ flags.ConlyFlags = append([]string{"${config.CommonGlobalConlyflags}"}, flags.ConlyFlags...)
- if flags.Clang {
- flags.AsFlags = append(flags.AsFlags, tc.ClangAsflags())
- flags.CppFlags = append([]string{"${config.CommonClangGlobalCppflags}"}, flags.CppFlags...)
- flags.GlobalFlags = append(flags.GlobalFlags,
- tc.ClangCflags(),
- "${config.CommonClangGlobalCflags}",
- fmt.Sprintf("${config.%sClangGlobalCflags}", hod))
- } else {
- flags.CppFlags = append([]string{"${config.CommonGlobalCppflags}"}, flags.CppFlags...)
- flags.GlobalFlags = append(flags.GlobalFlags,
- tc.Cflags(),
- "${config.CommonGlobalCflags}",
- fmt.Sprintf("${config.%sGlobalCflags}", hod))
- }
-
- if Bool(ctx.AConfig().ProductVariables.Brillo) {
- flags.GlobalFlags = append(flags.GlobalFlags, "-D__BRILLO__")
- }
-
- if ctx.Device() {
- if Bool(compiler.Properties.Rtti) {
- flags.CppFlags = append(flags.CppFlags, "-frtti")
- } else {
- flags.CppFlags = append(flags.CppFlags, "-fno-rtti")
- }
- }
-
- flags.AsFlags = append(flags.AsFlags, "-D__ASSEMBLY__")
-
- if flags.Clang {
- flags.CppFlags = append(flags.CppFlags, tc.ClangCppflags())
- } else {
- flags.CppFlags = append(flags.CppFlags, tc.Cppflags())
- }
-
- flags.YasmFlags = append(flags.YasmFlags, tc.YasmFlags())
+ if flags.Clang {
+ flags.AsFlags = append(flags.AsFlags, tc.ClangAsflags())
+ flags.CppFlags = append([]string{"${config.CommonClangGlobalCppflags}"}, flags.CppFlags...)
+ flags.GlobalFlags = append(flags.GlobalFlags,
+ tc.ClangCflags(),
+ "${config.CommonClangGlobalCflags}",
+ fmt.Sprintf("${config.%sClangGlobalCflags}", hod))
+ } else {
+ flags.CppFlags = append([]string{"${config.CommonGlobalCppflags}"}, flags.CppFlags...)
+ flags.GlobalFlags = append(flags.GlobalFlags,
+ tc.Cflags(),
+ "${config.CommonGlobalCflags}",
+ fmt.Sprintf("${config.%sGlobalCflags}", hod))
}
+ if Bool(ctx.AConfig().ProductVariables.Brillo) {
+ flags.GlobalFlags = append(flags.GlobalFlags, "-D__BRILLO__")
+ }
+
+ if ctx.Device() {
+ if Bool(compiler.Properties.Rtti) {
+ flags.CppFlags = append(flags.CppFlags, "-frtti")
+ } else {
+ flags.CppFlags = append(flags.CppFlags, "-fno-rtti")
+ }
+ }
+
+ flags.AsFlags = append(flags.AsFlags, "-D__ASSEMBLY__")
+
+ if flags.Clang {
+ flags.CppFlags = append(flags.CppFlags, tc.ClangCppflags())
+ } else {
+ flags.CppFlags = append(flags.CppFlags, tc.Cppflags())
+ }
+
+ flags.YasmFlags = append(flags.YasmFlags, tc.YasmFlags())
+
if flags.Clang {
flags.GlobalFlags = append(flags.GlobalFlags, tc.ToolchainClangCflags())
} else {
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index 390936a..13e9a08 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -23,49 +23,26 @@
var (
arm64Cflags = []string{
- "-fno-exceptions", // from build/core/combo/select.mk
- "-Wno-multichar", // from build/core/combo/select.mk
- "-fno-strict-aliasing",
- "-fstack-protector-strong",
- "-ffunction-sections",
"-fdata-sections",
- "-funwind-tables",
- "-Wa,--noexecstack",
- "-Werror=format-security",
- "-D_FORTIFY_SOURCE=2",
"-fno-short-enums",
- "-no-canonical-prefixes",
- "-fno-canonical-system-headers",
// Help catch common 32/64-bit errors.
- "-Werror=pointer-to-int-cast",
- "-Werror=int-to-pointer-cast",
"-Werror=implicit-function-declaration",
"-fno-strict-volatile-bitfields",
// TARGET_RELEASE_CFLAGS
- "-DNDEBUG",
- "-O2 -g",
- "-Wstrict-aliasing=2",
"-fgcse-after-reload",
"-frerun-cse-after-loop",
"-frename-registers",
}
arm64Ldflags = []string{
- "-Wl,-z,noexecstack",
- "-Wl,-z,relro",
- "-Wl,-z,now",
- "-Wl,--build-id=md5",
- "-Wl,--warn-shared-textrel",
- "-Wl,--fatal-warnings",
"-Wl,-m,aarch64_elf64_le_vec",
"-Wl,--hash-style=gnu",
"-Wl,--fix-cortex-a53-843419",
"-fuse-ld=gold",
"-Wl,--icf=safe",
- "-Wl,--no-undefined-version",
}
arm64Cppflags = []string{
diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go
index 7110ccb..2c439f0 100644
--- a/cc/config/arm_device.go
+++ b/cc/config/arm_device.go
@@ -28,29 +28,18 @@
}
armCflags = []string{
- "-fno-exceptions", // from build/core/combo/select.mk
- "-Wno-multichar", // from build/core/combo/select.mk
- "-ffunction-sections",
"-fdata-sections",
- "-funwind-tables",
- "-fstack-protector-strong",
- "-Wa,--noexecstack",
- "-Werror=format-security",
- "-D_FORTIFY_SOURCE=2",
"-fno-short-enums",
- "-no-canonical-prefixes",
- "-fno-canonical-system-headers",
"-fno-builtin-sin",
"-fno-strict-volatile-bitfields",
// TARGET_RELEASE_CFLAGS
- "-DNDEBUG",
- "-g",
- "-Wstrict-aliasing=2",
"-fgcse-after-reload",
"-frerun-cse-after-loop",
"-frename-registers",
+
+ "-fomit-frame-pointer",
}
armCppflags = []string{
@@ -58,21 +47,12 @@
}
armLdflags = []string{
- "-Wl,-z,noexecstack",
- "-Wl,-z,relro",
- "-Wl,-z,now",
- "-Wl,--build-id=md5",
- "-Wl,--warn-shared-textrel",
- "-Wl,--fatal-warnings",
"-Wl,--icf=safe",
"-Wl,--hash-style=gnu",
- "-Wl,--no-undefined-version",
"-Wl,-m,armelf",
}
armArmCflags = []string{
- "-O2",
- "-fomit-frame-pointer",
"-fstrict-aliasing",
"-funswitch-loops",
}
@@ -80,8 +60,6 @@
armThumbCflags = []string{
"-mthumb",
"-Os",
- "-fomit-frame-pointer",
- "-fno-strict-aliasing",
}
armArchVariantCflags = map[string][]string{
diff --git a/cc/config/global.go b/cc/config/global.go
index dae218c..de4fa11 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -34,9 +34,20 @@
"-Winit-self",
"-Wpointer-arith",
- // COMMON_RELEASE_CFLAGS
+ // Make paths in deps files relative
+ "-no-canonical-prefixes",
+ "-fno-canonical-system-headers",
+
"-DNDEBUG",
"-UDEBUG",
+
+ "-fno-exceptions",
+ "-Wno-multichar",
+
+ "-O2",
+ "-g",
+
+ "-fno-strict-aliasing",
}
commonGlobalConlyflags = []string{}
@@ -44,16 +55,36 @@
deviceGlobalCflags = []string{
"-fdiagnostics-color",
- // TARGET_ERROR_FLAGS
+ "-ffunction-sections",
+ "-funwind-tables",
+ "-fstack-protector-strong",
+ "-Wa,--noexecstack",
+ "-D_FORTIFY_SOURCE=2",
+
+ "-Wstrict-aliasing=2",
+
"-Werror=return-type",
"-Werror=non-virtual-dtor",
"-Werror=address",
"-Werror=sequence-point",
"-Werror=date-time",
+ "-Werror=format-security",
+ }
+
+ deviceGlobalLdflags = []string{
+ "-Wl,-z,noexecstack",
+ "-Wl,-z,relro",
+ "-Wl,-z,now",
+ "-Wl,--build-id=md5",
+ "-Wl,--warn-shared-textrel",
+ "-Wl,--fatal-warnings",
+ "-Wl,--no-undefined-version",
}
hostGlobalCflags = []string{}
+ hostGlobalLdflags = []string{}
+
commonGlobalCppflags = []string{
"-Wsign-promo",
}
@@ -91,7 +122,9 @@
pctx.StaticVariable("CommonGlobalCflags", strings.Join(commonGlobalCflags, " "))
pctx.StaticVariable("CommonGlobalConlyflags", strings.Join(commonGlobalConlyflags, " "))
pctx.StaticVariable("DeviceGlobalCflags", strings.Join(deviceGlobalCflags, " "))
+ pctx.StaticVariable("DeviceGlobalLdflags", strings.Join(deviceGlobalLdflags, " "))
pctx.StaticVariable("HostGlobalCflags", strings.Join(hostGlobalCflags, " "))
+ pctx.StaticVariable("HostGlobalLdflags", strings.Join(hostGlobalLdflags, " "))
pctx.StaticVariable("NoOverrideGlobalCflags", strings.Join(noOverrideGlobalCflags, " "))
pctx.StaticVariable("CommonGlobalCppflags", strings.Join(commonGlobalCppflags, " "))
diff --git a/cc/config/mips64_device.go b/cc/config/mips64_device.go
index e05dbf1..487b11a 100644
--- a/cc/config/mips64_device.go
+++ b/cc/config/mips64_device.go
@@ -22,32 +22,15 @@
var (
mips64Cflags = []string{
- "-fno-exceptions", // from build/core/combo/select.mk
- "-Wno-multichar", // from build/core/combo/select.mk
- "-O2",
"-fomit-frame-pointer",
- "-fno-strict-aliasing",
"-funswitch-loops",
"-Umips",
- "-ffunction-sections",
"-fdata-sections",
- "-funwind-tables",
- "-fstack-protector-strong",
- "-Wa,--noexecstack",
- "-Werror=format-security",
- "-D_FORTIFY_SOURCE=2",
- "-no-canonical-prefixes",
- "-fno-canonical-system-headers",
// Help catch common 32/64-bit errors.
- "-Werror=pointer-to-int-cast",
- "-Werror=int-to-pointer-cast",
"-Werror=implicit-function-declaration",
// TARGET_RELEASE_CFLAGS
- "-DNDEBUG",
- "-g",
- "-Wstrict-aliasing=2",
"-fgcse-after-reload",
"-frerun-cse-after-loop",
"-frename-registers",
@@ -62,14 +45,7 @@
}
mips64Ldflags = []string{
- "-Wl,-z,noexecstack",
- "-Wl,-z,relro",
- "-Wl,-z,now",
- "-Wl,--build-id=md5",
- "-Wl,--warn-shared-textrel",
- "-Wl,--fatal-warnings",
"-Wl,--allow-shlib-undefined",
- "-Wl,--no-undefined-version",
}
mips64ArchVariantCflags = map[string][]string{
diff --git a/cc/config/mips_device.go b/cc/config/mips_device.go
index 78e95b6..f178b97 100644
--- a/cc/config/mips_device.go
+++ b/cc/config/mips_device.go
@@ -22,27 +22,12 @@
var (
mipsCflags = []string{
- "-fno-exceptions", // from build/core/combo/select.mk
- "-Wno-multichar", // from build/core/combo/select.mk
- "-O2",
"-fomit-frame-pointer",
- "-fno-strict-aliasing",
"-funswitch-loops",
"-Umips",
- "-ffunction-sections",
"-fdata-sections",
- "-funwind-tables",
- "-fstack-protector-strong",
- "-Wa,--noexecstack",
- "-Werror=format-security",
- "-D_FORTIFY_SOURCE=2",
- "-no-canonical-prefixes",
- "-fno-canonical-system-headers",
// TARGET_RELEASE_CFLAGS
- "-DNDEBUG",
- "-g",
- "-Wstrict-aliasing=2",
"-fgcse-after-reload",
"-frerun-cse-after-loop",
"-frename-registers",
@@ -58,14 +43,7 @@
}
mipsLdflags = []string{
- "-Wl,-z,noexecstack",
- "-Wl,-z,relro",
- "-Wl,-z,now",
- "-Wl,--build-id=md5",
- "-Wl,--warn-shared-textrel",
- "-Wl,--fatal-warnings",
"-Wl,--allow-shlib-undefined",
- "-Wl,--no-undefined-version",
}
mipsToolchainLdflags = []string{
diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go
index a98001e..1eab9dd 100644
--- a/cc/config/x86_64_device.go
+++ b/cc/config/x86_64_device.go
@@ -22,47 +22,19 @@
var (
x86_64Cflags = []string{
- "-fno-exceptions", // from build/core/combo/select.mk
- "-Wno-multichar", // from build/core/combo/select.mk
- "-O2",
- "-Wa,--noexecstack",
- "-Werror=format-security",
- "-D_FORTIFY_SOURCE=2",
- "-Wstrict-aliasing=2",
- "-ffunction-sections",
"-finline-functions",
"-finline-limit=300",
"-fno-short-enums",
- "-fstrict-aliasing",
"-funswitch-loops",
- "-funwind-tables",
- "-fstack-protector-strong",
- "-no-canonical-prefixes",
- "-fno-canonical-system-headers",
// Help catch common 32/64-bit errors.
- "-Werror=pointer-to-int-cast",
- "-Werror=int-to-pointer-cast",
"-Werror=implicit-function-declaration",
-
- // TARGET_RELEASE_CFLAGS from build/core/combo/select.mk
- "-O2",
- "-g",
- "-fno-strict-aliasing",
}
x86_64Cppflags = []string{}
x86_64Ldflags = []string{
- "-Wl,-z,noexecstack",
- "-Wl,-z,relro",
- "-Wl,-z,now",
- "-Wl,--build-id=md5",
- "-Wl,--warn-shared-textrel",
- "-Wl,--fatal-warnings",
- "-Wl,--gc-sections",
"-Wl,--hash-style=gnu",
- "-Wl,--no-undefined-version",
}
x86_64ArchVariantCflags = map[string][]string{
diff --git a/cc/config/x86_darwin_host.go b/cc/config/x86_darwin_host.go
index 6d361b5..8d805c9 100644
--- a/cc/config/x86_darwin_host.go
+++ b/cc/config/x86_darwin_host.go
@@ -25,9 +25,6 @@
var (
darwinCflags = []string{
- "-fno-exceptions", // from build/core/combo/select.mk
- "-Wno-multichar", // from build/core/combo/select.mk
-
"-fdiagnostics-color",
"-fPIC",
@@ -38,10 +35,6 @@
"-D__STDC_FORMAT_MACROS",
"-D__STDC_CONSTANT_MACROS",
- // HOST_RELEASE_CFLAGS
- "-O2", // from build/core/combo/select.mk
- "-g", // from build/core/combo/select.mk
- "-fno-strict-aliasing", // from build/core/combo/select.mk
"-isysroot ${macSdkRoot}",
"-mmacosx-version-min=${macMinVersion}",
"-DMACOSX_DEPLOYMENT_TARGET=${macMinVersion}",
diff --git a/cc/config/x86_device.go b/cc/config/x86_device.go
index 53d2265..8aea64d 100644
--- a/cc/config/x86_device.go
+++ b/cc/config/x86_device.go
@@ -22,28 +22,10 @@
var (
x86Cflags = []string{
- "-fno-exceptions", // from build/core/combo/select.mk
- "-Wno-multichar", // from build/core/combo/select.mk
- "-O2",
- "-Wa,--noexecstack",
- "-Werror=format-security",
- "-D_FORTIFY_SOURCE=2",
- "-Wstrict-aliasing=2",
- "-ffunction-sections",
"-finline-functions",
"-finline-limit=300",
"-fno-short-enums",
- "-fstrict-aliasing",
"-funswitch-loops",
- "-funwind-tables",
- "-fstack-protector-strong",
- "-no-canonical-prefixes",
- "-fno-canonical-system-headers",
-
- // TARGET_RELEASE_CFLAGS from build/core/combo/select.mk
- "-O2",
- "-g",
- "-fno-strict-aliasing",
}
x86ClangCflags = append(x86Cflags, []string{
@@ -58,15 +40,7 @@
x86Cppflags = []string{}
x86Ldflags = []string{
- "-Wl,-z,noexecstack",
- "-Wl,-z,relro",
- "-Wl,-z,now",
- "-Wl,--build-id=md5",
- "-Wl,--warn-shared-textrel",
- "-Wl,--fatal-warnings",
- "-Wl,--gc-sections",
"-Wl,--hash-style=gnu",
- "-Wl,--no-undefined-version",
}
x86ArchVariantCflags = map[string][]string{
diff --git a/cc/config/x86_linux_bionic_host.go b/cc/config/x86_linux_bionic_host.go
index 277361b..9f0bbbd 100644
--- a/cc/config/x86_linux_bionic_host.go
+++ b/cc/config/x86_linux_bionic_host.go
@@ -22,15 +22,11 @@
var (
linuxBionicCflags = ClangFilterUnknownCflags([]string{
- "-fno-exceptions", // from build/core/combo/select.mk
- "-Wno-multichar", // from build/core/combo/select.mk
-
"-fdiagnostics-color",
"-Wa,--noexecstack",
"-fPIC",
- "-no-canonical-prefixes",
"-U_FORTIFY_SOURCE",
"-D_FORTIFY_SOURCE=2",
@@ -43,14 +39,8 @@
"-fno-short-enums",
"-funswitch-loops",
"-funwind-tables",
- "-no-canonical-prefixes",
"-fno-canonical-system-headers",
- // HOST_RELEASE_CFLAGS
- "-O2", // from build/core/combo/select.mk
- "-g", // from build/core/combo/select.mk
- "-fno-strict-aliasing", // from build/core/combo/select.mk
-
// Tell clang where the gcc toolchain is
"--gcc-toolchain=${LinuxBionicGccRoot}",
@@ -65,7 +55,6 @@
"-Wl,--build-id=md5",
"-Wl,--warn-shared-textrel",
"-Wl,--fatal-warnings",
- "-Wl,--gc-sections",
"-Wl,--hash-style=gnu",
"-Wl,--no-undefined-version",
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index 88bd514..4f05068 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -22,15 +22,11 @@
var (
linuxCflags = []string{
- "-fno-exceptions", // from build/core/combo/select.mk
- "-Wno-multichar", // from build/core/combo/select.mk
-
"-fdiagnostics-color",
"-Wa,--noexecstack",
"-fPIC",
- "-no-canonical-prefixes",
"-U_FORTIFY_SOURCE",
"-D_FORTIFY_SOURCE=2",
@@ -40,11 +36,6 @@
//See bug 12708004.
"-D__STDC_FORMAT_MACROS",
"-D__STDC_CONSTANT_MACROS",
-
- // HOST_RELEASE_CFLAGS
- "-O2", // from build/core/combo/select.mk
- "-g", // from build/core/combo/select.mk
- "-fno-strict-aliasing", // from build/core/combo/select.mk
}
linuxLdflags = []string{
diff --git a/cc/config/x86_windows_host.go b/cc/config/x86_windows_host.go
index 270084e..c9bafe6 100644
--- a/cc/config/x86_windows_host.go
+++ b/cc/config/x86_windows_host.go
@@ -22,9 +22,6 @@
var (
windowsCflags = []string{
- "-fno-exceptions", // from build/core/combo/select.mk
- "-Wno-multichar", // from build/core/combo/select.mk
-
"-DUSE_MINGW",
"-DWIN32_LEAN_AND_MEAN",
"-Wno-unused-parameter",
@@ -43,11 +40,6 @@
"-D_FILE_OFFSET_BITS=64",
"--sysroot ${WindowsGccRoot}/${WindowsGccTriple}",
-
- // HOST_RELEASE_CFLAGS
- "-O2", // from build/core/combo/select.mk
- "-g", // from build/core/combo/select.mk
- "-fno-strict-aliasing", // from build/core/combo/select.mk
}
windowsIncludeFlags = []string{
diff --git a/cc/linker.go b/cc/linker.go
index 1cf3f61..fae5542 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -196,38 +196,42 @@
func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
toolchain := ctx.toolchain()
- if !ctx.noDefaultCompilerFlags() {
- if Bool(linker.Properties.Allow_undefined_symbols) {
- if ctx.Darwin() {
- // darwin defaults to treating undefined symbols as errors
- flags.LdFlags = append(flags.LdFlags, "-Wl,-undefined,dynamic_lookup")
- }
- } else if !ctx.Darwin() {
- flags.LdFlags = append(flags.LdFlags, "-Wl,--no-undefined")
+ hod := "Host"
+ if ctx.Os().Class == android.Device {
+ hod = "Device"
+ }
+
+ flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLdflags}", hod))
+ if Bool(linker.Properties.Allow_undefined_symbols) {
+ if ctx.Darwin() {
+ // darwin defaults to treating undefined symbols as errors
+ flags.LdFlags = append(flags.LdFlags, "-Wl,-undefined,dynamic_lookup")
}
+ } else if !ctx.Darwin() {
+ flags.LdFlags = append(flags.LdFlags, "-Wl,--no-undefined")
+ }
- if flags.Clang {
- flags.LdFlags = append(flags.LdFlags, toolchain.ClangLdflags())
- } else {
- flags.LdFlags = append(flags.LdFlags, toolchain.Ldflags())
- }
+ if flags.Clang {
+ flags.LdFlags = append(flags.LdFlags, toolchain.ClangLdflags())
+ } else {
+ flags.LdFlags = append(flags.LdFlags, toolchain.Ldflags())
+ }
- if !ctx.toolchain().Bionic() {
- CheckBadHostLdlibs(ctx, "host_ldlibs", linker.Properties.Host_ldlibs)
+ if !ctx.toolchain().Bionic() {
+ CheckBadHostLdlibs(ctx, "host_ldlibs", linker.Properties.Host_ldlibs)
- flags.LdFlags = append(flags.LdFlags, linker.Properties.Host_ldlibs...)
+ flags.LdFlags = append(flags.LdFlags, linker.Properties.Host_ldlibs...)
- if !ctx.Windows() {
- // Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of device
- // builds
- flags.LdFlags = append(flags.LdFlags,
- "-ldl",
- "-lpthread",
- "-lm",
- )
- if !ctx.Darwin() {
- flags.LdFlags = append(flags.LdFlags, "-lrt")
- }
+ if !ctx.Windows() {
+ // Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of device
+ // builds
+ flags.LdFlags = append(flags.LdFlags,
+ "-ldl",
+ "-lpthread",
+ "-lm",
+ )
+ if !ctx.Darwin() {
+ flags.LdFlags = append(flags.LdFlags, "-lrt")
}
}
}
diff --git a/cc/makevars.go b/cc/makevars.go
index 295b4ac..f84ae24 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -174,6 +174,7 @@
toolchain.Cppflags(),
}, " "))
ctx.Strict(makePrefix+"GLOBAL_LDFLAGS", strings.Join([]string{
+ fmt.Sprintf("${config.%sGlobalLdflags}", hod),
toolchain.Ldflags(),
toolchain.ToolchainLdflags(),
productExtraLdflags,
@@ -219,6 +220,7 @@
toolchain.ClangCppflags(),
}, " "))
ctx.Strict(clangPrefix+"GLOBAL_LDFLAGS", strings.Join([]string{
+ fmt.Sprintf("${config.%sGlobalLdflags}", hod),
toolchain.ClangLdflags(),
toolchain.ToolchainClangLdflags(),
productExtraLdflags,
diff --git a/cc/object.go b/cc/object.go
index 402b105..2246dd3 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -53,7 +53,7 @@
func (*objectLinker) linkerInit(ctx BaseModuleContext) {}
func (object *objectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
- if !ctx.noDefaultCompilerFlags() && ctx.toolchain().Bionic() {
+ if ctx.useVndk() && ctx.toolchain().Bionic() {
// Needed for VNDK builds where bionic headers aren't automatically added.
deps.LateSharedLibs = append(deps.LateSharedLibs, "libc")
}
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 9e1f02f..5d7f617 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -34,9 +34,8 @@
cfiCflags = []string{"-flto", "-fsanitize-cfi-cross-dso",
"-fsanitize-blacklist=external/compiler-rt/lib/cfi/cfi_blacklist.txt"}
- // FIXME: revert the __cfi_check flag when clang is updated to r280031.
cfiLdflags = []string{"-flto", "-fsanitize-cfi-cross-dso", "-fsanitize=cfi",
- "-Wl,-plugin-opt,O1 -Wl,-export-dynamic-symbol=__cfi_check"}
+ "-Wl,-plugin-opt,O1"}
cfiArflags = []string{"--plugin ${config.ClangBin}/../lib64/LLVMgold.so"}
cfiExportsMapPath = "build/soong/cc/config/cfi_exports.map"
cfiExportsMap android.Path
@@ -364,9 +363,6 @@
// __cfi_check needs to be built as Thumb (see the code in linker_cfi.cpp). LLVM is not set up
// to do this on a function basis, so force Thumb on the entire module.
flags.RequiredInstructionSet = "thumb"
- // Workaround for b/33678192. CFI jumptables need Thumb2 codegen. Revert when
- // Clang is updated past r290384.
- flags.LdFlags = append(flags.LdFlags, "-march=armv7-a")
}
sanitizers = append(sanitizers, "cfi")
diff --git a/cc/test.go b/cc/test.go
index 9df3467..53c984a 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -47,39 +47,39 @@
}
func init() {
- android.RegisterModuleType("cc_test", testFactory)
- android.RegisterModuleType("cc_test_library", testLibraryFactory)
- android.RegisterModuleType("cc_benchmark", benchmarkFactory)
- android.RegisterModuleType("cc_test_host", testHostFactory)
- android.RegisterModuleType("cc_benchmark_host", benchmarkHostFactory)
+ android.RegisterModuleType("cc_test", TestFactory)
+ android.RegisterModuleType("cc_test_library", TestLibraryFactory)
+ android.RegisterModuleType("cc_benchmark", BenchmarkFactory)
+ android.RegisterModuleType("cc_test_host", TestHostFactory)
+ android.RegisterModuleType("cc_benchmark_host", BenchmarkHostFactory)
}
// Module factory for tests
-func testFactory() android.Module {
+func TestFactory() android.Module {
module := NewTest(android.HostAndDeviceSupported)
return module.Init()
}
// Module factory for test libraries
-func testLibraryFactory() android.Module {
+func TestLibraryFactory() android.Module {
module := NewTestLibrary(android.HostAndDeviceSupported)
return module.Init()
}
// Module factory for benchmarks
-func benchmarkFactory() android.Module {
+func BenchmarkFactory() android.Module {
module := NewBenchmark(android.HostAndDeviceSupported)
return module.Init()
}
// Module factory for host tests
-func testHostFactory() android.Module {
+func TestHostFactory() android.Module {
module := NewTest(android.HostSupported)
return module.Init()
}
// Module factory for host benchmarks
-func benchmarkHostFactory() android.Module {
+func BenchmarkHostFactory() android.Module {
module := NewBenchmark(android.HostSupported)
return module.Init()
}
diff --git a/cmd/sbox/sbox.go b/cmd/sbox/sbox.go
index e3e68c9..4b008eb 100644
--- a/cmd/sbox/sbox.go
+++ b/cmd/sbox/sbox.go
@@ -15,6 +15,7 @@
package main
import (
+ "flag"
"fmt"
"io/ioutil"
"os"
@@ -24,7 +25,50 @@
"strings"
)
+var (
+ sandboxesRoot string
+ rawCommand string
+ outputRoot string
+ keepOutDir bool
+ depfileOut string
+)
+
+func init() {
+ flag.StringVar(&sandboxesRoot, "sandbox-path", "",
+ "root of temp directory to put the sandbox into")
+ flag.StringVar(&rawCommand, "c", "",
+ "command to run")
+ flag.StringVar(&outputRoot, "output-root", "",
+ "root of directory to copy outputs into")
+ flag.BoolVar(&keepOutDir, "keep-out-dir", false,
+ "whether to keep the sandbox directory when done")
+
+ flag.StringVar(&depfileOut, "depfile-out", "",
+ "file path of the depfile to generate. This value will replace '__SBOX_DEPFILE__' in the command and will be treated as an output but won't be added to __SBOX_OUT_FILES__")
+}
+
+func usageViolation(violation string) {
+ if violation != "" {
+ fmt.Fprintf(os.Stderr, "Usage error: %s.\n\n", violation)
+ }
+
+ fmt.Fprintf(os.Stderr,
+ "Usage: sbox -c <commandToRun> --sandbox-path <sandboxPath> --output-root <outputRoot> [--depfile-out depFile] <outputFile> [<outputFile>...]\n"+
+ "\n"+
+ "Runs <commandToRun> and moves each <outputFile> out of <sandboxPath>\n"+
+ "and into <outputRoot>\n")
+
+ flag.PrintDefaults()
+
+ os.Exit(1)
+}
+
func main() {
+ flag.Usage = func() {
+ usageViolation("")
+ }
+ flag.Parse()
+
error := run()
if error != nil {
fmt.Fprintln(os.Stderr, error)
@@ -32,55 +76,9 @@
}
}
-var usage = "Usage: sbox -c <commandToRun> --sandbox-path <sandboxPath> --output-root <outputRoot> [--depfile-out depFile] <outputFile> [<outputFile>...]\n" +
- "\n" +
- "Runs <commandToRun> and moves each <outputFile> out of <sandboxPath>\n" +
- "If any file in <outputFiles> is specified by absolute path, then <outputRoot> must be specified as well,\n" +
- "to enable sbox to compute the relative path within the sandbox of the specified output files"
-
-func usageError(violation string) error {
- return fmt.Errorf("Usage error: %s.\n\n%s", violation, usage)
-}
-
func run() error {
- // the contents of the __SBOX_OUT_FILES__ variable
- var outputsVarEntries []string
- // all outputs
- var allOutputs []string
-
- args := os.Args[1:]
-
- var rawCommand string
- var sandboxesRoot string
- removeTempDir := true
- var outputRoot string
- var depfile string
-
- for i := 0; i < len(args); i++ {
- arg := args[i]
- if arg == "--sandbox-path" {
- sandboxesRoot = args[i+1]
- i++
- } else if arg == "-c" {
- rawCommand = args[i+1]
- i++
- } else if arg == "--output-root" {
- outputRoot = args[i+1]
- i++
- } else if arg == "--keep-out-dir" {
- removeTempDir = false
- } else if arg == "--depfile-out" {
- depfile = args[i+1]
- i++
- } else {
- outputsVarEntries = append(outputsVarEntries, arg)
- }
- }
if rawCommand == "" {
- return usageError("-c <commandToRun> is required and must be non-empty")
- }
- if len(outputsVarEntries) == 0 {
- return usageError("at least one output file must be given")
+ usageViolation("-c <commandToRun> is required and must be non-empty")
}
if sandboxesRoot == "" {
// In practice, the value of sandboxesRoot will mostly likely be at a fixed location relative to OUT_DIR,
@@ -88,12 +86,21 @@
// the value of sandboxesRoot will most likely be at a fixed location relative to the sbox executable
// However, Soong also needs to be able to separately remove the sandbox directory on startup (if it has anything left in it)
// and by passing it as a parameter we don't need to duplicate its value
- return usageError("--sandbox-path <sandboxPath> is required and must be non-empty")
+ usageViolation("--sandbox-path <sandboxPath> is required and must be non-empty")
}
if len(outputRoot) == 0 {
- return usageError("--output-root <outputRoot> is required and must be non-empty")
+ usageViolation("--output-root <outputRoot> is required and must be non-empty")
}
+ // the contents of the __SBOX_OUT_FILES__ variable
+ outputsVarEntries := flag.Args()
+ if len(outputsVarEntries) == 0 {
+ usageViolation("at least one output file must be given")
+ }
+
+ // all outputs
+ var allOutputs []string
+
os.MkdirAll(sandboxesRoot, 0777)
tempDir, err := ioutil.TempDir(sandboxesRoot, "sbox")
@@ -110,8 +117,8 @@
allOutputs = append([]string(nil), outputsVarEntries...)
- if depfile != "" {
- sandboxedDepfile, err := filepath.Rel(outputRoot, depfile)
+ if depfileOut != "" {
+ sandboxedDepfile, err := filepath.Rel(outputRoot, depfileOut)
if err != nil {
return err
}
@@ -132,7 +139,7 @@
// then at the beginning of the next build, Soong will retry the cleanup
defer func() {
// in some cases we decline to remove the temp dir, to facilitate debugging
- if removeTempDir {
+ if !keepOutDir {
os.RemoveAll(tempDir)
}
}()
@@ -190,7 +197,7 @@
if len(outputErrors) > 0 {
// Keep the temporary output directory around in case a user wants to inspect it for debugging purposes.
// Soong will delete it later anyway.
- removeTempDir = false
+ keepOutDir = true
return fmt.Errorf("mismatch between declared and actual outputs in sbox command (%s):\n%v", commandDescription, outputErrors)
}
// the created files match the declared files; now move them
diff --git a/java/builder.go b/java/builder.go
index 8b6eb9f..45e59a4 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -19,6 +19,8 @@
// functions.
import (
+ "path/filepath"
+ "strconv"
"strings"
"github.com/google/blueprint"
@@ -211,12 +213,16 @@
})
}
-func TransformJavaToClasses(ctx android.ModuleContext, outputFile android.WritablePath,
- srcFiles, srcJars android.Paths,
- flags javaBuilderFlags, deps android.Paths) {
+func TransformJavaToClasses(ctx android.ModuleContext, outputFile android.WritablePath, shardIdx int,
+ srcFiles, srcJars android.Paths, flags javaBuilderFlags, deps android.Paths) {
- transformJavaToClasses(ctx, outputFile, srcFiles, srcJars, flags, deps,
- "javac", "javac", javac)
+ // Compile java sources into .class files
+ desc := "javac"
+ if shardIdx >= 0 {
+ desc += strconv.Itoa(shardIdx)
+ }
+
+ transformJavaToClasses(ctx, outputFile, shardIdx, srcFiles, srcJars, flags, deps, "javac", desc, javac)
}
func RunErrorProne(ctx android.ModuleContext, outputFile android.WritablePath,
@@ -226,7 +232,7 @@
ctx.ModuleErrorf("cannot build with Error Prone, missing external/error_prone?")
}
- transformJavaToClasses(ctx, outputFile, srcFiles, srcJars, flags, nil,
+ transformJavaToClasses(ctx, outputFile, -1, srcFiles, srcJars, flags, nil,
"errorprone", "errorprone", errorprone)
}
@@ -275,7 +281,7 @@
// suffix will be appended to various intermediate files and directories to avoid collisions when
// this function is called twice in the same module directory.
func transformJavaToClasses(ctx android.ModuleContext, outputFile android.WritablePath,
- srcFiles, srcJars android.Paths,
+ shardIdx int, srcFiles, srcJars android.Paths,
flags javaBuilderFlags, deps android.Paths,
intermediatesDir, desc string, rule blueprint.Rule) {
@@ -298,6 +304,15 @@
deps = append(deps, flags.classpath...)
+ srcJarDir := "srcjars"
+ outDir := "classes"
+ annoDir := "anno"
+ if shardIdx >= 0 {
+ shardDir := "shard" + strconv.Itoa(shardIdx)
+ srcJarDir = filepath.Join(shardDir, srcJarDir)
+ outDir = filepath.Join(shardDir, outDir)
+ annoDir = filepath.Join(shardDir, annoDir)
+ }
ctx.Build(pctx, android.BuildParams{
Rule: rule,
Description: desc,
@@ -309,9 +324,9 @@
"bootClasspath": bootClasspath,
"classpath": flags.classpath.FormJavaClassPath("-classpath"),
"srcJars": strings.Join(srcJars.Strings(), " "),
- "srcJarDir": android.PathForModuleOut(ctx, intermediatesDir, "srcjars").String(),
- "outDir": android.PathForModuleOut(ctx, intermediatesDir, "classes").String(),
- "annoDir": android.PathForModuleOut(ctx, intermediatesDir, "anno").String(),
+ "srcJarDir": android.PathForModuleOut(ctx, intermediatesDir, srcJarDir).String(),
+ "outDir": android.PathForModuleOut(ctx, intermediatesDir, outDir).String(),
+ "annoDir": android.PathForModuleOut(ctx, intermediatesDir, annoDir).String(),
"javaVersion": flags.javaVersion,
},
})
diff --git a/java/config/config.go b/java/config/config.go
index c19a705..654d935 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -80,14 +80,18 @@
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips")
pctx.VariableFunc("DxCmd", func(config interface{}) (string, error) {
- dexer := "d8"
if config.(android.Config).IsEnvFalse("USE_D8") {
- dexer = "dx"
- }
- if config.(android.Config).UnbundledBuild() || config.(android.Config).IsPdkBuild() {
- return "prebuilts/build-tools/common/bin/" + dexer, nil
+ if config.(android.Config).UnbundledBuild() || config.(android.Config).IsPdkBuild() {
+ return "prebuilts/build-tools/common/bin/dx", nil
+ } else {
+ path, err := pctx.HostBinToolPath(config, "dx")
+ if err != nil {
+ return "", err
+ }
+ return path.String(), nil
+ }
} else {
- path, err := pctx.HostBinToolPath(config, dexer)
+ path, err := pctx.HostBinToolPath(config, "d8-compat-dx")
if err != nil {
return "", err
}
diff --git a/java/java.go b/java/java.go
index 1541dec..bb6e556 100644
--- a/java/java.go
+++ b/java/java.go
@@ -117,6 +117,9 @@
// List of classes to pass to javac to use as annotation processors
Annotation_processor_classes []string
+ // The number of Java source entries each Javac instance can process
+ Javac_shard_size *int64
+
Openjdk9 struct {
// List of source files that should only be used when passing -source 1.9
Srcs []string
@@ -355,6 +358,18 @@
return false
}
+func shardPaths(paths android.Paths, shardSize int) []android.Paths {
+ ret := make([]android.Paths, 0, (len(paths)+shardSize-1)/shardSize)
+ for len(paths) > shardSize {
+ ret = append(ret, paths[0:shardSize])
+ paths = paths[shardSize:]
+ }
+ if len(paths) > 0 {
+ ret = append(ret, paths)
+ }
+ return ret
+}
+
func (j *Module) hasSrcExt(ext string) bool {
return hasSrcExt(j.properties.Srcs, ext)
}
@@ -571,7 +586,17 @@
}
}
+ enable_sharding := false
if ctx.Device() && !ctx.AConfig().IsEnvFalse("TURBINE_ENABLED") {
+ if j.properties.Javac_shard_size != nil && *(j.properties.Javac_shard_size) > 0 {
+ enable_sharding = true
+ if len(j.properties.Annotation_processors) != 0 ||
+ len(j.properties.Annotation_processor_classes) != 0 {
+ ctx.PropertyErrorf("javac_shard_size",
+ "%q cannot be set when annotation processors are enabled.",
+ j.properties.Javac_shard_size)
+ }
+ }
// If sdk jar is java module, then directly return classesJar as header.jar
if j.Name() != "android_stubs_current" && j.Name() != "android_system_stubs_current" &&
j.Name() != "android_test_stubs_current" {
@@ -590,18 +615,35 @@
// TODO(ccross): Once we always compile with javac9 we may be able to conditionally
// enable error-prone without affecting the output class files.
errorprone := android.PathForModuleOut(ctx, "errorprone", jarName)
- RunErrorProne(ctx, errorprone, javaSrcFiles, srcJars, flags)
+ RunErrorProne(ctx, errorprone, uniqueSrcFiles, srcJars, flags)
extraJarDeps = append(extraJarDeps, errorprone)
}
- // Compile java sources into .class files
- classes := android.PathForModuleOut(ctx, "javac", jarName)
- TransformJavaToClasses(ctx, classes, javaSrcFiles, srcJars, flags, extraJarDeps)
+ if enable_sharding {
+ flags.classpath.AddPaths([]android.Path{j.headerJarFile})
+ shardSize := int(*(j.properties.Javac_shard_size))
+ var shardSrcs []android.Paths
+ if len(uniqueSrcFiles) > 0 {
+ shardSrcs = shardPaths(uniqueSrcFiles, shardSize)
+ for idx, shardSrc := range shardSrcs {
+ classes := android.PathForModuleOut(ctx, "javac", jarName+strconv.Itoa(idx))
+ TransformJavaToClasses(ctx, classes, idx, shardSrc, nil, flags, extraJarDeps)
+ jars = append(jars, classes)
+ }
+ }
+ if len(srcJars) > 0 {
+ classes := android.PathForModuleOut(ctx, "javac", jarName+strconv.Itoa(len(shardSrcs)))
+ TransformJavaToClasses(ctx, classes, len(shardSrcs), nil, srcJars, flags, extraJarDeps)
+ jars = append(jars, classes)
+ }
+ } else {
+ classes := android.PathForModuleOut(ctx, "javac", jarName)
+ TransformJavaToClasses(ctx, classes, -1, uniqueSrcFiles, srcJars, flags, extraJarDeps)
+ jars = append(jars, classes)
+ }
if ctx.Failed() {
return
}
-
- jars = append(jars, classes)
}
dirArgs, dirDeps := ResourceDirsToJarArgs(ctx, j.properties.Java_resource_dirs, j.properties.Exclude_java_resource_dirs)
@@ -869,7 +911,7 @@
binaryProperties binaryProperties
- wrapperFile android.ModuleSrcPath
+ wrapperFile android.SourcePath
binaryFile android.OutputPath
}
@@ -882,7 +924,11 @@
// Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by
// another build rule before the jar has been installed.
- j.wrapperFile = android.PathForModuleSrc(ctx, j.binaryProperties.Wrapper)
+ if j.binaryProperties.Wrapper != "" {
+ j.wrapperFile = android.PathForModuleSrc(ctx, j.binaryProperties.Wrapper).SourcePath
+ } else {
+ j.wrapperFile = android.PathForSource(ctx, "build/soong/scripts/jar-wrapper.sh")
+ }
j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"),
ctx.ModuleName(), j.wrapperFile, j.installFile)
}
diff --git a/java/java_test.go b/java/java_test.go
index b819447..82eff1e 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -22,6 +22,7 @@
"os"
"path/filepath"
"reflect"
+ "strconv"
"strings"
"testing"
)
@@ -669,6 +670,71 @@
}
}
+func TestTurbine(t *testing.T) {
+ ctx := testJava(t, `
+ java_library {
+ name: "foo",
+ srcs: ["a.java"],
+ }
+
+ java_library {
+ name: "bar",
+ srcs: ["b.java"],
+ static_libs: ["foo"],
+ }
+
+ java_library {
+ name: "baz",
+ srcs: ["c.java"],
+ libs: ["bar"],
+ sdk_version: "14",
+ }
+ `)
+
+ fooTurbine := ctx.ModuleForTests("foo", "android_common").Rule("turbine")
+ barTurbine := ctx.ModuleForTests("bar", "android_common").Rule("turbine")
+ barJavac := ctx.ModuleForTests("bar", "android_common").Rule("javac")
+ barTurbineCombined := ctx.ModuleForTests("bar", "android_common").Description("for turbine")
+ bazJavac := ctx.ModuleForTests("baz", "android_common").Rule("javac")
+
+ if len(fooTurbine.Inputs) != 1 || fooTurbine.Inputs[0].String() != "a.java" {
+ t.Errorf(`foo inputs %v != ["a.java"]`, fooTurbine.Inputs)
+ }
+
+ fooHeaderJar := filepath.Join(buildDir, ".intermediates", "foo", "android_common", "turbine-combined", "foo.jar")
+ if !strings.Contains(barTurbine.Args["classpath"], fooHeaderJar) {
+ t.Errorf("bar turbine classpath %v does not contain %q", barTurbine.Args["classpath"], fooHeaderJar)
+ }
+ if !strings.Contains(barJavac.Args["classpath"], fooHeaderJar) {
+ t.Errorf("bar javac classpath %v does not contain %q", barJavac.Args["classpath"], fooHeaderJar)
+ }
+ if len(barTurbineCombined.Inputs) != 2 || barTurbineCombined.Inputs[1].String() != fooHeaderJar {
+ t.Errorf("bar turbine combineJar inputs %v does not contain %q", barTurbineCombined.Inputs, fooHeaderJar)
+ }
+ if !strings.Contains(bazJavac.Args["classpath"], "prebuilts/sdk/14/android.jar") {
+ t.Errorf("baz javac classpath %v does not contain %q", bazJavac.Args["classpath"],
+ "prebuilts/sdk/14/android.jar")
+ }
+}
+
+func TestSharding(t *testing.T) {
+ ctx := testJava(t, `
+ java_library {
+ name: "bar",
+ srcs: ["a.java","b.java","c.java"],
+ javac_shard_size: 1
+ }
+ `)
+
+ barHeaderJar := filepath.Join(buildDir, ".intermediates", "bar", "android_common", "turbine-combined", "bar.jar")
+ for i := 0; i < 3; i++ {
+ barJavac := ctx.ModuleForTests("bar", "android_common").Description("javac" + strconv.Itoa(i))
+ if !strings.Contains(barJavac.Args["classpath"], barHeaderJar) {
+ t.Errorf("bar javac classpath %v does not contain %q", barJavac.Args["classpath"], barHeaderJar)
+ }
+ }
+}
+
func fail(t *testing.T, errs []error) {
if len(errs) > 0 {
for _, err := range errs {
diff --git a/root.bp b/root.bp
index 6788fa7..bc59171 100644
--- a/root.bp
+++ b/root.bp
@@ -29,6 +29,7 @@
"packages/apps/*",
"prebuilts/clang/host/linux-x86",
"prebuilts/ndk",
+ "prebuilts/r8",
"prebuilts/sdk",
"prebuilts/misc",
"system/*",
diff --git a/scripts/copygcclib.sh b/scripts/copygcclib.sh
index 93c52cc..4bd6f9b 100755
--- a/scripts/copygcclib.sh
+++ b/scripts/copygcclib.sh
@@ -2,6 +2,6 @@
OUT=$1
shift
-LIBPATH=$($@)
+LIBPATH=$($@ | sed -e "s|^$PWD/||")
cp -f $LIBPATH $OUT
echo "$OUT: $LIBPATH" > ${OUT}.d
diff --git a/scripts/jar-wrapper.sh b/scripts/jar-wrapper.sh
new file mode 100644
index 0000000..71c1d90
--- /dev/null
+++ b/scripts/jar-wrapper.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# Copyright (C) 2007 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Set up prog to be the path of this script, including following symlinks,
+# and set up progdir to be the fully-qualified pathname of its directory.
+
+prog="$0"
+while [ -h "${prog}" ]; do
+ fullprog=`/bin/ls -ld "${prog}"`
+ fullprog=`expr "${fullprog}" : ".* -> \(.*\)$"`
+ if expr "x${fullprog}" : 'x/' >/dev/null; then
+ prog="${fullprog}"
+ else
+ progdir=`dirname "${prog}"`
+ prog="${progdir}/${fullprog}"
+ fi
+done
+
+oldwd=`pwd`
+progdir=`dirname "${prog}"`
+cd "${progdir}"
+progdir=`pwd`
+prog="${progdir}"/`basename "${prog}"`
+cd "${oldwd}"
+
+jarfile=`basename "${prog}"`.jar
+jardir="${progdir}"
+
+if [ ! -r "${jardir}/${jarfile}" ]; then
+ jardir=`dirname "${progdir}"`/framework
+fi
+
+if [ ! -r "${jardir}/${jarfile}" ]; then
+ echo `basename "${prog}"`": can't find ${jarfile}"
+ exit 1
+fi
+
+javaOpts=""
+while expr "x$1" : 'x-J' >/dev/null; do
+ opt=`expr "$1" : '-J\(.*\)'`
+ javaOpts="${javaOpts} -${opt}"
+ shift
+done
+
+exec java ${javaOpts} -jar ${jardir}/${jarfile} "$@"