This commit is contained in:
Nikolaj Olsson 2023-11-26 15:29:02 +01:00
commit 20f386b183
5 changed files with 124 additions and 5 deletions

87
build.sh Normal file
View File

@ -0,0 +1,87 @@
#!bin/bash
function ShowHelp()
{
echo
echo "Usage: $0 [clean|Build|rebuild]"
echo
echo "$0 without any arguments is equivalent to $0 build"
exit
}
function EndWithError()
{
echo
echo "** ERROR: Build failed and aborted! **"
exit
}
#Check parameters
case $1 in
help | -h) ShowHelp;;
build | -b) BUILDTYPE="CoreBuild";;
clean | -c) BUILDTYPE="clean";;
rebuild | -r) BUILDTYPE="rebuild";;
"") BUILDTYPE="CoreBuild";;
*) echo; echo "Unsupported commandline switch!"; EndWithError
esac
#Search mono, msbuild and nuget
if [ -z $(command -v "mono") ]; then
echo "mono not found!"
echo "please download from official website <http://www.mono-project.com>";
EndWithError
fi
if [ -z $(command -v "msbuild") ]; then
echo "msbuild not found!"
echo "please download mono from official website <http://www.mono-project.com>"
EndWithError
fi
if [ -z $(command -v "nuget") ]; then
echo "nuget not found!"
echo "Please install nuget"
EndWithError
fi
# Enter in correct diretory
if [ ${0%/*} == $0 ]; then
cd ${PWD}
elif [ -e ${PWD}/${0%/*} ]; then
cd ${PWD}/${0%/*}
else
cd ${0%/*}
fi
#Try update souce code
git pull
echo
echo "Starting compilation..."
echo
echo "$BUILDTYPE""ing Subtitle Edit - Release|Any CPU..."
echo Check for new translation strings...
echo
msbuild src/UpdateLanguageFiles/UpdateLanguageFiles.csproj -r -t:Rebuild -p:Configuration=Debug -p:Platform=\"Any CPU\" -p:OutputPath=bin/Debug
echo
LanguageToolPath="src/UpdateLanguageFiles/bin/debug/UpdateLanguageFiles.exe"
if [ -e "./"$LanguageToolPath ]; then
mono $LanguageToolPath LanguageBaseEnglish.xml src/ui/Logic/LanguageDeserializer.cs
else
echo "Compile UpdateLanguageFiles!"
fi
echo
# Restore nuget package (the '-r' does nothing on my system)
nuget restore SubtitleEdit.sln
echo
msbuild SubtitleEdit.sln -r -t:SubtitleEdit:$BUILDTYPE -p:Configuration=Release -p:Platform=\"Any CPU\" -maxcpucount -consoleloggerparameters:DisableMPLogging\;Summary\;Verbosity=minimal
if [ $? -eq 1 ]; then
echo EndWithError
fi
echo
echo $BUILDTYPE"ing Subtitle Edit finished!"

30
build_helpers.sh Normal file
View File

@ -0,0 +1,30 @@
#!bin/bash
# Get script folder
if [ ${0%/*} == $0 ]; then
ScriptPath=${PWD}/
elif [ -e ${PWD}/${0%/*} ]; then
ScriptPath=${PWD}/${0%/*}/
else
ScriptPath=${0%/*}/
fi
ConfigurationName="$2"
if [ "$1" == "lang" ]; then
ToolPath=$ScriptPath"src/UpdateLanguageFiles/bin/$ConfigurationName/UpdateLanguageFiles.exe"
if [ -e $ToolPath ]; then
mono $ToolPath $ScriptPath"LanguageBaseEnglish.xml" $ScriptPath"src/ui/Logic/LanguageDeserializer.cs"
else
echo "Compile Subtitle Edit first!"
echo
fi
elif [ "$1" == "rev" ]; then
ToolPath=$ScriptPath"src/UpdateAssemblyInfo/bin/$ConfigurationName/UpdateAssemblyInfo.exe"
if [ -e $ToolPath ]; then
mono $ToolPath $ScriptPath"src/ui/Properties/AssemblyInfo.cs.template" $ScriptPath"src/libse/Properties/AssemblyInfo.cs.template"
else
echo "Compile Subtitle Edit first!"
echo
fi
fi

View File

@ -326,7 +326,7 @@ namespace UpdateAssemblyInfo
var gitPath = GetGitPath();
if (clrTags.RunCommandAndGetOutput(gitPath, "describe --long --tags", workingDirectory))
{
if (clrTags.Result.Contains("RC"))
if (clrTags.Result != null && clrTags.Result.Contains("RC"))
{
return true;
}

View File

@ -37,7 +37,8 @@
</ItemGroup>
<Target Name="InvokeBuildHelpers" BeforeTargets="BeforeCompile;CoreCompile">
<Exec Command="%22$(SolutionDir)build_helpers.bat%22 rev %22$(ConfigurationName)%22" />
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="%22$(SolutionDir)build_helpers.bat%22 rev %22$(ConfigurationName)%22" />
<Exec Condition="'$(OS)' == 'Unix'" Command="bash $(ProjectDir)../../build_helpers.sh rev $(ConfigurationName)" />
</Target>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

View File

@ -2641,14 +2641,15 @@
</HunspellAssemblies>
</ItemGroup>
<Target Name="BeforeCompile">
<XmlPeek XmlInputPath="$(SolutionDir)\src\ui\packages.config" Query="//package[@id='NHunspell']/@version">
<XmlPeek XmlInputPath="$(ProjectDir)packages.config" Query="//package[@id='NHunspell']/@version">
<Output TaskParameter="Result" PropertyName="HunspellVersion" />
</XmlPeek>
<PropertyGroup>
<HunspellDir>..\..\packages\NHunspell.$(HunspellVersion)\content\</HunspellDir>
</PropertyGroup>
<Copy SourceFiles="@(HunspellAssemblies -> '$(HunspellDir)%(Identity)')" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="True" />
<Exec Command="%22$(SolutionDir)\build_helpers.bat%22 rev %22$(ConfigurationName)%22" />
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="%22$(SolutionDir)\build_helpers.bat%22 rev %22$(ConfigurationName)%22" />
<Exec Condition="'$(OS)' == 'Unix'" Command="bash $(ProjectDir)../../build_helpers.sh rev $(ConfigurationName)" />
</Target>
<Target Name="BeforeClean">
<Delete Files="@(HunspellAssemblies -> '$(OutputPath)%(Identity)')" />