aboutsummaryrefslogtreecommitdiffstats
path: root/soong
diff options
context:
space:
mode:
authorLeo Li <aoli@google.com>2017-05-18 16:19:37 -0700
committerYi Kong <yikong@google.com>2017-06-03 22:43:59 +0000
commitd4ef2ead7138b216cec21e47adf5c0255d12e8aa (patch)
tree246dc440ec3ae15753d665c9ebf58dc2bd0a7c33 /soong
parent06923039e2e7e5d8f66087bd37386ff71f7847dc (diff)
downloadprebuilts_clang_host_linux-x86-d4ef2ead7138b216cec21e47adf5c0255d12e8aa.tar.gz
prebuilts_clang_host_linux-x86-d4ef2ead7138b216cec21e47adf5c0255d12e8aa.tar.bz2
prebuilts_clang_host_linux-x86-d4ef2ead7138b216cec21e47adf5c0255d12e8aa.zip
Check if custom clang version and release version is set before building libfuzzer.
Test: `make -j48 LLVM_PREBUILTS_VERSION=clang-stable LLVM_RELEASE_VERSION=5.0` Change-Id: I8ddf353f8ec3ec98d2526379e2f20f4b177f7b28 (cherry picked from commit 6bf99fee15091f213a253ce9f07ba5f06750cf78)
Diffstat (limited to 'soong')
-rw-r--r--soong/Android.bp30
-rw-r--r--soong/libfuzzer.go89
2 files changed, 119 insertions, 0 deletions
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()
+}