Manually adding thirdparty libs

This commit is contained in:
2025-04-14 14:49:36 -04:00
parent 1bd2dc2333
commit 77f1466ae3
70 changed files with 60610 additions and 4 deletions

305
thirdparty/harfbuzz/scripts/build.ps1 vendored Normal file
View File

@@ -0,0 +1,305 @@
$misc = join-path $PSScriptRoot 'helpers/misc.ps1'
. $misc
$path_root = git rev-parse --show-toplevel
$path_lib = join-path $path_root 'lib'
$path_win64 = join-path $path_lib 'win64'
$url_harfbuzz = 'https://github.com/harfbuzz/harfbuzz.git'
$path_harfbuzz = join-path $path_root 'harfbuzz'
function build-repo {
verify-path $script:path_lib
verify-path $path_win64
clone-gitrepo $path_harfbuzz $url_harfbuzz
push-location $path_harfbuzz
$library_type = "shared"
$build_type = "release"
# Meson configure and build
$mesonArgs = @(
"build",
"--default-library=$library_type",
"--buildtype=$build_type",
"--wrap-mode=forcefallback",
"-Dglib=disabled",
"-Dgobject=disabled",
"-Dcairo=disabled",
"-Dicu=disabled",
"-Dgraphite=disabled",
"-Dfreetype=disabled",
"-Ddirectwrite=disabled",
"-Dcoretext=disabled"
)
& meson $mesonArgs
& meson compile -C build
pop-location
$path_build = join-path $path_harfbuzz 'build'
$path_src = join-path $path_build 'src'
$path_dll = join-path $path_src 'harfbuzz.dll'
$path_lib = join-path $path_src 'harfbuzz.lib'
$path_lib_static = join-path $path_src 'libharfbuzz.a'
$path_pdb = join-path $path_src 'harfbuzz.pdb'
# Copy files based on build type and library type
if ($build_type -eq "debug") {
copy-item -Path $path_pdb -Destination $path_win64 -Force
}
if ($library_type -eq "static") {
copy-item -Path $path_lib_static -Destination (join-path $path_win64 'harfbuzz.lib') -Force
}
else {
copy-item -Path $path_lib -Destination $path_win64 -Force
copy-item -Path $path_dll -Destination $path_win64 -Force
}
write-host "Build completed and files copied to $path_win64"
}
# build-repo
function Build-RepoWithoutMeson {
$devshell = join-path $PSScriptRoot 'helpers/devshell.ps1'
& $devshell -arch amd64
verify-path $script:path_lib
verify-path $path_win64
clone-gitrepo $path_harfbuzz $url_harfbuzz
$path_harfbuzz_build = join-path $path_harfbuzz 'build'
verify-path $path_harfbuzz_build
$library_type = "shared"
$build_type = "release"
push-location $path_harfbuzz
$compiler_args = @(
"/nologo",
"/W3",
"/D_CRT_SECURE_NO_WARNINGS",
"/DHAVE_FALLBACK=1",
"/DHAVE_OT=1",
"/DHAVE_SUBSET=1",
"/DHB_USE_INTERNAL_PARSER",
"/DHB_NO_COLOR",
"/DHB_NO_DRAW",
"/DHB_NO_PARSE",
"/DHB_NO_MT",
"/DHB_NO_GRAPHITE2",
"/DHB_NO_ICU",
"/DHB_NO_DIRECTWRITE",
"/I$path_harfbuzz\src",
"/I$path_harfbuzz"
)
if ( $library_type -eq "shared" ) {
$compiler_args += "/DHAVE_DECLSPEC"
$compiler_args += "/DHARFBUZZ_EXPORTS"
}
if ($build_type -eq "debug") {
$compiler_args += "/MDd", "/Od", "/Zi"
} else {
$compiler_args += "/MD", "/O2"
}
$compiler_args = $compiler_args -join " "
$config_h_content = @"
#define HB_VERSION_MAJOR 9
#define HB_VERSION_MINOR 0
#define HB_VERSION_MICRO 0
#define HB_VERSION_STRING "9.0.0"
#define HAVE_ROUND 1
#define HB_NO_BITMAP 1
#define HB_NO_CFF 1
#define HB_NO_OT_FONT_CFF 1
#define HB_NO_SUBSET_CFF 1
#define HB_HAVE_SUBSET 0
#define HB_HAVE_OT 0
#define HB_USER_DATA_KEY_DEFINE1(_name) extern HB_EXTERN hb_user_data_key_t _name
"@
set-content -Path (join-path $path_harfbuzz "config.h") -Value $config_h_content
$unity_content = @"
#define HB_EXTERN __declspec(dllexport)
// base
#include "config.h"
#include "hb-aat-layout.cc"
#include "hb-aat-map.cc"
#include "hb-blob.cc"
#include "hb-buffer-serialize.cc"
#include "hb-buffer-verify.cc"
#include "hb-buffer.cc"
#include "hb-common.cc"
//#include "hb-draw.cc"
//#include "hb-paint.cc"
//#include "hb-paint-extents.cc"
#include "hb-face.cc"
#include "hb-face-builder.cc"
#include "hb-fallback-shape.cc"
#include "hb-font.cc"
#include "hb-map.cc"
#include "hb-number.cc"
#include "hb-ot-cff1-table.cc"
#include "hb-ot-cff2-table.cc"
#include "hb-ot-color.cc"
#include "hb-ot-face.cc"
#include "hb-ot-font.cc"
#include "hb-outline.cc"
#include "OT/Var/VARC/VARC.cc"
#include "hb-ot-layout.cc"
#include "hb-ot-map.cc"
#include "hb-ot-math.cc"
#include "hb-ot-meta.cc"
#include "hb-ot-metrics.cc"
#include "hb-ot-name.cc"
#include "hb-ot-shaper-arabic.cc"
#include "hb-ot-shaper-default.cc"
#include "hb-ot-shaper-hangul.cc"
#include "hb-ot-shaper-hebrew.cc"
#include "hb-ot-shaper-indic-table.cc"
#include "hb-ot-shaper-indic.cc"
#include "hb-ot-shaper-khmer.cc"
#include "hb-ot-shaper-myanmar.cc"
#include "hb-ot-shaper-syllabic.cc"
#include "hb-ot-shaper-thai.cc"
#include "hb-ot-shaper-use.cc"
#include "hb-ot-shaper-vowel-constraints.cc"
#include "hb-ot-shape-fallback.cc"
#include "hb-ot-shape-normalize.cc"
#include "hb-ot-shape.cc"
#include "hb-ot-tag.cc"
#include "hb-ot-var.cc"
#include "hb-set.cc"
#include "hb-shape-plan.cc"
#include "hb-shape.cc"
#include "hb-shaper.cc"
#include "hb-static.cc"
#include "hb-style.cc"
#include "hb-ucd.cc"
#include "hb-unicode.cc"
// libharfbuzz-subset
//#include "hb-subset-input.cc"
//#include "hb-subset-cff-common.cc"
//#include "hb-subset-cff1.cc"
//#include "hb-subset-cff2.cc"
//#include "hb-subset-instancer-iup.cc"
//#include "hb-subset-instancer-solver.cc"
//#include "hb-subset-plan.cc"
//#include "hb-subset-repacker.cc"
//#include "graph/gsubgpos-context.cc"
//#include "hb-subset.cc"
"@
$unity_file = join-path $path_harfbuzz_build "harfbuzz_unity.cc"
set-content -Path $unity_file -Value $unity_content
# Compile unity file
$obj_file = "harfbuzz_unity.obj"
$command = "cl.exe $compiler_args /c $unity_file /Fo$path_harfbuzz_build\$obj_file"
write-host "Compiling: $command"
invoke-expression $command
if ($LASTEXITCODE -ne 0) {
write-error "Compilation failed for unity build"
pop-location
return
}
push-location $path_harfbuzz_build
# Create library
if ($library_type -eq "static")
{
$lib_command = "lib.exe /OUT:harfbuzz.lib $obj_file"
write-host "Creating static library: $lib_command"
invoke-expression $lib_command
if ($LASTEXITCODE -ne 0) {
Write-Error "Static library creation failed"
pop-location
pop-location
return
}
$output_file = "harfbuzz.lib"
}
else
{
$linker_args = "/DLL", "/OUT:harfbuzz.dll"
if ($build_type -eq "debug") {
$linker_args += "/DEBUG"
}
$link_command = "link.exe $($linker_args -join ' ') $obj_file"
write-host "Creating shared library: $link_command"
invoke-expression $link_command
if ($LASTEXITCODE -ne 0) {
write-error "Shared library creation failed"
pop-location
pop-location
return
}
$output_file = "harfbuzz.dll"
}
pop-location # path_harfbuzz_build
pop-location # path_harfbuzz
# Copy files
$path_output = join-path $path_harfbuzz_build $output_file
if (test-path $path_output) {
copy-item -Path $path_output -Destination $path_win64 -Force
if ($library_type -eq "shared") {
$path_lib = join-path $path_harfbuzz_build "harfbuzz.lib"
if (test-path $path_lib) {
copy-item -Path $path_lib -Destination $path_win64 -Force
}
}
} else {
write-warning "Output file not found: $path_output"
}
write-host "Build completed and files copied to $path_win64"
}
Build-RepoWithoutMeson
function grab-binaries {
verify-path $script:path_lib
verify-path $path_win64
$url_harfbuzz_8_5_0_win64 = 'https://github.com/harfbuzz/harfbuzz/releases/latest/download/harfbuzz-win64-8.5.0.zip'
$path_harfbuzz_win64_zip = join-path $path_win64 'harfbuzz-win64-8.5.0.zip'
$path_harfbuzz_win64 = join-path $path_win64 'harfbuzz-win64'
grab-zip $url_harfbuzz_8_5_0_win64 $path_harfbuzz_win64_zip $path_win64
get-childitem -path $path_harfbuzz_win64 | move-item -destination $path_win64 -force
# Clean up the ZIP file and the now empty harfbuzz-win64 directory
remove-item $path_harfbuzz_win64_zip -force
remove-item $path_harfbuzz_win64 -recurse -force
}
# grab-binaries

