Skip to content

Commit 574246f

Browse files
committed
Update 1k
1 parent 2457d1f commit 574246f

File tree

7 files changed

+94
-61
lines changed

7 files changed

+94
-61
lines changed

1k/1kiss.ps1

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ $manifest = @{
205205
cmake = '3.23.0+';
206206
ninja = '1.10.0+';
207207
python = '3.8.0+';
208-
jdk = '11.0.23+';
208+
jdk = '17.0.10+'; # jdk17+ works for android cmdlinetools 7.0+
209209
emsdk = '3.1.53+';
210210
cmdlinetools = '7.0+'; # android cmdlinetools
211211
}
@@ -225,7 +225,7 @@ $cmake_generators = @{
225225
$channels = @{}
226226

227227
# refer to: https://developer.android.com/studio#command-line-tools-only
228-
$cmdlinetools_rev = '11076708'
228+
$cmdlinetools_rev = '11076708' # 12.0
229229

230230
$android_sdk_tools = @{
231231
'build-tools' = '34.0.0'
@@ -567,29 +567,31 @@ function find_prog($name, $path = $null, $mode = 'ONLY', $cmd = $null, $params =
567567

568568
# try get match expr and preferred ver
569569
$checkVerCond = $null
570-
$requiredMin = ''
570+
$minimalVer = ''
571571
$preferredVer = ''
572572
$requiredVer = $manifest[$name]
573573
if ($requiredVer) {
574574
$preferredVer = $null
575-
if ($requiredVer.EndsWith('+')) {
576-
$preferredVer = $requiredVer.TrimEnd('+')
577-
$checkVerCond = '$(version_ge $foundVer $preferredVer)'
578-
}
579-
elseif ($requiredVer -eq '*') {
575+
if ($requiredVer -eq '*') {
580576
$checkVerCond = '$True'
581577
$preferredVer = 'latest'
582578
}
583579
else {
584580
$verArr = $requiredVer.Split('~')
585581
$isRange = $verArr.Count -gt 1
582+
$minimalVer = $verArr[0]
586583
$preferredVer = $verArr[$isRange]
587-
if ($isRange -gt 1) {
588-
$requiredMin = $verArr[0]
589-
$checkVerCond = '$(version_in_range $foundVer $requiredMin $preferredVer)'
590-
}
591-
else {
592-
$checkVerCond = '$(version_eq $foundVer $preferredVer)'
584+
if ($preferredVer.EndsWith('+')) {
585+
$preferredVer = $preferredVer.TrimEnd('+')
586+
if ($minimalVer.EndsWith('+')) { $minimalVer = $minimalVer.TrimEnd('+') }
587+
$checkVerCond = '$(version_ge $foundVer $minimalVer)'
588+
} else {
589+
if ($isRange) {
590+
$checkVerCond = '$(version_in_range $foundVer $minimalVer $preferredVer)'
591+
}
592+
else {
593+
$checkVerCond = '$(version_eq $foundVer $preferredVer)'
594+
}
593595
}
594596
}
595597
if (!$checkVerCond) {
@@ -623,7 +625,7 @@ function find_prog($name, $path = $null, $mode = 'ONLY', $cmd = $null, $params =
623625
else {
624626
$foundVer = "$($cmd_info.Version)"
625627
}
626-
[void]$requiredMin
628+
[void]$minimalVer
627629
if ($checkVerCond) {
628630
$matched = Invoke-Expression $checkVerCond
629631
if ($matched) {
@@ -1662,33 +1664,6 @@ if (!$setupOnly) {
16621664

16631665
# determine generator, build_dir, inst_dir for non gradlew projects
16641666
if (!$is_gradlew) {
1665-
if (!$cmake_generator -and !$TARGET_OS.StartsWith('win')) {
1666-
$cmake_generator = $cmake_generators[$TARGET_OS]
1667-
if ($null -eq $cmake_generator) {
1668-
$cmake_generator = if (!$IsWin) { 'Unix Makefiles' } else { 'Ninja' }
1669-
}
1670-
}
1671-
1672-
if ($cmake_generator) {
1673-
$using_ninja = $cmake_generator.StartsWith('Ninja')
1674-
1675-
if (!$is_wasm) {
1676-
$CONFIG_ALL_OPTIONS += '-G', $cmake_generator
1677-
}
1678-
1679-
if ($cmake_generator -eq 'Unix Makefiles' -or $using_ninja) {
1680-
$CONFIG_ALL_OPTIONS += "-DCMAKE_BUILD_TYPE=$optimize_flag"
1681-
}
1682-
1683-
if ($using_ninja -and $Global:is_android) {
1684-
$CONFIG_ALL_OPTIONS += "-DCMAKE_MAKE_PROGRAM=$ninja_prog"
1685-
}
1686-
1687-
if ($cmake_generator -eq 'Xcode') {
1688-
setup_xcode
1689-
}
1690-
}
1691-
16921667
$INST_DIR = $null
16931668
$xopt_presets = 0
16941669
$xprefix_optname = '-DCMAKE_INSTALL_PREFIX='
@@ -1714,6 +1689,15 @@ if (!$setupOnly) {
17141689
}
17151690
++$xopt_presets
17161691
}
1692+
elseif ($opt.startsWith('-G')) {
1693+
if ($opt.Length -gt 2) {
1694+
$cmake_generator = $opt.Substring(2).Trim()
1695+
}
1696+
elseif (++$opti -lt $xopts.Count) {
1697+
$cmake_generator = $xopts[$opti]
1698+
}
1699+
++$xopt_presets
1700+
}
17171701
elseif ($opt.StartsWith($xprefix_optname)) {
17181702
++$xopt_presets
17191703
$INST_DIR = $opt.SubString($xprefix_optname.Length)
@@ -1723,6 +1707,33 @@ if (!$setupOnly) {
17231707
}
17241708
}
17251709

1710+
if (!$cmake_generator -and !$TARGET_OS.StartsWith('win')) {
1711+
$cmake_generator = $cmake_generators[$TARGET_OS]
1712+
if ($null -eq $cmake_generator) {
1713+
$cmake_generator = if (!$IsWin) { 'Unix Makefiles' } else { 'Ninja' }
1714+
}
1715+
}
1716+
1717+
if ($cmake_generator) {
1718+
$using_ninja = $cmake_generator.StartsWith('Ninja')
1719+
1720+
if (!$is_wasm) {
1721+
$CONFIG_ALL_OPTIONS += '-G', $cmake_generator
1722+
}
1723+
1724+
if ($cmake_generator -eq 'Unix Makefiles' -or $using_ninja) {
1725+
$CONFIG_ALL_OPTIONS += "-DCMAKE_BUILD_TYPE=$optimize_flag"
1726+
}
1727+
1728+
if ($using_ninja -and $Global:is_android) {
1729+
$CONFIG_ALL_OPTIONS += "-DCMAKE_MAKE_PROGRAM=$ninja_prog"
1730+
}
1731+
1732+
if ($cmake_generator -eq 'Xcode') {
1733+
setup_xcode
1734+
}
1735+
}
1736+
17261737
if (!$BUILD_DIR) {
17271738
$BUILD_DIR = resolve_out_dir 'build_'
17281739
}

1k/dm/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ project(dm)
66
find_program(PWSH_PROG NAMES pwsh powershell NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH)
77

88
message(STATUS "CMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
9+
message(STATUS "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
910
message(STATUS "CMAKE_C_FLAGS=${CMAKE_C_FLAGS}")
10-
message(STATUS "ANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}")
11+
message(STATUS "CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
12+
message(STATUS "CMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS}")
13+
message(STATUS "CMAKE_SYSROOT=${CMAKE_SYSROOT}")
1114

1215
set(cross_flags "")
1316
if(ANDROID)
17+
message(STATUS "ANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}")
1418
if(CMAKE_ANDROID_ARCH_ABI MATCHES "arm64-v8a")
1519
set(cross_flags "-target aarch64-none-linux-android${ANDROID_NATIVE_API_LEVEL}")
1620
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES "x86_64")
@@ -34,3 +38,5 @@ endif()
3438
if(NOT ${CMAKE_C_COMPILER} MATCHES ".*cl\.exe" OR "${MSVC_VERSION}" GREATER_EQUAL 1928)
3539
execute_process(COMMAND ${PWSH_PROG} "${CMAKE_CURRENT_SOURCE_DIR}/dm.ps1" "${CMAKE_C_COMPILER}" "${CMAKE_C_FLAGS} ${cross_flags}")
3640
endif()
41+
42+
add_library(dm dm.c)

1k/dm/dm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
long double dm2x(long double v)
2+
{
3+
return v * 10.33;
4+
}

1k/fsync.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if (!(Test-Path $destLoc -PathType Container)) {
5757
}
5858

5959
if ($linkOnly) {
60-
Write-Host "fsync.ps1: Linking $srcPath to $destPath ..."
60+
Write-Host "fsync.ps1: Symlink $srcPath to $destPath ..."
6161
if ($IsWin -and (Test-Path $srcPath -PathType Container)) {
6262
cmd.exe /c mklink /J $destPath $srcPath
6363
}

1k/install-pwsh.sh

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,31 @@ mkdir -p $cacheDir
1212

1313
pwsh_ver=$1
1414
if [ "$pwsh_ver" = "" ] ; then
15-
pwsh_ver='7.4.2'
15+
pwsh_ver='7.4.4'
16+
fi
17+
18+
pwsh_min_ver=$2
19+
if [ "$pwsh_min_ver" = "" ] ; then
20+
pwsh_min_ver='7.3.0'
21+
fi
22+
23+
if [[ "$pwsh_ver" < "$pwsh_min_ver" ]] ; then
24+
pwsh_ver=$pwsh_min_ver
1625
fi
1726

1827
function check_pwsh {
19-
pwsh_ver=$1
28+
min_ver=$1
29+
preferred_ver=$2
2030
if command -v pwsh >/dev/null ; then
21-
pwsh_veri_a=$(pwsh --version)
22-
pwsh_veri_b="PowerShell $pwsh_ver"
23-
if [ "$pwsh_veri_b" = "$pwsh_veri_a" ] ; then
24-
echo axmol: $pwsh_veri_a already installed.
31+
verx=$(pwsh --version)
32+
very="PowerShell $min_ver"
33+
if ([ "$preferred_ver" != "$min_ver" ] && ([[ "$verx" > "$very" ]] || [ "$verx" = "$very" ])) \
34+
|| ([ "$preferred_ver" = "$min_ver" ] && [ "$verx" = "$very" ]) ; then
35+
echo "1kiss: $verx installed."
2536
exit 0
2637
fi
2738
fi
28-
echo "Installing PowerShell $pwsh_ver ..."
39+
echo "Installing PowerShell $preferred_ver ..."
2940
}
3041

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

3647
if [ $HOST_OS = 'Darwin' ] ; then
37-
check_pwsh $pwsh_ver
48+
check_pwsh $pwsh_min_ver $preferred_ver
3849
pwsh_pkg="powershell-$pwsh_ver-osx-$HOST_ARCH.pkg"
3950
pwsh_pkg_out="$cacheDir/$pwsh_pkg"
4051
if [ ! -f "$pwsh_pkg_out" ] ; then
@@ -45,8 +56,8 @@ if [ $HOST_OS = 'Darwin' ] ; then
4556
sudo xattr -rd com.apple.quarantine "$pwsh_pkg_out"
4657
sudo installer -pkg "$pwsh_pkg_out" -target /
4758
elif [ $HOST_OS = 'Linux' ] ; then
48-
if which dpkg > /dev/null; then # Linux distro: deb (ubuntu)
49-
check_pwsh $pwsh_ver
59+
if command -v dpkg > /dev/null; then # Linux distro: deb (ubuntu)
60+
check_pwsh $pwsh_min_ver $preferred_ver
5061
pwsh_pkg="powershell_$pwsh_ver-1.deb_amd64.deb"
5162
pwsh_pkg_out="$cacheDir/$pwsh_pkg"
5263
if [ ! -f "$pwsh_pkg_out" ] ; then
@@ -55,10 +66,10 @@ elif [ $HOST_OS = 'Linux' ] ; then
5566
sudo_cmd=$(which sudo)
5667
$sudo_cmd dpkg -i "$pwsh_pkg_out"
5768
$sudo_cmd apt-get install -f
58-
elif which pacman > /dev/null; then # Linux distro: Arch
69+
elif command -v pacman > /dev/null; then # Linux distro: Arch
5970
# refer: https://ephos.github.io/posts/2018-9-17-Pwsh-ArchLinux
6071
# available pwsh version, refer to: https://aur.archlinux.org/packages/powershell-bin
61-
check_pwsh $pwsh_ver
72+
check_pwsh $pwsh_min_ver
6273
git clone https://aur.archlinux.org/powershell-bin.git $cacheDir/powershell-bin
6374
cd $cacheDir/powershell-bin
6475
makepkg -si --needed --noconfirm
@@ -69,10 +80,11 @@ else
6980
exit 1
7081
fi
7182

72-
if [ $? = 0 ] ; then
73-
echo "Install PowerShell $pwsh_ver done"
83+
if command -v pwsh >/dev/null ; then
84+
installed_pwsh_ver=$(pwsh --version)
85+
echo "Install PowerShell $installed_pwsh_ver succeed."
7486
else
75-
echo "Install PowerShell fail"
87+
echo "Install PowerShell fail, try again"
7688
if [ -f "$pwsh_pkg_out" ] ; then
7789
rm -f "$pwsh_pkg_out"
7890
fi

1k/manifest.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Default manifest, refer in 1k/1kiss.ps1
22

33
if ($IsWin) {
4-
$manifest['nasm'] = '2.16.01+'
4+
$manifest['nasm'] = '2.16.03+'
55
} else {
66
$manifest['nasm'] = '2.15.05+'
77
}

1k/setup-msvc.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ param(
44
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
55
$vs_installs = ConvertFrom-Json "$(&$vswhere -version '17.0' -format 'json')"
66
$vs_installs
7-
$vs_installer = 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe'
7+
$vs_installer = '${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe'
88
$vs_path = $vs_installs[0].installationPath
99
$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
1010
echo "Installing $msvc_comp_id ..."

0 commit comments

Comments
 (0)