2023-06-29 19:46:52 +08:00
|
|
|
|
|
|
|
# Can runs on Windows,Linux
|
2023-09-01 13:36:23 +08:00
|
|
|
$myRoot = $PSScriptRoot
|
2023-06-29 19:46:52 +08:00
|
|
|
|
|
|
|
$isWin = $IsWindows -or ("$env:OS" -eq 'Windows_NT')
|
|
|
|
|
2023-09-01 13:36:23 +08:00
|
|
|
$pwsh_ver = $PSVersionTable.PSVersion.ToString()
|
|
|
|
|
|
|
|
$AX_ROOT = (Resolve-Path $myRoot/../..)
|
2023-06-29 19:46:52 +08:00
|
|
|
|
2023-08-31 21:20:01 +08:00
|
|
|
function mkdirs([string]$path) {
|
|
|
|
if (!(Test-Path $path)) {
|
|
|
|
New-Item $path -ItemType Directory 1>$null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-01 13:36:23 +08:00
|
|
|
function download_file($url, $out) {
|
|
|
|
if($b1k.isfile($out)) { return }
|
|
|
|
$b1k.println("Downloading $url to $out ...")
|
|
|
|
if ($pwsh_ver -ge '7.0') {
|
|
|
|
curl -L $url -o $out
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Invoke-WebRequest -Uri $url -OutFile $out
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function download_zip_expand($url, $out, $dest) {
|
|
|
|
download_file $url $out
|
|
|
|
Expand-Archive -Path $out -DestinationPath $dest
|
|
|
|
}
|
|
|
|
|
|
|
|
$prefix = Join-Path $AX_ROOT 'tools/external'
|
|
|
|
if (!(Test-Path "$prefix" -PathType Container)) {
|
|
|
|
mkdirs $prefix
|
|
|
|
}
|
|
|
|
|
2023-06-29 19:46:52 +08:00
|
|
|
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"}
|
2023-09-01 13:36:23 +08:00
|
|
|
$doxygen_pkg_path = Join-Path $prefix $doxygen_pkg_name
|
2023-06-29 19:46:52 +08:00
|
|
|
|
|
|
|
if (!(Test-Path $doxygen_pkg_path -PathType Leaf)) {
|
|
|
|
$doxygen_ver_ul = $doxygen_ver.Replace('.', '_')
|
|
|
|
Invoke-WebRequest -Uri "https://github.com/doxygen/doxygen/releases/download/Release_$doxygen_ver_ul/$doxygen_pkg_name" -OutFile $doxygen_pkg_path | Out-Host
|
|
|
|
}
|
|
|
|
|
2023-09-01 13:36:23 +08:00
|
|
|
$doxygen_root = Join-Path $prefix "doxygen-$doxygen_ver"
|
2023-06-29 19:46:52 +08:00
|
|
|
$doxygen_bin = $doxygen_root
|
|
|
|
if (!(Test-Path $doxygen_root -PathType Container)) {
|
|
|
|
if ($isWin) {
|
2023-09-01 13:36:23 +08:00
|
|
|
mkdirs $doxygen_root
|
2023-06-29 19:46:52 +08:00
|
|
|
Expand-Archive -Path $doxygen_pkg_path -DestinationPath $doxygen_root
|
|
|
|
}
|
|
|
|
else {
|
2023-09-01 13:36:23 +08:00
|
|
|
tar xvf $doxygen_pkg_path -C $prefix
|
2023-06-29 19:46:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$isWin) {
|
|
|
|
$doxygen_bin += '/bin'
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($env:PATH.IndexOf($doxygen_bin) -eq -1) {
|
|
|
|
$envPathSep = if($isWin) {';'} else {':'}
|
|
|
|
$env:PATH = "$doxygen_bin$envPathSep$env:PATH"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_doxygen
|
|
|
|
|
|
|
|
Write-Host "Using doxygen $(doxygen --version)"
|
2023-08-31 21:20:01 +08:00
|
|
|
function query_axmol_latest() {
|
|
|
|
$axver_file = (Resolve-Path $AX_ROOT/core/axmolver.h.in).Path
|
|
|
|
$content = ($(Get-Content -Path $axver_file) | Select-String 'AX_VERSION_STR')
|
|
|
|
$axver = $content[0].Line.Split(' ')[2].Replace('"', '')
|
|
|
|
|
|
|
|
$git_prog = (Get-Command 'git' -ErrorAction SilentlyContinue).Source
|
|
|
|
if($git_prog) {
|
|
|
|
Write-Host "Found git: $git_prog"
|
|
|
|
$branchName = $(git -C $AX_ROOT branch --show-current)
|
|
|
|
if ($branchName -eq 'dev') {
|
|
|
|
$commitHash = $(git -C $AX_ROOT rev-parse --short=7 HEAD)
|
|
|
|
$axver += "-$commitHash"
|
|
|
|
}
|
2023-06-29 19:46:52 +08:00
|
|
|
}
|
2023-08-31 21:20:01 +08:00
|
|
|
return $axver
|
2023-06-29 19:46:52 +08:00
|
|
|
}
|
|
|
|
|
2023-09-01 13:36:23 +08:00
|
|
|
$site_src = (Resolve-Path "$myRoot/../../docs").Path
|
2023-08-31 21:20:01 +08:00
|
|
|
$site_dist = Join-Path $site_src 'dist'
|
2023-06-29 19:46:52 +08:00
|
|
|
|
2023-08-31 21:20:01 +08:00
|
|
|
mkdirs $site_dist
|
2023-06-29 19:46:52 +08:00
|
|
|
|
2023-08-31 21:20:01 +08:00
|
|
|
$store_cwd = (Get-Location).Path
|
|
|
|
Set-Location $site_src
|
2023-08-25 16:46:32 +08:00
|
|
|
|
2023-08-25 16:52:26 +08:00
|
|
|
function configure_file($infile, $outfile, $vars) {
|
|
|
|
$content = $(Get-Content $infile -raw)
|
|
|
|
foreach($var in $vars.GetEnumerator()) {
|
|
|
|
$content = [Regex]::Replace($content, $var.Key, $var.Value)
|
|
|
|
}
|
|
|
|
Set-Content -Path $outfile -Value "$content"
|
|
|
|
}
|
2023-08-25 16:46:32 +08:00
|
|
|
|
2023-09-01 10:31:34 +08:00
|
|
|
# query version map to build docs
|
|
|
|
$release_tags = $(git tag)
|
|
|
|
$verMap = @{'latest' = $null; }
|
|
|
|
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
|
|
|
|
}
|
2023-08-25 16:52:26 +08:00
|
|
|
}
|
|
|
|
$strVerList = "'$($verMap.Keys -join "','")'"
|
2023-09-01 10:31:34 +08:00
|
|
|
Write-Host "$(Out-String -InputObject $verMap)"
|
2023-08-25 16:49:08 +08:00
|
|
|
|
2023-08-25 16:52:26 +08:00
|
|
|
foreach($item in $verMap.GetEnumerator()) {
|
|
|
|
$ver = $item.Key
|
2023-08-31 21:20:01 +08:00
|
|
|
$html_out = Join-Path $site_dist "manual/$ver"
|
|
|
|
mkdirs $html_out
|
2023-08-25 16:52:26 +08:00
|
|
|
$release_tag = $item.Value
|
|
|
|
|
|
|
|
if ($ver -eq 'latest') {
|
|
|
|
git checkout dev
|
2023-08-31 21:20:01 +08:00
|
|
|
$release_tag = query_axmol_latest
|
2023-08-25 16:52:26 +08:00
|
|
|
} elseif($ver -eq '1.0') {
|
|
|
|
git checkout '1.x' # 1.x branch now for v1.0
|
|
|
|
} else {
|
|
|
|
git checkout $release_tag
|
|
|
|
}
|
2023-08-31 21:20:01 +08:00
|
|
|
configure_file './Doxyfile.in' './Doxyfile' @{'@VERSION@'=$release_tag; '@HTML_OUTPUT@' = "manual/$ver"}
|
2023-08-25 16:52:26 +08:00
|
|
|
|
2023-09-01 14:15:25 +08:00
|
|
|
Write-Host "Generating docs for $ver ..." -NoNewline
|
2023-09-01 14:28:11 +08:00
|
|
|
doxygen "./Doxyfile" # 1>$null 2>$null
|
2023-09-01 14:15:25 +08:00
|
|
|
Write-Host "done"
|
2023-08-25 16:52:26 +08:00
|
|
|
|
|
|
|
Copy-Item './hacks.js' $html_out
|
2023-08-31 21:20:01 +08:00
|
|
|
Copy-Item './doc_style.css' "$html_out/stylesheet.css"
|
2023-08-25 16:52:26 +08:00
|
|
|
configure_file './menu_version.js.in' "$html_out/menu_version.js" @{'@VERLIST@' = $strVerList; '@VERSION@' = $ver}
|
|
|
|
}
|
|
|
|
|
2023-08-25 16:57:38 +08:00
|
|
|
# set default doc ver to 'latest'
|
2023-08-31 21:20:01 +08:00
|
|
|
configure_file './doc_index.html.in' "$site_dist/manual/index.html" @{'@VERSION@' = 'latest'}
|
|
|
|
|
|
|
|
# build home site
|
|
|
|
mkdirs "$site_dist/assets/css"
|
|
|
|
Copy-Item './style.css' "$site_dist/assets/css/style.css"
|
|
|
|
Copy-Item './index.html' "$site_dist/index.html"
|
2023-08-25 16:57:38 +08:00
|
|
|
|
2023-09-01 13:36:23 +08:00
|
|
|
function download_appveyor_artifact($dest) {
|
|
|
|
$apiUrl = 'https://ci.appveyor.com/api'
|
2023-09-01 14:48:42 +08:00
|
|
|
$token = ${env:AX_DOCS_TOKEN}
|
2023-09-01 13:36:23 +08:00
|
|
|
$headers = @{
|
|
|
|
"Authorization" = "Bearer ${env:AX_DOCS_TOKEN}"
|
|
|
|
"Content-type" = "application/json"
|
|
|
|
}
|
|
|
|
$accountName = 'halx99'
|
|
|
|
$projectSlug = 'axmol'
|
|
|
|
|
|
|
|
# get project with last build details
|
|
|
|
$project = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$accountName/$projectSlug" -Headers $headers
|
|
|
|
|
|
|
|
# we assume here that build has a single job
|
|
|
|
# get this job id
|
|
|
|
$jobId = $project.build.jobs[0].jobId
|
|
|
|
|
|
|
|
# get job artifacts (just to see what we've got)
|
|
|
|
$artifacts = Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts" -Headers $headers
|
|
|
|
|
|
|
|
# here we just take the first artifact, but you could specify its file name
|
|
|
|
# $artifactFileName = 'MyWebApp.zip'
|
|
|
|
$artifactFileName = $artifacts[0].fileName
|
|
|
|
|
|
|
|
# artifact will be downloaded as
|
|
|
|
mkdirs $dest
|
|
|
|
$localArtifactPath = Join-Path $dest $artifactFileName
|
|
|
|
|
|
|
|
if (!(Test-Path $localArtifactPath -PathType Leaf)) {
|
|
|
|
# download artifact
|
|
|
|
# -OutFile - is local file name where artifact will be downloaded into
|
|
|
|
# the Headers in this call should only contain the bearer token, and no Content-type, otherwise it will fail!
|
|
|
|
Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifactFileName" `
|
|
|
|
-OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer $token" }
|
|
|
|
}
|
|
|
|
|
|
|
|
Expand-Archive -Path $localArtifactPath -DestinationPath $dest
|
|
|
|
}
|
|
|
|
|
2023-09-01 14:15:25 +08:00
|
|
|
# deploy wasm cpp_tests demo
|
2023-09-01 14:02:58 +08:00
|
|
|
download_appveyor_artifact $(Join-Path $AX_ROOT 'tmp')
|
2023-09-01 13:36:23 +08:00
|
|
|
$wasm_dist = Join-Path $site_dist 'wasm/'
|
|
|
|
mkdirs $wasm_dist
|
2023-09-01 14:02:58 +08:00
|
|
|
Copy-Item $(Join-Path $AX_ROOT 'tmp/build_wasm/bin/cpp_tests') $wasm_dist -Container -Recurse
|
2023-09-01 13:36:23 +08:00
|
|
|
|
2023-08-25 16:52:26 +08:00
|
|
|
Set-Location $store_cwd
|