284
thirdparty/harfbuzz/scripts/build.sh vendored Normal file
View File

@@ -0,0 +1,284 @@
#!/bin/bash
# Source the misc.sh script
misc_script="$(dirname "$0")/helpers/misc.sh"
chmod +x "$misc_script"
source "$misc_script"
path_root=$(git rev-parse --show-toplevel)
path_lib="$path_root/lib"
path_osx="$path_lib/osx"
path_linux64="$path_lib/linux64"
OS=$(uname -s)
# Set the appropriate output directory and file extension
case "$OS" in
Darwin*)
path_output="$path_osx"
shared_lib_extension="dylib"
;;
Linux*)
path_output="$path_linux64"
shared_lib_extension="so"
;;
*)
echo "Unsupported operating system: $OS"
exit 1
;;
esac
url_harfbuzz='https://github.com/harfbuzz/harfbuzz.git'
path_harfbuzz="$path_root/harfbuzz"
build_repo() {
verify_path "$path_lib"
verify_path "$path_output"
# grab the actual repo
clone_gitrepo "$path_harfbuzz" "$url_harfbuzz"
pushd "$path_harfbuzz" > /dev/null
library_type="shared"
build_type="release"
# Check if meson is installed
if ! command -v meson &> /dev/null; then
echo "Meson is not installed. Please install it and try again."
exit 1
fi
# Meson configure and build
meson_args=(
"build"
"--default-library=$library_type"
"--buildtype=$build_type"
"--wrap-mode=forcefallback"
"-Dglib=disabled"
"-Dgobject=disabled"
"-Dcairo=disabled"
"-Dicu=disabled"
"-Dgraphite=disabled"
"-Dfreetype=disabled"
"-Ddirectwrite=disabled"
"-Dcoretext=disabled"
)
meson "${meson_args[@]}"
ninja -C build
popd > /dev/null
path_build="$path_harfbuzz/build"
path_src="$path_build/src"
path_so="$path_src/libharfbuzz.so"
path_a="$path_src/libharfbuzz.a"
# Copy files based on build type and library type
if [ "$build_type" = "debug" ]; then
# Debug symbols are typically embedded in the .so file on Linux
# If there's a separate debug file, you would copy it here
:
fi
if [ "$library_type" = "static" ]; then
cp "$path_a" "$path_linux64/libharfbuzz.a"
else
cp "$path_so" "$path_linux64/libharfbuzz.so"
fi
echo "Build completed and files copied to $path_linux64"
}
build_repo_without_meson() {
# Detect the operating system
OS=$(uname -s)
echo $url_harfbuzz
echo $path_harfbuzz
echo $path_lib
echo $path_linux64
verify_path "$path_lib"
verify_path "$path_linux64"
path_harfbuzz_build="$path_harfbuzz/build"
echo $path_harfbuzz_build
# grab the actual repo
clone_gitrepo "$path_harfbuzz" "$url_harfbuzz"
verify_path "$path_harfbuzz_build"
library_type="shared"
build_type="release"
pushd "$path_harfbuzz" > /dev/null
# Determine the latest C++ standard supported by the compiler
latest_cpp_standard=$(clang++ -dM -E - < /dev/null | grep __cplusplus | awk '{print $3}')
case $latest_cpp_standard in
201703L) cpp_flag="-std=c++17" ;;
202002L) cpp_flag="-std=c++20" ;;
202302L) cpp_flag="-std=c++23" ;;
*) cpp_flag="-std=c++14" ;; # Default to C++14 if unable to determine
esac
echo "Using C++ standard: $cpp_flag"
compiler_args=(
"$cpp_flag"
"-Wall"
"-Wextra"
"-D_REENTRANT"
"-DHAVE_FALLBACK=1"
"-DHAVE_OT=1"
"-DHAVE_SUBSET=1"
"-DHB_USE_INTERNAL_PARSER"
"-DHB_NO_COLOR"
"-DHB_NO_DRAW"
"-DHB_NO_PARSE"
"-DHB_NO_MT"
"-DHB_NO_GRAPHITE2"
"-DHB_NO_ICU"
"-DHB_NO_DIRECTWRITE"
"-I$path_harfbuzz/src"
"-I$path_harfbuzz"
)
if [ "$library_type" = "shared" ]; then
compiler_args+=("-fPIC")
compiler_args+=("-DHAVE_DECLSPEC")
compiler_args+=("-DHARFBUZZ_EXPORTS")
fi
if [ "$build_type" = "debug" ]; then
compiler_args+=("-g" "-O0")
else
compiler_args+=("-O2")
fi
compiler_args_str="${compiler_args[*]}"
# Create config.h
cat > "$path_harfbuzz/config.h" << EOL
#define HB_VERSION_MAJOR 9
#define HB_VERSION_MINOR 0
#define HB_VERSION_MICRO 0
#define HB_VERSION_STRING "9.0.0"
#define HAVE_ROUND 1
#define HB_NO_BITMAP 1
#define HB_NO_CFF 1
#define HB_NO_OT_FONT_CFF 1
#define HB_NO_SUBSET_CFF 1
#define HB_HAVE_SUBSET 0
#define HB_HAVE_OT 0
#define HB_USER_DATA_KEY_DEFINE1(_name) extern HB_EXTERN hb_user_data_key_t _name
EOL
# Create unity build file
cat > "$path_harfbuzz_build/harfbuzz_unity.cc" << EOL
#define HB_EXTERN __attribute__((visibility("default")))
// base
#include "config.h"
#include "hb-aat-layout.cc"
#include "hb-aat-map.cc"
#include "hb-blob.cc"
#include "hb-buffer-serialize.cc"
#include "hb-buffer-verify.cc"
#include "hb-buffer.cc"
#include "hb-common.cc"
#include "hb-face.cc"
#include "hb-face-builder.cc"
#include "hb-fallback-shape.cc"
#include "hb-font.cc"
#include "hb-map.cc"
#include "hb-number.cc"
#include "hb-ot-cff1-table.cc"
#include "hb-ot-cff2-table.cc"
#include "hb-ot-color.cc"
#include "hb-ot-face.cc"
#include "hb-ot-font.cc"
#include "hb-outline.cc"
#include "OT/Var/VARC/VARC.cc"
#include "hb-ot-layout.cc"
#include "hb-ot-map.cc"
#include "hb-ot-math.cc"
#include "hb-ot-meta.cc"
#include "hb-ot-metrics.cc"
#include "hb-ot-name.cc"
#include "hb-ot-shaper-arabic.cc"
#include "hb-ot-shaper-default.cc"
#include "hb-ot-shaper-hangul.cc"
#include "hb-ot-shaper-hebrew.cc"
#include "hb-ot-shaper-indic-table.cc"
#include "hb-ot-shaper-indic.cc"
#include "hb-ot-shaper-khmer.cc"
#include "hb-ot-shaper-myanmar.cc"
#include "hb-ot-shaper-syllabic.cc"
#include "hb-ot-shaper-thai.cc"
#include "hb-ot-shaper-use.cc"
#include "hb-ot-shaper-vowel-constraints.cc"
#include "hb-ot-shape-fallback.cc"
#include "hb-ot-shape-normalize.cc"
#include "hb-ot-shape.cc"
#include "hb-ot-tag.cc"
#include "hb-ot-var.cc"
#include "hb-set.cc"
#include "hb-shape-plan.cc"
#include "hb-shape.cc"
#include "hb-shaper.cc"
#include "hb-static.cc"
#include "hb-style.cc"
#include "hb-ucd.cc"
#include "hb-unicode.cc"
EOL
# Compile unity file
pushd "$path_harfbuzz_build" > /dev/null
g++ $compiler_args_str -c harfbuzz_unity.cc -o harfbuzz_unity.o
if [ $? -ne 0 ]; then
echo "Compilation failed for unity build"
popd > /dev/null
popd > /dev/null
return 1
fi
# Create library
if [ "$library_type" = "static" ]; then
ar rcs libharfbuzz.a harfbuzz_unity.o
if [ $? -ne 0 ]; then
echo "Static library creation failed"
popd > /dev/null
popd > /dev/null
return 1
fi
output_file="libharfbuzz.a"
else
g++ -shared -o libharfbuzz.so harfbuzz_unity.o
if [ $? -ne 0 ]; then
echo "Shared library creation failed"
popd > /dev/null
popd > /dev/null
return 1
fi
output_file="libharfbuzz.so"
fi
popd > /dev/null # path_harfbuzz_build
popd > /dev/null # path_harfbuzz
# Copy files
cp "$path_harfbuzz_build/$output_file" "$path_linux64/"
if [ "$library_type" = "shared" ]; then
if [ -f "$path_harfbuzz_build/libharfbuzz.so" ]; then
cp "$path_harfbuzz_build/libharfbuzz.so" "$path_linux64/"
fi
fi
echo "Build completed and files copied to $path_linux64"
}
# Uncomment the function you want to use
# build_repo
build_repo_without_meson

