diff --git a/build-template/build.sh b/build-template/build.sh new file mode 100644 index 0000000000000000000000000000000000000000..db1e0c3dde26c8d73f117d8a3f959bf0e706f4cc --- /dev/null +++ b/build-template/build.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +if test `uname` = Darwin; then + cachedir=~/Library/Caches/KBuild +else + if x$XDG_DATA_HOME = x; then + cachedir=$HOME/.local/share + else + cachedir=$XDG_DATA_HOME; + fi +fi +mkdir -p $cachedir + +url=https://www.nuget.org/nuget.exe + +if test ! -f $cachedir/nuget.exe; then + wget -o $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null +fi + +if test ! -e .nuget; then + mkdir .nuget + cp $cachedir/nuget.exe .nuget +fi + +if test ! -d packages/KoreBuild; then + mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre + mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion +fi + +mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" \ No newline at end of file diff --git a/build/_k-standard-goals.shade b/build/_k-standard-goals.shade index f38f899f1946de5b3e0584da2daaa06aa095fbdf..9b67005a61c99ac5b0579eb6290b72b605becad0 100644 --- a/build/_k-standard-goals.shade +++ b/build/_k-standard-goals.shade @@ -3,6 +3,7 @@ use namespace="System.IO" use import="Files" use import="BuildEnv" use import="FileWatcher" +use import="Environment" default BASE_DIR='${Directory.GetCurrentDirectory()}' default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}' @@ -16,7 +17,7 @@ default Configuration='Release' #repo-initialize target='initialize' k-restore - k-generate-projects solutionPath='${BASE_DIR}' + k-generate-projects solutionPath='${BASE_DIR}' if='!IsMono' #target-dir-clean target='clean' directory delete="${TARGET_DIR}" @@ -33,7 +34,7 @@ default Configuration='Release' } } -#native-compile target='compile' +#native-compile target='compile' if='!IsMono' var programFilesX86 = '${Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}' var msbuild = '${Path.Combine(programFilesX86, "MSBuild", "12.0", "Bin", "MSBuild.exe")}' var nativeProjects ='${Files.Include(Path.Combine(BASE_DIR, "src", "**", "*.vcxproj"))}' diff --git a/build/_k.shade b/build/_k.shade index 11faa3391cdbac7ccb8a590c7c113995414dc09d..afd61f8d3cb6dd46fdfcd80609fc638b5115e3e8 100644 --- a/build/_k.shade +++ b/build/_k.shade @@ -17,8 +17,10 @@ prefetch='true' */} default prefetch='${true}' +default mono='${IsMono}' -nuget-install package='ProjectK' outputDir='packages' extra='-pre -nocache' once='ProjectK-NuGet' if='prefetch' +nuget-install package='ProjectK' outputDir='packages' extra='-pre -nocache' once='ProjectK-NuGet' if='prefetch && !mono' +nuget-install package='ProjectK.Mono' outputDir='packages' extra='-pre -nocache' once='ProjectK-NuGet' if='mono' @{ Func<string, long> getVersion = version => { @@ -38,12 +40,42 @@ nuget-install package='ProjectK' outputDir='packages' extra='-pre -nocache' once return Int64.MaxValue; }; + var projectKPrefix = mono ? "ProjectK.Mono*" : "ProjectK"; + string packagesDir = Path.Combine(Directory.GetCurrentDirectory(), "packages"), - projectKDir = Directory.EnumerateDirectories(packagesDir, "ProjectK*") + projectKDir = Directory.EnumerateDirectories(packagesDir, projectKPrefix) .OrderByDescending(getVersion) .First(); } default kProgram='${projectKDir}/tools/k.cmd' -exec program='${Path.GetFullPath(kProgram)}' commandline='${command}' +exec program='${Path.GetFullPath(kProgram)}' commandline='${command}' if='!mono' + +default kMonoProgram='${projectKDir}/tools/net45/klr.mono.managed.dll' +default monoPath='${Environment.GetEnvironmentVariable("MONO_PATH")}' + +@{ + if(string.IsNullOrEmpty(monoPath)) + { + monoPath = "mono"; + } + + var folder = Path.Combine(projectKDir, "tools", "net45"); + var kMonoEntryPoint = Path.GetFullPath(kMonoProgram); + + if(command.StartsWith("build")) + { + command = kMonoEntryPoint + " --lib " + folder + " Microsoft.Net.Project " + command; + } + else if(command.StartsWith("restore")) + { + command = Path.Combine(projectKDir, "tools", "NuGet.exe") + " " + command; + } + else + { + command = kMonoEntryPoint + " --lib " + folder + " Microsoft.Net.ApplicationHost " + command; + } +} + +exec program='${monoPath}' commandline='${command}' if='mono' \ No newline at end of file