-
Notifications
You must be signed in to change notification settings - Fork 23
/
CMakeClangRes.txt
56 lines (54 loc) · 1.91 KB
/
CMakeClangRes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 2018 Adrien Guinet <[email protected]>
#
# 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.
file(GLOB_RECURSE CLANG_RES_GLOB LIST_DIRECTORIES false RELATIVE "${CLANG_RES_DIR}" "${CLANG_RES_DIR}/*")
set(VFS_INIT "")
set(FILE_IDX 0)
file(WRITE "${CLANG_RES_HEADER}" "")
set(RES_BLACKLIST
"riscv_vector.h"
"opencl-c.h"
"opencl-c-base.h"
"altivec.h"
"hexagon_protos.h"
"hvx_hexagon_protos.h"
"hexagon_types.h"
"wasm_simd128.h"
)
set(DIR_BLACKLIST
"cuda_wrappers"
"ppc_wrappers"
"profile"
"sanitizer"
"xray"
)
foreach(RES_NAME ${CLANG_RES_GLOB})
# Is blacklisted?
list(FIND RES_BLACKLIST "${RES_NAME}" IS_BLACKLISTED)
if (NOT IS_BLACKLISTED EQUAL -1)
continue()
endif()
get_filename_component(RES_DIR "${RES_NAME}" DIRECTORY)
list(FIND DIR_BLACKLIST "${RES_DIR}" IS_BLACKLISTED)
if (NOT IS_BLACKLISTED EQUAL -1)
continue()
endif()
set(RES "${CLANG_RES_DIR}/${RES_NAME}")
file(READ "${RES}" RES_DATA HEX)
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," RES_DATA_ARRAY "${RES_DATA}")
set(VAR_NAME "__file_${FILE_IDX}")
file(APPEND "${CLANG_RES_HEADER}" "static const uint8_t ${VAR_NAME}[] = { ${RES_DATA_ARRAY} 0x00 };\n")
set(VFS_INIT "${VFS_INIT}addPath(VFS, \"include/${RES_NAME}\", ${VAR_NAME}, sizeof(${VAR_NAME})-1);\n")
MATH(EXPR FILE_IDX "${FILE_IDX}+1")
endforeach()
file(APPEND "${CLANG_RES_HEADER}" "void initVFS(llvm::vfs::InMemoryFileSystem& VFS) {\n ${VFS_INIT} \n}")