Skip to content

Commit

Permalink
rework fsenv
Browse files Browse the repository at this point in the history
  • Loading branch information
humbletim committed Sep 17, 2022
1 parent 863c2b2 commit a3368d9
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 66 deletions.
107 changes: 56 additions & 51 deletions .github/fsenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,27 @@
# github actions helper to initialize environment variables for building firestorm
# -- humbletim 2022.03.27

set -eu

# function wrapper to avoid leaking variables when "sourced" into other scripts
function _fsenv() {
local os
if [[ ${RUNNER_OS+x} ]] ; then
case $RUNNER_OS in
Windows) os=windows ;;
Linux) os=linux ;;
esac
fi
if [[ ! ${os+x} ]] ; then
set -eu
local os= gha= workspace=
if [[ ${GITHUB_ACTIONS+x} ]] ; then
gha=1
workspace=${GITHUB_WORKSPACE}
os=${RUNNER_OS,,} # lowercase
else
case `uname -s` in
MINGW*) os=windows ;;
*) os=linux ;;
MINGW*) os=windows workspace=$(pwd -W) ;;
*) os=linux workspace=$PWD ;;
esac
fi
function debug() { if [[ -n "${DEBUG:-}" ]] ; then echo "[_fsenv] $@" >&2 ; fi }

