From ddaeeed0d7e237fa373f37a87a621a0559bbbba1 Mon Sep 17 00:00:00 2001 From: halx99 Date: Mon, 8 Jan 2024 23:12:19 +0800 Subject: [PATCH] Bump v71 --- .github/workflows/build.yml | 13 ++---- .github/workflows/dist.yml | 2 +- 1k/build.ps1 | 4 +- 1k/config.h.in | 6 +-- 1k/config_ab.h.in | 6 +-- 1k/dist.sh | 25 ++++------ 1k/fetchd.ps1 | 33 ++++++------- 1k/ios.cmake | 16 ++++++- 1k/nsdk1k.cpp | 93 ------------------------------------- 1k/xcutils.ps1 | 74 +++++++++++++++++++++++++++++ README.md | 8 ++-- build.ps1 | 30 +++++++----- src/luajit/build1.ps1 | 9 +--- src/openssl/build1.ps1 | 13 +++--- 14 files changed, 158 insertions(+), 174 deletions(-) delete mode 100644 1k/nsdk1k.cpp create mode 100644 1k/xcutils.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c86dc8..5108f20 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,6 @@ on: paths: - .github/workflows/build.yml - 1k/build* - - 1k/nsdk1k.cpp - 1k/ios.cmake - src/**/build* - src/**/install* @@ -78,9 +77,7 @@ jobs: - name: Build shell: pwsh - run: | - $env:XCODE_VERSION='${{ steps.setup-xcode.outputs.version }}' - ./build.ps1 osx $env:BUILD_ARCH + run: ./build.ps1 osx $env:BUILD_ARCH - name: Upload uses: actions/upload-artifact@v3 @@ -114,9 +111,7 @@ jobs: - name: Build shell: pwsh - run: | - $env:XCODE_VERSION='${{ steps.setup-xcode.outputs.version }}' - ./build.ps1 ios $env:BUILD_ARCH + run: ./build.ps1 ios $env:BUILD_ARCH - name: Upload uses: actions/upload-artifact@v3 @@ -150,9 +145,7 @@ jobs: - name: Build shell: pwsh - run: | - $env:XCODE_VERSION='${{ steps.setup-xcode.outputs.version }}' - ./build.ps1 tvos $env:BUILD_ARCH + run: ./build.ps1 tvos $env:BUILD_ARCH - name: Upload uses: actions/upload-artifact@v3 diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index dc6660b..4c9074f 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -99,4 +99,4 @@ jobs: ${{ env.DIST_VERLIST }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_REPOSITORY: axmolengine/buildware + GITHUB_REPOSITORY: simdsoft/1kiss diff --git a/1k/build.ps1 b/1k/build.ps1 index ed2bcd9..4dc2b2f 100644 --- a/1k/build.ps1 +++ b/1k/build.ps1 @@ -26,7 +26,7 @@ # SOFTWARE. # # -# The 1k/build.ps1, will be core script of project https://github.com/axmolengine/1k +# The 1k/build.ps1, the core script of project 1kiss(1k) # options # -p: build target platform: win32,winrt(winuwp),linux,android,osx(mac),ios,tvos,watchos,wasm # for android: will search ndk in sdk_root which is specified by env:ANDROID_HOME first, @@ -830,7 +830,7 @@ function setup_llvm() { $7z_pkg_out = Join-Path $external_prefix '7z2301-x64.zip' if (!(Test-Path $7z_prog -PathType Leaf)) { # https://www.7-zip.org/download.html - download_and_expand -url 'https://github.com/axmolengine/archive/releases/download/v1.0.0/7z2301-x64.zip' -out $7z_pkg_out $external_prefix/ + download_and_expand -url 'https://github.com/simdsoft/1kiss/releases/download/devtools/7z2301-x64.zip' -out $7z_pkg_out $external_prefix/ } } diff --git a/1k/config.h.in b/1k/config.h.in index 444745b..d2b9f1d 100644 --- a/1k/config.h.in +++ b/1k/config.h.in @@ -1,8 +1,8 @@ /* -** This file is auto generated by https://github.com/axmolengine/buildware.git +** This file is auto generated by https://github.com/simdsoft/1kiss.git */ -#ifndef BUILDWARE_@LIB_NAME@_REDIRECT_H -#define BUILDWARE_@LIB_NAME@_REDIRECT_H +#ifndef _1KISS_@LIB_NAME@_REDIRECT_H +#define _1KISS_@LIB_NAME@_REDIRECT_H #if defined(_WIN32) diff --git a/1k/config_ab.h.in b/1k/config_ab.h.in index 675842e..bd36fae 100644 --- a/1k/config_ab.h.in +++ b/1k/config_ab.h.in @@ -1,8 +1,8 @@ /* -** This file is auto generated by https://github.com/axmolengine/buildware.git +** This file is auto generated by https://github.com/simdsoft/1kiss.git */ -#ifndef BUILDWARE_@LIB_NAME@_REDIRECT_H -#define BUILDWARE_@LIB_NAME@_REDIRECT_H +#ifndef _1KISS_@LIB_NAME@_REDIRECT_H +#define _1KISS_@LIB_NAME@_REDIRECT_H #if defined(_WIN32) # include "win32/@INC_DIR@@CONF_HEADER@" diff --git a/1k/dist.sh b/1k/dist.sh index a4b3b7f..3011fcd 100755 --- a/1k/dist.sh +++ b/1k/dist.sh @@ -212,23 +212,18 @@ function dist_lib { if [ "$verinfo_file" != "" ] ; then eval $(parse_yaml "$verinfo_file") - if [ "$ver" != "" ] ; then + if [ "$rev" = "" ] ; then # no rev, not a git repo echo "$LIB_NAME: $ver" >> "$DIST_VERLIST" echo "- $LIB_NAME: $ver" >> "$DIST_NOTES" - else - if [ "$branch" != "" ] && [ "$branch" != "master" ] ; then - eval $(parse_yaml "src/${LIB_NAME}/build.yml") - if [ "$ver" != "" ] ; then - echo "$LIB_NAME: $ver-$rev" >> "$DIST_VERLIST" - echo "- $LIB_NAME: $ver-$rev" >> "$DIST_NOTES" - else - echo "$LIB_NAME: $branch-$rev" >> "$DIST_VERLIST" - echo "- $LIB_NAME: $branch-$rev" >> "$DIST_NOTES" - fi - else - echo "$LIB_NAME: git $rev" >> "$DIST_VERLIST" - echo "- $LIB_NAME: git $rev" >> "$DIST_NOTES" - fi + else # have rev, is a git repo + if [ "$branch" != "" ] ; then + eval $(parse_yaml "src/${LIB_NAME}/build.yml") + echo "$LIB_NAME: $ver-$rev" >> "$DIST_VERLIST" + echo "- $LIB_NAME: $ver-$rev" >> "$DIST_NOTES" + else + echo "$LIB_NAME: git $rev" >> "$DIST_VERLIST" + echo "- $LIB_NAME: git $rev" >> "$DIST_NOTES" + fi fi else # read version from src/${LIB_NAME}/build.yml diff --git a/1k/fetchd.ps1 b/1k/fetchd.ps1 index 79b93b2..c827580 100644 --- a/1k/fetchd.ps1 +++ b/1k/fetchd.ps1 @@ -42,7 +42,7 @@ if ($folder_name.EndsWith('.tar')) { } $lib_src = Join-Path $prefix $folder_name -function download_repo($url, $out) { +function fetch_repo($url, $out) { if (!$url.EndsWith('.git')) { download_file $url $out if ($out.EndsWith('.zip')) { @@ -75,11 +75,12 @@ if (!(Test-Path $sentry -PathType Leaf)) { } elseif ($url.EndsWith('.zip')) { $out_file = Join-Path $cache_dir "${folder_name}.zip" - } else { + } + else { $out_file = $null } - download_repo -url $url -out $out_file + fetch_repo -url $url -out $out_file if (Test-Path $lib_src -PathType Container) { New-Item $sentry -ItemType File @@ -98,26 +99,26 @@ if ($is_git_repo) { $new_rev_hash = $(git -C $lib_src rev-parse HEAD) - if(!$is_rev_modified) { + if (!$is_rev_modified) { $is_rev_modified = $old_rev_hash -ne $new_rev_hash } } if ($is_rev_modified) { - $branch_name = $(git -C $lib_src branch --show-current) $sentry_content = "ver: $version" - if ($branch_name) { - git pull - $commits = $(git -C $lib_src rev-list --count HEAD) - $sentry_content += "`nbranch: $branch_name" - $sentry_content += "`ncommits: $commits" - - # track branch change revision to latest short commit hash of branch - $revision = $(git -C $lib_src rev-parse --short=7 HEAD) - } - if ($version -ne $revision) { - $sentry_content += "`nrev: $revision" + + if ($is_git_repo) { + $branch_name = $(git -C $lib_src branch --show-current) + if ($branch_name) { # track branch + git pull + $commits = $(git -C $lib_src rev-list --count HEAD) + $sentry_content += "`nbranch: $branch_name" + $sentry_content += "`ncommits: $commits" + $revision = $(git -C $lib_src rev-parse --short=7 HEAD) + $sentry_content += "`nrev: $revision" + } } + [System.IO.File]::WriteAllText($sentry, $sentry_content) } diff --git a/1k/ios.cmake b/1k/ios.cmake index 87859c8..12f160f 100644 --- a/1k/ios.cmake +++ b/1k/ios.cmake @@ -1,6 +1,6 @@ # # The minimal ios toolchain file: https://github.com/yasio/yasio/blob/dev/cmake/ios.cmake -# version: 4.1.1 +# version: 4.1.2 # # The supported params: # PLAT: iOS, tvOS, default: iOS @@ -84,13 +84,25 @@ if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET) set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET} CACHE STRING "") endif() -if(SIMULATOR) +if (NOT SIMULATOR) + if(PLAT STREQUAL "iOS") + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos") + elseif(PLAT STREQUAL "tvOS") + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-appletvos") + elseif(PLAT STREQUAL "watchOS") + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-watchos") + endif() +else() if (PLAT STREQUAL "iOS") set(_SDK_NAME "iphonesimulator") + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator") elseif(PLAT STREQUAL "tvOS") set(_SDK_NAME "appletvsimulator") + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-tvsimulator") + elseif(PLAT STREQUAL "watchOS") set(_SDK_NAME "watchsimulator") + set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-watchsimulator") else() message(FATAL_ERROR "PLAT=${PLAT} unsupported!") endif() diff --git a/1k/nsdk1k.cpp b/1k/nsdk1k.cpp deleted file mode 100644 index 740316a..0000000 --- a/1k/nsdk1k.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// nsdk1k.cpp : This file contains the 'main' function. Program execution begins and ends there. -// g++ -std=c++17 1k/nsdk1k.cpp -o build/nsdk1k - -// usage: nsdk1k xcode_ver target -// i.e. nsdk1k 13.4 ios -#include -#include -#include -#include -#include -using namespace std::string_view_literals; - -int main(int argc, char** argv) -{ - if (argc < 3) return EINVAL; - bool simulator = false; - if (argc >= 4) simulator = !!atoi(argv[3]); - - std::unordered_map> sdks = { - {"osx"sv, - { - {"13.1.0"sv, "12.0"sv}, - {"13.2.1"sv, "12.1"sv}, - {"13.3.1"sv, "12.3"sv}, - {"13.4.0"sv, "12.3"sv}, - {"13.4.1"sv, "12.3"sv}, - {"14.0.1"sv, "12.3"sv}, - {"14.1.0"sv, "13.0"sv}, - {"14.2.0"sv, "13.1"sv} - } - }, - {"ios"sv, - { - {"13.1.0"sv, "15.0"sv}, - {"13.2.1"sv, "15.2"sv}, - {"13.3.1"sv, "15.4"sv}, - {"13.4.0"sv, "15.5"sv}, - {"13.4.1"sv, "15.5"sv}, - {"14.0.1"sv, "16.0"sv}, - {"14.1.0"sv, "16.1"sv}, - {"14.2.0"sv, "16.2"sv} - } - }, - {"tvos"sv, - { - {"13.1.0"sv, "15.0"sv}, - {"13.2.1"sv, "15.2"sv}, - {"13.3.1"sv, "15.4"sv}, - {"13.4.0"sv, "15.4"sv}, - {"13.4.1"sv, "15.4"sv}, - {"14.0.1"sv, "16.0"sv}, - {"14.1.0"sv, "16.1"sv}, - {"14.2.0"sv, "16.1"sv} - } - }, - {"watchos"sv, - { - {"13.1.0"sv, "8.0"sv}, - {"13.2.1"sv, "8.3"sv}, - {"13.3.1"sv, "8.5"sv}, - {"13.4.1"sv, "8.5"sv}, - {"14.0.1"sv, "9.0"sv}, - {"14.1.0"sv, "9.1"sv}, - {"14.2.0"sv, "9.1"sv} - } - } - }; - - std::string_view xcode_ver = argv[1]; - std::string_view target = argv[2]; - auto target_it = sdks.find(target); - if (target_it != sdks.end()) { - auto sdk_it = target_it->second.find(xcode_ver); - if (sdk_it != target_it->second.end()) { - auto& sdk_ver = sdk_it->second; - if (target == "osx"sv) { - printf("%s%s", "macosx", sdk_ver.data()); - } - else if (target == "ios"sv) { // ios - printf("%s%s", !simulator ? "iphoneos" : "iphonesimulator", sdk_ver.data()); - } - else if (target == "tvos"sv) { // tvos - printf("%s%s", !simulator ? "appletvos" : "appletvsimulator", sdk_ver.data()); - } - else if (target == "watchos"sv) { // watchos - printf("%s%s", !simulator ? "watchos" : "watchsimulator", sdk_ver.data()); - } - return 0; - } - } - - return ENOENT; -} diff --git a/1k/xcutils.ps1 b/1k/xcutils.ps1 new file mode 100644 index 0000000..1d6a9bf --- /dev/null +++ b/1k/xcutils.ps1 @@ -0,0 +1,74 @@ +# query sdk name by xcode version +$xcode_sdks_map = @{ + 'osx' = + @{ + '13.1.0' = '12.0' + '13.2.1' = '12.1' + '13.3.1' = '12.3' + '13.4.0' = '12.3' + '13.4.1' = '12.3' + '14.0.1' = '12.3' + '14.1.0' = '13.0' + '14.2.0' = '13.1' + '14.3.1' = '13.3' + '15.0.1' = '14.0' + } + + 'ios' = + @{ + '13.1.0' = '15.0' + '13.2.1' = '15.2' + '13.3.1' = '15.4' + '13.4.0' = '15.5' + '13.4.1' = '15.5' + '14.0.1' = '16.0' + '14.1.0' = '16.1' + '14.2.0' = '16.2' + '14.3.1' = '16.4' + '15.0.1' = '17.0' + } + 'tvos' = + @{ + '13.1.0' = '15.0' + '13.2.1' = '15.2' + '13.3.1' = '15.4' + '13.4.0' = '15.4' + '13.4.1' = '15.4' + '14.0.1' = '16.0' + '14.1.0' = '16.1' + '14.2.0' = '16.1' + '14.3.1' = '16.4' + '15.0.1' = '17.0' + } + 'watchos' = + @{ + '13.1.0' = '8.0' + '13.2.1' = '8.3' + '13.3.1' = '8.5' + '13.4.1' = '8.5' + '14.0.1' = '9.0' + '14.1.0' = '9.1' + '14.2.0' = '9.1' + '14.3.1' = '9.4' + '15.0.1' = '10.0' + } +}; + +function xcode_get_sdkname($xcode_ver, $target, $simulator = $false) { + $xcode_ver_nums = $xcode_ver.Split('.') + if ($xcode_ver_nums.Count -lt 3) { + $xcode_ver += '.0' + } + $target_sdks = $xcode_sdks_map[$target] + if ($target_sdks) { + $sdk_ver = $target_sdks[$xcode_ver] + if ($sdk_ver) { + switch ($target) { + 'osx' { Write-Output "macosx$sdk_ver" } + 'ios' { Write-Output "$(@('iphoneos', 'iphonesimulator')[$simulator])$sdk_ver" } + 'tvos' { Write-Output "$(@('appletvos', 'appletvsimulator')[$simulator])$sdk_ver" } + 'watchos' { Write-Output "$(@('watchos', 'watchsimulator')[$simulator])$sdk_ver" } + } + } + } +} diff --git a/README.md b/README.md index f0dd62a..a7ae3a7 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ A cross-platform one step build powershell script with auto setup general dependent tools. Your programing life will relex if you're using 1k! -[![Release](https://img.shields.io/github/v/release/axmolengine/buildware?include_prereleases&label=release)](../../releases/latest) -[![build](https://github.com/axmolengine/buildware/actions/workflows/build.yml/badge.svg)](https://github.com/axmolengine/buildware/actions/workflows/build.yml) -[![dist](https://github.com/axmolengine/buildware/actions/workflows/dist.yml/badge.svg)](https://github.com/axmolengine/buildware/actions/workflows/dist.yml) -[![Downloads](https://img.shields.io/github/downloads/axmolengine/buildware/total.svg?label=downloads&colorB=orange)](../../releases/latest) +[![Release](https://img.shields.io/github/v/release/simdsoft/1kiss?include_prereleases&label=release)](../../releases/latest) +[![build](https://github.com/simdsoft/1kiss/actions/workflows/build.yml/badge.svg)](https://github.com/simdsoft/1kiss/actions/workflows/build.yml) +[![dist](https://github.com/simdsoft/1kiss/actions/workflows/dist.yml/badge.svg)](https://github.com/simdsoft/1kiss/actions/workflows/dist.yml) +[![Downloads](https://img.shields.io/github/downloads/simdsoft/1kiss/total.svg?label=downloads&colorB=orange)](../../releases/latest) ## opensources - [![zlib](https://img.shields.io/badge/zlib-green.svg)](https://github.com/madler/zlib) diff --git a/build.ps1 b/build.ps1 index c200040..df3ebbc 100644 --- a/build.ps1 +++ b/build.ps1 @@ -14,16 +14,15 @@ function mkdirs($path) { } } -println "env:NO_DLL=$env:NO_DLL" +$_1k_root = $PSScriptRoot +println "1kiss: _1k_root=$_1k_root" + +println "1kiss: env:NO_DLL=$env:NO_DLL" if ($target_arch -eq 'amd64_arm64') { $target_arch = 'arm64' } -$_1k_root = $PSScriptRoot - -println "_1k_root=$_1k_root" - $build_script = Join-Path "$_1k_root" "1k/build.ps1" $fetchd_script = Join-Path "$_1k_root" "1k/fetchd.ps1" $build_src = Join-Path $_1k_root "buildsrc_$target_os" @@ -57,12 +56,21 @@ if ($target_os -eq 'android') { $Global:android_api_level = @{arm64 = 21; x64 = 22; armv7 = 16; x86 = 16}[$target_arch] } elseif ($is_apple_family) { - # compile nsdk1k on macOS - echo "1kiss: XCODE_VERSION=$env:XCODE_VERSION" - $1kiss_bin = Join-Path ~/.1kiss "bin" - mkdirs $1kiss_bin - g++ -std=c++17 1k/nsdk1k.cpp -o $1kiss_bin/nsdk1k - $env:PATH = "${1kiss_bin}:${env:PATH}" + # query xcode version + $xcode_ver_str = xcodebuild -version | Select-Object -First 1 + if ($xcode_ver_str) { + $matchInfo = [Regex]::Match($xcode_ver_str, '(\d+\.)+(\*|\d+)(\-[a-z]+[0-9]*)?') + $Global:XCODE_VERSION = $matchInfo.Value + } + + if (!$Global:XCODE_VERSION) { + throw "1kiss: query XCODE_VERSION fail" + } + + println "1kiss: XCODE_VERSION=$Global:XCODE_VERSION" + + # require xcutils.ps1 for xcode_get_sdkname + . $(Join-Path $_1k_root '1k/xcutils.ps1') } mkdirs $install_root diff --git a/src/luajit/build1.ps1 b/src/luajit/build1.ps1 index c9a32a2..cf3695c 100644 --- a/src/luajit/build1.ps1 +++ b/src/luajit/build1.ps1 @@ -40,17 +40,12 @@ else { $CONFIG_TARGET = @("HOST_CC=$HOST_CC", "CROSS=$NDKCROSS", "STATIC_CC=$NDKCC", "DYNAMIC_CC=`"$NDKCC -fPIC`"", "TARGET_LD=$NDKCC", "TARGET_SYS=`"Linux`"") } elseif ($is_apple_family) { - if (!$env:XCODE_VERSION) { throw "Missing env var: XCODE_VERSION" } if ($target_os -eq 'osx') { $env:MACOSX_DEPLOYMENT_TARGET = '10.12' } # regard ios,tvos x64 as simulator - if ($target_arch -eq 'x64' -and ($target_os -eq 'ios' -or $target_os -eq 'tvos')) { - $SDK_NAME = $(nsdk1k $env:XCODE_VERSION $target_os 1) - } - else { - $SDK_NAME = $(nsdk1k $env:XCODE_VERSION $target_os) - } + $use_simulator_sdk = ($target_os -eq 'ios' -or $target_os -eq 'tvos') -and $target_arch -eq 'x64' + $SDK_NAME = $(xcode_get_sdkname $XCODE_VERSION $target_os $use_simulator_sdk) println "SDK_NAME=$SDK_NAME" $target_uarch = $target_arch diff --git a/src/openssl/build1.ps1 b/src/openssl/build1.ps1 index e667c45..d027090 100644 --- a/src/openssl/build1.ps1 +++ b/src/openssl/build1.ps1 @@ -51,17 +51,16 @@ else { } elseif ($target_os -eq 'ios' -or $target_os -eq 'tvos') { # Export OPENSSL_LOCAL_CONFIG_DIR for perl script file 'openssl/Configure' - $env:OPENSSL_LOCAL_CONFIG_DIR = Join-Path $_1k_root '1k' + $env:OPENSSL_LOCAL_CONFIG_DIR = Join-Path $_1k_root '1k' + $ossl_target_os = "$target_os-" $ios_plat_suffix = 'OS' - if ( $target_arch -eq 'x64' ) { - # asume x64 as simulator - $TARGET_OPTIONS += "ios-sim-cross-$target_uarch" + if ( $target_arch -eq 'x64' ) { # asume x64 as simulator + $ossl_target_os += 'sim-' $ios_plat_suffix = 'Simulator' } - else { - $TARGET_OPTIONS += "ios-cross-$target_arch" - } + $ossl_target_os += "cross-$target_uarch" + $TARGET_OPTIONS += $ossl_target_os $IOS_PLAT = if ($target_os -eq 'ios') { "iPhone${ios_plat_suffix}" } else { "AppleTV${ios_plat_suffix}" }