2019-11-07 21:02:59 +00:00
#!/usr/bin/env sh
set -eu
2016-03-29 20:58:18 +00:00
2023-11-14 18:12:33 +00:00
TARGET_FRAMEWORK = "net8.0"
2019-01-11 15:48:40 +00:00
2017-11-13 01:13:29 +00:00
MAIN_PROJECT = "ArchiSteamFarm"
2020-06-15 11:21:56 +00:00
STEAM_TOKEN_DUMPER_NAME = " ${ MAIN_PROJECT } .OfficialPlugins.SteamTokenDumper "
2017-11-13 01:13:29 +00:00
TESTS_PROJECT = " ${ MAIN_PROJECT } .Tests "
SOLUTION = " ${ MAIN_PROJECT } .sln "
2017-10-18 13:03:52 +00:00
CONFIGURATION = "Release"
2019-09-26 18:28:25 +00:00
OUT = "out"
2020-06-15 11:21:56 +00:00
OUT_ASF = " ${ OUT } /result "
2023-07-23 10:25:14 +00:00
PLUGINS = " ${ MAIN_PROJECT } .OfficialPlugins.ItemsMatcher ${ MAIN_PROJECT } .OfficialPlugins.MobileAuthenticator "
2017-08-31 05:54:07 +00:00
2021-05-07 22:17:27 +00:00
ANALYSIS = 1
2019-01-10 23:55:15 +00:00
ASF_UI = 1
2016-03-29 20:58:18 +00:00
CLEAN = 0
2018-02-26 18:58:25 +00:00
PULL = 1
2018-02-07 05:37:21 +00:00
SHARED_COMPILATION = 1
2017-10-18 13:03:52 +00:00
TEST = 1
2016-03-29 20:58:18 +00:00
2019-01-11 15:48:40 +00:00
PRINT_USAGE( ) {
2021-05-07 22:17:27 +00:00
echo " Usage: $0 [--clean] [--no-analysis] [--no-asf-ui] [--no-pull] [--no-shared-compilation] [--no-test] [debug/release] "
2019-01-11 15:48:40 +00:00
}
2021-05-15 21:37:52 +00:00
OS_TYPE = " $( uname -s) "
case " $OS_TYPE " in
"Darwin" ) SCRIPT_PATH = " $( readlink " $0 " ) " ; ;
"FreeBSD" ) SCRIPT_PATH = " $( readlink -f " $0 " ) " ; ;
"Linux" ) SCRIPT_PATH = " $( readlink -f " $0 " ) " ; ;
*) echo " ERROR: Unknown OS type: ${ OS_TYPE } . If you believe that our script should work on your machine, please let us know. " ; exit 1
esac
SCRIPT_DIR = " $( dirname " $SCRIPT_PATH " ) "
cd " $SCRIPT_DIR "
2016-03-29 20:58:18 +00:00
for ARG in " $@ " ; do
case " $ARG " in
2017-08-31 05:54:07 +00:00
debug| Debug) CONFIGURATION = "Debug" ; ;
2018-05-13 18:33:44 +00:00
release| Release) CONFIGURATION = "Release" ; ;
2021-05-07 22:17:27 +00:00
--analysis) ANALYSIS = 1 ; ;
--no-analysis) ANALYSIS = 0 ; ;
2019-01-10 23:55:15 +00:00
--asf-ui) ASF_UI = 1 ; ;
--no-asf-ui) ASF_UI = 0 ; ;
2016-03-29 20:58:18 +00:00
--clean) CLEAN = 1 ; ;
2018-05-13 18:33:44 +00:00
--no-clean) CLEAN = 0 ; ;
--pull) PULL = 1 ; ;
2018-02-26 18:58:25 +00:00
--no-pull) PULL = 0 ; ;
2018-05-13 18:33:44 +00:00
--shared-compilation) SHARED_COMPILATION = 1 ; ;
2018-02-07 05:37:21 +00:00
--no-shared-compilation) SHARED_COMPILATION = 0 ; ;
2018-05-13 18:33:44 +00:00
--test) TEST = 1 ; ;
2017-10-18 13:03:52 +00:00
--no-test) TEST = 0 ; ;
2019-01-11 15:48:40 +00:00
--help) PRINT_USAGE; exit 0 ; ;
*) PRINT_USAGE; exit 1
2016-03-29 20:58:18 +00:00
esac
done
2019-11-07 21:02:59 +00:00
trap " trap - TERM && kill -- - $$ " INT TERM
2017-10-18 13:03:52 +00:00
2019-11-07 21:02:59 +00:00
if ! command -v dotnet >/dev/null; then
2017-06-26 03:14:44 +00:00
echo "ERROR: dotnet CLI tools are not installed!"
exit 1
fi
2016-03-29 20:58:18 +00:00
2017-08-31 05:54:07 +00:00
dotnet --info
2019-11-07 21:02:59 +00:00
if [ " $PULL " -eq 1 ] && [ -d ".git" ] && command -v git >/dev/null; then
2018-12-26 01:53:06 +00:00
git pull --recurse-submodules= on-demand || true
2016-03-29 20:58:18 +00:00
fi
2019-11-07 21:02:59 +00:00
if [ ! -f " $SOLUTION " ] ; then
2017-08-31 05:54:25 +00:00
echo " ERROR: $SOLUTION could not be found! "
2016-03-29 20:58:18 +00:00
exit 1
fi
2021-05-15 21:37:52 +00:00
case " $OS_TYPE " in
2020-04-22 20:48:42 +00:00
"Darwin" ) os_type = "osx" ; ;
2021-01-14 09:54:15 +00:00
"FreeBSD" ) os_type = "freebsd" ; ;
2020-04-22 20:48:42 +00:00
"Linux" ) os_type = "linux" ; ;
2021-05-15 21:37:52 +00:00
*) echo " ERROR: Unknown OS type: ${ OS_TYPE } . If you believe that our script should work on your machine, please let us know. " ; exit 1
2020-04-22 20:48:42 +00:00
esac
cpu_architecture = " $( uname -m) "
case " $cpu_architecture " in
"aarch64" ) cpu_architecture = "arm64" ; ;
2021-01-14 09:54:15 +00:00
"amd64" ) cpu_architecture = "x64" ; ;
2021-11-10 19:36:09 +00:00
"arm64" ) ; ;
2020-04-22 20:48:42 +00:00
"armv7l" ) cpu_architecture = "arm" ; ;
"x86_64" ) cpu_architecture = "x64" ; ;
*) echo " ERROR: Unknown CPU architecture: ${ cpu_architecture } . If you believe that our script should work on your machine, please let us know. " ; exit 1
esac
echo " INFO: Detected ${ os_type } - ${ cpu_architecture } machine. "
2019-11-07 21:02:59 +00:00
if [ " $ASF_UI " -eq 1 ] ; then
if [ -f "ASF-ui/package.json" ] && command -v npm >/dev/null; then
2020-04-22 20:48:42 +00:00
echo "INFO: Building ASF-ui..."
2018-09-22 23:52:19 +00:00
2019-01-10 23:55:15 +00:00
# ASF-ui doesn't clean itself after old build
rm -rf "ASF-ui/dist"
2018-12-05 22:17:09 +00:00
2020-04-22 20:48:42 +00:00
npm ci --no-progress --prefix ASF-ui
npm run-script deploy --no-progress --prefix ASF-ui
2018-12-05 22:23:59 +00:00
2019-01-10 23:55:15 +00:00
# ASF's output www folder needs cleaning as well
2020-06-15 11:21:56 +00:00
rm -rf " ${ OUT_ASF } /www "
2019-01-10 23:55:15 +00:00
else
2019-08-03 00:16:16 +00:00
echo "WARNING: ASF-ui dependencies are missing, skipping build of ASF-ui..."
2019-01-10 23:55:15 +00:00
fi
2018-09-22 23:52:19 +00:00
fi
2021-11-29 08:56:43 +00:00
DOTNET_FLAGS = " -c $CONFIGURATION -f $TARGET_FRAMEWORK -p:ContinuousIntegrationBuild=true -p:UseAppHost=false --nologo "
PUBLISH_FLAGS = " -r ${ os_type } - ${ cpu_architecture } --no-self-contained "
2018-02-07 05:37:21 +00:00
2021-05-07 22:17:27 +00:00
if [ " $ANALYSIS " -eq 0 ] ; then
DOTNET_FLAGS = " $DOTNET_FLAGS -p:AnalysisMode=AllDisabledByDefault "
fi
2019-11-07 21:02:59 +00:00
if [ " $SHARED_COMPILATION " -eq 0 ] ; then
2020-04-22 20:48:42 +00:00
DOTNET_FLAGS = " $DOTNET_FLAGS -p:UseSharedCompilation=false "
2018-05-13 18:33:44 +00:00
fi
2019-11-07 21:02:59 +00:00
if [ " $CLEAN " -eq 1 ] ; then
dotnet clean $DOTNET_FLAGS
2019-09-26 18:28:25 +00:00
rm -rf " $OUT "
2018-02-07 05:37:21 +00:00
fi
2017-08-31 05:54:07 +00:00
2019-11-07 21:02:59 +00:00
if [ " $TEST " -eq 1 ] ; then
dotnet test " $TESTS_PROJECT " $DOTNET_FLAGS
2017-10-18 13:03:52 +00:00
fi
2016-03-29 20:58:18 +00:00
2022-12-15 17:46:37 +00:00
echo " INFO: Building ${ MAIN_PROJECT } ... "
2021-11-29 08:56:43 +00:00
dotnet publish " $MAIN_PROJECT " -o " $OUT_ASF " $DOTNET_FLAGS $PUBLISH_FLAGS
2020-06-15 11:21:56 +00:00
2021-01-14 10:03:42 +00:00
if [ -n " ${ STEAM_TOKEN_DUMPER_TOKEN - } " ] && [ -f " ${ STEAM_TOKEN_DUMPER_NAME } /SharedInfo.cs " ] && command -v git >/dev/null; then
2020-06-15 11:45:17 +00:00
git checkout -- " ${ STEAM_TOKEN_DUMPER_NAME } /SharedInfo.cs "
sed " s/STEAM_TOKEN_DUMPER_TOKEN/ ${ STEAM_TOKEN_DUMPER_TOKEN } /g " " ${ STEAM_TOKEN_DUMPER_NAME } /SharedInfo.cs " > " ${ STEAM_TOKEN_DUMPER_NAME } /SharedInfo.cs.new " ;
mv " ${ STEAM_TOKEN_DUMPER_NAME } /SharedInfo.cs.new " " ${ STEAM_TOKEN_DUMPER_NAME } /SharedInfo.cs "
2022-12-15 17:46:37 +00:00
echo " INFO: Building ${ STEAM_TOKEN_DUMPER_NAME } ... "
2020-06-15 11:21:56 +00:00
2022-12-15 17:46:37 +00:00
dotnet publish " $STEAM_TOKEN_DUMPER_NAME " -o " ${ OUT_ASF } /plugins/ ${ STEAM_TOKEN_DUMPER_NAME } " $DOTNET_FLAGS $PUBLISH_FLAGS
git checkout -- " ${ STEAM_TOKEN_DUMPER_NAME } /SharedInfo.cs "
2020-06-15 11:45:17 +00:00
else
2021-01-14 10:03:42 +00:00
echo " WARNING: ${ STEAM_TOKEN_DUMPER_NAME } dependencies are missing, skipping build of ${ STEAM_TOKEN_DUMPER_NAME } ... "
2020-06-15 11:21:56 +00:00
fi
2018-05-13 18:33:44 +00:00
2022-12-15 17:46:37 +00:00
for plugin in $PLUGINS ; do
echo " INFO: Building ${ plugin } ... "
dotnet publish " $plugin " -o " ${ OUT_ASF } /plugins/ ${ plugin } " $DOTNET_FLAGS $PUBLISH_FLAGS
done
2016-03-29 20:58:18 +00:00
echo
2019-08-03 00:16:16 +00:00
echo "SUCCESS: Compilation finished successfully! :)"