• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2018 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17package {
18    // http://go/android-license-faq
19    // A large-scale-change added 'default_applicable_licenses' to import
20    // the below license kinds from "external_swiftshader_license":
21    //   SPDX-license-identifier-Apache-2.0
22    //   SPDX-license-identifier-BSD
23    default_applicable_licenses: ["external_swiftshader_license"],
24}
25
26cc_defaults {
27    name: "libswiftshadervk_llvm_defaults",
28
29    header_libs: [
30        "swiftshader_platform_headers",
31    ],
32
33    srcs: [
34        "Reactor/Assert.cpp",
35        "Reactor/CPUID.cpp",
36        "Reactor/Debug.cpp",
37        "Reactor/ExecutableMemory.cpp",
38        "Reactor/LLVMJIT.cpp",
39        "Reactor/LLVMReactor.cpp",
40        "Reactor/Pragma.cpp",
41        "Reactor/Reactor.cpp",
42    ],
43
44    cflags: [
45        "-DREACTOR_ANONYMOUS_MMAP_NAME=swiftshader_jit",
46        "-Wno-unused-parameter",
47        "-Wno-implicit-fallthrough",
48    ],
49
50    static_libs: [
51        "libLLVM10_swiftshader",
52    ],
53
54    shared_libs: [
55        "libcutils",
56        "liblog",
57    ],
58}
59
60cc_library_static {
61    name: "libswiftshadervk_llvm",
62    vendor: true,
63    defaults: [ "libswiftshadervk_llvm_defaults" ],
64}
65
66cc_library_static {
67    name: "libswiftshadervk_llvm_debug",
68    vendor: true,
69    defaults: [ "libswiftshadervk_llvm_defaults" ],
70}
71
72genrule {
73    name: "commit_header",
74    out: ["commit.h"],
75    tool_files: ["commit_id.py"],
76    cmd: "$(location commit_id.py) gen $(genDir)/commit.h",
77}
78
79cc_defaults {
80    name: "libvk_swiftshader_defaults",
81    vendor: true,
82
83    defaults: [ "swiftshader_common" ],
84
85    cflags: [
86        "-D_GNU_SOURCE",
87        "-D__STDC_LIMIT_MACROS",
88        "-D__STDC_CONSTANT_MACROS",
89        "-D__STDC_FORMAT_MACROS",
90        "-DHAVE_GRALLOC1",
91        "-DHAVE_GRALLOC3",
92        "-DHAVE_GRALLOC4",
93        "-DNO_SANITIZE_FUNCTION=",
94        // FIXME: Use <android/api-level.h> instead?
95        "-DANDROID_PLATFORM_SDK_VERSION=10000",
96        "-Wno-implicit-fallthrough",
97        "-Wno-unused-parameter",
98        "-Wno-unused-local-typedef",
99        "-Wno-missing-field-initializers",
100        // Enable to output commit hash when SwiftShader is initialized
101        //"-DENABLE_BUILD_VERSION_OUTPUT",
102    ],
103
104    cppflags: [
105        "-Wno-sign-promo",
106        "-Wno-non-virtual-dtor",
107    ],
108
109    ldflags: [
110        // -Bsymbolic binds symbol references to their global definitions within
111        // a shared object, thereby preventing symbol preemption.
112        "-Wl,-Bsymbolic",
113    ],
114
115    local_include_dirs: [ "Vulkan" ],
116
117    version_script: "Vulkan/android_vk_swiftshader.lds",
118
119    generated_headers: [ "commit_header" ],
120
121    target: {
122        android: {
123            relative_install_path: "hw",
124            header_libs: [
125                "swiftshader_platform_headers",
126                "vulkan_headers",
127                "hwvulkan_headers",
128            ],
129            shared_libs: [
130                "android.hardware.graphics.mapper@3.0",
131                "android.hardware.graphics.mapper@4.0",
132                "libnativewindow",
133                "libhardware",
134                "libhidlbase",
135                "libcutils",
136                "libsync",
137                "liblog",
138                "libutils",
139            ],
140            static_libs: [
141                "libarect",
142            ],
143        },
144    },
145}
146
147cc_library_static {
148    name: "swiftshader_debug",
149
150    vendor_available: true,
151
152    cflags: [
153        "-DLOG_TAG=\"swiftshader\"",
154    ],
155
156    srcs: [
157        "System/Debug.cpp",
158    ],
159
160    export_include_dirs: [
161        ".",
162    ],
163
164    shared_libs: [
165        "liblog",
166    ],
167}
168
169cc_defaults {
170    name: "libvk_swiftshader_common_defaults",
171
172    cflags: [
173        "-DLOG_TAG=\"swiftshader\"",
174        "-DSWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER",
175        "-DSWIFTSHADER_ENABLE_ASTC",  // TODO(b/150130101)
176        "-DSWIFTSHADER_DEVICE_MEMORY_REPORT",
177    ],
178
179    srcs: [
180        "System/Build.cpp",
181        "System/Configurator.cpp",
182        "System/CPUID.cpp",
183        "System/GrallocAndroid.cpp",
184        "System/Half.cpp",
185        "System/Linux/MemFd.cpp",
186        "System/Math.cpp",
187        "System/Memory.cpp",
188        "System/Socket.cpp",
189        "System/SwiftConfig.cpp",
190        "System/Timer.cpp",
191        "Device/*.cpp",
192        "Pipeline/*.cpp",
193        "Vulkan/*.cpp",
194        "WSI/HeadlessSurfaceKHR.cpp",
195        "WSI/VkSurfaceKHR.cpp",
196    ],
197
198    static_libs: [
199        "swiftshader_astc",
200        "swiftshader_debug",
201        "swiftshader_marl",
202        "swiftshader_spirv-tools",
203    ],
204
205    include_dirs: [
206        "external/swiftshader/third_party/SPIRV-Headers/include",
207        "external/swiftshader/include",
208    ],
209}
210
211cc_library_shared {
212    name: "vulkan.pastel",
213
214    static_libs: [
215        "libswiftshadervk_llvm_debug",
216        "libLLVM10_swiftshader",
217    ],
218
219    defaults: [
220        "libvk_swiftshader_common_defaults",
221        "libvk_swiftshader_defaults"
222    ],
223}
224
225cc_library_shared {
226    name: "vulkan.pastel.debug",
227
228    static_libs: [
229        "libswiftshadervk_llvm_debug",
230        "libLLVM10_swiftshader_debug",
231    ],
232
233    cflags: [
234        "-UNDEBUG",
235        "-g",
236        "-O0",
237        "-DDEFAULT_THREAD_COUNT=1",
238    ],
239
240    defaults: [
241        "libvk_swiftshader_common_defaults",
242        "libvk_swiftshader_defaults",
243    ],
244}
245