-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathFinalizeSdk.cmake
More file actions
228 lines (210 loc) · 9.58 KB
/
Copy pathFinalizeSdk.cmake
File metadata and controls
228 lines (210 loc) · 9.58 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#
# Copyright(c) 2016 codestation
# Distributed under the MIT License (http://opensource.org/licenses/MIT)
#
# vdpm owns Pacman, its private dependencies and the channel helper. Keep this
# compatibility target while buildscripts callers migrate to the component
# boundary; the outer superbuild only waits for vdpm and audits the result.
if(BUILD_PACMAN_CLIENT)
set(package_client_dependencies vdpm)
set(package_client_audit_root ${PACMAN_CLIENT_INSTALL_DIR})
if(vdpm_use_release_bundle)
set(package_client_audit_root ${CMAKE_INSTALL_PREFIX})
endif()
add_custom_target(pacman-client-spike
COMMAND ${CMAKE_COMMAND} -E env
VITASDK=${package_client_audit_root}
VITASDK_HOST_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
${PROJECT_SOURCE_DIR}/scripts/audit-host-deps.sh
DEPENDS ${package_client_dependencies}
VERBATIM)
add_custom_target(package-client-configuration
COMMAND ${CMAKE_COMMAND}
-DOUTPUT=${CMAKE_INSTALL_PREFIX}/etc/pacman.conf
-DHOST_ARCHITECTURE=${host_published}
-DWORLD_ARCH=${world_arch}
-P ${PROJECT_SOURCE_DIR}/cmake/WritePacmanConfig.cmake
DEPENDS vdpm
VERBATIM)
endif()
set(finalize_sdk_dependencies
vita-toolchain_${target_suffix}
binutils_${target_suffix}
gdb_${target_suffix}
vdpm
vita-makepkg
${target_half_dependencies})
if(BUILD_PACMAN_CLIENT)
list(APPEND finalize_sdk_dependencies package-client-configuration)
endif()
# Target objects are stripped where they are produced. In stage 2 they arrive
# already stripped from stage 1, and the objcopy that would do it belongs to
# the stage-1 host anyway -- unusable on a host that only imports the sysroot.
set(target_object_strip_commands)
if(NOT VITASDK_STAGE1_DIR)
list(APPEND target_object_strip_commands
COMMAND ${CMAKE_COMMAND}
-DOBJCOPY_COMMAND=${binutils_prefix}-objcopy
"-DPATTERN_GLOB=${CMAKE_INSTALL_PREFIX}/${target_arch}/lib/*.[ao]"
-P ${CMAKE_SOURCE_DIR}/cmake/strip_target_objects.cmake
COMMAND ${CMAKE_COMMAND}
-DOBJCOPY_COMMAND=${binutils_prefix}-objcopy
"-DPATTERN_GLOB=${CMAKE_INSTALL_PREFIX}/lib/gcc/${target_arch}/${GCC_VERSION}/*[!d][!d][!l].[ao]"
-DSKIP_GCC_LTO_PLUGIN=ON
-P ${CMAKE_SOURCE_DIR}/cmake/strip_target_objects.cmake)
endif()
# The audit reads the SDK's own binaries, so it needs an objdump that
# understands them. A cross build has the host-prefixed one in PATH; a native
# build may only have the plain name -- Alpine, for one, ships no
# aarch64-linux-musl-objdump. Prefer the prefixed name, fall back to the
# system's, and say so rather than failing at the last step of a long build.
find_program(VITASDK_HOST_OBJDUMP NAMES ${host_native}-objdump objdump)
if(NOT VITASDK_HOST_OBJDUMP)
message(FATAL_ERROR
"no objdump for the host dependency audit: looked for "
"${host_native}-objdump and objdump")
endif()
message(STATUS "Host dependency audit reads with ${VITASDK_HOST_OBJDUMP}")
# Finalize only after every component has installed into the SDK. This is the
# single barrier for cleanup, stripping, provenance and structural checks.
add_custom_target(finalize-sdk
COMMAND ${CMAKE_COMMAND}
-DHOST_SYSTEM_NAME=${CMAKE_HOST_SYSTEM_NAME}
-DCMAKE_STRIP=${CMAKE_STRIP}
-DBINDIR=${CMAKE_INSTALL_PREFIX}/bin
-P ${CMAKE_SOURCE_DIR}/cmake/strip_host_binaries.cmake
COMMAND ${CMAKE_COMMAND}
-DHOST_SYSTEM_NAME=${CMAKE_HOST_SYSTEM_NAME}
-DCMAKE_STRIP=${CMAKE_STRIP}
-DBINDIR=${CMAKE_INSTALL_PREFIX}/${target_arch}/bin
-P ${CMAKE_SOURCE_DIR}/cmake/strip_host_binaries.cmake
COMMAND ${CMAKE_COMMAND}
-DHOST_SYSTEM_NAME=${CMAKE_HOST_SYSTEM_NAME}
-DCMAKE_STRIP=${CMAKE_STRIP}
-DBINDIR=${CMAKE_INSTALL_PREFIX}/lib/gcc/${target_arch}/${GCC_VERSION}
-P ${CMAKE_SOURCE_DIR}/cmake/strip_host_binaries.cmake
${target_object_strip_commands}
COMMAND ${CMAKE_COMMAND}
-DSDK_DIR=${CMAKE_INSTALL_PREFIX}
-DTARGET_TRIPLE=${target_arch}
-DGCC_VERSION=${GCC_VERSION}
-P ${CMAKE_SOURCE_DIR}/cmake/PublishBfdPlugins.cmake
COMMAND ${CMAKE_COMMAND} -E remove_directory
${CMAKE_INSTALL_PREFIX}/share/man
COMMAND ${CMAKE_COMMAND} -E remove_directory
${CMAKE_INSTALL_PREFIX}/share/info
COMMAND ${CMAKE_COMMAND}
"-DGLOB_PATTERN=${CMAKE_INSTALL_PREFIX}/*.la"
-P ${CMAKE_SOURCE_DIR}/cmake/remove_files.cmake
COMMAND ${CMAKE_COMMAND}
-DSDK_DIR=${CMAKE_INSTALL_PREFIX}
-DTARGET_TRIPLE=${target_arch}
-DHOST_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
-DHOST_TRIPLE=${host_native}
-DVERSION_FILE=${version_info_file}
-P ${CMAKE_SOURCE_DIR}/cmake/ValidateSdk.cmake
COMMAND ${CMAKE_COMMAND}
-DSDK_DIR=${CMAKE_INSTALL_PREFIX}
-DTARGET_TRIPLE=${target_arch}
-P ${CMAKE_SOURCE_DIR}/cmake/ValidateStaticSdk.cmake
COMMAND ${CMAKE_COMMAND} -E env
VITASDK=${CMAKE_INSTALL_PREFIX}
VITASDK_HOST_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
VITASDK_OBJDUMP=${VITASDK_HOST_OBJDUMP}
${CMAKE_SOURCE_DIR}/scripts/audit-host-deps.sh
DEPENDS ${finalize_sdk_dependencies}
COMMENT "Finalizing and validating VitaSDK"
VERBATIM
)
# Empty when the host's binaries run here as they are. A cross whose output
# this machine can still execute -- x86_64 macOS on arm64, through Rosetta --
# sets it to the launcher that makes that true, so the contract runs against
# the SDK that was actually built rather than being skipped.
include(${CMAKE_CURRENT_LIST_DIR}/../HostRunner.cmake)
set(VITASDK_HOST_RUNNER "" CACHE STRING
"Launcher prefix for running this host's binaries, if one is needed")
vitasdk_host_runner_command(vitasdk_host_runner_argv "${VITASDK_HOST_RUNNER}")
add_custom_target(check-toolchain-contract
COMMAND ${CMAKE_COMMAND} -E env
VITASDK=${CMAKE_INSTALL_PREFIX}
${vitasdk_host_runner_argv}
${CMAKE_SOURCE_DIR}/tests/toolchain-contract/run.sh
DEPENDS finalize-sdk
VERBATIM
)
add_custom_target(audit-host-dependencies
COMMAND ${CMAKE_COMMAND} -E env
VITASDK=${CMAKE_INSTALL_PREFIX}
VITASDK_HOST_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
VITASDK_OBJDUMP=${VITASDK_HOST_OBJDUMP}
${CMAKE_SOURCE_DIR}/scripts/audit-host-deps.sh
DEPENDS finalize-sdk
VERBATIM
)
add_custom_target(check-sdk-partition
COMMAND ${CMAKE_COMMAND}
-P ${CMAKE_SOURCE_DIR}/tests/cmake/sysroot-manifest.cmake
COMMAND ${CMAKE_COMMAND}
-P ${CMAKE_SOURCE_DIR}/tests/cmake/host-binary-format.cmake
VERBATIM)
add_custom_target(check-static-policy
COMMAND ${CMAKE_COMMAND}
-P ${CMAKE_SOURCE_DIR}/tests/cmake/static-policy.cmake
COMMAND ${CMAKE_COMMAND}
-P ${CMAKE_SOURCE_DIR}/tests/cmake/static-sdk-validation.cmake
VERBATIM
)
add_custom_command(OUTPUT "vitasdk-${host_published}-${build_date}.tar.bz2"
COMMAND ${CMAKE_COMMAND} -E tar "cfvj" "vitasdk-${host_published}-${build_date}.tar.bz2" "${CMAKE_INSTALL_PREFIX}"
DEPENDS finalize-sdk
COMMENT "Creating vitasdk-${host_published}-${build_date}.tar.bz2"
)
# Create a sdk tarball
add_custom_target(tarball DEPENDS "vitasdk-${host_published}-${build_date}.tar.bz2")
if(BUILD_PACMAN_CLIENT)
set(VITASDK_BOOTSTRAP_OUTPUT_DIR "${CMAKE_BINARY_DIR}/bootstraps" CACHE PATH
"Output directory for verified VitaSDK bootstrap archives")
set(bootstrap_archive
"${VITASDK_BOOTSTRAP_OUTPUT_DIR}/vitasdk-bootstrap-${host_published}.tar.bz2")
add_custom_command(OUTPUT ${bootstrap_archive}
BYPRODUCTS ${bootstrap_archive}.sha256
COMMAND ${CMAKE_COMMAND} -E make_directory ${VITASDK_BOOTSTRAP_OUTPUT_DIR}
COMMAND ${CMAKE_COMMAND} -E rm -f
${bootstrap_archive} ${bootstrap_archive}.sha256
COMMAND ${PROJECT_SOURCE_DIR}/scripts/create-bootstrap-archive.sh
${CMAKE_INSTALL_PREFIX}
${VITASDK_BOOTSTRAP_OUTPUT_DIR}
${host_published}
${VITASDK_SOURCE_DATE_EPOCH}
DEPENDS finalize-sdk
${PROJECT_SOURCE_DIR}/scripts/create-bootstrap-archive.sh
VERBATIM)
add_custom_target(bootstrap-archive DEPENDS ${bootstrap_archive})
endif()
if(BUILD_PACMAN_CLIENT)
set(VITASDK_PACKAGE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/packages" CACHE PATH
"Output directory for the vitasdk-core package")
set(core_package
"${VITASDK_PACKAGE_OUTPUT_DIR}/vitasdk-core-${VITASDK_PACKAGE_VERSION}-1-${host_published}.pkg.tar.xz")
# A core release is two packages: the toolchain, and the client that
# installs it. Both are outputs, and both have to be gone before a rerun.
file(GLOB stale_client_packages
"${VITASDK_PACKAGE_OUTPUT_DIR}/vdpm-*-1-${host_published}.pkg.tar.xz")
add_custom_command(OUTPUT ${core_package}
COMMAND ${CMAKE_COMMAND} -E make_directory ${VITASDK_PACKAGE_OUTPUT_DIR}
COMMAND ${CMAKE_COMMAND} -E rm -f ${core_package} ${stale_client_packages}
COMMAND ${CMAKE_COMMAND} -E env
SOURCE_DATE_EPOCH=${VITASDK_SOURCE_DATE_EPOCH}
${CMAKE_SOURCE_DIR}/scripts/create-core-package.sh
${CMAKE_INSTALL_PREFIX}
${VITASDK_PACKAGE_OUTPUT_DIR}
${host_published}
${VITASDK_PACKAGE_VERSION}
${VITASDK_SOURCE_REVISION}
DEPENDS finalize-sdk
${CMAKE_SOURCE_DIR}/scripts/create-core-package.sh
${CMAKE_SOURCE_DIR}/scripts/validate-core-package.sh
COMMENT "Creating ${core_package}"
VERBATIM)
add_custom_target(core-package DEPENDS ${core_package})
endif()