Skip to content

Commit

Permalink
Update scripts and configs
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Jul 26, 2024
1 parent ffaa52e commit 4efb362
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 48 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,7 @@ jobs:

- name: setup-msvc
shell: pwsh
run: .\1k\setup-msvc.ps1 -ver $env:TOOLSET

- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: ${{ env.TOOLSET }}
arch: ${{ env.BUILD_ARCH }}
run: .\1k\setup-msvc.ps1 -ver $env:TOOLSET -arch $env:BUILD_ARCH

- name: Build
shell: pwsh
Expand All @@ -317,16 +312,21 @@ jobs:
matrix:
arch:
- x64
- amd64_arm64
- arm64
env:
NO_DLL: ${{ github.event.inputs.no_dll }}
BUILD_ARCH: ${{ matrix.arch }}
TOOLSET: '14.39'

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

- name: setup-msvc
shell: pwsh
run: .\1k\setup-msvc.ps1 -ver $env:TOOLSET -arch $env:BUILD_ARCH

- name: Build
shell: pwsh
run: .\build.ps1 -p winrt -a $env:BUILD_ARCH -libs '${{ github.event.inputs.libs }}'
Expand Down
40 changes: 27 additions & 13 deletions 1k/1kiss.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ function devtool_url($filename) {
function version_eq($ver1, $ver2) {
return $ver1 -eq $ver2
}
function version_like($ver1, $ver2) {
return $ver1 -like $ver2
}

# $ver2: accept x.y.z-rc1
function version_ge($ver1, $ver2) {
Expand Down Expand Up @@ -567,29 +570,39 @@ function find_prog($name, $path = $null, $mode = 'ONLY', $cmd = $null, $params =

# try get match expr and preferred ver
$checkVerCond = $null
$requiredMin = ''
$minimalVer = ''
$preferredVer = ''
$wildcardVer = ''
$requiredVer = $manifest[$name]
if ($requiredVer) {
$preferredVer = $null
if ($requiredVer.EndsWith('+')) {
$preferredVer = $requiredVer.TrimEnd('+')
$checkVerCond = '$(version_ge $foundVer $preferredVer)'
}
elseif ($requiredVer -eq '*') {
if ($requiredVer -eq '*') {
$checkVerCond = '$True'
$preferredVer = 'latest'
}
else {
$verArr = $requiredVer.Split('~')
$isRange = $verArr.Count -gt 1
$minimalVer = $verArr[0]
$preferredVer = $verArr[$isRange]
if ($isRange -gt 1) {
$requiredMin = $verArr[0]
$checkVerCond = '$(version_in_range $foundVer $requiredMin $preferredVer)'
if ($preferredVer.EndsWith('+')) {
$preferredVer = $preferredVer.TrimEnd('+')
if ($minimalVer.EndsWith('+')) { $minimalVer = $minimalVer.TrimEnd('+') }
$checkVerCond = '$(version_ge $foundVer $minimalVer)'
}
else {
$checkVerCond = '$(version_eq $foundVer $preferredVer)'
if ($isRange) {
$checkVerCond = '$(version_in_range $foundVer $minimalVer $preferredVer)'
}
else {
if (!$preferredVer.Contains('*')) {
$checkVerCond = '$(version_eq $foundVer $preferredVer)'
} else {
$wildcardVer = $preferredVer
$preferredVer = $wildcardVer.TrimLast('*')
$checkVerCond = '$(version_like $foundVer $wildcardVer)'
}
}
}
}
if (!$checkVerCond) {
Expand Down Expand Up @@ -623,7 +636,7 @@ function find_prog($name, $path = $null, $mode = 'ONLY', $cmd = $null, $params =
else {
$foundVer = "$($cmd_info.Version)"
}
[void]$requiredMin
[void]$minimalVer
if ($checkVerCond) {
$matched = Invoke-Expression $checkVerCond
if ($matched) {
Expand All @@ -642,7 +655,6 @@ function find_prog($name, $path = $null, $mode = 'ONLY', $cmd = $null, $params =
}
else {
if ($preferredVer) {
# if (!$silent) { $1k.println("Not found $name, needs install: $preferredVer") }
$found_rets = $null, $preferredVer
}
else {
Expand Down Expand Up @@ -1218,7 +1230,9 @@ function setup_msvc() {
if (!$cl_prog) {
if ($VS_INST) {
Import-Module "$VS_PATH\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstanceId $VS_INST.instanceId -SkipAutomaticLocation -DevCmdArguments "-arch=$target_cpu -host_arch=x64 -no_logo"
$dev_cmd_args = "-arch=$target_cpu -host_arch=x64 -no_logo"
if (!$manifest['msvc'].EndsWith('+')) { $dev_cmd_args += " -vcvars_ver=$cl_ver" }
Enter-VsDevShell -VsInstanceId $VS_INST.instanceId -SkipAutomaticLocation -DevCmdArguments $dev_cmd_args

$cl_prog, $cl_ver = find_prog -name 'msvc' -cmd 'cl' -silent $true -usefv $true
$1k.println("Using msvc: $cl_prog, version: $cl_ver")
Expand Down
21 changes: 18 additions & 3 deletions 1k/fetch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ function fetch_repo($url, $name, $dest, $ext) {
if ($ext -eq '.zip') {
Expand-Archive -Path $out -DestinationPath $prefix -Force
}
elseif ($ext -match '\.tar(\..*)?$'){
tar xf "$out" -C $prefix
elseif ($ext -match '\.tar(\..*)?$') {
tar xvf "$out" -C $prefix
}
}
catch {
Expand All @@ -62,7 +62,22 @@ function fetch_repo($url, $name, $dest, $ext) {
if (!(Test-Path $dest -PathType Container)) {
$original_lib_src = Join-Path $prefix $Script:url_pkg_name
if (Test-Path $original_lib_src -PathType Container) {
Rename-Item $original_lib_src $dest -Force
$tries = 0
do {
try {
Rename-Item $original_lib_src $dest -Force
if ($?) {
break
}
}
catch {

}

println "fetch.ps1: rename $original_lib_src to $dest failed, try after 1 seconds"
$tries += 1
Start-Sleep -Seconds 1
} while ($tries -lt 10)
}
else {
throw "fetch.ps1: the package name mismatch for $out"
Expand Down
42 changes: 27 additions & 15 deletions 1k/install-pwsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,31 @@ mkdir -p $cacheDir

pwsh_ver=$1
if [ "$pwsh_ver" = "" ] ; then
pwsh_ver='7.4.2'
pwsh_ver='7.4.4'
fi

pwsh_min_ver=$2
if [ "$pwsh_min_ver" = "" ] ; then
pwsh_min_ver='7.3.0'
fi

if [[ "$pwsh_ver" < "$pwsh_min_ver" ]] ; then
pwsh_ver=$pwsh_min_ver
fi

function check_pwsh {
pwsh_ver=$1
min_ver=$1
preferred_ver=$2
if command -v pwsh >/dev/null ; then
pwsh_veri_a=$(pwsh --version)
pwsh_veri_b="PowerShell $pwsh_ver"
if [ "$pwsh_veri_b" = "$pwsh_veri_a" ] ; then
echo axmol: $pwsh_veri_a already installed.
verx=$(pwsh --version)
very="PowerShell $min_ver"
if ([ "$preferred_ver" != "$min_ver" ] && ([[ "$verx" > "$very" ]] || [ "$verx" = "$very" ])) \
|| ([ "$preferred_ver" = "$min_ver" ] && [ "$verx" = "$very" ]) ; then
echo "1kiss: $verx installed."
exit 0
fi
fi
echo "Installing PowerShell $pwsh_ver ..."
echo "Installing PowerShell $preferred_ver ..."
}

HOST_ARCH=$(uname -m)
Expand All @@ -34,7 +45,7 @@ if [ "$HOST_ARCH" = 'x86_64' ] ; then
fi

if [ $HOST_OS = 'Darwin' ] ; then
check_pwsh $pwsh_ver
check_pwsh $pwsh_min_ver $preferred_ver
pwsh_pkg="powershell-$pwsh_ver-osx-$HOST_ARCH.pkg"
pwsh_pkg_out="$cacheDir/$pwsh_pkg"
if [ ! -f "$pwsh_pkg_out" ] ; then
Expand All @@ -45,8 +56,8 @@ if [ $HOST_OS = 'Darwin' ] ; then
sudo xattr -rd com.apple.quarantine "$pwsh_pkg_out"
sudo installer -pkg "$pwsh_pkg_out" -target /
elif [ $HOST_OS = 'Linux' ] ; then
if which dpkg > /dev/null; then # Linux distro: deb (ubuntu)
check_pwsh $pwsh_ver
if command -v dpkg > /dev/null; then # Linux distro: deb (ubuntu)
check_pwsh $pwsh_min_ver $preferred_ver
pwsh_pkg="powershell_$pwsh_ver-1.deb_amd64.deb"
pwsh_pkg_out="$cacheDir/$pwsh_pkg"
if [ ! -f "$pwsh_pkg_out" ] ; then
Expand All @@ -55,10 +66,10 @@ elif [ $HOST_OS = 'Linux' ] ; then
sudo_cmd=$(which sudo)
$sudo_cmd dpkg -i "$pwsh_pkg_out"
$sudo_cmd apt-get install -f
elif which pacman > /dev/null; then # Linux distro: Arch
elif command -v pacman > /dev/null; then # Linux distro: Arch
# refer: https://ephos.github.io/posts/2018-9-17-Pwsh-ArchLinux
# available pwsh version, refer to: https://aur.archlinux.org/packages/powershell-bin
check_pwsh $pwsh_ver
check_pwsh $pwsh_min_ver
git clone https://aur.archlinux.org/powershell-bin.git $cacheDir/powershell-bin
cd $cacheDir/powershell-bin
makepkg -si --needed --noconfirm
Expand All @@ -69,10 +80,11 @@ else
exit 1
fi

if [ $? = 0 ] ; then
echo "Install PowerShell $pwsh_ver done"
if command -v pwsh >/dev/null ; then
installed_pwsh_ver=$(pwsh --version)
echo "Install PowerShell $installed_pwsh_ver succeed."
else
echo "Install PowerShell fail"
echo "Install PowerShell fail, try again"
if [ -f "$pwsh_pkg_out" ] ; then
rm -f "$pwsh_pkg_out"
fi
Expand Down
5 changes: 3 additions & 2 deletions 1k/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ if ($IsWin) {
}

# since 3.1.60+, the llvm-19 compiling class template more strict
$manifest['emsdk'] = '3.1.60+'
$manifest['cmake'] = '3.29.3+'
$manifest['emsdk'] = '3.1.63+'
$manifest['cmake'] = '3.29.3~3.30.2+'
$manifest['msvc'] = '14.39.*'
3 changes: 3 additions & 0 deletions 1k/platforms.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "tvOS")
set(IOS TRUE)
set(TVOS TRUE)
set(PLATFORM_NAME tvos)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "OHOS")
set(OHOS TRUE)
set(PLATFORM_NAME ohos)
else()
message(AUTHOR_WARNING "Unhandled platform: ${CMAKE_SYSTEM_NAME}")
endif()
Expand Down
14 changes: 9 additions & 5 deletions 1k/setup-msvc.ps1
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
param(
$ver = '14.39'
$ver = '14.39',
$arch = 'x64'
)
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vs_installs = ConvertFrom-Json "$(&$vswhere -version '17.0' -format 'json')"
$vs_installs
$vs_installer = 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe'
$vs_installer = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
$vs_path = $vs_installs[0].installationPath
$msvc_comp_id = "Microsoft.VisualStudio.Component.VC.$ver.17.9.x86.x64" # refer to: https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022

$vs_arch = @{x64 = 'x86.x64'; x86 = 'x86.x64'; arm64 = 'ARM64'; arm = 'ARM' }[$arch]
$msvc_comp_id = "Microsoft.VisualStudio.Component.VC.$ver.17.9.$vs_arch" # refer to: https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022
echo "Installing $msvc_comp_id ..."
&$vs_installer modify --quiet --installPath $vs_path --add $msvc_comp_id | Out-Host

if($?) {
if ($?) {
echo 'setup msvc success.'
} else {
}
else {
echo 'setup msvc fail'
}

Expand Down
1 change: 1 addition & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ mkdirs $install_root
$embed_family = ''
if ($is_win_family) {
$os_family = 'msw'
setup_msvc
}
else {
$os_family = 'unix'
Expand Down
2 changes: 1 addition & 1 deletion src/cares/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repo: https://github.com/c-ares/c-ares.git
ver: 1.32.3
ver: 1.33.0
tag_prefix: 'v'
tag_dot2ul: false
cb_tool: cmake
Expand Down
4 changes: 2 additions & 2 deletions src/curl/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repo: https://curl.se/download/curl-8.9.0.zip
ver: 8.9.0
repo: https://curl.se/download/curl-8.9.1.zip
ver: 8.9.1
tag_prefix: curl-
tag_dot2ul: true
cb_tool: cmake
Expand Down

0 comments on commit 4efb362

Please sign in to comment.