diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..842db92 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +OUTPUTS = VisualCard.*/bin VisualCard.*/obj VisualCard/bin VisualCard/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. diff --git a/tools/Makefile b/tools/Makefile new file mode 100644 index 0000000..77bbf99 --- /dev/null +++ b/tools/Makefile @@ -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) diff --git a/tools/build.cmd b/tools/build.cmd new file mode 100644 index 0000000..0faf652 --- /dev/null +++ b/tools/build.cmd @@ -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 "..\VisualCard.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 "..\VisualCard.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 diff --git a/tools/build.sh b/tools/build.sh new file mode 100644 index 0000000..9aeb75a --- /dev/null +++ b/tools/build.sh @@ -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 "../VisualCard.sln" -t:restore -p:Configuration=$releaseconf +if [ ! $? == 0 ]; then + echo Download failed. + exit 1 +fi + +# Build KS +echo Building KS... +"$dotnetpath" msbuild "../VisualCard.sln" -p:Configuration=$releaseconf +if [ ! $? == 0 ]; then + echo Build failed. + exit 1 +fi + +# Inform success +echo Build successful. +exit 0 diff --git a/tools/docgen-pack.cmd b/tools/docgen-pack.cmd new file mode 100644 index 0000000..ad177a5 --- /dev/null +++ b/tools/docgen-pack.cmd @@ -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 diff --git a/tools/docgen-pack.sh b/tools/docgen-pack.sh new file mode 100644 index 0000000..74eab82 --- /dev/null +++ b/tools/docgen-pack.sh @@ -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 diff --git a/tools/docgen.cmd b/tools/docgen.cmd new file mode 100644 index 0000000..e408d76 --- /dev/null +++ b/tools/docgen.cmd @@ -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 diff --git a/tools/docgen.sh b/tools/docgen.sh new file mode 100644 index 0000000..b22aafd --- /dev/null +++ b/tools/docgen.sh @@ -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 diff --git a/tools/pack.cmd b/tools/pack.cmd new file mode 100644 index 0000000..1bc286b --- /dev/null +++ b/tools/pack.cmd @@ -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 "..\VisualCard\bin\%releaseconfig%\netstandard2.0\" +"%ProgramFiles%\WinRAR\rar.exe" a -ep1 -r -m5 %temp%/%version%-demo.rar "..\VisualCard.ShowContacts\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 diff --git a/tools/pack.sh b/tools/pack.sh new file mode 100644 index 0000000..f07b2d2 --- /dev/null +++ b/tools/pack.sh @@ -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 "../VisualCard/bin/$releaseconf/netstandard2.0/" +"$rarpath" a -ep1 -r -m5 /tmp/$version-demo.rar "../VisualCard.ShowContacts/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 diff --git a/tools/version b/tools/version new file mode 100644 index 0000000..bad34a3 --- /dev/null +++ b/tools/version @@ -0,0 +1 @@ +0.1.0.4