Skip to content

Commit

Permalink
Prepare release v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Jan 18, 2024
1 parent 3b4bf5c commit fc6fff7
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 47 deletions.
56 changes: 27 additions & 29 deletions 1k/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ $exeSuffix = if ($HOST_OS -eq 0) { '.exe' } else { '' }

$Script:cmake_generator = $null

# import VersionEx
. (Join-Path $PSScriptRoot 'versionex.ps1')

class build1k {
[void] println($msg) {
Write-Host "1kiss: $msg"
Expand Down Expand Up @@ -249,7 +252,7 @@ if ($options.xb.GetType() -eq [string]) {
}

$pwsh_ver = $PSVersionTable.PSVersion.ToString()
if ([System.Version]$pwsh_ver -lt [System.Version]"7.0.0") {
if ([VersionEx]$pwsh_ver -lt [VersionEx]"7.0") {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
}

Expand Down Expand Up @@ -376,7 +379,7 @@ function version_eq($ver1, $ver2) {
function version_ge($ver1, $ver2) {
$validatedVer = [Regex]::Match($ver1, '(\d+\.)+(-)?(\*|\d+)')
if ($validatedVer.Success) {
return [System.Version]$validatedVer.Value -ge [System.Version]$ver2
return [VersionEx]$validatedVer.Value -ge [VersionEx]$ver2
}
return $false
}
Expand All @@ -385,9 +388,9 @@ function version_ge($ver1, $ver2) {
function version_in_range($ver1, $verMin, $verMax) {
$validatedVer = [Regex]::Match($ver1, '(\d+\.)+(-)?(\*|\d+)')
if ($validatedVer.Success) {
$typedVer1 = [System.Version]$validatedVer.Value
$typedVerMin = [System.Version]$verMin
$typedVerMax = [System.Version]$verMax
$typedVer1 = [VersionEx]$validatedVer.Value
$typedVerMin = [VersionEx]$verMin
$typedVerMax = [VersionEx]$verMax
return $typedVer1 -ge $typedVerMin -and $typedVer1 -le $typedVerMax
}
return $false
Expand Down Expand Up @@ -503,8 +506,8 @@ function find_prog($name, $path = $null, $mode = 'ONLY', $cmd = $null, $params =
$verStr = "$($verInfo.Major).$($verInfo.Minor).$($verInfo.Build)"
}

# full pattern: '(\d+\.)+(\*|\d+)(\-[a-z]+[0-9]*)?' can match x.y.z-rc3, but not require for us
$matchInfo = [Regex]::Match($verStr, '(\d+\.)+(\*|\d+)(\-[a-z]+[0-9]*)?')
# can match x.y.z-rc3 or x.y.z-65a239b
$matchInfo = [Regex]::Match($verStr, '(\d+\.)+(\*|\d+)(\-[a-z0-9]+)?')
$foundVer = $matchInfo.Value
} else {
$foundVer = "$($cmd_info.Version)"
Expand Down Expand Up @@ -672,11 +675,6 @@ function setup_cmake($skipOS = $false) {
$b1k.rmdirs($cmake_root)

$cmake_suffix = @(".zip", ".sh", ".tar.gz").Get($HOST_OS)
$cmake_dev_hash = $channels['cmake']
if ($cmake_dev_hash) {
$cmake_ver = "$cmake_ver-$cmake_dev_hash"
}

if ($HOST_OS -ne $HOST_MAC) {
$cmake_pkg_name = "cmake-$cmake_ver-$HOST_OS_NAME-x86_64"
}
Expand All @@ -686,11 +684,12 @@ function setup_cmake($skipOS = $false) {

$cmake_pkg_path = Join-Path $external_prefix "$cmake_pkg_name$cmake_suffix"

if (!$cmake_dev_hash) {
$assemble_url = $channels['cmake']
if (!$assemble_url) {
$cmake_url = "https://github.com/Kitware/CMake/releases/download/v$cmake_ver/$cmake_pkg_name$cmake_suffix"
}
else {
$cmake_url = "https://cmake.org/files/dev/$cmake_pkg_name$cmake_suffix"
$cmake_url = & $assemble_url -FileName "$cmake_pkg_name$cmake_suffix"
}

$cmake_dir = Join-Path $external_prefix $cmake_pkg_name
Expand Down Expand Up @@ -718,7 +717,7 @@ function setup_cmake($skipOS = $false) {
}
elseif ($IsLinux) {
$b1k.mkdirs($cmake_root)
& "$cmake_pkg_path" '--skip-license' '--exclude-subdir' "--prefix=$cmake_root"
& "$cmake_pkg_path" '--skip-license' '--exclude-subdir' "--prefix=$cmake_root" 1>$null 2>$null
}

$cmake_prog, $_ = find_prog -name 'cmake' -path $cmake_bin -silent $true
Expand Down Expand Up @@ -747,7 +746,7 @@ function ensure_cmake_ninja($cmake_prog, $ninja_prog) {
if(!$? -and $IsWin) { # try runas admin again
$mklink_args = "-Command ""& ""$myRoot\fsync.ps1"" -s '$ninja_prog' -d '$ninja_symlink_target' -l `$true 2>`$null"""
Write-Host "mklink_args={$mklink_args}"
Start-Process powershell -ArgumentList $mklink_args -Verb runas -Wait
Start-Process powershell -ArgumentList $mklink_args -WindowStyle Hidden -Wait -Verb runas
}
}
return $?
Expand Down Expand Up @@ -1145,7 +1144,7 @@ $Global:VS_VERSION = $null
$Global:VS_PATH = $null
$Global:VS_INST = $null
function find_vs_latest() {
$vs_version = [System.Version]'12.0.0.0'
$vs_version = [VersionEx]'12.0'
if (!$Global:VS_INST) {
$VSWHERE_EXE = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$eap = $ErrorActionPreference
Expand All @@ -1157,7 +1156,7 @@ function find_vs_latest() {
if($vs_installs) {
$vs_inst_latest = $null
foreach($vs_inst in $vs_installs) {
$inst_ver = [System.Version]$vs_inst.installationVersion
$inst_ver = [VersionEx]$vs_inst.installationVersion
if ($vs_version -lt $inst_ver) {
$vs_version = $inst_ver
$vs_inst_latest = $vs_inst
Expand Down Expand Up @@ -1185,7 +1184,7 @@ function preprocess_win([string[]]$inputOptions) {
$arch = if ($options.a -eq 'x86') { 'Win32' } else { $options.a }

# arch
if ($VS_VERSION -ge [System.Version]'16.0.0.0') {
if ($VS_VERSION -ge [VersionEx]'16.0') {
$outputOptions += '-A', $arch
if ($TOOLCHAIN_VER) {
$outputOptions += "-Tv$TOOLCHAIN_VER"
Expand Down Expand Up @@ -1393,6 +1392,14 @@ if ($Global:is_win32) {
}
elseif ($Global:is_android) {
$ninja_prog = setup_ninja
# ensure ninja in cmake_bin
if (!(ensure_cmake_ninja $cmake_prog $ninja_prog)) {
$cmake_prog = setup_cmake -Force
if (!(ensure_cmake_ninja $cmake_prog $ninja_prog)) {
$b1k.println("Ensure ninja in cmake bin directory fail")
}
}

$null = setup_jdk # setup android sdk cmdlinetools require jdk
$sdk_root, $ndk_root = setup_android_sdk
$env:ANDROID_HOME = $sdk_root
Expand All @@ -1405,15 +1412,6 @@ elseif ($Global:is_android) {

$ndk_host = @('windows', 'linux', 'darwin').Get($HOST_OS)
$env:ANDROID_NDK_BIN = Join-Path $ndk_root "toolchains/llvm/prebuilt/$ndk_host-x86_64/bin"

# ensure ninja in cmake_bin
if (!(ensure_cmake_ninja $cmake_prog $ninja_prog)) {
$cmake_prog = setup_cmake -Force
if (!(ensure_cmake_ninja $cmake_prog $ninja_prog)) {
$b1k.println("Ensure ninja in cmake bin directory fail")
}
}

function active_ndk_toolchain() {
if ($env:PATH.IndexOf($env:ANDROID_NDK_BIN) -eq -1) {
$env:PATH = "$env:ANDROID_NDK_BIN$ENV_PATH_SEP$env:PATH"
Expand Down Expand Up @@ -1704,7 +1702,7 @@ if (!$setupOnly) {
cmd /c "gn $gn_gen_args"
}
else {
if ([System.Version]$pwsh_ver -ge [System.Version]'7.3.0') {
if ([VersionEx]$pwsh_ver -ge [VersionEx]'7.3') {
bash -c "gn $gn_gen_args"
} else {
gn $gn_gen_args
Expand Down
4 changes: 2 additions & 2 deletions 1k/install-pwsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ HOST_OS=$(uname)

myRoot=$(dirname "$0")

$prefix = ~/.1kiss
prefix=~/.1kiss
mkdir -p $prefix

pwsh_ver=$1
if [ "$pwsh_ver" = "" ] ; then
pwsh_ver='7.4.0'
pwsh_ver='7.4.1'
fi

function check_pwsh {
Expand Down
2 changes: 0 additions & 2 deletions 1k/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ $manifest['glslcc'] = '1.9.4+'
# android sdk tools
$android_sdk_tools['build-tools'] = '34.0.0' # match with AGP, current 8.2.1 android studio 2023.1.1
$android_sdk_tools['platforms'] = 'android-34'

# [void]$manifest
206 changes: 206 additions & 0 deletions 1k/versionex.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# The System.Version compare not relex: [Version]'1.0' -eq [Version]'1.0.0' == false
# So provide a spec VersionEx make [VersionEx]'1.0' -eq [VersionEx]'1.0.0' == true available
if (-not ([System.Management.Automation.PSTypeName]'System.VersionEx').Type) {

Add-Type -TypeDefinition @"
namespace System
{
public sealed class VersionEx : ICloneable, IComparable
{
int _Major = 0;
int _Minor = 0;
int _Build = 0;
int _Revision = 0;
public int Minor { get { return _Major; } }
public int Major { get { return _Minor; } }
public int Build { get { return _Build; } }
public int Revision { get { return _Revision; } }
int DefaultFormatFieldCount { get { return (_Build > 0 || _Revision > 0) ? (_Revision > 0 ? 4 : 3) : 2; } }
public VersionEx() { }
public VersionEx(string version)
{
var v = Parse(version);
_Major = v.Major;
_Minor = v.Minor;
_Build = v.Build;
_Revision = v.Revision;
}
public VersionEx(System.Version version) {
_Major = version.Major;
_Minor = version.Minor;
_Build = Math.Max(version.Build, 0);
_Revision = Math.Max(version.Revision, 0);
}
public VersionEx(int major, int minor, int build, int revision)
{
_Major = major;
_Minor = minor;
_Build = build;
_Revision = revision;
}
public static VersionEx Parse(string input)
{
var versionNums = input.Split('.');
int major = 0;
int minor = 0;
int build = 0;
int revision = 0;
for (int i = 0; i < versionNums.Length; ++i)
{
switch (i)
{
case 0:
major = int.Parse(versionNums[i]);
break;
case 1:
minor = int.Parse(versionNums[i]);
break;
case 2:
build = int.Parse(versionNums[i]);
break;
case 3:
revision = int.Parse(versionNums[i]);
break;
}
}
return new VersionEx(major, minor, build, revision);
}
public static bool TryParse(string input, out VersionEx result)
{
try
{
result = VersionEx.Parse(input);
return true;
}
catch (Exception)
{
result = null;
return false;
}
}
public object Clone()
{
return new VersionEx(Major, Minor, Build, Revision);
}
public int CompareTo(object obj)
{
if (obj is VersionEx)
{
return CompareTo((VersionEx)obj);
}
else if (obj is Version)
{
var rhs = (Version)obj;
return _Major != rhs.Major ? (_Major > rhs.Major ? 1 : -1) :
_Minor != rhs.Minor ? (_Minor > rhs.Minor ? 1 : -1) :
_Build != rhs.Build ? (_Build > rhs.Build ? 1 : -1) :
_Revision != rhs.Revision ? (_Revision > rhs.Revision ? 1 : -1) :
0;
}
else return 1;
}
public int CompareTo(VersionEx obj)
{
return
ReferenceEquals(obj, this) ? 0 :
ReferenceEquals(obj, null) ? 1 :
_Major != obj._Major ? (_Major > obj._Major ? 1 : -1) :
_Minor != obj._Minor ? (_Minor > obj._Minor ? 1 : -1) :
_Build != obj._Build ? (_Build > obj._Build ? 1 : -1) :
_Revision != obj._Revision ? (_Revision > obj._Revision ? 1 : -1) :
0;
}
public bool Equals(VersionEx obj)
{
return CompareTo(obj) == 0;
}
public override bool Equals(object obj)
{
return CompareTo(obj) == 0;
}
public override string ToString()
{
return ToString(DefaultFormatFieldCount);
}
public string ToString(int fieldCount)
{
switch (fieldCount)
{
case 2:
return string.Format("{0}.{1}", _Major, _Minor);
case 3:
return string.Format("{0}.{1}.{2}", _Major, _Minor, _Build);
case 4:
return string.Format("{0}.{1}.{2}.{3}", _Major, _Minor, _Build, _Revision);
default:
return "0.0.0.0";
}
}
public override int GetHashCode()
{
// Let's assume that most version numbers will be pretty small and just
// OR some lower order bits together.
int accumulator = 0;
accumulator |= (_Major & 0x0000000F) << 28;
accumulator |= (_Minor & 0x000000FF) << 20;
accumulator |= (_Build & 0x000000FF) << 12;
accumulator |= (_Revision & 0x00000FFF);
return accumulator;
}
public static bool operator ==(VersionEx v1, VersionEx v2)
{
return v1.Equals(v2);
}
public static bool operator !=(VersionEx v1, VersionEx v2)
{
return !v1.Equals(v2);
}
public static bool operator <(VersionEx v1, VersionEx v2)
{
return v1.CompareTo(v2) < 0;
}
public static bool operator >(VersionEx v1, VersionEx v2)
{
return v1.CompareTo(v2) > 0;
}
public static bool operator <=(VersionEx v1, VersionEx v2)
{
return v1.CompareTo(v2) <= 0;
}
public static bool operator >=(VersionEx v1, VersionEx v2)
{
return v1.CompareTo(v2) >= 0;
}
}
}
"@
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# axmol-2.1.0 Jan.?? 2024
# axmol-2.1.0 Jan.20 2024

### Significant changes relative to 2.0.0:

Expand Down
Loading

0 comments on commit fc6fff7

Please sign in to comment.