Repository navigation
Expand file tree
/
Copy pathLibraryMap.cmake
More file actions
72 lines (69 loc) · 3.24 KB
/
Copy pathLibraryMap.cmake
File metadata and controls
72 lines (69 loc) · 3.24 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
set(ANYBOX_XDLL_ROOT ${CMAKE_SOURCE_DIR}/core/libs/xdll)
file(GLOB ANYBOX_XDLL_IMPORT_FILES CONFIGURE_DEPENDS ${ANYBOX_XDLL_ROOT}/*/Imports.txt)
list(SORT ANYBOX_XDLL_IMPORT_FILES)
set(ANYBOX_LIBRARY_NAMES "")
set(route_lines "")
set(map_lines "")
set(ordinal_lines "")
foreach(imports_file IN LISTS ANYBOX_XDLL_IMPORT_FILES)
get_filename_component(library_dir ${imports_file} DIRECTORY)
get_filename_component(library ${library_dir} NAME)
list(APPEND ANYBOX_LIBRARY_NAMES ${library})
file(STRINGS ${imports_file} patterns)
foreach(pattern IN LISTS patterns)
string(STRIP "${pattern}" pattern)
string(TOLOWER "${pattern}" pattern)
if(pattern STREQUAL "")
continue()
endif()
if(NOT pattern MATCHES "^[a-z0-9_.*-]+$")
message(FATAL_ERROR "${imports_file}: '${pattern}' is not a DLL name pattern")
endif()
string(APPEND route_lines " {\"${pattern}\", \"ab_${library}.dll\", \"${library}\"},\n")
string(APPEND map_lines "${pattern}\tab_${library}.dll\t${library}\n")
endforeach()
set(ANYBOX_ORDINALS_${library} "")
set(ordinals_file ${library_dir}/Ordinals.txt)
if(EXISTS ${ordinals_file})
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${ordinals_file})
file(STRINGS ${ordinals_file} entries)
set(seen_names "")
set(seen_ordinals "")
foreach(entry IN LISTS entries)
string(STRIP "${entry}" entry)
if(entry STREQUAL "")
continue()
endif()
if(NOT entry MATCHES "^([A-Za-z_][A-Za-z0-9_]*)[ \t]+@([1-9][0-9]*)$")
message(FATAL_ERROR "${ordinals_file}: '${entry}' is not '<Name> @<ordinal>'")
endif()
set(name ${CMAKE_MATCH_1})
set(ordinal ${CMAKE_MATCH_2})
if(ordinal GREATER 65535)
message(FATAL_ERROR "${ordinals_file}: ordinal ${ordinal} of ${name} is above 65535")
endif()
if(name IN_LIST seen_names OR ordinal IN_LIST seen_ordinals)
message(FATAL_ERROR "${ordinals_file}: '${entry}' repeats a name or an ordinal")
endif()
list(APPEND seen_names ${name})
list(APPEND seen_ordinals ${ordinal})
list(APPEND ANYBOX_ORDINALS_${library} "${name}=${ordinal}")
string(APPEND ordinal_lines " {\"${library}\", ${ordinal}, \"${name}\"},\n")
endforeach()
endif()
endforeach()
file(STRINGS ${CMAKE_SOURCE_DIR}/core/relinker/HostDlls.txt host_patterns)
set(host_lines "")
foreach(pattern IN LISTS host_patterns)
string(STRIP "${pattern}" pattern)
string(TOLOWER "${pattern}" pattern)
if(pattern STREQUAL "")
continue()
endif()
string(APPEND host_lines " \"${pattern}\",\n")
endforeach()
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/core/relinker/HostDlls.txt)
file(CONFIGURE OUTPUT ${ANYBOX_GENERATED_DIR}/LibraryMapData.inc CONTENT "${route_lines}")
file(CONFIGURE OUTPUT ${ANYBOX_GENERATED_DIR}/HostDllsData.inc CONTENT "${host_lines}")
file(CONFIGURE OUTPUT ${ANYBOX_GENERATED_DIR}/LibraryOrdinalsData.inc CONTENT "${ordinal_lines}")
file(CONFIGURE OUTPUT ${ANYBOX_LIBS_DIR}/anybox-libs.map CONTENT "${map_lines}")