View File

@@ -0,0 +1,28 @@
if ($env:VCINSTALLDIR) {
return
}
$ErrorActionPreference = "Stop"
# Use vswhere to find the latest Visual Studio installation
$vswhere_out = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
if ($null -eq $vswhere_out) {
Write-Host "ERROR: Visual Studio installation not found"
exit 1
}
# Find Launch-VsDevShell.ps1 in the Visual Studio installation
$vs_path = $vswhere_out
$vs_devshell = Join-Path $vs_path "\Common7\Tools\Launch-VsDevShell.ps1"
if ( -not (Test-Path $vs_devshell) ) {
Write-Host "ERROR: Launch-VsDevShell.ps1 not found in Visual Studio installation"
Write-Host Tested path: $vs_devshell
exit 1
}
# Launch the Visual Studio Developer Shell
Push-Location
write-host @args
& $vs_devshell @args
Pop-Location

View File

@@ -0,0 +1,72 @@
function Clone-Gitrepo { param( [string] $path, [string] $url )
if (test-path $path) {
# git -C $path pull
}
else {
Write-Host "Cloning $url ..."
git clone $url $path
}
}
function Grab-Zip { param( $url, $path_file, $path_dst )
Invoke-WebRequest -Uri $url -OutFile $path_file
Expand-Archive -Path $path_file -DestinationPath $path_dst -Force
}
function Update-GitRepo
{
param( [string] $path, [string] $url, [string] $build_command )
if ( $build_command -eq $null ) {
write-host "Attempted to call Update-GitRepo without build_command specified"
return
}
$repo_name = $url.Split('/')[-1].Replace('.git', '')
$last_built_commit = join-path $path_build "last_built_commit_$repo_name.txt"
if ( -not(test-path -Path $path))
{
write-host "Cloining repo from $url to $path"
git clone $url $path
write-host "Building $url"
push-location $path
& "$build_command"
pop-location
git -C $path rev-parse HEAD | out-file $last_built_commit
$script:binaries_dirty = $true
write-host
return
}
git -C $path fetch
$latest_commit_hash = git -C $path rev-parse '@{u}'
$last_built_hash = if (Test-Path $last_built_commit) { Get-Content $last_built_commit } else { "" }
if ( $latest_commit_hash -eq $last_built_hash ) {
write-host
return
}
write-host "Build out of date for: $path, updating"
write-host 'Pulling...'
git -C $path pull
write-host "Building $url"
push-location $path
& $build_command
pop-location
$latest_commit_hash | out-file $last_built_commit
$script:binaries_dirty = $true
write-host
}
function Verify-Path { param( $path )
if (test-path $path) {return $true}
new-item -ItemType Directory -Path $path
return $false
}

