Skip to content

Commit

Permalink
Improve scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Mar 24, 2024
1 parent 4411c6a commit 9ed19a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
3 changes: 3 additions & 0 deletions 1k/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ $toolchains = @{
if (!$TOOLCHAIN) {
$TOOLCHAIN = $toolchains[$TARGET_OS]
}
if (!$TOOLCHAIN) {
throw "1kiss: Unsupported target os: $TARGET_OS"
}
$TOOLCHAIN_INFO = $TOOLCHAIN.Split('-')
$TOOLCHAIN_VER = $null
if ($TOOLCHAIN_INFO.Count -ge 2) {
Expand Down
20 changes: 7 additions & 13 deletions 1k/fetch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function fetch_repo($url, $name, $dest, $ext) {
else {
$out = Join-Path $cache_dir "${name}$ext"
download_file $url $out

try {
if ($ext -eq '.zip') {
Expand-Archive -Path $out -DestinationPath $prefix -Force
Expand All @@ -55,10 +54,11 @@ function fetch_repo($url, $name, $dest, $ext) {
}
}
catch {
throw "fetch.ps1: extract $out failed, $_"
Remove-Item $out -Force
throw "fetch.ps1: extract $out failed, try again"
}

if (!(Test-Path $dest)) {
if (!(Test-Path $dest -PathType Container)) {
throw "fetch.ps1: the package name mismatch for $out"
}
}
Expand Down Expand Up @@ -175,12 +175,8 @@ if (!$revision) {
}
if ($is_git_repo) {
$old_rev_hash = $(git -C $lib_src rev-parse HEAD)

$tag_info = git -C $lib_src tag | Select-String $revision
if ($tag_info) {
$revision = ([array]$tag_info.Line)[0]
}

if ($tag_info) { $revision = ([array]$tag_info.Line)[0] }
$cur_rev_hash = $(git -C $lib_src rev-parse --verify --quiet "$revision^{}")

if (!$cur_rev_hash) {
Expand All @@ -193,9 +189,7 @@ if ($is_git_repo) {

if ($old_rev_hash -ne $cur_rev_hash) {
git -C $lib_src checkout $revision 1>$null 2>$null

$new_rev_hash = $(git -C $lib_src rev-parse HEAD)

println "fetch.ps1: Checked out to $revision@$new_rev_hash"

if (!$is_rev_modified) {
Expand All @@ -209,7 +203,6 @@ if ($is_git_repo) {

if ($is_rev_modified) {
$sentry_content = "ver: $version"

if ($is_git_repo) {
$branch_name = $(git -C $lib_src branch --show-current)
if ($branch_name) {
Expand All @@ -225,15 +218,16 @@ if ($is_rev_modified) {

[System.IO.File]::WriteAllText($sentry, $sentry_content)

git -C $lib_src add '_1kiss'
if ($is_git_repo) { git -C $lib_src add '_1kiss' }
}

# google gclient spec
if (Test-Path (Join-Path $lib_src '.gn') -PathType Leaf) {
# the repo use google gn build system manage deps and build
Push-Location $lib_src
# angle (A GLES native implementation by google)
if (Test-Path 'scripts/bootstrap.py' -PathType Leaf) {
if (Test-Path 'scripts/bootstrap.py' -PathType Leaf)
{
python scripts/bootstrap.py
}
# darwin (A WebGPU native implementation by google)
Expand Down

0 comments on commit 9ed19a3

Please sign in to comment.