Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Makefiles and build scripts added
Browse files Browse the repository at this point in the history
  • Loading branch information
AptiviCEO committed Aug 24, 2023
1 parent 92f5131 commit 546f454
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
OUTPUTS = SharpLyrics.*/bin SharpLyrics.*/obj SharpLyrics/bin SharpLyrics/obj

.PHONY: all

# General use

all: all-online

all-online:
$(MAKE) -C tools invoke-build

clean:
rm -rf $(OUTPUTS)

# This makefile is just a wrapper for tools scripts.
9 changes: 9 additions & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Below is a workaround for .NET SDK 7.0 trying to allocate large amounts of memory for GC work:
# https://github.com/dotnet/runtime/issues/85556#issuecomment-1529177092
DOTNET_PAGE_SIZE = $(shell getconf PAGESIZE)
DOTNET_AVPHYS_PAGES = $(shell getconf _AVPHYS_PAGES)
DOTNET_HEAP_LIMIT = $(shell printf '%X\n' $$(($(DOTNET_AVPHYS_PAGES) * $(DOTNET_PAGE_SIZE))))

invoke-build:
chmod +x ./build.sh
./build.sh || (echo Retrying with heap limit 0x$(DOTNET_HEAP_LIMIT)... && DOTNET_GCHeapHardLimit=$(DOTNET_HEAP_LIMIT) ./build.sh)
23 changes: 23 additions & 0 deletions tools/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@echo off

REM This script builds and packs the artifacts. Use when you have VS installed.
set releaseconfig=%1
if "%releaseconfig%" == "" set releaseconfig=Release

:download
echo Downloading packages...
"%ProgramFiles%\dotnet\dotnet.exe" msbuild "..\SharpLyrics.sln" -t:restore -p:Configuration=%releaseconfig%
if %errorlevel% == 0 goto :build
echo There was an error trying to download packages (%errorlevel%).
goto :finished

:build
echo Building Nitrocid KS...
"%ProgramFiles%\dotnet\dotnet.exe" msbuild "..\SharpLyrics.sln" -p:Configuration=%releaseconfig%
if %errorlevel% == 0 goto :success
echo There was an error trying to build (%errorlevel%).
goto :finished

:success
echo Build successful.
:finished
34 changes: 34 additions & 0 deletions tools/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# This script builds. Use when you have dotnet installed.
releaseconf=$1
if [ -z $releaseconf ]; then
releaseconf=Release
fi

# Check for dependencies
dotnetpath=`which dotnet`
if [ ! $? == 0 ]; then
echo dotnet is not found.
exit 1
fi

# Download packages
echo Downloading packages...
"$dotnetpath" msbuild "../SharpLyrics.sln" -t:restore -p:Configuration=$releaseconf
if [ ! $? == 0 ]; then
echo Download failed.
exit 1
fi

# Build KS
echo Building KS...
"$dotnetpath" msbuild "../SharpLyrics.sln" -p:Configuration=$releaseconf
if [ ! $? == 0 ]; then
echo Build failed.
exit 1
fi

# Inform success
echo Build successful.
exit 0
22 changes: 22 additions & 0 deletions tools/docgen-pack.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@echo off

REM This script builds KS documentation and packs the artifacts. Use when you have VS installed.
for /f "tokens=* USEBACKQ" %%f in (`type version`) do set version=%%f

:pack
echo Packing documentation...
"%ProgramFiles%\WinRAR\rar.exe" a -ep1 -r -m5 %temp%/%version%-doc.rar "..\docs\"
if %errorlevel% == 0 goto :finalize
echo There was an error trying to pack documentation (%errorlevel%).
goto :finished

:finalize
rmdir /S /Q "..\DocGen\api\"
rmdir /S /Q "..\DocGen\obj\"
rmdir /S /Q "..\docs\"
move %temp%\%version%-doc.rar
echo Build and pack successful.
goto :finished

:finished
pause
27 changes: 27 additions & 0 deletions tools/docgen-pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# This script builds and packs the artifacts. Use when you have MSBuild installed.
version=$(cat version)

# Check for dependencies
rarpath=`which rar`
if [ ! $? == 0 ]; then
echo rar is not found.
exit 1
fi

# Pack documentation
echo Packing documentation...
"$rarpath" a -ep1 -r -m5 /tmp/$version-doc.rar "../docs/"
if [ ! $? == 0 ]; then
echo Packing using rar failed.
exit 1
fi

# Inform success
rm -rf "../DocGen/api"
rm -rf "../DocGen/obj"
rm -rf "../docs"
mv /tmp/$version-doc.rar .
echo Pack successful.
exit 0
19 changes: 19 additions & 0 deletions tools/docgen.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off

REM This script builds documentation and packs the artifacts.

echo Finding DocFX...
if exist %ProgramData%\chocolatey\bin\docfx.exe goto :build
echo You don't have DocFX installed. Download and install Chocolatey and DocFX.
goto :finished

:build
echo Building Documentation...
%ProgramData%\chocolatey\bin\docfx.exe "..\DocGen\docfx.json"
if %errorlevel% == 0 goto :success
echo There was an error trying to build documentation (%errorlevel%).
goto :finished

:success
echo Build and pack successful.
:finished
20 changes: 20 additions & 0 deletions tools/docgen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Check for dependencies
msbuildpath=`which docfx`
if [ ! $? == 0 ]; then
echo DocFX is not found.
exit 1
fi

# Build KS
echo Building documentation...
docfx DocGen/docfx.json
if [ ! $? == 0 ]; then
echo Build failed.
exit 1
fi

# Inform success
echo Build successful.
exit 0
20 changes: 20 additions & 0 deletions tools/pack.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@echo off

for /f "tokens=* USEBACKQ" %%f in (`type version`) do set version=%%f
set releaseconfig=%1
if "%releaseconfig%" == "" set releaseconfig=Release

:packbin
echo Packing binary...
"%ProgramFiles%\WinRAR\rar.exe" a -ep1 -r -m5 %temp%/%version%-bin.rar "..\SharpLyrics\bin\%releaseconfig%\netstandard2.0\"
"%ProgramFiles%\WinRAR\rar.exe" a -ep1 -r -m5 %temp%/%version%-demo.rar "..\SharpLyrics.Demo\bin\%releaseconfig%\net6.0\"
if %errorlevel% == 0 goto :complete
echo There was an error trying to pack binary (%errorlevel%).
goto :finished

:complete
move %temp%\%version%-bin.rar
move %temp%\%version%-demo.rar

echo Pack successful.
:finished
30 changes: 30 additions & 0 deletions tools/pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# This script builds and packs the artifacts. Use when you have MSBuild installed.
version=$(cat version)
releaseconf=$1
if [ -z $releaseconf ]; then
releaseconf=Release
fi

# Check for dependencies
rarpath=`which rar`
if [ ! $? == 0 ]; then
echo rar is not found.
exit 1
fi

# Pack binary
echo Packing binary...
"$rarpath" a -ep1 -r -m5 /tmp/$version-bin.rar "../SharpLyrics/bin/$releaseconf/netstandard2.0/"
"$rarpath" a -ep1 -r -m5 /tmp/$version-demo.rar "../SharpLyrics.Demo/bin/$releaseconf/net6.0/"
if [ ! $? == 0 ]; then
echo Packing using rar failed.
exit 1
fi

# Inform success
mv ~/tmp/$version-bin.rar .
mv ~/tmp/$version-demo.rar .
echo Build and pack successful.
exit 0
1 change: 1 addition & 0 deletions tools/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0.4

0 comments on commit 546f454

Please sign in to comment.