Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cmake/Components.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ set(LIBZIP_VERSION 1.11.4)
set(LIBZIP_HASH SHA256=8a247f57d1e3e6f6d11413b12a6f28a9d388de110adc0ec608d893180ed7097b)
set(LIBZIP_URL https://libzip.org/download/libzip-${LIBZIP_VERSION}.tar.xz)

set(PKGCONF_VERSION 3.0.7)
set(PKGCONF_HASH SHA256=c926ff491cbd9a331a589160811bd97ab1749b4d5198a519338f2cdfabe6940a)
set(PKGCONF_URL https://github.com/pkgconf/pkgconf/releases/download/pkgconf-${PKGCONF_VERSION}/pkgconf-${PKGCONF_VERSION}.tar.xz)

# Each VitaSDK component selects both its source and its revision from the
# command line. A local clone can be named here so that a change spanning two
# repositories can be built before either side is published.
Expand All @@ -94,7 +98,7 @@ set(SAMPLES_REPOSITORY https://github.com/vitasdk/samples
CACHE STRING "samples repository URL or local path")
set(HEADERS_REPOSITORY https://github.com/vitasdk/vita-headers
CACHE STRING "vita-headers repository URL or local path")
set(TOOLCHAIN_REPOSITORY https://github.com/vitasdk/vita-toolchain
set(TOOLCHAIN_REPOSITORY https://github.com/devnoname120/vita-toolchain
CACHE STRING "vita-toolchain repository URL or local path")
set(PTHREAD_REPOSITORY https://github.com/vitasdk/pthread-embedded
CACHE STRING "pthread-embedded repository URL or local path")
Expand All @@ -106,7 +110,7 @@ set(VITA_MAKEPKG_REPOSITORY https://github.com/vitasdk/vita-makepkg.git
set(NEWLIB_TAG 2e428297c0b6aefd830c5a75a7daa7e774562a42 CACHE STRING "newlib branch, commit id or tag")
set(SAMPLES_TAG fe8fbef570f3280586c0c20157146e3faefb2181 CACHE STRING "samples branch, commit id or tag")
set(HEADERS_TAG e66ebe90b73d1fa4cce005a5b2072cec27322544 CACHE STRING "vita-headers branch, commit id or tag")
set(TOOLCHAIN_TAG e8bc8f70ee5d3036f1562486cbc6065b52a8d173 CACHE STRING "vita-toolchain branch, commit id or tag")
set(TOOLCHAIN_TAG 9e3860c1617b8f55162851ff4093d3446093d8b9 CACHE STRING "vita-toolchain branch, commit id or tag")
set(PTHREAD_TAG 11d2e5722d98c86f33c908fc47b2cf6e55205db5 CACHE STRING "pthread-embedded branch, commit id or tag")
set(VDPM_TAG v0.1.4 CACHE STRING "vdpm branch, commit id or tag")
set(VITA_MAKEPKG_TAG bbd1b18731cf8b6a69a18c9acdefd79a5b8c36eb CACHE STRING "vita-makepkg branch, commit id or tag")
11 changes: 11 additions & 0 deletions cmake/ValidateSdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ foreach(tool IN LISTS required_tools)
endif()
endforeach()

set(host_suffix "")
if(HOST_SYSTEM_NAME STREQUAL "Windows")
set(host_suffix ".exe")
endif()
foreach(tool pkgconf ${TARGET_TRIPLE}-pkg-config)
set(path "${SDK_DIR}/bin/${tool}${host_suffix}")
if(NOT EXISTS "${path}")
message(FATAL_ERROR "Missing SDK pkg-config tool: ${path}")
endif()
endforeach()

set(sysroot "${SDK_DIR}/${TARGET_TRIPLE}")
foreach(directory include lib)
if(NOT IS_DIRECTORY "${sysroot}/${directory}")
Expand Down
27 changes: 27 additions & 0 deletions cmake/recipes/BuildHostTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@
# because stage 1's vdpm/vita-makepkg were built for stage 1's own host, not
# this one.

ExternalProject_Add(pkgconf
URL ${PKGCONF_URL}
URL_HASH ${PKGCONF_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${host_native}
--prefix=/
--disable-shared
--enable-static
--disable-dependency-tracking
--with-system-libdir=/usr/lib
--with-system-includedir=/usr/include
CPPFLAGS=-DPKGCONFIG_IS_STATIC
BUILD_COMMAND ${compiler_flags} ${wrapper_command} $(MAKE) pkgconf${CMAKE_EXECUTABLE_SUFFIX}
INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_INSTALL_PREFIX}/bin
${CMAKE_INSTALL_PREFIX}/share/licenses/pkgconf
COMMAND ${CMAKE_COMMAND} -E copy
<BINARY_DIR>/pkgconf${CMAKE_EXECUTABLE_SUFFIX}
${CMAKE_INSTALL_PREFIX}/bin/pkgconf${CMAKE_EXECUTABLE_SUFFIX}
COMMAND ${CMAKE_COMMAND} -E copy
<SOURCE_DIR>/COPYING
${CMAKE_INSTALL_PREFIX}/share/licenses/pkgconf/COPYING
)

set(vdpm_use_release_bundle OFF)
if(BUILD_PACMAN_CLIENT AND (VDPM_BUNDLE OR VDPM_BUNDLE_SHA256))
if(NOT VDPM_BUNDLE OR NOT VDPM_BUNDLE_SHA256)
Expand Down
1 change: 1 addition & 0 deletions cmake/recipes/FinalizeSdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ set(finalize_sdk_dependencies
vita-toolchain_${target_suffix}
binutils_${target_suffix}
gdb_${target_suffix}
pkgconf
vdpm
vita-makepkg
${target_half_dependencies})
Expand Down
29 changes: 27 additions & 2 deletions scripts/ci/build-host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ download_vdpm_bundle() {

# Same-runner smoke test only; a canadian cross cannot run what it built.
smoke_test_bootstrap() {
local bootstrap_archive=$1 digest install_root
local bootstrap_archive=$1 digest install_root probe_pc version
# Empty for a host that runs here directly; a launcher for one that needs
# it. Unquoted on purpose, so an empty prefix contributes no argument.
local -a run=(${2:-})
digest=$(awk '{print $1}' "$bootstrap_archive.sha256")
install_root="$PWD/bootstrap-installed"
install_root="$PWD/bootstrap installed"
# ${run[@]+...}: macOS's /bin/bash is 3.2, where expanding an empty array
# under set -u is an unbound-variable error -- and empty is the normal
# case here, for every host that runs its own binaries.
Expand All @@ -163,6 +163,31 @@ smoke_test_bootstrap() {
# vdpm ships pacman under libexec/vdpm, not bin/.
${run[@]+"${run[@]}"} "$install_root/libexec/vdpm/pacman" --version >/dev/null
${run[@]+"${run[@]}"} "$install_root/bin/arm-vita-eabi-gcc" --version
probe_pc="$install_root/arm-vita-eabi/lib/pkgconfig/vitasdk-wrapper-probe.pc"
mkdir -p "$(dirname "$probe_pc")"
cat > "$probe_pc" <<'EOF'
prefix=${VITASDK}/arm-vita-eabi
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: vitasdk-wrapper-probe
Description: VitaSDK pkg-config frontend smoke test
Version: 1.0
Libs: -L${libdir} -lprobe
Cflags: -I${includedir}/probe
EOF
version=$(VITASDK="$install_root" \
PKG_CONFIG_DIR=/host/pkgconfig \
PKG_CONFIG_PATH=/host/pkgconfig \
PKG_CONFIG_SYSROOT_DIR=/host \
PKG_CONFIG_LIBDIR=/host/pkgconfig \
${run[@]+"${run[@]}"} "$install_root/bin/arm-vita-eabi-pkg-config" \
--modversion vitasdk-wrapper-probe)
[[ $version == 1.0 ]] || {
printf 'pkg-config frontend returned version %s, expected 1.0\n' "$version" >&2
exit 1
}
}

# Builds against $stage1_dir if set, then stages outputs plus provenance.
Expand Down
62 changes: 61 additions & 1 deletion scripts/ci/smoke-windows-bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $vdpmCheckout = Join-Path $tempRoot "vdpm-bootstrap-$([guid]::NewGuid())"
git clone --depth=1 --branch $vdpmTag https://github.com/vitasdk/vdpm.git $vdpmCheckout
if ($LASTEXITCODE -ne 0) { throw 'failed to check out the vdpm frontend' }

$installRoot = Join-Path $tempRoot "vitasdk-bootstrap-installed-$([guid]::NewGuid())"
$installRoot = Join-Path $tempRoot "Vita SDK bootstrap installed $([guid]::NewGuid())"
& (Join-Path $vdpmCheckout 'bootstrap-vitasdk.ps1') `
-ArchivePath $archive -Sha256 $digest -InstallDirectory $installRoot
if ($LASTEXITCODE -ne 0) { throw 'bootstrap-vitasdk.ps1 failed' }
Expand All @@ -54,4 +54,64 @@ if ($LASTEXITCODE -ne 0) { throw 'pacman self-test failed' }
& (Join-Path $installRoot 'bin/arm-vita-eabi-gcc.exe') --version
if ($LASTEXITCODE -ne 0) { throw 'compiler self-test failed' }

$pkgconf = Join-Path $installRoot 'bin/pkgconf.exe'
$pkgConfig = Join-Path $installRoot 'bin/arm-vita-eabi-pkg-config.exe'
foreach ($tool in @($pkgconf, $pkgConfig)) {
if (-not (Test-Path -PathType Leaf $tool)) {
throw "pkg-config tool is missing: $tool"
}
}

$probeDirectory = Join-Path $installRoot 'arm-vita-eabi/lib/pkgconfig'
New-Item -ItemType Directory -Force -Path $probeDirectory | Out-Null
$probeFile = Join-Path $probeDirectory 'vitasdk-wrapper-probe.pc'
@'
prefix=${VITASDK}/arm-vita-eabi
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: vitasdk-wrapper-probe
Description: VitaSDK pkg-config frontend smoke test
Version: 1.0
Libs: -L${libdir} -lprobe
Cflags: -I${includedir}/probe
'@ | Set-Content -NoNewline -Encoding utf8 $probeFile

$hostMetadata = Join-Path $tempRoot "host-pkgconfig-$([guid]::NewGuid())"
New-Item -ItemType Directory -Path $hostMetadata | Out-Null
@'
Name: vitasdk-wrapper-probe
Description: Host package that must not be selected
Version: 9.9
Libs: -lhost-contamination
'@ | Set-Content -NoNewline -Encoding utf8 (Join-Path $hostMetadata 'vitasdk-wrapper-probe.pc')

$env:VITASDK = Join-Path $tempRoot 'wrong sdk root'
$env:PKG_CONFIG_DIR = $hostMetadata
$env:PKG_CONFIG_PATH = $hostMetadata
$env:PKG_CONFIG_SYSROOT_DIR = $hostMetadata
$env:PKG_CONFIG_LIBDIR = $hostMetadata
$version = (& $pkgConfig --modversion vitasdk-wrapper-probe | Out-String).Trim()
if ($LASTEXITCODE -ne 0 -or $version -ne '1.0') {
throw "pkg-config frontend selected version '$version' instead of the Vita package"
}

$cmakeProject = Join-Path $tempRoot "pkgconfig-cmake-project-$([guid]::NewGuid())"
$cmakeBuild = Join-Path $tempRoot "pkgconfig-cmake-build-$([guid]::NewGuid())"
New-Item -ItemType Directory -Path $cmakeProject | Out-Null
@'
cmake_minimum_required(VERSION 3.16)
project(vitasdk_pkgconfig_probe NONE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(PROBE REQUIRED IMPORTED_TARGET vitasdk-wrapper-probe)
if(NOT PROBE_VERSION STREQUAL "1.0")
message(FATAL_ERROR "unexpected probe version: ${PROBE_VERSION}")
endif()
'@ | Set-Content -NoNewline -Encoding utf8 (Join-Path $cmakeProject 'CMakeLists.txt')
$env:VITASDK = $installRoot
& cmake -S $cmakeProject -B $cmakeBuild `
"-DCMAKE_TOOLCHAIN_FILE=$(Join-Path $installRoot 'share/vita.toolchain.cmake')"
if ($LASTEXITCODE -ne 0) { throw 'native Windows CMake could not use the Vita pkg-config frontend' }

Write-Host "Windows bootstrap smoke test passed for $windowsHost"
7 changes: 5 additions & 2 deletions scripts/create-bootstrap-archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ source_date_epoch=$4

required=(version_info.txt etc/pacman.conf share/vdpm/THIRD_PARTY_NOTICES.md
share/vdpm/licenses/vdpm-LGPL-2.1.txt
share/vdpm/licenses/pacman-GPL-2.0.txt)
share/vdpm/licenses/pacman-GPL-2.0.txt
share/licenses/pkgconf/COPYING)
case $host in
*-w64-mingw32)
required+=(bin/vdpm.exe bin/arm-vita-eabi-gcc.exe \
bin/pkgconf.exe bin/arm-vita-eabi-pkg-config.exe \
share/vdpm/msys/usr/bin/pacman.exe \
share/vdpm/msys/usr/bin/vdpm-channel.exe \
share/vdpm/msys/usr/bin/msys-2.0.dll \
share/vdpm/refresh-repositories.ps1)
;;
*)
required+=(bin/vdpm bin/arm-vita-eabi-gcc libexec/vdpm/pacman bin/vdpm-channel \
required+=(bin/vdpm bin/arm-vita-eabi-gcc bin/pkgconf \
bin/arm-vita-eabi-pkg-config libexec/vdpm/pacman bin/vdpm-channel \
bin/include/refresh-repositories.sh)
;;
esac
Expand Down
12 changes: 12 additions & 0 deletions scripts/validate-core-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ if [[ $pkgname == vitasdk-core ]]; then
printf 'core package does not contain the Vita compiler driver\n' >&2
exit 1
}
if [[ $architecture == *-w64-mingw32 ]]; then
pkgconfig_runtime=(bin/pkgconf.exe bin/arm-vita-eabi-pkg-config.exe)
else
pkgconfig_runtime=(bin/pkgconf bin/arm-vita-eabi-pkg-config)
fi
for runtime_file in ${pkgconfig_runtime[@]+"${pkgconfig_runtime[@]}"} \
share/licenses/pkgconf/COPYING; do
grep -Fqx "$runtime_file" <<< "$archive_entries" || {
printf 'core package does not contain %s\n' "$runtime_file" >&2
exit 1
}
done
grep -qx 'version_info.txt' <<< "$archive_entries" || {
printf 'core package does not contain provenance information\n' >&2
exit 1
Expand Down
49 changes: 49 additions & 0 deletions tests/cmake/pkgconf-sdk-validation.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.19)

set(validate_script "${CMAKE_CURRENT_LIST_DIR}/../../cmake/ValidateSdk.cmake")
set(required_tools gcc g++ ld as ar ranlib strip objcopy objdump readelf nm gdb)

function(create_sdk_fixture root suffix)
file(REMOVE_RECURSE "${root}")
file(MAKE_DIRECTORY "${root}/bin" "${root}/arm-vita-eabi/include" "${root}/arm-vita-eabi/lib")
foreach(tool IN LISTS required_tools)
file(WRITE "${root}/bin/arm-vita-eabi-${tool}${suffix}" "")
endforeach()
endfunction()

function(run_validation root system_name expected_success)
execute_process(
COMMAND "${CMAKE_COMMAND}"
-DSDK_DIR=${root}
-DTARGET_TRIPLE=arm-vita-eabi
-DHOST_SYSTEM_NAME=${system_name}
-P "${validate_script}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE error)
if(expected_success AND NOT result EQUAL 0)
message(FATAL_ERROR "${system_name} validation failed unexpectedly:\n${output}${error}")
endif()
if(NOT expected_success AND result EQUAL 0)
message(FATAL_ERROR "${system_name} validation accepted an SDK without the pkg-config frontend/backend")
endif()
endfunction()

set(test_root "${CMAKE_CURRENT_BINARY_DIR}/pkgconf-sdk-validation")

set(unix_root "${test_root}/unix")
create_sdk_fixture("${unix_root}" "")
run_validation("${unix_root}" Linux FALSE)
file(WRITE "${unix_root}/bin/pkgconf" "")
file(WRITE "${unix_root}/bin/arm-vita-eabi-pkg-config" "")
run_validation("${unix_root}" Linux TRUE)

set(windows_root "${test_root}/windows")
create_sdk_fixture("${windows_root}" ".exe")
run_validation("${windows_root}" Windows FALSE)
file(WRITE "${windows_root}/bin/pkgconf.exe" "")
file(WRITE "${windows_root}/bin/arm-vita-eabi-pkg-config.exe" "")
run_validation("${windows_root}" Windows TRUE)

file(REMOVE_RECURSE "${test_root}")
message(STATUS "pkgconf SDK validation checks passed")
2 changes: 2 additions & 0 deletions tests/cmake/static-sdk-validation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ file(MAKE_DIRECTORY "${fixture}/bin")
foreach(tool gcc g++ ld as ar ranlib strip objcopy objdump readelf nm gdb)
file(WRITE "${fixture}/bin/${target_triple}-${tool}.exe" "")
endforeach()
file(WRITE "${fixture}/bin/pkgconf.exe" "")
file(WRITE "${fixture}/bin/${target_triple}-pkg-config.exe" "")
execute_process(
COMMAND "${CMAKE_COMMAND}"
-DSDK_DIR=${fixture}
Expand Down
9 changes: 7 additions & 2 deletions tests/package/test-bootstrap-archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ cleanup() { rm -rf -- "$temporary_directory"; }
trap cleanup EXIT

sdk="$temporary_directory/sdk"
mkdir -p "$sdk/bin/include" "$sdk/libexec/vdpm" "$sdk/etc" "$sdk/share/vdpm/licenses"
for file in vdpm arm-vita-eabi-gcc vdpm-channel; do
mkdir -p "$sdk/bin/include" "$sdk/libexec/vdpm" "$sdk/etc" \
"$sdk/share/vdpm/licenses" "$sdk/share/licenses/pkgconf"
for file in vdpm arm-vita-eabi-gcc vdpm-channel pkgconf arm-vita-eabi-pkg-config; do
printf '%s\n' "$file" > "$sdk/bin/$file"
done
printf 'pacman\n' > "$sdk/libexec/vdpm/pacman"
Expand All @@ -19,6 +20,7 @@ printf 'revision\n' > "$sdk/version_info.txt"
printf 'notices\n' > "$sdk/share/vdpm/THIRD_PARTY_NOTICES.md"
printf 'vdpm license\n' > "$sdk/share/vdpm/licenses/vdpm-LGPL-2.1.txt"
printf 'pacman license\n' > "$sdk/share/vdpm/licenses/pacman-GPL-2.0.txt"
printf 'pkgconf license\n' > "$sdk/share/licenses/pkgconf/COPYING"

for output in one two; do
"$repository_root/scripts/create-bootstrap-archive.sh" \
Expand All @@ -28,9 +30,12 @@ archive=vitasdk-bootstrap-x86_64-linux-gnu.tar.bz2
cmp "$temporary_directory/one/$archive" "$temporary_directory/two/$archive"
entries=$(tar -tjf "$temporary_directory/one/$archive")
grep -qx 'vitasdk/bin/vdpm' <<< "$entries"
grep -qx 'vitasdk/bin/pkgconf' <<< "$entries"
grep -qx 'vitasdk/bin/arm-vita-eabi-pkg-config' <<< "$entries"
grep -qx 'vitasdk/libexec/vdpm/pacman' <<< "$entries"
grep -qx 'vitasdk/etc/pacman.conf' <<< "$entries"
grep -qx 'vitasdk/version_info.txt' <<< "$entries"
grep -qx 'vitasdk/share/vdpm/THIRD_PARTY_NOTICES.md' <<< "$entries"
grep -qx 'vitasdk/share/licenses/pkgconf/COPYING' <<< "$entries"

printf 'reproducible VitaSDK bootstrap archive contract passed\n'
Loading
Loading