View File

@@ -0,0 +1,111 @@
#!/bin/bash
clone_gitrepo() {
local path="$1"
local url="$2"
if [ -d "$path" ]; then
# git -C "$path" pull
:
else
echo "Cloning $url ..."
git clone "$url" "$path"
fi
}
get_ini_content() {
local path_file="$1"
declare -A ini
local current_section=""
while IFS= read -r line; do
if [[ $line =~ ^\[(.+)\]$ ]]; then
current_section="${BASH_REMATCH[1]}"
ini["$current_section"]=""
elif [[ $line =~ ^([^=]+)=(.*)$ ]]; then
local key="${BASH_REMATCH[1]}"
local value="${BASH_REMATCH[2]}"
if [ -n "$current_section" ]; then
ini["$current_section,$key"]="$value"
fi
fi
done < "$path_file"
# To use this function, you would need to pass the result by reference
# and then access it in the calling function
}
invoke_with_color_coded_output() {
local command="$1"
eval "$command" 2>&1 | while IFS= read -r line; do
if [[ "$line" =~ [Ee]rror ]]; then
echo -e "\033[0;31m\t$line\033[0m" # Red for errors
elif [[ "$line" =~ [Ww]arning ]]; then
echo -e "\033[0;33m\t$line\033[0m" # Yellow for warnings
else
echo -e "\033[0;37m\t$line\033[0m" # White for other output
fi
done
}
update_git_repo() {
local path="$1"
local url="$2"
local build_command="$3"
if [ -z "$build_command" ]; then
echo "Attempted to call update_git_repo without build_command specified"
return
fi
local repo_name=$(basename "$url" .git)
local last_built_commit="$path_build/last_built_commit_$repo_name.txt"
if [ ! -d "$path" ]; then
echo "Cloning repo from $url to $path"
git clone "$url" "$path"
echo "Building $url"
pushd "$path" > /dev/null
eval "$build_command"
popd > /dev/null
git -C "$path" rev-parse HEAD > "$last_built_commit"
binaries_dirty=true
echo
return
fi
git -C "$path" fetch
local latest_commit_hash=$(git -C "$path" rev-parse '@{u}')
local last_built_hash=""
[ -f "$last_built_commit" ] && last_built_hash=$(cat "$last_built_commit")
if [ "$latest_commit_hash" = "$last_built_hash" ]; then
echo
return
fi
echo "Build out of date for: $path, updating"
echo 'Pulling...'
git -C "$path" pull
echo "Building $url"
pushd "$path" > /dev/null
eval "$build_command"
popd > /dev/null
echo "$latest_commit_hash" > "$last_built_commit"
binaries_dirty=true
echo
}
verify_path() {
local path="$1"
if [ -d "$path" ]; then
return 0
fi
mkdir -p "$path"
return 1
}