diff --git a/debian_config.json b/debian_config.json index bd8f0bd1e..3cc322128 100644 --- a/debian_config.json +++ b/debian_config.json @@ -9,7 +9,7 @@ "homepage": "https://dotnet.github.io/core", "release":{ - "package_version":"0.3", + "package_version":"0.201", "package_revision":"1", "urgency" : "low", "changelog_message" : "Bootstrap loop package" diff --git a/package_tool/scripts/debian_build_lib.sh b/package_tool/scripts/debian_build_lib.sh index eb51f0b93..14ddbc35a 100644 --- a/package_tool/scripts/debian_build_lib.sh +++ b/package_tool/scripts/debian_build_lib.sh @@ -42,6 +42,11 @@ add_system_dir_placement(){ abs_installation_dir=$2 dir_files=( $(_get_files_in_dir_tree $PACKAGE_SOURCE_DIR/$in_package_dir) ) + + # If in_package_dir isn't empty include a slash + if [ ! -z "$in_package_dir" ]; then + in_package_dir="${in_package_dir}/" + fi for rel_filepath in ${dir_files[@]} do @@ -49,9 +54,9 @@ add_system_dir_placement(){ # If there is no parent, parent_path = "." if [[ "$parent_path" == "." ]]; then - add_system_file_placement "${in_package_dir}/${rel_filepath}" "${abs_installation_dir}" + add_system_file_placement "${in_package_dir}${rel_filepath}" "${abs_installation_dir}" else - add_system_file_placement "${in_package_dir}/${rel_filepath}" "${abs_installation_dir}/${parent_path}" + add_system_file_placement "${in_package_dir}${rel_filepath}" "${abs_installation_dir}/${parent_path}" fi done diff --git a/scripts/package.sh b/scripts/package.sh index bd913c0c5..26bdb2c2f 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -set -e SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink diff --git a/scripts/windows_dockerbuild.sh b/scripts/windows_dockerbuild.sh index 940bce6e8..a2bc95d39 100755 --- a/scripts/windows_dockerbuild.sh +++ b/scripts/windows_dockerbuild.sh @@ -68,7 +68,11 @@ create_or_start_vm(){ if [[ $(docker-machine ls | grep $VM_NAME) == "" ]]; then docker-machine create -d virtualbox $VM_NAME else - docker-machine start $VM_NAME + # This fails sometimes + if ! docker-machine start $VM_NAME; then + docker-machine rm -f $VM_NAME + docker-machine create -d virtualbox $VM_NAME + fi fi } diff --git a/src/Microsoft.DotNet.Cli.Utils/Constants.cs b/src/Microsoft.DotNet.Cli.Utils/Constants.cs index 4800ab900..929b1efcc 100644 --- a/src/Microsoft.DotNet.Cli.Utils/Constants.cs +++ b/src/Microsoft.DotNet.Cli.Utils/Constants.cs @@ -13,5 +13,10 @@ namespace Microsoft.DotNet.Cli.Utils public static readonly string DefaultConfiguration = "Debug"; public static readonly string BinDirectoryName = "bin"; public static readonly string ObjDirectoryName = "obj"; + + public static readonly string DynamicLibSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".dll" : + RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? ".dylib" : ".so"; + + public static readonly string StaticLibSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".lib" : ".a" ; } } diff --git a/src/Microsoft.DotNet.Tools.Compiler/Program.cs b/src/Microsoft.DotNet.Tools.Compiler/Program.cs index 570fed998..a1882a70e 100644 --- a/src/Microsoft.DotNet.Tools.Compiler/Program.cs +++ b/src/Microsoft.DotNet.Tools.Compiler/Program.cs @@ -29,6 +29,7 @@ namespace Microsoft.DotNet.Tools.Compiler var configuration = app.Option("-c|--configuration ", "Configuration under which to build", CommandOptionType.SingleValue); var noProjectDependencies = app.Option("--no-project-dependencies", "Skips building project references.", CommandOptionType.NoValue); var project = app.Argument("", "The project to compile, defaults to the current directory. Can be a path to a project.json or a project directory"); + var native = app.Option("-n|--native", "Compiles source to native machine code.", CommandOptionType.NoValue); app.OnExecute(() => { @@ -40,6 +41,7 @@ namespace Microsoft.DotNet.Tools.Compiler } var buildProjectReferences = !noProjectDependencies.HasValue(); + var isNative = native.HasValue(); // Load project contexts for each framework and compile them bool success = true; @@ -48,6 +50,11 @@ namespace Microsoft.DotNet.Tools.Compiler foreach (var context in framework.Values.Select(f => ProjectContext.Create(path, NuGetFramework.Parse(f)))) { success &= Compile(context, configuration.Value() ?? Constants.DefaultConfiguration, output.Value(), buildProjectReferences); + + if (isNative) + { + success &= CompileNative(context, configuration.Value() ?? Constants.DefaultConfiguration, output.Value(), buildProjectReferences); + } } } else @@ -55,6 +62,11 @@ namespace Microsoft.DotNet.Tools.Compiler foreach (var context in ProjectContext.CreateContextForEachFramework(path)) { success &= Compile(context, configuration.Value() ?? Constants.DefaultConfiguration, output.Value(), buildProjectReferences); + + if (isNative) + { + success &= CompileNative(context, configuration.Value() ?? Constants.DefaultConfiguration, output.Value(), buildProjectReferences); + } } } return success ? 0 : 1; @@ -75,10 +87,33 @@ namespace Microsoft.DotNet.Tools.Compiler } } - private static bool Compile(ProjectContext context, string configuration, string outputPath, bool buildProjectReferences) + private static bool CompileNative(ProjectContext context, string configuration, string outputOptionValue, bool buildProjectReferences) + { + string outputPath = Path.Combine(GetOutputPath(context, configuration, outputOptionValue), "native"); + + var compilationOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration); + var managedBinaryPath = Path.Combine(outputPath, context.ProjectFile.Name + (compilationOptions.EmitEntryPoint.GetValueOrDefault() ? ".exe" : ".dll")); + + // Do Native Compilation + var result = Command.Create($"dotnet-compile-native", $"\"{managedBinaryPath}\" \"{outputPath}\"") + .ForwardStdErr() + .ForwardStdOut() + .Execute(); + + return result.ExitCode == 0; + } + + private static bool Compile(ProjectContext context, string configuration, string outputOptionValue, bool buildProjectReferences) { Reporter.Output.WriteLine($"Compiling {context.RootProject.Identity.Name.Yellow()} for {context.TargetFramework.DotNetFrameworkName.Yellow()}"); + //Set up Output Paths + string outputPath = GetOutputPath(context, configuration, outputOptionValue); + string intermediateOutputPath = GetIntermediateOutputPath(context, configuration, outputOptionValue); + + CleanOrCreateDirectory(outputPath); + CleanOrCreateDirectory(intermediateOutputPath); + // Create the library exporter var exporter = context.CreateExporter(configuration); @@ -127,35 +162,6 @@ namespace Microsoft.DotNet.Tools.Compiler // file anyways // ShowDependencyInfo(dependencies); - // Hackily generate the output path - if (string.IsNullOrEmpty(outputPath)) - { - outputPath = Path.Combine( - context.ProjectFile.ProjectDirectory, - Constants.BinDirectoryName, - configuration, - context.TargetFramework.GetTwoDigitShortFolderName()); - } - - string intermediateOutputPath = Path.Combine( - context.ProjectFile.ProjectDirectory, - Constants.ObjDirectoryName, - configuration, - context.TargetFramework.GetTwoDigitShortFolderName()); - - if (Directory.Exists(outputPath)) - { - Directory.Delete(outputPath, recursive: true); - } - - if (Directory.Exists(intermediateOutputPath)) - { - Directory.Delete(intermediateOutputPath, recursive: true); - } - - Directory.CreateDirectory(outputPath); - Directory.CreateDirectory(intermediateOutputPath); - // Get compilation options var compilationOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration); var outputExtension = ".dll"; @@ -248,7 +254,83 @@ namespace Microsoft.DotNet.Tools.Compiler return success; } + + private static string GetOutputPath(ProjectContext context, string configuration, string outputOptionValue) + { + var outputPath = string.Empty; + if (string.IsNullOrEmpty(outputOptionValue)) + { + outputPath = Path.Combine( + GetDefaultRootOutputPath(context, outputOptionValue), + Constants.BinDirectoryName, + configuration, + context.TargetFramework.GetTwoDigitShortFolderName()); + } + else + { + outputPath = outputOptionValue; + } + + return outputPath; + + string intermediateOutputPath = Path.Combine( + context.ProjectFile.ProjectDirectory, + Constants.ObjDirectoryName, + configuration, + context.TargetFramework.GetTwoDigitShortFolderName()); + } + + private static string GetIntermediateOutputPath(ProjectContext context, string configuration, string outputOptionValue) + { + var intermediateOutputPath = String.Empty; + + if (string.IsNullOrEmpty(outputOptionValue)) + { + intermediateOutputPath = Path.Combine( + GetDefaultRootOutputPath(context, outputOptionValue), + Constants.ObjDirectoryName, + configuration, + context.TargetFramework.GetTwoDigitShortFolderName()); + } + else + { + intermediateOutputPath = outputOptionValue; + } + + return intermediateOutputPath; + } + + private static string GetDefaultRootOutputPath(ProjectContext context, string outputOptionValue) + { + string rootOutputPath = String.Empty; + + if (string.IsNullOrEmpty(outputOptionValue)) + { + rootOutputPath = context.ProjectFile.ProjectDirectory; + } + + return rootOutputPath; + } + + private static void CleanOrCreateDirectory(string path) + { + if (Directory.Exists(path)) + { + try + { + Directory.Delete(path, recursive: true); + } + catch(Exception e) + { + Console.WriteLine("Unable to remove directory: " + path); + Console.WriteLine(e.Message); + } + } + + Directory.CreateDirectory(path); + } + private static void EmitHost(string outputPath, string projectName, LibraryExporter exporter) { // Write the Host information file (basically a simplified form of the lock file)