add mac build
This commit is contained in:
parent
1a9a5acb41
commit
1a01bfb931
12 changed files with 163 additions and 13 deletions
BIN
ext/CLRHost/osx.10.10-x64/coreconsole
Executable file
BIN
ext/CLRHost/osx.10.10-x64/coreconsole
Executable file
Binary file not shown.
BIN
ext/CLRHost/osx.10.10-x64/corerun
Executable file
BIN
ext/CLRHost/osx.10.10-x64/corerun
Executable file
Binary file not shown.
58
scripts/bootstrap
Executable file
58
scripts/bootstrap
Executable file
|
@ -0,0 +1,58 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SOURCE="${BASH_SOURCE[0]}"
|
||||||
|
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||||
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
|
SOURCE="$(readlink "$SOURCE")"
|
||||||
|
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||||
|
done
|
||||||
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
|
REPOROOT="$( cd -P "$DIR/.." && pwd )"
|
||||||
|
|
||||||
|
echo "Bootstrapping dotnet.exe using DNX"
|
||||||
|
|
||||||
|
UNAME=$(uname)
|
||||||
|
if [ "$UNAME" == "Darwin" ]; then
|
||||||
|
RID=osx.10.10-x64
|
||||||
|
elif [ "$UNAME" == "Linux" ]; then
|
||||||
|
# Detect Distro?
|
||||||
|
RID=ubuntu.14.04-x64
|
||||||
|
else
|
||||||
|
echo "Unknown OS: $UNAME" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
OUTPUT_ROOT=$REPOROOT/artifacts/$RID
|
||||||
|
STAGE1_DIR=$OUTPUT_ROOT/stage1
|
||||||
|
STAGE2_DIR=$OUTPUT_ROOT/stage2
|
||||||
|
|
||||||
|
STAGE0_PUBLISH=$REPOROOT/scripts/stage0/dotnet-publish
|
||||||
|
|
||||||
|
export DOTNET_CLR_HOSTS_PATH=$REPOROOT/ext/CLRHost/$RID
|
||||||
|
export DOTNET_CSC_PATH=$REPOROOT/src/cscthingy/bin/Debug/dnxcore50/publish
|
||||||
|
|
||||||
|
type -p dnx >/dev/null
|
||||||
|
if [ ! $? ]; then
|
||||||
|
echo "DNX is required to bootstrap stage1" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running 'dnu restore' to restore packages for DNX-hosted projects"
|
||||||
|
|
||||||
|
dnu restore "$REPOROOT" --runtime osx.10.10-x64 --runtime osx.10.11-x64
|
||||||
|
|
||||||
|
# Clean up stage1
|
||||||
|
[ -d "$STAGE1_DIR" ] && rm -Rf "$STAGE1_DIR"
|
||||||
|
|
||||||
|
echo "Building basic dotnet tools using Stage 0 (DNX hosted)"
|
||||||
|
$STAGE0_PUBLISH --framework dnxcore50 --runtime $RID --output "$STAGE1_DIR" "$REPOROOT/src/Microsoft.DotNet.Cli"
|
||||||
|
$STAGE0_PUBLISH --framework dnxcore50 --runtime $RID --output "$STAGE1_DIR" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler"
|
||||||
|
$STAGE0_PUBLISH --framework dnxcore50 --runtime $RID --output "$STAGE1_DIR" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
|
||||||
|
|
||||||
|
# Add stage1 to the path and use it to build stage2
|
||||||
|
export PATH=$STAGE1_DIR:$PATH
|
||||||
|
|
||||||
|
echo "Building stage2 dotnet using stage1 ..."
|
||||||
|
dotnet publish --framework dnxcore50 --runtime $RID --output "$STAGE2_DIR" "$REPOROOT/src/Microsoft.DotNet.Cli"
|
||||||
|
dotnet publish --framework dnxcore50 --runtime $RID --output "$STAGE2_DIR" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler"
|
||||||
|
dotnet publish --framework dnxcore50 --runtime $RID --output "$STAGE2_DIR" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
|
0
scripts/dnxhost/dotnet-compile → scripts/stage0/dotnet-compile
Normal file → Executable file
0
scripts/dnxhost/dotnet-compile → scripts/stage0/dotnet-compile
Normal file → Executable file
0
scripts/dnxhost/dotnet-publish → scripts/stage0/dotnet-publish
Normal file → Executable file
0
scripts/dnxhost/dotnet-publish → scripts/stage0/dotnet-publish
Normal file → Executable file
|
@ -2,17 +2,20 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
namespace Microsoft.DotNet.Cli.Utils
|
||||||
{
|
{
|
||||||
internal static class Constants
|
internal static class Constants
|
||||||
{
|
{
|
||||||
// TODO: On Unix, exe suffix is empty string...
|
// TODO: On Unix, exe suffix is empty string...
|
||||||
public static readonly string ExeSuffix = ".exe";
|
public static readonly string ExeSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "";
|
||||||
public static readonly string CoreConsoleName = "coreconsole" + ExeSuffix;
|
public static readonly string CoreConsoleName = "coreconsole" + ExeSuffix;
|
||||||
|
public static readonly string CoreRunName = "corerun" + ExeSuffix;
|
||||||
public static readonly string DefaultConfiguration = "Debug";
|
public static readonly string DefaultConfiguration = "Debug";
|
||||||
public static readonly string BinDirectoryName = "bin";
|
public static readonly string BinDirectoryName = "bin";
|
||||||
|
|
||||||
public static readonly string HostsPathEnvironmentVariable = "DOTNET_CLR_HOSTS_PATH";
|
public static readonly string HostsPathEnvironmentVariable = "DOTNET_CLR_HOSTS_PATH";
|
||||||
|
public static readonly string CSCPathEnvironmentVariable = "DOTNET_CSC_PATH";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,16 +152,16 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
private static Command RunCsc(string cscArgs)
|
private static Command RunCsc(string cscArgs)
|
||||||
{
|
{
|
||||||
// Locate CoreRun
|
// Locate CoreRun
|
||||||
string hostRoot = Environment.GetEnvironmentVariable(Constants.HostsPathEnvironmentVariable);
|
string hostRoot = Environment.GetEnvironmentVariable("DOTNET_CSC_PATH");
|
||||||
if(string.IsNullOrEmpty(hostRoot))
|
if(string.IsNullOrEmpty(hostRoot))
|
||||||
{
|
{
|
||||||
hostRoot = AppContext.BaseDirectory;
|
hostRoot = AppContext.BaseDirectory;
|
||||||
}
|
}
|
||||||
var corerun = Path.Combine(hostRoot, "CoreRun.exe");
|
var corerun = Path.Combine(hostRoot, Constants.CoreRunName);
|
||||||
var cscExe = Path.Combine(AppContext.BaseDirectory, "csc.exe");
|
var cscExe = Path.Combine(hostRoot, "csc.exe");
|
||||||
return File.Exists(corerun) && File.Exists(cscExe)
|
return File.Exists(corerun) && File.Exists(cscExe)
|
||||||
? Command.Create(corerun, $@"""{cscExe}"" {cscArgs}")
|
? Command.Create(corerun, $@"""{cscExe}"" {cscArgs}")
|
||||||
: Command.Create("csc.exe", cscArgs);
|
: Command.Create("csc", cscArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ApplyCompilationOptions(CompilerOptions compilationOptions, List<string> cscArgs)
|
private static void ApplyCompilationOptions(CompilerOptions compilationOptions, List<string> cscArgs)
|
||||||
|
|
|
@ -115,8 +115,23 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publishing for windows, TODO(anurse): Publish for Mac/Linux/etc.
|
// Publishing for windows, TODO(anurse): Publish for Mac/Linux/etc.
|
||||||
|
int exitCode;
|
||||||
|
if(context.RuntimeIdentifier.Equals("win7-x64"))
|
||||||
|
{
|
||||||
|
exitCode = PublishForWindows(context, outputPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exitCode = PublishForUnix(context, outputPath);
|
||||||
|
}
|
||||||
|
|
||||||
// Locate CoreConsole
|
Reporter.Output.WriteLine($"Published to {outputPath}".Green().Bold());
|
||||||
|
return exitCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int PublishForUnix(ProjectContext context, string outputPath)
|
||||||
|
{
|
||||||
|
// Locate Hosts
|
||||||
string hostsPath = Environment.GetEnvironmentVariable(Constants.HostsPathEnvironmentVariable);
|
string hostsPath = Environment.GetEnvironmentVariable(Constants.HostsPathEnvironmentVariable);
|
||||||
if(string.IsNullOrEmpty(hostsPath))
|
if(string.IsNullOrEmpty(hostsPath))
|
||||||
{
|
{
|
||||||
|
@ -125,15 +140,78 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
var coreConsole = Path.Combine(hostsPath, Constants.CoreConsoleName);
|
var coreConsole = Path.Combine(hostsPath, Constants.CoreConsoleName);
|
||||||
if(!File.Exists(coreConsole))
|
if(!File.Exists(coreConsole))
|
||||||
{
|
{
|
||||||
Reporter.Error.WriteLine($"Unable to locate CoreConsole.exe in {coreConsole}, use {Constants.HostsPathEnvironmentVariable} to set the path to it.".Red().Bold());
|
Reporter.Error.WriteLine($"Unable to locate {Constants.CoreConsoleName} in {coreConsole}, use {Constants.HostsPathEnvironmentVariable} to set the path to it.".Red().Bold());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
var coreRun = Path.Combine(hostsPath, Constants.CoreRunName);
|
||||||
|
if(!File.Exists(coreRun))
|
||||||
|
{
|
||||||
|
Reporter.Error.WriteLine($"Unable to locate {Constants.CoreRunName} in {coreConsole}, use {Constants.HostsPathEnvironmentVariable} to set the path to it.".Red().Bold());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TEMPORARILY bring CoreConsole along for the ride on it's own (without renaming)
|
// TEMPORARILY bring CoreConsole and CoreRun along for the ride on it's own (without renaming)
|
||||||
File.Copy(coreConsole, Path.Combine(outputPath, Constants.CoreConsoleName), overwrite: true);
|
File.Copy(coreConsole, Path.Combine(outputPath, Constants.CoreConsoleName), overwrite: true);
|
||||||
|
File.Copy(coreRun, Path.Combine(outputPath, Constants.CoreRunName), overwrite: true);
|
||||||
|
|
||||||
// Use the 'command' field to generate the name
|
// Use the 'command' field to generate the name
|
||||||
var outputExe = Path.Combine(outputPath, context.ProjectFile.Name + ".exe");
|
var outputExe = Path.Combine(outputPath, context.ProjectFile.Name);
|
||||||
|
var outputDll = Path.Combine(outputPath, context.ProjectFile.Name + ".dll");
|
||||||
|
|
||||||
|
// Check if the a command name is specified, and rename the necessary files
|
||||||
|
if(context.ProjectFile.Commands.Count == 1)
|
||||||
|
{
|
||||||
|
// Write a script that can be used to launch with CoreRun
|
||||||
|
var script = $@"#!/usr/bin/env bash
|
||||||
|
SOURCE=""${{BASH_SOURCE[0]}}""
|
||||||
|
while [ -h ""$SOURCE"" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||||
|
DIR=""$( cd -P ""$( dirname ""$SOURCE"" )"" && pwd )""
|
||||||
|
SOURCE=""$(readlink ""$SOURCE"")""
|
||||||
|
[[ $SOURCE != /* ]] && SOURCE=""$DIR/$SOURCE"" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||||
|
done
|
||||||
|
DIR=""$( cd -P ""$( dirname ""$SOURCE"" )"" && pwd )""
|
||||||
|
exec ""$DIR/corerun"" ""$DIR/{context.ProjectFile.Name}.exe"" $*";
|
||||||
|
outputExe = Path.Combine(outputPath, context.ProjectFile.Commands.Single().Key);
|
||||||
|
File.WriteAllText(outputExe, script);
|
||||||
|
Command.Create("chmod", $"a+x {outputExe}")
|
||||||
|
.ForwardStdOut()
|
||||||
|
.ForwardStdErr()
|
||||||
|
.RunAsync()
|
||||||
|
.Wait();
|
||||||
|
File.Copy(outputDll, Path.ChangeExtension(outputDll, ".exe"));
|
||||||
|
File.Delete(outputDll);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int PublishForWindows(ProjectContext context, string outputPath)
|
||||||
|
{
|
||||||
|
// Locate Hosts
|
||||||
|
string hostsPath = Environment.GetEnvironmentVariable(Constants.HostsPathEnvironmentVariable);
|
||||||
|
if(string.IsNullOrEmpty(hostsPath))
|
||||||
|
{
|
||||||
|
hostsPath = AppContext.BaseDirectory;
|
||||||
|
}
|
||||||
|
var coreConsole = Path.Combine(hostsPath, Constants.CoreConsoleName);
|
||||||
|
if(!File.Exists(coreConsole))
|
||||||
|
{
|
||||||
|
Reporter.Error.WriteLine($"Unable to locate {Constants.CoreConsoleName} in {coreConsole}, use {Constants.HostsPathEnvironmentVariable} to set the path to it.".Red().Bold());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
var coreRun = Path.Combine(hostsPath, Constants.CoreRunName);
|
||||||
|
if(!File.Exists(coreRun))
|
||||||
|
{
|
||||||
|
Reporter.Error.WriteLine($"Unable to locate {Constants.CoreRunName} in {coreConsole}, use {Constants.HostsPathEnvironmentVariable} to set the path to it.".Red().Bold());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TEMPORARILY bring CoreConsole and CoreRun along for the ride on it's own (without renaming)
|
||||||
|
File.Copy(coreConsole, Path.Combine(outputPath, Constants.CoreConsoleName), overwrite: true);
|
||||||
|
File.Copy(coreRun, Path.Combine(outputPath, Constants.CoreRunName), overwrite: true);
|
||||||
|
|
||||||
|
// Use the 'command' field to generate the name
|
||||||
|
var outputExe = Path.Combine(outputPath, context.ProjectFile.Name + Constants.ExeSuffix);
|
||||||
|
var outputDll = Path.Combine(outputPath, context.ProjectFile.Name + ".dll");
|
||||||
File.Copy(coreConsole, outputExe, overwrite: true);
|
File.Copy(coreConsole, outputExe, overwrite: true);
|
||||||
|
|
||||||
// Check if the a command name is specified, and rename the necessary files
|
// Check if the a command name is specified, and rename the necessary files
|
||||||
|
@ -149,11 +227,9 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
File.Delete(renamedExe);
|
File.Delete(renamedExe);
|
||||||
}
|
}
|
||||||
File.Move(outputExe, renamedExe);
|
File.Move(outputExe, renamedExe);
|
||||||
File.Move(Path.ChangeExtension(outputExe, ".dll"), renamedDll);
|
File.Move(outputDll, renamedDll);
|
||||||
outputExe = Path.Combine(outputPath, commandName + ".exe");
|
outputExe = Path.Combine(outputPath, commandName + ".exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
Reporter.Output.WriteLine($"Published to {outputExe}".Green().Bold());
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
src/cscthingy/project.json
Normal file
13
src/cscthingy/project.json
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.TestHost": "1.0.0-*",
|
||||||
|
"Microsoft.NETCore.ConsoleHost": "1.0.0-*",
|
||||||
|
"Microsoft.NETCore.Runtime": "1.0.1-*",
|
||||||
|
"Microsoft.Net.Compilers.netcore": "1.1.0-*",
|
||||||
|
"System.Xml.ReaderWriter": "4.0.11-*"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"dnxcore50": { }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue