aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Li <aoli@google.com>2017-06-04 19:13:48 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-06-04 19:13:48 +0000
commit6176ddb4dd3ebb8993eb36c3c319d69cc4835f5a (patch)
tree246dc440ec3ae15753d665c9ebf58dc2bd0a7c33
parent77c005f8e0033477fe85c335ab1c57da19c47d6c (diff)
parent13bd08a1ce83943f5ac04e3e49de8594731bc049 (diff)
downloadprebuilts_clang_host_linux-x86-6176ddb4dd3ebb8993eb36c3c319d69cc4835f5a.tar.gz
prebuilts_clang_host_linux-x86-6176ddb4dd3ebb8993eb36c3c319d69cc4835f5a.tar.bz2
prebuilts_clang_host_linux-x86-6176ddb4dd3ebb8993eb36c3c319d69cc4835f5a.zip
Check if custom clang version and release version is set before building libfuzzer. am: d4ef2ead71 am: 7a970137a9
am: 13bd08a1ce Change-Id: I8dfc58f5d1028b582f343a61fcb4107de82a2433
-rw-r--r--Android.bp30
-rw-r--r--soong/Android.bp30
-rw-r--r--soong/libfuzzer.go89
3 files changed, 124 insertions, 25 deletions
diff --git a/Android.bp b/Android.bp
index d9f1783c..9981e4d0 100644
--- a/Android.bp
+++ b/Android.bp
@@ -14,33 +14,13 @@
// limitations under the License.
//
-clang_version = "3859424"
-clang_libfuzzer_dir = "clang-" + clang_version + "/lib64/clang/4.0/lib/linux/"
-
-cc_prebuilt_library_static {
+libfuzzer_prebuilt_library_static {
name: "libFuzzer",
- export_include_dirs: ["clang-" + clang_version + "/prebuilt_include/llvm/lib/Fuzzer/"],
- target: {
- android_arm: {
- srcs: [clang_libfuzzer_dir + "arm/libFuzzer.a"],
- },
- android_arm64: {
- srcs: [clang_libfuzzer_dir + "aarch64/libFuzzer.a"],
- },
- android_mips: {
- srcs: [clang_libfuzzer_dir + "mips/libFuzzer.a"],
- },
- android_mips64: {
- srcs: [clang_libfuzzer_dir + "mips64/libFuzzer.a"],
- },
- android_x86: {
- srcs: [clang_libfuzzer_dir + "i386/libFuzzer.a"],
- },
- android_x86_64: {
- srcs: [clang_libfuzzer_dir + "x86_64/libFuzzer.a"],
- },
- },
sanitize: {
never: true,
},
}
+
+subdirs = [
+ "soong",
+]
diff --git a/soong/Android.bp b/soong/Android.bp
new file mode 100644
index 00000000..0bb87a89
--- /dev/null
+++ b/soong/Android.bp
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2017 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.
+//
+
+bootstrap_go_package {
+ name: "soong-libfuzzer",
+ pkgPath: "android/soong/prebuilts/clang/host/linux-x86",
+ deps: [
+ "blueprint",
+ "soong-android",
+ "soong-cc",
+ "soong-cc-config"
+ ],
+ srcs: [
+ "libfuzzer.go",
+ ],
+ pluginFor: ["soong_build"],
+}
diff --git a/soong/libfuzzer.go b/soong/libfuzzer.go
new file mode 100644
index 00000000..a0ce14c1
--- /dev/null
+++ b/soong/libfuzzer.go
@@ -0,0 +1,89 @@
+//
+// Copyright (C) 2017 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.
+//
+
+package libfuzzer
+
+import (
+ "path"
+
+ "github.com/google/blueprint"
+
+ "android/soong/android"
+ "android/soong/cc"
+ "android/soong/cc/config"
+)
+
+// This module is used to generate libfuzzer static libraries. When
+// LLVM_PREBUILTS_VERSION and LLVM_RELEASE_VERSION are set, the library will
+// generated from the given path.
+
+func init() {
+ android.RegisterModuleType("libfuzzer_prebuilt_library_static",
+ libfuzzerPrebuiltLibraryStaticFactory)
+}
+
+func libfuzzerPrebuiltLibraryStatic(ctx android.LoadHookContext) {
+ // Because of b/38393317, changing clang base dir is not allowed.
+ clangDir := path.Join(
+ "./",
+ ctx.AConfig().GetenvWithDefault("LLVM_PREBUILTS_VERSION", config.ClangDefaultVersion),
+ )
+ headerDir := path.Join(clangDir, "prebuilt_include", "llvm", "lib", "Fuzzer")
+ releaseVersion := ctx.AConfig().GetenvWithDefault("LLVM_RELEASE_VERSION",
+ config.ClangDefaultShortVersion)
+ libDir := path.Join(clangDir, "lib64", "clang", releaseVersion, "lib", "linux")
+
+ type props struct {
+ Export_include_dirs []string
+ Target struct {
+ Android_arm struct {
+ Srcs []string
+ }
+ Android_arm64 struct {
+ Srcs []string
+ }
+ Android_mips struct {
+ Srcs []string
+ }
+ Android_mips64 struct {
+ Srcs []string
+ }
+ Android_x86 struct {
+ Srcs []string
+ }
+ Android_x86_64 struct {
+ Srcs []string
+ }
+ }
+ }
+
+ p := &props{}
+
+ p.Export_include_dirs = []string{headerDir}
+ p.Target.Android_arm.Srcs = []string{path.Join(libDir, "arm/libFuzzer.a")}
+ p.Target.Android_arm64.Srcs = []string{path.Join(libDir, "aarch64/libFuzzer.a")}
+ p.Target.Android_mips.Srcs = []string{path.Join(libDir, "mips/libFuzzer.a")}
+ p.Target.Android_mips64.Srcs = []string{path.Join(libDir, "mips64/libFuzzer.a")}
+ p.Target.Android_x86.Srcs = []string{path.Join(libDir, "i386/libFuzzer.a")}
+ p.Target.Android_x86_64.Srcs = []string{path.Join(libDir, "x86_64/libFuzzer.a")}
+ ctx.AppendProperties(p)
+}
+
+func libfuzzerPrebuiltLibraryStaticFactory() (blueprint.Module, []interface{}) {
+ module, _ := cc.NewPrebuiltStaticLibrary(android.HostAndDeviceSupported)
+ android.AddLoadHook(module, libfuzzerPrebuiltLibraryStatic)
+ return module.Init()
+}