Skip to content

Commit 364ce82

Browse files
committed
Download packages to folder axmol/cache
1 parent 444d143 commit 364ce82

File tree

3 files changed

+46
-32
lines changed

3 files changed

+46
-32
lines changed

1k/1kiss.ps1

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -459,19 +459,24 @@ if (!$TOOLCHAIN_VER) {
459459
$Global:is_clang = $TOOLCHAIN_NAME -eq 'clang'
460460
$Global:is_msvc = $TOOLCHAIN_NAME -eq 'msvc'
461461

462-
$external_prefix = if ($options.prefix) { $options.prefix } else { Join-Path $HOME '.1kiss' }
463-
if (!$1k.isdir($external_prefix)) {
464-
$1k.mkdirs($external_prefix)
465-
}
466-
467-
$1k.println("proj_dir=$((Get-Location).Path), external_prefix=$external_prefix")
468-
469462
# load toolset manifest
470463
$manifest_file = Join-Path $myRoot 'manifest.ps1'
471464
if ($1k.isfile($manifest_file)) {
472465
. $manifest_file
473466
}
474467

468+
$install_prefix = if ($options.prefix) { $options.prefix } else { Join-Path $HOME '.1kiss' }
469+
if (!$1k.isdir($install_prefix)) {
470+
$1k.mkdirs($install_prefix)
471+
}
472+
if ($Global:download_path) {
473+
$1k.mkdirs($Global:download_path)
474+
} else {
475+
$Global:download_path = $install_prefix
476+
}
477+
478+
$1k.println("proj_dir=$((Get-Location).Path), install_prefix=$install_prefix")
479+
475480
# 1kdist
476481
$sentry_file = Join-Path $myRoot '.gitee'
477482
$mirror = if ($1k.isfile($sentry_file)) { 'gitee' } else { 'github' }
@@ -745,11 +750,18 @@ function download_and_expand($url, $out, $dest) {
745750
}
746751
}
747752

748-
function resolve_path ($path) { if ($1k.isabspath($path)) { $path } else { Join-Path $external_prefix $path } }
753+
function resolve_path ($path, $prefix = $null) {
754+
if ($1k.isabspath($path)) {
755+
return $path
756+
} else {
757+
if(!$prefix) { $prefix = $install_prefix }
758+
return Join-Path $prefix $path
759+
}
760+
}
749761

750762
function fetch_pkg($url, $out = $null, $exrep = $null, $prefix = $null) {
751-
if (!$out) { $out = Join-Path $external_prefix $(Split-Path $url.Split('?')[0] -Leaf) }
752-
else { $out = resolve_path $out }
763+
if (!$out) { $out = Join-Path $download_path $(Split-Path $url.Split('?')[0] -Leaf) }
764+
else { $out = resolve_path $out $download_path }
753765

754766
$pfn_rename = $null
755767

@@ -778,7 +790,7 @@ function fetch_pkg($url, $out = $null, $exrep = $null, $prefix = $null) {
778790
if ($1k.isdir($inst_dst)) { $1k.rmdirs($inst_dst) }
779791
}
780792
} else {
781-
$prefix = $external_prefix
793+
$prefix = $install_prefix
782794
}
783795

