2020-03-04 00:03:33 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Author: Evan Hemsley
|
|
|
|
# Usage: ./install.sh
|
|
|
|
|
|
|
|
# This file is heavily borrowed from Caleb Cornett's template install script.
|
|
|
|
|
|
|
|
# Get the directory of this script
|
2020-03-04 00:22:12 +00:00
|
|
|
MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
2020-03-04 00:03:33 +00:00
|
|
|
|
2021-04-05 20:57:34 +00:00
|
|
|
FNA_VERSION=21.04
|
2020-07-11 21:41:42 +00:00
|
|
|
|
2020-07-11 21:07:50 +00:00
|
|
|
readlinkf(){ perl -MCwd -e 'print Cwd::abs_path shift' "$1";}
|
|
|
|
|
2020-03-04 00:03:33 +00:00
|
|
|
# Checks if git is installed
|
|
|
|
function checkGit()
|
|
|
|
{
|
2022-08-30 04:39:34 +00:00
|
|
|
git --version > /dev/null 2>&1
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo >&2 "ERROR: Git is not installed. Please install git to download FNA."
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-03-04 00:03:33 +00:00
|
|
|
}
|
|
|
|
|
2020-07-11 21:07:50 +00:00
|
|
|
# Pulls FNA from github
|
2020-03-04 00:03:33 +00:00
|
|
|
function pullFNA()
|
|
|
|
{
|
2022-08-30 04:39:34 +00:00
|
|
|
checkGit
|
|
|
|
git submodule add https://github.com/FNA-XNA/FNA.git
|
|
|
|
echo "Updating to the latest git version of FNA..."
|
2020-03-04 00:03:33 +00:00
|
|
|
git submodule update --init --recursive
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Finished updating!"
|
|
|
|
else
|
|
|
|
echo >&2 "ERROR: Unable to update."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Downloads and extracts prepackaged archive of native libraries ("fnalibs")
|
|
|
|
function getLibs()
|
|
|
|
{
|
2022-08-30 04:39:34 +00:00
|
|
|
# Downloading
|
|
|
|
echo "Downloading latest fnalibs..."
|
|
|
|
curl https://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 > "$MY_DIR/fnalibs.tar.bz2"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Finished downloading!"
|
|
|
|
else
|
|
|
|
>&2 echo "ERROR: Unable to download successfully."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Decompressing
|
|
|
|
echo "Decompressing fnalibs..."
|
|
|
|
mkdir -p "$MY_DIR"/fnalibs
|
|
|
|
tar xjC "$MY_DIR"/fnalibs -f "$MY_DIR"/fnalibs.tar.bz2
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Finished decompressing!"
|
|
|
|
echo ""
|
|
|
|
rm "$MY_DIR"/fnalibs.tar.bz2
|
|
|
|
else
|
|
|
|
>&2 echo "ERROR: Unable to decompress successfully."
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-03-04 00:03:33 +00:00
|
|
|
}
|
|
|
|
|
2020-03-04 00:22:12 +00:00
|
|
|
read -p "Enter your project name or 'exit' to quit: " newProjectName
|
2020-03-04 00:03:33 +00:00
|
|
|
if [[ $newProjectName = 'exit' || -z "$newProjectName" ]]; then
|
2022-08-30 04:39:34 +00:00
|
|
|
exit 1
|
2020-03-04 00:03:33 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-04 00:22:12 +00:00
|
|
|
NEW_PROJECT_DIR="$MY_DIR/../$newProjectName"
|
2022-08-30 04:24:56 +00:00
|
|
|
|
|
|
|
if [ -d "$NEW_PROJECT_DIR" ]; then
|
|
|
|
>&2 echo "ERROR: Project directory already exists."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
getLibs
|
|
|
|
|
|
|
|
# copy everything into new dir
|
2020-05-02 06:06:09 +00:00
|
|
|
cp -R "$MY_DIR" "$NEW_PROJECT_DIR"
|
2020-03-04 00:03:33 +00:00
|
|
|
|
2020-05-02 06:06:09 +00:00
|
|
|
cd "$NEW_PROJECT_DIR"
|
2020-03-04 00:03:33 +00:00
|
|
|
files=(ProjectName.Core.sln ProjectName.Framework.sln .gitignore ProjectName/ProjectName.Core.csproj ProjectName/ProjectName.Framework.csproj ProjectName/ProjectNameGame.cs ProjectName/Program.cs .vscode/tasks.json .vscode/launch.json)
|
|
|
|
for file in "${files[@]}"; do
|
2022-08-30 04:39:34 +00:00
|
|
|
sed -i -e "s/ProjectName/$newProjectName/g" "./$file"
|
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
|
|
rm ./${file}-e
|
|
|
|
fi
|
2020-03-04 00:03:33 +00:00
|
|
|
done
|
|
|
|
|
2020-03-04 00:22:12 +00:00
|
|
|
mv ./ProjectName.Core.sln "./$newProjectName.Core.sln"
|
|
|
|
mv ./ProjectName.Framework.sln "./$newProjectName.Framework.sln"
|
|
|
|
mv ./ProjectName/ProjectName.Core.csproj "./ProjectName/$newProjectName.Core.csproj"
|
|
|
|
mv ./ProjectName/ProjectName.Framework.csproj "./ProjectName/$newProjectName.Framework.csproj"
|
|
|
|
mv ./ProjectName/ProjectNameGame.cs ./ProjectName/${newProjectName}Game.cs
|
|
|
|
mv ./ProjectName "./$newProjectName"
|
|
|
|
rm ./install.sh
|
2020-07-11 21:07:50 +00:00
|
|
|
rm ./LICENSE
|
|
|
|
|
|
|
|
rm -rf .git
|
|
|
|
git init
|
|
|
|
pullFNA
|
|
|
|
|
2021-02-03 04:06:56 +00:00
|
|
|
dotnet sln ${newProjectName}.Framework.sln add FNA/FNA.csproj
|
|
|
|
dotnet sln ${newProjectName}.Core.sln add FNA/FNA.Core.csproj
|
|
|
|
|
2020-07-11 21:07:50 +00:00
|
|
|
echo "Project $newProjectName created at: "
|
2020-03-04 00:22:12 +00:00
|
|
|
|
2020-07-11 21:07:50 +00:00
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
2022-08-30 04:39:34 +00:00
|
|
|
echo $(readlinkf $NEW_PROJECT_DIR)
|
2020-07-11 21:07:50 +00:00
|
|
|
else
|
2022-08-30 04:39:34 +00:00
|
|
|
echo $(readlink -f $NEW_PROJECT_DIR)
|
2020-07-11 21:07:50 +00:00
|
|
|
fi
|