Fix docs menu_versions

This commit is contained in:
halx99 2024-05-20 23:46:48 +08:00
parent c07139544b
commit d9563d1741
4 changed files with 86 additions and 65 deletions

View File

@ -1572,6 +1572,7 @@ $is_host_target = $Global:is_win32 -or $Global:is_linux -or $Global:is_mac
if (!$setupOnly) {
$BUILD_DIR = $null
$SOURCE_DIR = $null
function resolve_out_dir($prefix, $sub_prefix) {
if (!$prefix) {
@ -1690,7 +1691,7 @@ if (!$setupOnly) {
}
$INST_DIR = $null
$xopts_hints = 2
$xopts_hints = 3
$xopt_presets = 0
$xprefix_optname = '-DCMAKE_INSTALL_PREFIX='
$xopts = [array]$options.xc
@ -1699,6 +1700,10 @@ if (!$setupOnly) {
$BUILD_DIR = $opt.Substring(2).Trim()
++$xopt_presets
}
elseif($opts.StartsWith('-S')) {
$SOURCE_DIR = $opt.Substring(2).Trim()
++$xopt_presets
}
elseif ($opt.StartsWith($xprefix_optname)) {
++$xopt_presets
$INST_DIR = $opt.SubString($xprefix_optname.Length)
@ -1768,7 +1773,8 @@ if (!$setupOnly) {
else {
# step3. configure
$workDir = $(Get-Location).Path
$mainDep = Join-Path $workDir 'CMakeLists.txt'
$cmakeEntryFile = 'CMakeLists.txt'
$mainDep = if (!$SOURCE_DIR) { Join-Path $workDir $cmakeEntryFile } else { realpath (Join-Path $SOURCE_DIR $cmakeEntryFile) }
if ($1k.isfile($mainDep)) {
$mainDepChanged = $false
# A Windows file time is a 64-bit value that represents the number of 100-nanosecond
@ -1825,7 +1831,7 @@ if (!$setupOnly) {
}
}
else {
$1k.println("Missing CMakeLists.txt in $workDir")
$1k.println("Missing file: $cmakeEntryFile")
}
}

View File

@ -152,7 +152,7 @@ Set-Variable -Name "${name}_src" -Value $lib_src -Scope global
$sentry = Join-Path $lib_src '_1kiss'
$need_update = $false
$is_rev_mod = $false # indicate whether rev already modfied or updated
# if sentry file missing, re-clone
if (!(Test-Path $sentry -PathType Leaf)) {
if (Test-Path $lib_src -PathType Container) {
@ -163,11 +163,12 @@ if (!(Test-Path $sentry -PathType Leaf)) {
if (Test-Path $lib_src -PathType Container) {
New-Item $sentry -ItemType File 1>$null
$need_update = $true
}
else {
throw "fetch.ps1: fetch content from $url failed"
}
$is_rev_mod = $true
}
# re-check does valid local git repo
@ -182,48 +183,49 @@ if (!$revision) {
}
$branch_name = $null
$tracking_branch = $false
if ($is_git_repo) {
$old_rev_hash = $(git -C $lib_src rev-parse HEAD)
$cur_rev_hash = $(git -C $lib_src rev-parse --verify --quiet "$revision^{}")
if (!$cur_rev_hash) {
git -C $lib_src fetch
$cur_rev_hash = $(git -C $lib_src rev-parse --verify --quiet "$revision^{}")
if (!$cur_rev_hash) {
throw "fetch.ps1: Could not found commit hash of $revision"
}
}
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 (!$need_update) {
$need_update = $old_rev_hash -ne $new_rev_hash
$branch_name = $(git -C $lib_src branch --show-current)
$tracking_branch = $revision -eq $branch_name
if (!$tracking_branch) {
$new_rev_hash = $(git -C $lib_src rev-parse --verify --quiet "$revision^{}")
if (!$new_rev_hash) {
git -C $lib_src fetch
$new_rev_hash = $(git -C $lib_src rev-parse --verify --quiet "$revision^{}")
if (!$new_rev_hash) {
throw "fetch.ps1: Could not found commit hash of $revision"
}
}
if ((Test-Path (Join-Path $lib_src '.gitmodules') -PathType Leaf)) {
git -C $lib_src submodule update --recursive --init
if ($old_rev_hash -ne $new_rev_hash) {
git -C $lib_src checkout $revision 1>$null 2>$null
$cur_rev_hash = $(git -C $lib_src rev-parse HEAD)
if ($cur_rev_hash -ne $new_rev_hash) {
println "fetch.ps1: warning: cur_rev_hash($cur_rev_hash) != new_rev_hash($new_rev_hash)"
}
if ((Test-Path (Join-Path $lib_src '.gitmodules') -PathType Leaf)) {
git -C $lib_src submodule update --recursive --init
}
$is_rev_mod = $true
}
}
if (!$need_update) {
$branch_name = $(git -C $lib_src branch --show-current)
$need_update = ($branch_name -eq $revision) -and $pull_branch
}
if(!$need_update) {
println "fetch.ps1: HEAD is now at $revision@$cur_rev_hash"
elseif ($pull_branch -and !$is_rev_mod) {
git -C $lib_src pull
$cur_rev_hash = $(git -C $lib_src rev-parse HEAD)
$is_rev_mod = $old_rev_hash -ne $cur_rev_hash
}
}
if ($need_update) {
if ($is_rev_mod) {
$sentry_content = "ver: $version"
if ($is_git_repo) {
if ($branch_name) {
# track branch
git -C $lib_src pull
if ($tracking_branch) {
# tracking branch
$commits = $(git -C $lib_src rev-list --count HEAD)
$sentry_content += "`nbranch: $branch_name"
$sentry_content += "`ncommits: $commits"
@ -231,6 +233,9 @@ if ($need_update) {
$sentry_content += "`nrev: $revision"
println "fetch.ps1: HEAD is now at $branch_name@$revision"
}
else {
println "fetch.ps1: HEAD is now at $revision@$cur_rev_hash"
}
}
[System.IO.File]::WriteAllText($sentry, $sentry_content)

View File

@ -1,7 +1,7 @@
(function() {
'use strict';
var url_re = /(axmol\.org\/manual\/)(latest|(\d\.\d+|\d\.\d+\.\d+)(-beta\d)?)\//;
var url_re = /(axmol\.dev\/manual\/)(latest|(\d\.\d+|\d\.\d+\.\d+)(-beta\d)?)\//;
var url_local = /docs\/dist\/manual\/(latest|(\d\.\d+|\d\.\d+\.\d+)(-beta\d)?)\//;
var current_version_local = '@VERSION@'
var all_versions = [

View File

@ -1,6 +1,11 @@
# Can runs on Windows,Linux
$wasm_artifact_dir = (Resolve-Path $args[0]).Path
param(
$wasm_artifact_dir = $null
)
if ($wasm_artifact_dir) {
$wasm_artifact_dir = (Resolve-Path $wasm_artifact_dir).Path
}
$myRoot = $PSScriptRoot
$isWin = $IsWindows -or ("$env:OS" -eq 'Windows_NT')
@ -16,7 +21,7 @@ function mkdirs([string]$path) {
}
function download_file($url, $out) {
if(Test-Path $out -PathType Leaf) { return }
if (Test-Path $out -PathType Leaf) { return }
Write-Host "Downloading $url to $out ..."
if ($pwsh_ver -ge '7.0') {
curl -L $url -o $out
@ -43,7 +48,7 @@ if (!(Test-Path "$prefix" -PathType Container)) {
function setup_doxygen() {
$doxygen_ver = '1.9.7'
$doxygen_pkg_name = if ($isWin) {"doxygen-$doxygen_ver.windows.x64.bin.zip"} else {"doxygen-$doxygen_ver.linux.bin.tar.gz"}
$doxygen_pkg_name = if ($isWin) { "doxygen-$doxygen_ver.windows.x64.bin.zip" } else { "doxygen-$doxygen_ver.linux.bin.tar.gz" }
$doxygen_pkg_path = Join-Path $prefix $doxygen_pkg_name
if (!(Test-Path $doxygen_pkg_path -PathType Leaf)) {
@ -68,7 +73,7 @@ function setup_doxygen() {
}
if ($env:PATH.IndexOf($doxygen_bin) -eq -1) {
$envPathSep = if($isWin) {';'} else {':'}
$envPathSep = if ($isWin) { ';' } else { ':' }
$env:PATH = "$doxygen_bin$envPathSep$env:PATH"
}
}
@ -88,7 +93,7 @@ function query_axmol_latest() {
$axver = "$(parse_axver 'MAJOR').$(parse_axver 'MINOR').$(parse_axver 'PATCH')"
$git_prog = (Get-Command 'git' -ErrorAction SilentlyContinue).Source
if($git_prog) {
if ($git_prog) {
Write-Host "Found git: $git_prog"
$branchName = $(git -C $AX_ROOT branch --show-current)
if ($branchName -eq 'dev') {
@ -108,38 +113,40 @@ Set-Location $site_src
function configure_file($infile, $outfile, $vars) {
$content = $(Get-Content $infile -raw)
foreach($var in $vars.GetEnumerator()) {
foreach ($var in $vars.GetEnumerator()) {
$content = [Regex]::Replace($content, $var.Key, $var.Value)
}
Set-Content -Path $outfile -Value "$content"
}
# build site_dist2 aka isolated site wasm demos preview with pthread support
$site_dist2 = Join-Path $site_src 'dist2'
$wasm_dist2 = Join-Path $site_dist2 'wasm/'
mkdirs $wasm_dist2
Copy-Item $(Join-Path $site_src 'isolated.html') $(Join-Path $site_dist2 'index.html')
Copy-Item $(Join-Path $site_src '_headers') $site_dist2
function copy_tree_if($source, $dest) {
if (Test-Path $source) {
Copy-Item $source $dest -Container -Recurse
if ($wasm_artifact_dir) {
$site_dist2 = Join-Path $site_src 'dist2'
$wasm_dist2 = Join-Path $site_dist2 'wasm/'
mkdirs $wasm_dist2
Copy-Item $(Join-Path $site_src 'isolated.html') $(Join-Path $site_dist2 'index.html')
Copy-Item $(Join-Path $site_src '_headers') $site_dist2
function copy_tree_if($source, $dest) {
if (Test-Path $source) {
Copy-Item $source $dest -Container -Recurse
}
}
}
$cpp_tests_dir = $(Join-Path $wasm_artifact_dir 'cpp-tests')
if (!(Test-Path $cpp_tests_dir -PathType Container)) {
throw "Missing wasm cpp-tests, caused by last wasm ci build fail."
$cpp_tests_dir = $(Join-Path $wasm_artifact_dir 'cpp-tests')
if (!(Test-Path $cpp_tests_dir -PathType Container)) {
throw "Missing wasm cpp-tests, caused by last wasm ci build fail."
}
copy_tree_if $cpp_tests_dir $wasm_dist2
copy_tree_if $(Join-Path $wasm_artifact_dir 'fairygui-tests') $wasm_dist2
copy_tree_if $(Join-Path $wasm_artifact_dir 'HelloLua') $wasm_dist2
}
copy_tree_if $cpp_tests_dir $wasm_dist2
copy_tree_if $(Join-Path $wasm_artifact_dir 'fairygui-tests') $wasm_dist2
copy_tree_if $(Join-Path $wasm_artifact_dir 'HelloLua') $wasm_dist2
# build manuals
# query version map to build docs
$release_tags = $(git tag)
$verMap = @{'latest' = $null; }
foreach($item in $release_tags) {
foreach ($item in $release_tags) {
if ([Regex]::Match($item, '^v[0-9]+\.[0-9]+\.[0-9]+$').Success) {
$docVer = $($item.Split('.')[0..1] -join '.').TrimStart('v')
$verMap[$docVer] = $item
@ -151,7 +158,7 @@ Write-Host "$(Out-String -InputObject $verMap)"
# set default doc ver to 'latest'
mkdirs "$site_dist/manual"
configure_file './doc_index.html.in' "$site_dist/manual/index.html" @{'@VERSION@' = 'latest'}
configure_file './doc_index.html.in' "$site_dist/manual/index.html" @{'@VERSION@' = 'latest' }
# build home site
mkdirs "$site_dist/assets/css"
@ -163,12 +170,12 @@ Copy-Item './logo.png' "$site_dist/logo.png"
$branches = $(git branch -a)
$canon_branches = @{}
foreach($branch in $branches) {
foreach ($branch in $branches) {
$canon_branches[$branch.Trim()] = $true
}
# build manuals
foreach($item in $verMap.GetEnumerator()) {
foreach ($item in $verMap.GetEnumerator()) {
$ver = $item.Key
$html_out = Join-Path $site_dist "manual/$ver"
mkdirs $html_out
@ -177,12 +184,15 @@ foreach($item in $verMap.GetEnumerator()) {
if ($ver -eq 'latest') {
git checkout dev
$release_tag = query_axmol_latest
} elseif($canon_branches.Contains($ver)) { # prefer LTS branch
}
elseif ($canon_branches.Contains($ver)) {
# prefer LTS branch
git checkout $ver
} else {
}
else {
git checkout $release_tag
}
configure_file './Doxyfile.in' './Doxyfile' @{'@VERSION@'=$release_tag; '@HTML_OUTPUT@' = "manual/$ver"}
configure_file './Doxyfile.in' './Doxyfile' @{'@VERSION@' = $release_tag; '@HTML_OUTPUT@' = "manual/$ver" }
Write-Host "Generating docs for $ver ..." -NoNewline
doxygen "./Doxyfile" # 1>$null 2>$null
@ -190,7 +200,7 @@ foreach($item in $verMap.GetEnumerator()) {
Copy-Item './hacks.js' $html_out
Copy-Item './doc_style.css' "$html_out/stylesheet.css"
configure_file './menu_version.js.in' "$html_out/menu_version.js" @{'@VERLIST@' = $strVerList; '@VERSION@' = $ver}
configure_file './menu_version.js.in' "$html_out/menu_version.js" @{'@VERLIST@' = $strVerList; '@VERSION@' = $ver }
}
# redirect cpp_tests.html to isolated site