# setenv <name> [default-value]
# exports the named variable and emits a key="value" to stdout
# (a no-op when both the variable doesn't exist and no default is specified)
function setenv() {
if [[ ! ${!1+x} ]] ; then
if [[ $# -lt 2 ]] ; then
echo "# setenv($1) -- no-op" >&2
return 0
fi
# var not present assign to default and export
echo "# setenv($1,$2)" >&2
printf -v "${1}" "%s" "${2}"
fi
echo "# export($1)" >&2
[[ ${os} == linux ]] && eval "export ${1}"
emitvar "$@"
}
debug "os=$os | gha=$gha | workspace=$workspace" >&2

function emitvar() {
if [[ ${GITHUB_ACTIONS+x} ]] ; then
debug "# emitvar($1)" >&2
if [[ $gha ]] ; then
# output github action (GITHUB_ENV) compatible multiline/escaped variables
if [[ ${!1} == *$'\n'* ]] ; then
echo "${1}<<EOF"
Expand All @@ -50,21 +33,41 @@ function _fsenv() {
fi
else
# output bash compatible multiline/escaped variables
declare -p "${1}"
debug "# ... emitvar($1)" >&2
declare -p "$1"
fi
}

setenv GHA_TEST_WITH_SPACES "testing \"1\" 2 3...tab\t."
function isset() {
if [[ ${!1+x} ]] ; then return 0 ; fi
return -1
}

if [[ ! ${GITHUB_WORKSPACE+x} ]] ; then
case `uname -s` in
MINGW*) local GITHUB_WORKSPACE=$(pwd -W) ;;
*) local GITHUB_WORKSPACE=$PWD ;;
esac
fi
echo "os=$os"
function assign() {
if [[ ${2+x} ]] ; then
debug "# assign($1,$2)" >&2
printf -v "${1}" "%s" "${2}"
return 0
else
debug "# assign($1) -- no-op" >&2
return -1
fi
}

# setenv <name> [default-value]
# exports the named variable and emits a key="value" to stdout
# (a no-op when both the variable doesn't exist and no default is specified)
function setenv() {
isset "$@" || assign "$@" || return 0
if [[ $os == linux ]] ; then eval "export ${1}" ; fi
debug "# setenv($@)" >&2
emitvar "${1}"
}


setenv GHA_TEST_WITH_SPACES "testing \"1\" 2 3...tab\t."

setenv _3P_UTILSDIR ${GITHUB_WORKSPACE}/.github/3p
setenv _3P_UTILSDIR ${workspace}/.github/3p

############################################################################
# workaround for github actions receiving 403: Forbidden errors when trying to
Expand Down Expand Up @@ -107,9 +110,9 @@ function _fsenv() {

### AUTOBUILD_ environment variables

setenv AUTOBUILD_VARIABLES_FILE ${GITHUB_WORKSPACE}/fs-build-variables/variables
setenv AUTOBUILD_CONFIG_FILE ${GITHUB_WORKSPACE}/autobuild.xml
setenv AUTOBUILD_INSTALLABLE_CACHE ${GITHUB_WORKSPACE}/autobuild-cache
setenv AUTOBUILD_VARIABLES_FILE ${workspace}/fs-build-variables/variables
setenv AUTOBUILD_CONFIG_FILE ${workspace}/autobuild.xml
setenv AUTOBUILD_INSTALLABLE_CACHE ${workspace}/autobuild-cache

setenv AUTOBUILD_LOGLEVEL --verbose
setenv AUTOBUILD_PLATFORM ${os}64
Expand All @@ -118,7 +121,7 @@ function _fsenv() {
setenv AUTOBUILD_CONFIGURATION ReleaseFS_open
setenv AUTOBUILD_BUILD_ID 0

### environment variables specific to github actions / windows builds
### environment variables specific to github actions / mod builds
# setenv VIEWER_CHANNEL=FirestormVR-GHA
setenv PYTHONUTF8 1
setenv PreferredToolArchitecture x64
Expand All @@ -128,24 +131,26 @@ function _fsenv() {
else
setenv FSBUILD_DIR build-linux-x86_64
fi
setenv FSVS_TARGET Ninja # 'Visual Studio 16 2019'
setenv FSVS_TARGET Ninja # for msbuild this would be 'Visual Studio 16 2019'

setenv VIEWER_VERSION_STR `echo $(cat indra/newview/VIEWER_VERSION.txt)`.${AUTOBUILD_BUILD_ID}
setenv VIEWER_VERSION_GITHASH $(git log -n 1 | grep "Merge " | awk '{ print $2 }' | xargs git rev-parse --short 2>/dev/null || git rev-parse --short HEAD)
setenv VIEWER_CHANNEL
unset _fsenv
}

if [[ ! ${GITHUB_ACTIONS+x} ]] ; then
if (return 0 2>/dev/null) ; then
# fsenv.sh was sourced ; export only
_fsenv > /dev/null
fi
elif [[ -n $# ]] ; then
if [[ ${GITHUB_ACTIONS+x} ]] ; then
_fsenv
elif (return 0 2>/dev/null) ; then
echo "[_fsenv] sourced (export only)" >&2
_fsenv > /dev/null
elif [[ $# -gt 0 ]] ; then
echo "[_fsenv] export + exec ($@)" >&2
# fsenv.sh was passed subcommands ; export and execute
_fsenv > /dev/null
"$@"
else
echo "[_fsenv] export and echo" >&2
# fsenv.sh was called without arguments ; export and echo to stdout
_fsenv
fi
82 changes: 67 additions & 15 deletions .github/workflows/CompileWindows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,33 @@ on:
# pull_request:
workflow_dispatch:
inputs:
fs3p_giturl:
description: |
base HTTPS folder to clone 3p dependencies from
- https://vcs.firestormviewer.org/3p-libraries
- https://github.com
required: true
default: https://github.com
buildsys:
description: 'ninja or msbuild'
required: true
default: ninja
llpackage:
description: 'build/package/upload firestorm installer (if false only autobuild configure and caching is performed)'
required: true
default: 'false'
tmate:
type: boolean
description: pause with tmate session
default: false
depth:
type: choice
description: depth
default: fsenv.3p.configure
options:
- fsenv
- fsenv.3p
- fsenv.3p.configure
- fsenv.3p.configure.llcommon
- fsenv.3p.configure.llcommon.plugins
- fsenv.3p.configure.llcommon.plugins.firestorm-bin
- fsenv.3p.configure.llcommon.plugins.firestorm-bin.llpackage

defaults:
run:
Expand All @@ -25,12 +44,27 @@ jobs:
AUTOBUILD_BUILD_ID: 67470
AUTOBUILD_CONFIGURATION: ReleaseFS_open
steps:
- uses: actions/checkout@v2
# - uses: actions/checkout@v2
# with:
# submodules: true
- name: Quick Checkout
shell: bash
run: |
pwd
set -x
git clone --quiet --recurse-submodules --filter=tree:0 https://github.com/${GITHUB_REPOSITORY}.git --branch ${GITHUB_REF_NAME} ${GITHUB_WORKSPACE}
ls -lrtha
- name: Setup tmate session
if: ${{ inputs.tmate == true }}
uses: mxschmitt/action-tmate@v3
with:
submodules: true
limit-access-to-actor: true

- name: Preset ENV
shell: bash
run: |
export INLINE_FS3P_GITURL="${{ github.event.inputs.fs3p_giturl }}"
echo =============================================================
.github/fsenv.sh
echo =============================================================
Expand All @@ -39,6 +73,13 @@ jobs:
if [[ ! ${GITHUB_ACTIONS+x} ]] ; then #dev
set -ea && source <( .github/fsenv.sh ) && set +ea && test -n "$VIEWER_CHANNEL" -a -n "$FSBUILD_DIR" -a -n "$AUTOBUILD_VSVER" #dev
fi #dev
- name: Verify ENV
shell: bash
run: |
. ${_3P_UTILSDIR}/_assert_defined.sh
assert_defined VIEWER_CHANNEL FSBUILD_DIR AUTOBUILD_CONFIG_FILE INLINE_FS3P_GITURL
- name: Prep build dirs
shell: cmd
run: |
Expand All @@ -57,6 +98,7 @@ jobs:
dir %FSBUILD_DIR%
dir
echo AUTOBUILD_INSTALLABLE_CACHE=c:\cache\autobuild>> %GITHUB_ENV%
- name: Setup vsdevenv
uses: seanmiddleditch/gha-setup-vsdevenv@master
- name: Setup MSBuild
Expand Down Expand Up @@ -94,7 +136,9 @@ jobs:
shell: bash
run: |
for x in $INLINE_FS3P_DEPS ; do echo $x ; done | sort -u | tee 3p-inline.sorted.txt
- name: cache -- 3p-inline
if: ${{ inputs.depth >= 'fsenv.3p' }}
id: cached-3p-inline
uses: actions/cache@v2
with:
Expand All @@ -103,58 +147,66 @@ jobs:
3p-inline/*/_results.env
3p-inline/*/*.tar.bz2
- name: Patch and build local 3p packages
if: ${{ inputs.depth >= 'fsenv.3p' }}
# if: steps.cached-3p-inline.outputs.cache-hit != 'true'
shell: bash
run: |
.github/3p/CompileWindows.autobuild-setup.sh #dev
test -f autobuild.xml.sorted.txt
- name: cache -- autobuild downloads
if: ${{ inputs.depth >= 'fsenv.3p.configure' }}
id: cached-downloads
uses: actions/cache@v2
with:
path: ${{ env.AUTOBUILD_INSTALLABLE_CACHE }}
key: ${{ runner.os }}-downloads-${{ hashFiles('autobuild.xml.sorted.txt') }}-FirestormVR-GHA

- name: cache -- buildir packages
if: ${{ inputs.depth >= 'fsenv.3p.configure' }}
id: cached-buildir-packages
uses: actions/cache@v2
with:
path: c:\cache\packages
key: ${{ runner.os }}-buildir-packages-${{ hashFiles('autobuild.xml.sorted.txt') }}-FirestormVR-GHA

- name: Reset cached packages sentinels
if: ${{ inputs.depth >= 'fsenv.3p.configure' }}
# if: steps.cached-buildir-packages.outputs.cache-hit == 'true'
shell: bash
run: |
.github/fs_reset_sentinels.sh ${FSBUILD_DIR} #dev
ls -lrt autobuild.xml ${FSBUILD_DIR}/packages/cmake_tracking/*_installed || true
- name: Configure autobuild (ninja)
if: ${{ github.event.inputs.buildsys == 'ninja' }}
if: ${{ inputs.buildsys == 'ninja' && inputs.depth >= 'fsenv.3p.configure' }}
shell: bash
run: |
autobuild --version
test -n "${VIEWER_CHANNEL}" && test -n "${PYTHON_EXECUTABLE}" #dev
autobuild configure -- --ninja --package --openal --chan "${VIEWER_CHANNEL}" -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DLL_TESTS:BOOL=FALSE -DVS_DISABLE_FATAL_WARNINGS=ON #dev
- name: Build llcommon (ninja)
if: ${{ inputs.buildsys == 'ninja' && inputs.depth >= 'fsenv.3p.configure.llcommon' }}
run: |
ninja -C ${FSBUILD_DIR} SLPlugin media_plugin_cef media_plugin_libvlc #dev
- name: Build plugins (ninja)
if: ${{ github.event.inputs.buildsys == 'ninja' && github.event.inputs.llpackage == 'true' }}
if: ${{ inputs.buildsys == 'ninja' && inputs.depth >= 'fsenv.3p.configure.llcommon.plugins' }}
run: |
ninja -C ${FSBUILD_DIR} SLPlugin media_plugin_cef media_plugin_libvlc #dev
- name: Build precompiled header (ninja)
if: ${{ github.event.inputs.buildsys == 'ninja' && github.event.inputs.llpackage == 'true' }}
if: ${{ inputs.buildsys == 'ninja' && inputs.depth >= 'fsenv.3p.configure.llcommon.plugins.firestorm-bin' }}
run: |
ninja -C ${FSBUILD_DIR} newview/CMakeFiles/firestorm-bin.dir/llviewerprecompiledheaders.cpp.obj #dev
- name: Build firestorm-bin (ninja)
if: ${{ github.event.inputs.buildsys == 'ninja' && github.event.inputs.llpackage == 'true' }}
if: ${{ inputs.buildsys == 'ninja' && inputs.depth >= 'fsenv.3p.configure.llcommon.plugins.firestorm-bin' }}
run: |
ninja -C ${FSBUILD_DIR} firestorm-bin #dev
- name: Package (ninja)
if: ${{ github.event.inputs.buildsys == 'ninja' && github.event.inputs.llpackage == 'true' }}
if: ${{ inputs.buildsys == 'ninja' && inputs.depth >= 'fsenv.3p.configure.llcommon.plugins.firestorm-bin.llpackage' }}
run: |
ninja -C ${FSBUILD_DIR} llpackage #dev
- name: Upload Artifact (ninja)
if: ${{ github.event.inputs.buildsys == 'ninja' && github.event.inputs.llpackage == 'true' }}
if: ${{ inputs.buildsys == 'ninja' && inputs.depth >= 'fsenv.3p.configure.llcommon.plugins.firestorm-bin.llpackage' }}
uses: actions/upload-artifact@v2
with:
name: ${{ format('{0}-{1}-{2}-{3}-{4}', runner.os, github.event.inputs.buildsys, env.VIEWER_CHANNEL, env.VIEWER_VERSION_STR, env.VIEWER_VERSION_GITHASH) }}
Expand All @@ -164,18 +216,18 @@ jobs:
3p-inline.sorted.txt
- name: Configure autobuild (msbuild)
if: ${{ github.event.inputs.buildsys == 'msbuild' }}
if: ${{ inputs.buildsys == 'msbuild' && inputs.depth >= 'fsenv.3p.configure' }}
shell: cmd
run: |
autobuild --version
autobuild configure -- --package --openal --chan ${{ env.VIEWER_CHANNEL }} -DPYTHON_EXECUTABLE=${{ env.PYTHON_EXECUTABLE }} -DLL_TESTS:BOOL=FALSE -DVS_DISABLE_FATAL_WARNINGS=ON
- name: Build & Package (msbuild)
if: ${{ github.event.inputs.buildsys == 'msbuild' && github.event.inputs.llpackage == 'true' }}
if: ${{ inputs.buildsys == 'msbuild' && inputs.depth >= 'fsenv.3p.configure.llcommon.plugins.firestorm-bin.llpackage' }}
shell: cmd
run: |
msbuild ${{ env.FSBUILD_DIR }}/Firestorm.sln /target:llpackage /property:Configuration=Release;Platform=x64 /maxcpucount
- name: Upload Artifact (msbuild)
if: ${{ github.event.inputs.buildsys == 'msbuild' && github.event.inputs.llpackage == 'true' }}
if: ${{ inputs.buildsys == 'msbuild' && inputs.depth >= 'fsenv.3p.configure.llcommon.plugins.firestorm-bin.llpackage' }}
uses: actions/upload-artifact@v2
with:
name: windows-${{ env.VIEWER_CHANNEL }}-${{ env.VIEWER_VERSION_STR }}-${{ env.VIEWER_VERSION_GITHASH }}
Expand Down

0 comments on commit a3368d9

Please sign in to comment.