784796
download_and_expand $url $out $prefix
@@ -879,7 +891,7 @@ else {
879891
# setup nuget, not add to path
880892
function setup_nuget() {
881893
if (!$manifest['nuget']) { return $null }
882-
$nuget_bin = Join-Path $external_prefix 'nuget'
894+
$nuget_bin = Join-Path $install_prefix 'nuget'
883895
$nuget_prog, $nuget_ver = find_prog -name 'nuget' -path $nuget_bin -mode 'BOTH' -params 'help' -silent $true
884896
if (!$nuget_prog) {
885897
$1k.rmdirs($nuget_bin)
@@ -918,7 +930,7 @@ function setup_python3() {
918930
# setup axslcc, not add to path
919931
function setup_axslcc() {
920932
if (!$manifest['axslcc']) { return $null }
921-
$axslcc_bin = Join-Path $external_prefix 'axslcc'
933+
$axslcc_bin = Join-Path $install_prefix 'axslcc'
922934
$axslcc_prog, $axslcc_ver = find_prog -name 'axslcc' -path $axslcc_bin -mode 'BOTH'
923935
if ($axslcc_prog) {
924936
return $axslcc_prog
@@ -949,7 +961,7 @@ function setup_axslcc() {
949961
function setup_ninja() {
950962
if (!$manifest['ninja']) { return $null }
951963
$suffix = $('win', 'linux', 'mac').Get($HOST_OS)
952-
$ninja_bin = Join-Path $external_prefix 'ninja'
964+
$ninja_bin = Join-Path $install_prefix 'ninja'
953965
$ninja_prog, $ninja_ver = find_prog -name 'ninja'
954966
if ($ninja_prog) {
955967
return $ninja_prog
@@ -973,7 +985,7 @@ function setup_cmake($skipOS = $false) {
973985
return $cmake_prog, $cmake_ver
974986
}
975987

976-
$cmake_root = $(Join-Path $external_prefix 'cmake')
988+
$cmake_root = $(Join-Path $install_prefix 'cmake')
977989
$cmake_bin = Join-Path $cmake_root 'bin'
978990
$cmake_prog, $cmake_ver = find_prog -name 'cmake' -path $cmake_bin -mode 'ONLY' -silent $true
979991
if (!$cmake_prog) {
@@ -987,7 +999,7 @@ function setup_cmake($skipOS = $false) {
987999
$cmake_pkg_name = "cmake-$cmake_ver-$HOST_OS_NAME-universal"
9881000
}
9891001

990-
$cmake_pkg_path = Join-Path $external_prefix "$cmake_pkg_name$cmake_suffix"
1002+
$cmake_pkg_path = Join-Path $install_prefix "$cmake_pkg_name$cmake_suffix"
9911003

9921004
$assemble_url = $channels['cmake']
9931005
if (!$assemble_url) {
@@ -997,7 +1009,7 @@ function setup_cmake($skipOS = $false) {
9971009
$cmake_url = & $assemble_url -FileName "$cmake_pkg_name$cmake_suffix"
9981010
}
9991011

1000-
$cmake_dir = Join-Path $external_prefix $cmake_pkg_name
1012+
$cmake_dir = Join-Path $install_prefix $cmake_pkg_name
10011013
if ($IsMacOS) {
10021014
$cmake_app_contents = Join-Path $cmake_dir 'CMake.app/Contents'
10031015
}
@@ -1058,7 +1070,7 @@ function ensure_cmake_ninja($cmake_prog, $ninja_prog) {
10581070

10591071
function setup_nsis() {
10601072
if (!$manifest['nsis']) { return $null }
1061-
$nsis_bin = Join-Path $external_prefix "nsis"
1073+
$nsis_bin = Join-Path $install_prefix "nsis"
10621074
$nsis_prog, $nsis_ver = find_prog -name 'nsis' -cmd 'makensis' -params '/VERSION'
10631075
if ($nsis_prog) {
10641076
return $nsis_prog
@@ -1076,11 +1088,11 @@ function setup_nsis() {
10761088

10771089
function setup_nasm() {
10781090
if (!$manifest['nasm']) { return $null }
1079-
$nasm_prog, $nasm_ver = find_prog -name 'nasm' -path "$external_prefix/nasm" -mode 'BOTH' -silent $true
1091+
$nasm_prog, $nasm_ver = find_prog -name 'nasm' -path "$install_prefix/nasm" -mode 'BOTH' -silent $true
10801092

10811093
if (!$nasm_prog) {
10821094
if ($IsWin) {
1083-
$nasm_bin = Join-Path $external_prefix "nasm-$nasm_ver"
1095+
$nasm_bin = Join-Path $install_prefix "nasm-$nasm_ver"
10841096
if (!$1k.isdir($nasm_bin)) {
10851097
fetch_pkg "https://www.nasm.us/pub/nasm/releasebuilds/$nasm_ver/win64/nasm-$nasm_ver-win64.zip"
10861098
}
@@ -1096,7 +1108,7 @@ function setup_nasm() {
10961108
}
10971109
}
10981110

1099-
$nasm_prog, $nasm_ver = find_prog -name 'nasm' -path "$external_prefix/nasm" -mode 'BOTH' -silent $true
1111+
$nasm_prog, $nasm_ver = find_prog -name 'nasm' -path "$install_prefix/nasm" -mode 'BOTH' -silent $true
11001112
if ($nasm_prog) {
11011113
$1k.println("Using nasm: $nasm_prog, version: $nasm_ver")
11021114
}
@@ -1111,7 +1123,7 @@ function setup_jdk() {
11111123
return $javac_prog
11121124
}
11131125

1114-
$jdk_root = Join-Path $external_prefix "jdk"
1126+
$jdk_root = Join-Path $install_prefix "jdk"
11151127
$java_home = if (!$IsMacOS) { $jdk_root } else { Join-Path $jdk_root 'Contents/Home' }
11161128
$jdk_bin = Join-Path $java_home 'bin'
11171129

@@ -1155,7 +1167,7 @@ function setup_7z() {
11551167
$7z_cmd_info = Get-Command '7z' -ErrorAction SilentlyContinue
11561168
if (!$7z_cmd_info) {
11571169
if ($IsWin) {
1158-
$7z_prog = Join-Path $external_prefix '7z2301-x64/7z.exe'
1170+
$7z_prog = Join-Path $install_prefix '7z2301-x64/7z.exe'
11591171
if (!$1k.isfile($7z_prog)) {
11601172
fetch_pkg $(devtool_url '7z2301-x64.zip')
11611173
}
@@ -1181,7 +1193,7 @@ function setup_llvm() {
11811193
if (!$manifest.Contains('llvm')) { return $null }
11821194
$clang_prog, $clang_ver = find_prog -name 'llvm' -cmd "clang"
11831195
if (!$clang_prog) {
1184-
$llvm_root = Join-Path $external_prefix 'LLVM'
1196+
$llvm_root = Join-Path $install_prefix 'LLVM'
11851197
$llvm_bin = Join-Path $llvm_root 'bin'
11861198
$clang_prog, $clang_ver = find_prog -name 'llvm' -cmd "clang" -path $llvm_bin -silent $true
11871199
if (!$clang_prog) {
@@ -1210,7 +1222,7 @@ function setup_android_sdk() {
12101222
$ndk_ver = $ndk_ver.Substring(0, $ndk_ver.Length - 1)
12111223
}
12121224

1213-
$my_sdk_root = Join-Path $external_prefix 'adt/sdk'
1225+
$my_sdk_root = Join-Path $install_prefix 'adt/sdk'
12141226

12151227
$sdk_dirs = @()
12161228
$1k.insert([ref]$sdk_dirs, $env:ANDROID_HOME)
@@ -1278,24 +1290,24 @@ function setup_android_sdk() {
12781290
$sdkmanager_prog, $sdkmanager_ver = (find_prog -name 'cmdlinetools' -cmd 'sdkmanager' -path $cmdlinetools_bin -params "--version", "--sdk_root=$sdk_root")
12791291
}
12801292
else {
1281-
$sdk_root = Join-Path $external_prefix 'adt/sdk'
1293+
$sdk_root = Join-Path $install_prefix 'adt/sdk'
12821294
if (!$1k.isdir($sdk_root)) {
12831295
$1k.mkdirs($sdk_root)
12841296
}
12851297
}
12861298

12871299
if (!$sdkmanager_prog) {
1288-
$cmdlinetools_bin = Join-Path $external_prefix 'cmdline-tools/bin'
1300+
$cmdlinetools_bin = Join-Path $install_prefix 'cmdline-tools/bin'
12891301
$sdkmanager_prog, $sdkmanager_ver = (find_prog -name 'cmdlinetools' -cmd 'sdkmanager' -path $cmdlinetools_bin -params "--version", "--sdk_root=$sdk_root")
12901302
$suffix = $('win', 'linux', 'mac').Get($HOST_OS)
12911303
if (!$sdkmanager_prog) {
12921304
$1k.println("Installing cmdlinetools version: $sdkmanager_ver ...")
12931305

12941306
$cmdlinetools_pkg_name = "commandlinetools-$suffix-$($cmdlinetools_rev)_latest.zip"
1295-
$cmdlinetools_pkg_path = Join-Path $external_prefix $cmdlinetools_pkg_name
1307+
$cmdlinetools_pkg_path = Join-Path $install_prefix $cmdlinetools_pkg_name
12961308
$cmdlinetools_url = "https://dl.google.com/android/repository/$cmdlinetools_pkg_name"
12971309
download_file $cmdlinetools_url $cmdlinetools_pkg_path
1298-
Expand-Archive -Path $cmdlinetools_pkg_path -DestinationPath "$external_prefix/"
1310+
Expand-Archive -Path $cmdlinetools_pkg_path -DestinationPath "$install_prefix/"
12991311
$sdkmanager_prog, $_ = (find_prog -name 'cmdlinetools' -cmd 'sdkmanager' -path $cmdlinetools_bin -params "--version", "--sdk_root=$sdk_root" -silent $True)
13001312
if (!$sdkmanager_prog) {
13011313
throw "Install cmdlinetools version: $sdkmanager_ver fail"
@@ -1380,7 +1392,7 @@ function setup_emsdk() {
13801392
$1k.println('Not found emcc toolchain in $env:PATH, setup emsdk ...')
13811393
$emsdk_cmd = (Get-Command emsdk -ErrorAction SilentlyContinue)
13821394
if (!$emsdk_cmd) {
1383-
$emsdk_root = Join-Path $external_prefix 'emsdk'
1395+
$emsdk_root = Join-Path $install_prefix 'emsdk'
13841396
if (!$1k.isdir($emsdk_root)) {
13851397
git clone 'https://github.com/emscripten-core/emsdk.git' $emsdk_root
13861398
}
@@ -1461,7 +1473,7 @@ function setup_gclient() {
14611473
# setup gclient tool
14621474
# download depot_tools
14631475
# git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $gclient_dir
1464-
$gclient_dir = Join-Path $external_prefix 'depot_tools'
1476+
$gclient_dir = Join-Path $install_prefix 'depot_tools'
14651477
if (!$1k.isdir($gclient_dir)) {
14661478
if ($IsWin) {
14671479
$1k.mkdirs($gclient_dir)

1k/manifest.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ if ($Global:is_axmol_app -or $Global:is_axmol_engine) {
3030
$android_sdk_tools['platforms'] = "android-$($build_profiles['target_sdk'])"
3131

3232
$Global:build_profiles = $build_profiles
33+
34+
$Global:download_path = $1k.realpath("$PSScriptRoot/../cache")
3335
} else {
3436
$Global:build_profiles = @{}
3537
}

README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Axmol 引擎在 Cocos2d-x v4.0 的基础上进行迭代和改进。现在速度
154154
## 参考链接
155155

156156
- [1kiss](https://github.com/simdsoft/1kiss): 一个由 PowerShell 编写的能够自动配置各平台编译工具链的跨平台构建工具。
157-
- [axmolengine/glslcc](https://github.com/axmolengine/glslcc): 一个 glslcc 的分支, 用于 Axmol 引擎跨平台 Shader 编译工作流
157+
- [axslcc](https://github.com/axmolengine/axslcc): Axmol 引擎专用跨平台 Shader 编译器(fork 自 `glslcc`)
158158
- [Cocos2d-x](https://github.com/cocos2d/cocos2d-x):原 Cocos2d-x 官方引擎仓库。
159159

160160
## Axmol 活跃状态

0 commit comments

Comments
 (0)