Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .backportrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"repoOwner": "EpicGamesExt",
"repoName": "PixelStreamingInfrastructure",
"targetBranchChoices": ["master", "UE5.2", "UE5.3", "UE5.4", "UE5.5"],
"autoMerge": true,
"autoMergeMethod": "squash"
"repoOwner": "EpicGamesExt",
"repoName": "PixelStreamingInfrastructure",
"targetBranchChoices": ["master", "UE5.2", "UE5.3", "UE5.4", "UE5.5", "LatencyTest"],
"autoMerge": true,
"autoMergeMethod": "squash"
}
87 changes: 35 additions & 52 deletions SignallingWebServer/platform_scripts/bash/common.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

NODE_VERSION=$(<"${SCRIPT_DIR}/../../../NODE_VERSION")
NPM="${SCRIPT_DIR}/node/bin/npm"

# Prints the arguments and their descriptions to the console
function print_usage() {
Expand Down Expand Up @@ -35,7 +34,7 @@ function print_usage() {
if [[ -d "${SCRIPT_DIR}/../../dist/" ]]; then
pushd "${SCRIPT_DIR}/../.."
echo "Server options:"
"${NPM}" run start -- --help
npm run start -- --help
popd
fi
exit 1
Expand Down Expand Up @@ -76,40 +75,21 @@ function parse_args() {
}

function check_version() { #current_version #min_version
#check if same string
if [ -z "$2" ] || [ "$1" = "$2" ]; then
local current="$1"
local minimum="$2"

# Check if no minimum or both are the same
if [ -z "$minimum" ] || [ "$current" = "$minimum" ]; then
return 0
fi

local i current minimum

IFS="." read -r -a current <<< $1
IFS="." read -r -a minimum <<< $2

# fill empty fields in current with zeros
for ((i=${#current[@]}; i<${#minimum[@]}; i++))
do
current[i]=0
done

for ((i=0; i<${#current[@]}; i++))
do
if [[ -z ${minimum[i]} ]]; then
# fill empty fields in minimum with zeros
minimum[i]=0
fi
local ordered=$(printf "%s\n%s\n" "$minimum" "$current" | sort -V | head -n1)

if ((10#${current[i]} > 10#${minimum[i]})); then
return 1
fi

if ((10#${current[i]} < 10#${minimum[i]})); then
return 2
fi
done

# if got this far string is the same once we added missing 0
return 0
if [ "$ordered" = "$minimum" ]; then
return 1
else
return 2
fi
}

function check_and_install() { #dep_name #get_version_string #version_min #install_command
Expand Down Expand Up @@ -168,15 +148,9 @@ function setup_node() {
# navigate to project root
pushd "${SCRIPT_DIR}/../../.." > /dev/null

# setup the path so we're using our node. required when calling npm
PATH="${SCRIPT_DIR}/node/bin:$PATH"

node_version=""
if [[ -f "${SCRIPT_DIR}/node/bin/node" ]]; then
node_version=$("${SCRIPT_DIR}/node/bin/node" --version)
fi
local node_version=$("node" --version)

node_url=""
local node_url=""
if [ "$(uname)" == "Darwin" ]; then
arch=$(uname -m)
if [[ $arch == x86_64* ]]; then
Expand All @@ -190,16 +164,27 @@ function setup_node() {
else
node_url="https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-linux-x64.tar.gz"
fi
check_and_install "${SCRIPT_DIR}/node/bin/node" "$node_version" "$NODE_VERSION" "curl $node_url --output node.tar.xz

check_and_install "node" "$node_version" "$NODE_VERSION" "curl $node_url --output node.tar.xz
&& tar -xf node.tar.xz
&& rm node.tar.xz
&& mv node-v*-*-* \"${SCRIPT_DIR}/node\""

if [ $? -eq 1 ] || [ "$INSTALL_DEPS" == "1" ]; then
if [ $? -eq 1 ]; then
# installed node, point PATH to it
PATH="${SCRIPT_DIR}/node/bin:$PATH"
fi

# if node_modules doesnt exist or the package-lock file is newer than node_modules, install deps
if [ ! -d node_modules ] || [ ../package-lock.json -nt node_modules ] || [ "$INSTALL_DEPS" == "1" ]; then
echo "Installing dependencies..."
"${NPM}" install
npm install
fi

# log node version for audits
echo "Using node version: $(node --version)"
echo "Using NPM version: $(npm --version)"

popd > /dev/null
}

Expand All @@ -209,14 +194,14 @@ function setup_libraries() {
if [ ! -d "${SCRIPT_DIR}/../../../Common/dist/" ] || [ "$BUILD_LIBRARIES" == "1" ]; then
pushd "${SCRIPT_DIR}/../../../Common" > /dev/null
echo "Building common library."
"${NPM}" run build:cjs
npm run build:cjs
popd > /dev/null
fi

if [ ! -d "${SCRIPT_DIR}/../../../Signalling/dist/" ] || [ "$BUILD_LIBRARIES" == "1" ]; then
pushd "${SCRIPT_DIR}/../../../Signalling" > /dev/null
echo "Building signalling library."
"${NPM}" run build:cjs
npm run build:cjs
popd > /dev/null
fi

Expand All @@ -242,13 +227,13 @@ function setup_frontend() {
echo "Building Typescript Frontend."
# Using our bundled NodeJS, build the web frontend files
pushd "${SCRIPT_DIR}/../../../Frontend/library" > /dev/null
"${NPM}" run build:cjs
npm run build:cjs
popd > /dev/null
pushd "${SCRIPT_DIR}/../../../Frontend/ui-library" > /dev/null
"${NPM}" run build:cjs
npm run build:cjs
popd > /dev/null
pushd "${SCRIPT_DIR}/../../../Frontend/implementations/typescript" > /dev/null
"${NPM}" run build:dev
npm run build:dev
popd > /dev/null
else
echo 'Skipping building Frontend because files already exist. Please run with "--build" to force a rebuild'
Expand Down Expand Up @@ -372,27 +357,25 @@ function start_process() {

# Assumes the following are set
# SCRIPT_DIR = The path to the platform_scripts
# NPM = The npm command path
function build_wilbur() {
if [ ! -d "${SCRIPT_DIR}/../../dist" ] || [ "$BUILD_WILBUR" == "1" ] ; then
pushd "${SCRIPT_DIR}/../.." > /dev/null
echo Building wilbur
"${NPM}" run build
npm run build
popd > /dev/null
fi
}

# Assumes the following are set
# SCRIPT_DIR = The path to the platform_scripts
# NPM = The npm command path
# SERVER_ARGS The arguments to be passed to the server
function start_wilbur() {
pushd "${SCRIPT_DIR}/../../../SignallingWebServer" > /dev/null

echo "Starting wilbur signalling server use ctrl-c to exit"
echo "----------------------------------"

start_process "sudo PATH=\"$PATH\" \"$NPM\" start -- ${SERVER_ARGS}"
start_process "sudo env \"PATH=$PATH\" npm start -- ${SERVER_ARGS}"

popd > /dev/null
}