This commit is contained in:
tim
2024-03-22 00:24:22 -04:00
parent 46fc27579e
commit 51aaf2f6c6
14 changed files with 236 additions and 299 deletions
+32 -21
View File
@@ -15,20 +15,14 @@ on:
run-name: ${{ fromJSON(inputs.fstuple).branch }} @ ${{ fromJSON(inputs.fstuple).base }}
# shell: bash
#bash --noprofile --norc -e -o pipefail ./SHELL.sh {0}
# shell: c:/PROGRA~1/Git/usr/bin/bash.exe --noprofile --norc -e -o pipefail ./SHELL.sh {0}
# shell: c:\Program Files\Git\usr\bin\bash.exe --noprofile --norc -e -o pipefail {0}
# shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail {0}
defaults:
run:
shell: c:/PROGRA~1/Git/usr/bin/bash.exe --noprofile --norc -e -o pipefail {0}
# shell: c:\Program Files\Git\usr\bin\bash.exe --noprofile --norc -e -o pipefail {0}
# shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail {0}
env:
BASH_ENV: ${{ github.workspace }}/SHELL.env
# SHELL: c:/PROGRA~1/Git/usr/bin/bash.exe --noprofile --norc -e -o pipefail {0}
jobs:
windows_build:
@@ -64,14 +58,34 @@ jobs:
fsvr_dir=$PWD/fsvr fsvr/gha-generate-shell-env.sh | tee -a SHELL.env
fsvr/util/_utils.sh ht-ln fsvr/actions-node-script ./fsvr-action
# - name: SHELL.env test 0
# run: echo fsvr_dir=$fsvr_dir "${BASH_SOURCE[@]}"
#
# - name: SHELL.sh env test
# run: |
# env bash -c 'echo PWD=$PWD'
# env bash -c 'echo PATH=$PATH'
# declare -f tee | head -1
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
- name: Generate bin/ proxies
run: |
test -d "$fsvr_dir" || exit 63
. bashland/gha.alias-exe.bash
make-stub
fsvr/util/_utils.sh ht-ln bin/BASH_FUNC_invoke.exe bin/ht-ln.exe
ht-ln bin/BASH_FUNC_invoke.exe bin/hostname.exe
ht-ln bin/BASH_FUNC_invoke.exe bin/parallel.exe
- name: SHELL.sh env test
run: |
set -eu
echo base=$base repo=$repo branch=$branch
which tee.exe
which parallel.exe
tee --version
parallel --version
hostname --version
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
- name: Initial Bootstrapping
run: |
@@ -250,15 +264,12 @@ jobs:
with:
environment: '*=process.env'
run: |
declare -xp > declare.txt
env > env.txt
./fsvr/util/_utils.sh upload_artifact debug "$(cat <<EOF
declare.txt
env.txt
gha-bootstrap.env
SHELL.env
gha-bootstrap.env
build/build_vars.env
build/msvc.env
build/msvc.path.env
build/msvc.nunja.env
EOF
)"
+1 -13
View File
@@ -1,14 +1,2 @@
cmd_exe = cmd.exe
ninja_exe = ninja.exe
python_exe = python.exe
cl_exe = cl.exe
lib_exe = lib.exe
link_exe = link.exe
mt_exe = mt.exe
rc_exe = rc.exe
cmake_exe = cmake.exe
cmake_gui_exe = cmake.exe
cmcldeps_exe = cmcldeps.exe
cmake_gui_exe = $cmake_exe
cmake_pch = newview\cmake_pch
Regular → Executable
+28 -44
View File
@@ -1,66 +1,50 @@
#!/bin/bash
set -Euo pipefail
# env | grep -E '^[_a-z][a-z]'
_PRESHELL_PATH="${_PRESHELL_PATH:-}"
PATH="$PATH:/usr/bin"
_workspace=$(/usr/bin/cygpath -ua "${workspace:-$GITHUB_WORKSPACE}")
_userprofile=$(/usr/bin/cygpath -ua "$USERPROFILE")
_programfiles=$(/usr/bin/cygpath -ua "$PROGRAMFILES") # | /usr/bin/sed -e 's@[cC]:/@/c/@')
_comspec=$(/usr/bin/cygpath -ua "$COMSPEC") # | /usr/bin/sed -e 's@[cC]:/@/c/@')
_PRESHELL_PATH="$PATH"
fsvr_dir="${fsvr_dir:-$PWD/fsvr}"
if [[ $OSTYPE == msys ]] ; then
function _cygpath() { cygpath -ua "$1"; }
_workspace=$(cygpath -ua "${workspace:-${GITHUB_WORKSPACE:-.}}" | sed 's@/$@@')
_userprofile=$(cygpath -ua "$USERPROFILE")
_programfiles=$(cygpath -ua "$PROGRAMFILES") # | /usr/bin/sed -e 's@[cC]:/@/c/@')
_comspec=$(cygpath -ua "$COMSPEC") # | /usr/bin/sed -e 's@[cC]:/@/c/@')
_PATH="$_workspace/bin:$_userprofile/bin:/c/tools/zstd:$_programfiles/Git/bin:$_programfiles/Git/usr/bin:$_programfiles/Git/mingw64/bin:/c/hostedtoolcache/windows/Python/3.9.13/x64/Scripts:/c/hostedtoolcache/windows/Python/3.9.13/x64:$_programfiles/OpenSSL/bin:/c/Windows/System32/OpenSSH:$_programfiles/nodejs:$_programfiles/LLVM/bin:/c/ProgramData/Chocolatey/bin:$_programfiles/CMake/bin:/c/Windows/system32:/usr/bin:/bin:/c/msys64/usr/bin"
if [[ -v GITHUB_WORKSPACE ]]; then
TEE=c:/msys64/usr/bin/tee.exe
WGET=c:/msys64/usr/bin/wget.exe
ENVSUBST=$_programfiles/Git/mingw64/bin/envsubst.exe #/mingw64/bin/envsubst.exe #c:/msys64/usr/bin/envsubst.exe
PYTHON=/c/hostedtoolcache/windows/Python/3.9.13/x64/python3.exe
else
TEE=`which tee`
WGET=`which wget`
ENVSUBST=`which envsubst`
PYTHON=`which python3`
_PATH="$PWD/bin:$PATH"
fi
PATH="$_workspace/bin:$_userprofile/bin:/c/tools/zstd:$_programfiles/Git/bin:$_programfiles/Git/usr/bin:$_programfiles/Git/mingw64/bin:/c/hostedtoolcache/windows/Python/3.9.13/x64/Scripts:/c/hostedtoolcache/windows/Python/3.9.13/x64:$_programfiles/OpenSSL/bin:/c/Windows/System32/OpenSSH:$_programfiles/nodejs:$_programfiles/LLVM/bin:/c/ProgramData/Chocolatey/bin:$_programfiles/CMake/bin:/c/Windows/system32:/usr/bin:/bin:/c/msys64/usr/bin"
#. $(dirname $0)/util/_utils.sh
_PRESHELL_PATH=
#`subtract_paths "$_PRESHELL_PATH" "$PATH"`
######################################################################
echo "$(cat<<EOF
export fsvr_dir="$fsvr_dir"
_PRESHELL_PATH="$_PRESHELL_PATH"
_workspace="$_workspace"
_userprofile="$_userprofile"
_programfiles="$_programfiles"
_comspec="$_comspec"
_PATH="$PATH"
_xpath="\$_PATH"
if [[ -v msvc_path ]]; then _xpath="\$(/usr/bin/cygpath -p "\$msvc_path"):\$_xpath" ; fi
if [[ -n "\$_PRESHELL_PATH" ]]; then _xpath="\$_xpath:\$_PRESHELL_PATH" ; fi
set -a
base="$base"
repo="$repo"
branch="$branch"
fsvr_dir="$PWD/fsvr"
_PATH="$_PATH"
test ! -f $PWD/gha-bootstrap.env || source $PWD/gha-bootstrap.env
test ! -f $PWD/build/build_vars.env || source $PWD/build/build_vars.env
_xpath="\$_PATH"
[[ -v msvc_path ]] && _xpath="\$msvc_path:\$_xpath"
[[ -n "\$_PRESHELL_PATH" ]] && _xpath="\$_xpath:\$_PRESHELL_PATH"
export PATH="\$_xpath"
function _err() { local rc=\$1 ; shift; echo "[_err rc=\$rc] \$@" >&2; return \$rc; }
function tee() { TEE="$TEE" "$PYTHON" "$fsvr_dir/util/tee.py" "\$@" ; }
function hostname() { "$PWD/bin/hostname.exe" "\$@" ; }
function ninja() { "$PWD/bin/ninja.exe" "\$@" ; }
function ht-ln() { '$fsvr_dir/util/_utils.sh' ht-ln "\$@" ; }
function hostname(){ echo 'windows-2022' ; }
function tee() { TEE="`which tee`" "`which python3`" "$fsvr_dir/util/tee.py" "\$@" ; }
function parallel() { PARALLEL_HOME="$PWD/bin/parallel-home" "$PWD/bin/parallel" "\$@" ; }
function envsubst() { "$ENVSUBST" "\$@" ; }
function wget() { "$WGET" "\$@" ; }
function fsvr_step() { set -Euo pipefail; $PWD/fsvr/util/build.sh "\$@" ; }
declare -xf _err tee hostname parallel wget envsubst ninja fsvr_step
declare -x PATH="\$_xpath"
set +a
declare -xf _err tee parallel ht-ln hostname fsvr_step
set -Eo pipefail
EOF
)"
+14 -80
View File
@@ -4,6 +4,10 @@
_fsvr_utils_dir=$(readlink -f $(dirname "$BASH_SOURCE"))
source $_fsvr_utils_dir/gha.reduce-paths.bash
source $_fsvr_utils_dir/gha.wget-sha256.bash
source $_fsvr_utils_dir/gha.ht-ln.bash
_dbgopts='set -Euo pipefail'
_die_exit_code=128
@@ -32,6 +36,16 @@ function _relativize() {
# usage: _getenv NAME
function _getenv(){ /usr/bin/env | /usr/bin/grep -E "^$1=" | /usr/bin/cut -d '=' -f 2- || true ; }
# extract environment variable value
# while supporting hyphens in names AND ALSO newlines/etc. in values
# eg: local value="$(__getenv INPUT_x-y-z)"
function __getenv() {
local eenv="$(printf "%q" "$( echo ; env ; echo )")"
eenv="$(echo "$eenv" | sed -E 's@\\n?([-_A-Za-z0-9%.]+)=@\n\n\n\1=@g')"
local evalue="$(echo "$eenv" | grep -Eo "^$1=.*" | cut -d '=' -f 2-)"
echo -e "$evalue" | sed "s@\\\'@'@g;"
}
# _setenv exports and emits to stdout a canonicalized name=value argument
# escaping attempts to emerge both ninja and bash compatible variable assignments
# example scenarios and escaping:
@@ -68,16 +82,6 @@ function _setenv_ma() {
_setenv "$name=$value"
}
# subtract_paths(a,b) => a less b, de-duplicated and normalized
# subtract_paths(a,"") => a de-duplicated and normalized
# note: the order of elements from 'a' is preserved
function subtract_paths() {( $_dbgopts;
PATH="/usr/bin:$PATH"
grep -x -vf <(echo "$2" | tr ':' '\n') <(echo "$1" | tr ':' '\n') \
| awk '!seen[$0]++' | tr '\n' ':' | sed 's@[: ]*$@@g'
return 0
)}
function _realpath() { cygpath -ma "$1" 2>/dev/null || readlink -f "$1"; }
function _relative_path() { realpath --relative-to "$2" "$1" ; }
@@ -87,76 +91,6 @@ function _git_sha() {
git -C "$1" describe --always --first-parent --abbrev=7
}
# helper to download + checksum verify using wget
# usage: wget_sha256 <sha256sumhex> <url> <outputdir>
# returns the resulting outputdir/filename to stdout
function wget_sha256() {(
set -Euo pipefail
local hash=$1 url=$2 dir=${3:-.}
local filename=`basename $url`
test ! -d "$dir" || cd $dir
wget -q -N $url >&2
echo "$hash $filename" | sha256sum --strict --check >&2
echo $dir/$filename
)}
# helper to create symbolic links
# usage: ht-ln <SOURCE> <destination folder/ or desired link filepath>
function ht-ln() {
local source="$1" linkname="$2" opts=""
test -e "$source" || { echo "source does not exist '$source'" >&2 ; return 1; }
# ht-ln source.file dir/
test ! -d "$source" && test -d "$linkname" && linkname="$linkname/$(basename "$source")"
# verify destination link folder exists
test -d "$(dirname "$linkname")" || { echo "link location does not exist '$(dirname "$linkname")'" >&2 ; return 1; }
# default to linux style hard links
local cmd="ln -v $source $linkname"
# but on Linux use symbolic links for directories
test -d "$source" && cmd="ln -vs \"$source\" \"$linkname\""
# but on Windows / msys use mklink instead
if [[ "$OSTYPE" == "msys" ]]; then
# for directories /J junctions are used; /D (directory symbolic) is another option to consider
test -d "$source" && opts="/J"
# for files /H hardlinks are used
test -f "$source" && opts="/H"
PATH=/usr/bin
COMMAND="mklink $opts \"$(/usr/bin/cygpath -wa "$linkname")\" \"$(/usr/bin/cygpath -wa "$source")\""
cmd="/c/Windows/system32/cmd.exe //C call $(echo "$COMMAND" | /usr/bin/sed 's@/@//@g;s@\\@\\\\@g') "
fi
type -t _relativize >/dev/null && _relativize "[ht-ln] $cmd" >&2
test -e "$linkname" && { false && _relativize "skipping (exists) $linkname" >&2 ; return 0; }
eval "$cmd" || exit $?
}
function upload_artifact() {( set -Euo pipefail ;
local script=/d/a/_actions/actions/upload-artifact/v4/dist/upload/index.js
test -f $script || return `_err $? "$script missing"`
test -v ACTIONS_RUNTIME_TOKEN || return `_err $? "ACTIONS_RUNTIME_TOKEN missing"`
local INPUT=(zed
name
path
retention-days=1
compression-level=0
overwrite=false
if-no-files-found=error
)
echo "----------------------------------------" >&2
local args=`echo $(for i in "${!INPUT[@]}"; do
name="${INPUT[$i]/=*/}"
value="${INPUT[$i]/#$name=/}"
iv=$(_getenv $name)
value="${!i:-${iv:-$value}}"
echo INPUT_$name=$(printf "%q" "$value")
done) | tee /dev/stderr`
echo "----------------------------------------" >&2
PATH="/c/Program Files/nodejs:$PATH" eval "env $args node $script" | tr -d '\n'
)}
# usage: __utils_main__ ${BASH_SOURCE[0]} ${0}
# => if first argument is a declared function, invoke with args
-106
View File
@@ -1,106 +0,0 @@
#!/bin/bash
# helper to utilize gha artifact upload as part of bash scripting
# see: https://github.com/actions/toolkit/tree/main/packages/artifacts
# 2024.03.11 humbletim
#
# usage:
# # optional environment vars: retentionDays=N compressionLevel=N
# ./actions-artifact.sh upload id-1 ...paths
#
function actions-artifact-nodeeval() {
local cmd=$1 script=$2
shift 2
echo "node -e {{$cmd}} $@" >&2
result="$(node -e "${script}" "$@" 2>&1 || echo "${cmd}_error=$?")"
test -n "$NODE_DEBUG" && echo "$result" >&2 ;
outvalue=$(echo "$result" | grep -Eo "^${cmd}_(result|error)=(.*)\$" | sed -E 's@^\w+_result=@@')
echo "$outvalue"
}
function actions-artifact-list() {
local list=$(cat <<'EOF'
const [_, ownername, id] = process.argv;
const [ owner, name ] = ownername.split('/');
console.warn("argv", { owner, name, id });
const {DefaultArtifactClient} = require('@actions/artifact')
const artifact = new DefaultArtifactClient()
artifact.listArtifacts({
findBy: {
// must have actions:read permission on target repository
token: process.env['GITHUB_TOKEN'],
workflowRunId: id,
repositoryOwner: owner,
repositoryName: name,
}
}
).then((x,y) =>console.log('list_result='+JSON.stringify(x))
).catch((e)=>console.error('list_error='+e));
EOF
)
actions-artifact-nodeeval list "${list}" "$@"
}
# ```ts
# await artifact.downloadArtifact(1337, {
# findBy
# })
#
# // can also be used in other methods
#
# await artifact.getArtifact('my-artifact', {
# findBy
# })
#
function actions-artifact-upload() {
local upload=$(cat <<'EOF'
const [_, name, ...files] = process.argv;
console.warn("argv", name, files);
const args = {
name, files,
rentionDays: +process.env.retentionDays || 1,
compressionLevel: +process.env.compressionLevel || 0,
workingDirectory: process.env.workingDirectory || '.',
};
console.warn(args);
const {DefaultArtifactClient} = require('@actions/artifact')
const artifact = new DefaultArtifactClient()
artifact.uploadArtifact(
args.name,
args.files,
args.workingDirectory,
{ retentionDays: args.retentionDays, compressionLevel: args.compressionLevel}
).then((x) =>console.log('upload_result='+JSON.strigify(x))
).catch((e)=>console.error('upload_error='+e));
EOF
)
actions-artifact-nodeeval upload "${upload}" "$@"
}
function actions-artifact-test() {
local test=$(cat <<'EOF'
const [_, name, ...files] = process.argv;
console.warn("argv", name, files);
const args = {
name, files,
rentionDays: +process.env.retentionDays || 1,
compressionLevel: +process.env.compressionLevel || 0,
workingDirectory: process.env.workingDirectory || '.',
};
console.log('test_result='+JSON.stringify(args));
//process.exit(-1);
EOF
)
actions-artifact-nodeeval test "${test}" "$@"
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
func=$1 && shift
declare -f actions-artifact-$func &>/dev/null && func=actions-artifact-$func
$func "$@"
fi
+15 -29
View File
@@ -4,6 +4,9 @@ require_here=`readlink -f $(dirname $BASH_SOURCE)`
function require() { source $require_here/$@ ; }
require _utils.sh
require gha.upload-artifact.bash
require gha.load-level.bash
# echo "root_dir=$root_dir" >&2
_assert "root_dir" 'test -d "$root_dir"'
_assert "build_dir" 'test -d "$build_dir"'
@@ -79,18 +82,6 @@ function 020_perform_replacements() {( $_dbgopts;
)
)}
function get_msvcdir() {( $_dbgopts;
_assert "fsvr_dir/util" test -f "$fsvr_dir/util/generate_msvc_env.bat"
_assert "$build_dir/msvc.env" test -s $build_dir/msvc.env
. $build_dir/msvc.env
test -n "$VCToolsVersion" || _die "!VCToolsVersion"
test -d "$VCToolsRedistDir" || _die "!VCToolsRedistDir"
local TOOLSVER=$(echo $VCToolsVersion | sed -e 's@^\([0-9]\+\)[.]\([0-9]\).*$@\1\2@')
local CRT=$(cygpath -mas "$VCToolsRedistDir/x64/Microsoft.VC$TOOLSVER.CRT/")
test -d $CRT || { echo "msvc CRT '$CRT' does not exist" &>2 ; return 1 ; }
echo "$CRT"
)}
function 085_prepare_msys_msvc() {( $_dbgopts;
[[ "$OSTYPE" == "msys" ]] || { echo "skipping msys (found OSTYPE='$OSTYPE')" >&2 ; return 0; }
@@ -102,12 +93,6 @@ function 085_prepare_msys_msvc() {( $_dbgopts;
# note: autobuild is not necessary here, but viewer_manifest still depends on python-llsd
python -c 'import llsd' 2>/dev/null || pip install llsd # needed for viewer_manifest.py invocation
fi
# make msvcp140.dll redists easy to reference as build/msvc/
msvc_dir=$(get_msvcdir) || _die "could not get msvc_dir $(ls -l $build_dir/)"
# ht-ln $msvc_dir $build_dir/msvc
grep msvc_dir $build_dir/build_vars.env >/dev/null \
|| { echo "msvc_dir=$msvc_dir" | tee -a $build_dir/build_vars.env ; }
)}
function merge_packages_info() {( $_dbgopts;
@@ -231,14 +216,18 @@ function 080_untar_packages() {( $_dbgopts;
function 090_ninja_preflight() {( $_dbgopts;
_assert nunja_dir 'test -d "$nunja_dir"'
(
echo "include build_vars.env"
echo "nunja_dir=$nunja_dir" ;
cat $nunja_dir/cl.arrant.nunja
) > $build_dir/build.ninja
cat << EOF > $build_dir/build.ninja
include build_vars.env
include msvc.nunja.env
nunja_dir=$nunja_dir
include \$nunja_dir/cl.arrant.nunja
EOF
_assert msvc.env 'test -f $build_dir/msvc.env'
set -a
. $build_dir/msvc.env
. $build_dir/msvc_path.env
. $BASH_ENV
echo $msvc_path
@@ -253,6 +242,7 @@ function 0a0_ninja_build() {( $_dbgopts;
_assert msvc.env 'test -f $build_dir/msvc.env'
set -a
. $build_dir/msvc.env
. $build_dir/msvc_path.env
. $BASH_ENV
which cl.exe > /dev/null || return 256
echo "[$FUNCNAME] ninja -C $build_dir ${@:-llpackage}" >&2
@@ -324,23 +314,19 @@ function 0c0_upload_artifacts() {( $_dbgopts;
mkdir dist
ht-ln $Installer dist/$InstallerExe
( cd dist && upload_artifact ${InstallerExe/.exe/} $InstallerExe )
( cd dist && upload-artifact ${InstallerExe/.exe/} $InstallerExe )
local Portable=`ls build/Firestorm*.7z |head -1`
local PortableArchive=$branch-$(basename $Portable)
ht-ln $Portable dist/$PortableArchive
( cd dist && upload_artifact ${PortableArchive/.7z/} $PortableArchive )
( cd dist && upload-artifact ${PortableArchive/.7z/} $PortableArchive )
)}
function _steps() {
declare -f | grep '^0.*()' | sed 's@^@ @g;s@()@@' | sort
}
function load-level() {
/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -NoLogo -Command "Get-Counter -Counter '\Processor(_Total)\% Processor Time' -MaxSamples 1" 2>&1 | /usr/bin/xargs /usr/bin/echo| /usr/bin/grep -Eo '[^ ]+$'
}
# Check if the script is being sourced
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
$_dbgopts
+1 -5
View File
@@ -19,11 +19,7 @@ if exist "%VS170COMNTOOLS%" (
echo "%VS2022_COMMON_TOOLS%"\VsDevCmd.bat -arch=x64 -host_arch=x64 -no_logo >&2
call "%VS2022_COMMON_TOOLS%"\VsDevCmd.bat -arch=x64 -host_arch=x64 -no_logo >&2
bash -c 'declare -x PATH="$($fsvr_dir/util/_utils.sh subtract_paths "$PATH" "/mingw64/bin:/usr/bin:/c/msys64/home/runneradmin/bin")"; declare -x |sort | sed "s@ PATH=@ msvc_env_PATH=@"' > after
bash -c 'paths="$(for x in cl rc; do dirname "$(which $x.exe)"; done | tr "\n" ":")"; paths="$($fsvr_dir/util/_utils.sh subtract_paths "$paths" "/bin:/usr/bin:/mingw64/bin:/mingw64/usr/bin:/usr/local/bin")" ; export msvc_path="$(cygpath -p "$paths")"; declare -xp msvc_path' | tee -a after > build/msvc_path.env
bash -c '. build/msvc_path.env ; export PATH="$msvc_path:/usr/bin"; for x in cl lib link mt rc; do echo ${x}_exe=$(cygpath -msa "$(which $x.exe)"); done' | tee build/msvc.nunja.env
bash -c 'declare -x |sort | sed "s@ PATH=@ msvc_env_PATH=@"' > after
bash -c "diff before after | grep '^[>]' | sed -e 's@^> @@'"
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
test -s build/msvc.env || fsvr/util/generate_msvc_env.bat > build/msvc.env
. build/msvc.env
msvc_path="$(
fsvr/util/_utils.sh reduce-paths "$msvc_env_PATH" \
"/mingw64/bin:/usr/bin:/bin:/c/msys64/home/runneradmin/bin:$HOME/bin"
)"
echo "$msvc_path" > build/msvc_path.txt
declare -xp msvc_path | tee build/msvc_path.env
# calculate MSVR redistributable location
test -n "$VCToolsVersion" || _die "!VCToolsVersion"
test -d "$VCToolsRedistDir" || _die "!VCToolsRedistDir"
TOOLSVER=$(echo $VCToolsVersion | sed -e 's@^\([0-9]\+\)[.]\([0-9]\).*$@\1\2@')
CRT=$(cygpath -mas "$VCToolsRedistDir/x64/Microsoft.VC$TOOLSVER.CRT/")
test -d $CRT || { echo "msvc CRT '$CRT' does not exist" &>2 ; return 20 ; }
{
echo msvc_dir=$CRT
for x in cl lib link mt rc cmake ninja python cmcldeps cmd; do
echo ${x}_exe=$(PATH="$msvc_path:$PATH:/usr/bin:/c/Windows/system32" cygpath -msa "$(which $x.exe)")
done
} | tee build/msvc.nunja.env
+42
View File
@@ -0,0 +1,42 @@
# bash helper to create system-level filesystem links in ubuntu/windows gha runners
# -- 2023.03.20 humbletim
# usage: ht-ln <SOURCE> <destination folder/ or desired link filepath>
function ht-ln() {
local source="$1" linkfilepath="$2"
test -e "$source" || { echo "source does not exist '$source'" >&2 ; return 1; }
# if source is a file an destination a directory then generate link filepath
test -f "$source" && test -d "$linkfilepath" && linkfilepath="$linkfilepath/$(basename "$source")"
# verify link folder exists
test -d "$(dirname "$linkfilepath")" || { echo "link location does not exist '$(dirname "$linkfilepath")'" >&2 ; return 1; }
# no-op if linkfilepath already exists
test -e "$linkfilepath" && return 0
# default to linux style hard links
local cmd="ln -v \"$source\" \"$linkfilepath\""
# but on Linux use symbolic links for directories
test -d "$source" && cmd="ln -vs \"$source\" \"$linkfilepath\""
# but on Windows / msys use mklink instead
if [[ "$OSTYPE" == "msys" ]]; then
local opts=""
# for files /H hardlinks are used
test -f "$source" && opts="/H"
# for directories /J junctions are used; /D (directory symbolic) is another option to consider
test -d "$source" && opts="/J"
PATH=/usr/bin
COMMAND="mklink $opts \"$(/usr/bin/cygpath -wa "$linkfilepath")\" \"$(/usr/bin/cygpath -wa "$source")\""
cmd="/c/Windows/system32/cmd.exe //C call $(echo "$COMMAND" | /usr/bin/sed 's@/@//@g;s@\\@\\\\@g') "
fi
type -t _relativize >/dev/null && _relativize "[ht-ln] $cmd" >&2
eval "$cmd" || exit $?
}
+7
View File
@@ -0,0 +1,7 @@
# bash helper that returns unit CPU load level [0.0-1.0]
# note: somewhat specific to github actions windows-2022 runner
# -- 2024.03.20 humbletim
function load-level() {
/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -NoLogo -Command "Get-Counter -Counter '\Processor(_Total)\% Processor Time' -MaxSamples 1" 2>&1 | /usr/bin/xargs /usr/bin/echo | /usr/bin/grep -Eo '[^ ]+$'
}
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
# bash helper to reduce/subtract/dedupe PATH sets while preserving order
# NOTE: assumes unix style colon-separated '/c/Program Files:/d/a/path/bin' paths
# -- humbletim 2024.03.20
# usage:
# reduce-paths(A) => (A) deduplicated / normalized
# reduce-paths(A, B) => (A - B) deduplicated / normalized
function reduce-paths() {(
set -Euo pipefail
PATH="$PATH:/usr/bin"
grep -x -vf <(echo "$2" | tr ':' '\n') <(echo "${1:-}" | tr ':' '\n') \
| awk '!seen[$0]++' | tr '\n' ':' | sed 's@::@:@g;s@[: ]*$@@g'
return 0
)}
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# bash gha helper for uploading artifacts; depends on @actions/artifact
# -- 2023.03.20 humbletim
# usage:
# upload_artifacts <name> "<paths>" [retention-days=1] [compression-level=0]
function upload-artifact() {(
set -Euo pipefail
local PATH="$PATH:/usr/bin"
local node="/c/Program Files/nodejs/node"
local script="/d/a/_actions/actions/upload-artifact/v4/dist/upload/index.js"
test -f $script || { echo "$script missing" >&2 ; return 7; }
test -v ACTIONS_RUNTIME_TOKEN || { echo "env ACTIONS_RUNTIME_TOKEN missing" >&2 ; return 8; }
local -a inputs=(
INPUT_name=$(printf "%q" "$1")
INPUT_path=$(printf "%q" "$2")
INPUT_retention-days=${3:-1}
INPUT_compression-level=${4:-0}
INPUT_overwrite=false
INPUT_if-no-files-found=error
)
echo "----------------------------------------" >&2
echo "env ${inputs[@]} $node $script" >&2
echo "----------------------------------------" >&2
eval "env ${inputs[@]} $node $script"
echo "----------------------------------------" >&2
)}
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
# helper to download + checksum verify using wget
# usage: wget-sha256 <sha256sumhex> <url> <outputdir>
# returns the resulting outputdir/filename to stdout
# -- humbletim 2024.03.20
function wget-sha256() {(
set -Euo pipefail
PATH="$PATH:/usr/bin"
local hash="$1" url="$2" dir="${3:-.}"
local filename=$(basename "$url")
test ! -d "$dir" || cd "$dir"
wget -q -N "$url" >&2
echo "$hash $filename" | sha256sum --strict --check >&2 || return $?
echo "$dir/$filename"
)}
+3 -1
View File
@@ -45,4 +45,6 @@ while data:
except KeyboardInterrupt: sys.exit(-1)
for stream in write_streams:
stream.write(data)
stream.flush()
try:
stream.flush()
except BrokenPipeError: sys.exit(-2)