Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Change some variables to use the term 'runtime' instead of 'dotnet'
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengTian committed Jan 19, 2015
1 parent 48dc387 commit 1698e09
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 86 deletions.
68 changes: 34 additions & 34 deletions makefile.shade
Original file line number Diff line number Diff line change
Expand Up @@ -246,37 +246,37 @@ var RC_FILES = '${FindAllFiles("Resource.rc", "dotnet", "dotnet.net45", "dotnet.

for each='var nupkgPath in nupkgPaths'
@{
var dotnetName = Path.GetFileNameWithoutExtension(nupkgPath);
var dotnetPath = Path.Combine(TEST_RESULTS, "dotnet", dotnetName);
var runtimeName = Path.GetFileNameWithoutExtension(nupkgPath);
var runtimePath = Path.Combine(TEST_RESULTS, "dotnet", runtimeName);

Log.Info("Unpacking " + nupkgPath);
if (Directory.Exists(dotnetPath))
if (Directory.Exists(runtimePath))
{
Directory.Delete(dotnetPath, recursive:true);
Directory.Delete(runtimePath, recursive:true);
}

Directory.CreateDirectory(dotnetPath);
Directory.CreateDirectory(runtimePath);

System.IO.Compression.ZipFile.ExtractToDirectory(
nupkgPath,
dotnetPath);
runtimePath);
}

@{
Action<string> runWithFramework = nupkgPath => {
var envPath = Environment.GetEnvironmentVariable("PATH");
try
{
var dotnetName = Path.GetFileNameWithoutExtension(nupkgPath);
var dotnetPath = Path.Combine(TEST_RESULTS, "dotnet", dotnetName);
var runtimeName = Path.GetFileNameWithoutExtension(nupkgPath);
var runtimePath = Path.Combine(TEST_RESULTS, "dotnet", runtimeName);

var dotnetExePath = Path.Combine(dotnetPath, "bin", "dotnet");
var kpmPath = Path.Combine(dotnetPath, "bin", "kpm");
var dotnetPath = Path.Combine(runtimePath, "bin", "dotnet");
var kpmPath = Path.Combine(runtimePath, "bin", "kpm");

Log.Info("dotnetName = " + dotnetName);
Log.Info("runtimeName = " + runtimeName);
Log.Info("DOTNET_APPBASE = " + helloWorld);

Exec(dotnetExePath, helloWorld + " run");
Exec(dotnetPath, helloWorld + " run");

var commands = new [] { "build" };
foreach(var cmd in commands)
Expand All @@ -293,18 +293,18 @@ var RC_FILES = '${FindAllFiles("Resource.rc", "dotnet", "dotnet.net45", "dotnet.
};

Action<string> crossGen = nupkgPath => {
var dotnetName = Path.GetFileNameWithoutExtension(nupkgPath);
var dotnetPath = Path.Combine(TEST_RESULTS, "dotnet", dotnetName);
var runtimeName = Path.GetFileNameWithoutExtension(nupkgPath);
var runtimePath = Path.Combine(TEST_RESULTS, "dotnet", runtimeName);

var kPath = Path.Combine(dotnetPath, "bin", "k");
var kPath = Path.Combine(runtimePath, "bin", "k");

var kTools = new[] {
Path.Combine(dotnetPath, "bin", "lib", "Microsoft.Framework.Project"),
Path.Combine(dotnetPath, "bin", "lib", "Microsoft.Framework.PackageManager"),
Path.Combine(dotnetPath, "bin", "lib", "Microsoft.Framework.DesignTimeHost"),
Path.Combine(runtimePath, "bin", "lib", "Microsoft.Framework.Project"),
Path.Combine(runtimePath, "bin", "lib", "Microsoft.Framework.PackageManager"),
Path.Combine(runtimePath, "bin", "lib", "Microsoft.Framework.DesignTimeHost"),
};

Log.Info("dotnetName = " + dotnetName);
Log.Info("runtimeName = " + runtimeName);

foreach(var kTool in kTools) {
Exec("cmd", string.Format("/C \"\"{0}\" crossgen --in \"{1}\"\"", kPath, kTool));
Expand Down Expand Up @@ -704,14 +704,14 @@ var RC_FILES = '${FindAllFiles("Resource.rc", "dotnet", "dotnet.net45", "dotnet.

#dev-install
@{
InstallDevDotnet(DOTNET_MONO_BIN);
InstallDevRuntime(DOTNET_MONO_BIN);

if (!IsMono)
{
InstallDevDotnet(DOTNET_CLR_x86_BIN);
InstallDevDotnet(DOTNET_CLR_amd64_BIN);
InstallDevDotnet(DOTNET_CORECLR_x86_BIN);
InstallDevDotnet(DOTNET_CORECLR_amd64_BIN);
InstallDevRuntime(DOTNET_CLR_x86_BIN);
InstallDevRuntime(DOTNET_CLR_amd64_BIN);
InstallDevRuntime(DOTNET_CORECLR_x86_BIN);
InstallDevRuntime(DOTNET_CORECLR_amd64_BIN);
}
}

Expand Down Expand Up @@ -816,7 +816,7 @@ functions @{
}
}

string FindDotnetFolder()
string FindRuntimeFolder()
{
var profileDirectory = Environment.GetEnvironmentVariable("USERPROFILE");

Expand All @@ -828,17 +828,17 @@ functions @{
return Path.Combine(profileDirectory, ".kre");
}

string FindDotnetPackagesFolder()
string FindRuntimePackagesFolder()
{
return Path.Combine(FindDotnetFolder(), "packages");
return Path.Combine(FindRuntimeFolder(), "packages");
}

void InstallDevDotnet(string binPath)
void InstallDevRuntime(string binPath)
{
var sourceDir = Path.GetDirectoryName(binPath);
var sourceDotnet= Path.GetFileName(sourceDir);
var destinationDotnet= sourceDotnet+ ".1.0.0-dev";
var destinationDir = Path.Combine(FindDotnetPackagesFolder(), destinationDotnet);
var sourceRuntime= Path.GetFileName(sourceDir);
var destinationRuntime= sourceRuntime+ ".1.0.0-dev";
var destinationDir = Path.Combine(FindRuntimePackagesFolder(), destinationRuntime);

if (Directory.Exists(destinationDir))
{
Expand All @@ -847,7 +847,7 @@ functions @{
}

// Trim "dotnet-" part from alias to keep it short
var alias = sourceDotnet.Substring(7) + "-dev";
var alias = sourceRuntime.Substring(7) + "-dev";

var symlinkProgram = "cmd";
var symlinkProgramArgs = "/C mklink /J {0} {1}";
Expand All @@ -863,7 +863,7 @@ functions @{
kvmProgram = "bash";
kvmProgramArgs =
"-c 'source " +
Path.Combine(FindDotnetFolder(), "kvm", "kvm.sh") +
Path.Combine(FindRuntimeFolder(), "kvm", "kvm.sh") +
" && kvm alias {0} {1}'";
}

Expand All @@ -873,7 +873,7 @@ functions @{

kvmProgramArgs = String.Format(kvmProgramArgs,
alias,
destinationDotnet);
destinationRuntime);

Exec(symlinkProgram, symlinkProgramArgs);
Exec(kvmProgram, kvmProgramArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static NativeImageGenerator Create(PackOptions options, PackRoot root, IE
if (VersionUtility.IsDesktop(frameworkName))
{
options.Reports.Information.WriteLine(
"Native image generation is only supported for Dotnet Core flavors.".Yellow());
"Native image generation is only supported for dotnet core flavors.".Yellow());
return null;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Microsoft.Framework.PackageManager/Packing/PackManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,21 +272,21 @@ public bool Package()
return !anyUnresolvedDependency;
}

bool TryAddRuntime(PackRoot root, FrameworkName frameworkName, string dotnetPath)
bool TryAddRuntime(PackRoot root, FrameworkName frameworkName, string runtimePath)
{
if (!Directory.Exists(dotnetPath))
if (!Directory.Exists(runtimePath))
{
return false;
}

var dotnetName = Path.GetFileName(Path.GetDirectoryName(Path.Combine(dotnetPath, ".")));
var dotnetNupkgPath = Path.Combine(dotnetPath, dotnetName + ".nupkg");
if (!File.Exists(dotnetNupkgPath))
var runtimeName = Path.GetFileName(Path.GetDirectoryName(Path.Combine(runtimePath, ".")));
var runtimeNupkgPath = Path.Combine(runtimePath, runtimeName + ".nupkg");
if (!File.Exists(runtimeNupkgPath))
{
return false;
}

root.Runtimes.Add(new PackRuntime(root, frameworkName, dotnetNupkgPath));
root.Runtimes.Add(new PackRuntime(root, frameworkName, runtimeNupkgPath));
return true;
}

Expand Down
12 changes: 6 additions & 6 deletions src/Microsoft.Framework.PackageManager/Packing/PackRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ private void GenerateBatchFiles()

foreach (var commandName in _project.Commands.Keys)
{
var dotnetFolder = string.Empty;
var runtimeFolder = string.Empty;
if (Runtimes.Any())
{
dotnetFolder = string.Format(@"%~dp0{0}\packages\{1}\bin\", AppRootName, Runtimes.First().Name);
runtimeFolder = string.Format(@"%~dp0{0}\packages\{1}\bin\", AppRootName, Runtimes.First().Name);
}

File.WriteAllText(
Path.Combine(OutputPath, commandName + ".cmd"),
string.Format(template, dotnetFolder, relativeAppBase, commandName));
string.Format(template, runtimeFolder, relativeAppBase, commandName));
}
}

Expand Down Expand Up @@ -145,16 +145,16 @@ private void GenerateBashScripts()

foreach (var commandName in _project.Commands.Keys)
{
var dotnetFolder = string.Empty;
var runtimeFolder = string.Empty;
if (Runtimes.Any())
{
dotnetFolder = string.Format(@"$DIR/{0}/packages/{1}/bin/",
runtimeFolder = string.Format(@"$DIR/{0}/packages/{1}/bin/",
AppRootName, Runtimes.First().Name);
}

var scriptPath = Path.Combine(OutputPath, commandName);
File.WriteAllText(scriptPath,
string.Format(template, relativeAppBase, dotnetFolder, commandName).Replace("\r\n", "\n"));
string.Format(template, relativeAppBase, runtimeFolder, commandName).Replace("\r\n", "\n"));
if (PlatformHelper.IsMono)
{
MarkExecutable(scriptPath);
Expand Down
12 changes: 6 additions & 6 deletions src/Microsoft.Framework.PackageManager/Packing/PackRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace Microsoft.Framework.PackageManager.Packing
public class PackRuntime
{
private readonly FrameworkName _frameworkName;
private readonly string _dotnetNupkgPath;
private readonly string _runtimeNupkgPath;

public PackRuntime(PackRoot root, FrameworkName frameworkName, string dotnetNupkgPath)
public PackRuntime(PackRoot root, FrameworkName frameworkName, string runtimeNupkgPath)
{
_frameworkName = frameworkName;
_dotnetNupkgPath = dotnetNupkgPath;
Name = Path.GetFileName(Path.GetDirectoryName(_dotnetNupkgPath));
_runtimeNupkgPath = runtimeNupkgPath;
Name = Path.GetFileName(Path.GetDirectoryName(_runtimeNupkgPath));
TargetPath = Path.Combine(root.TargetPackagesPath, Name);
}

Expand All @@ -42,14 +42,14 @@ public void Emit(PackRoot root)
}

var targetNupkgPath = Path.Combine(TargetPath, Name + ".nupkg");
using (var sourceStream = File.OpenRead(_dotnetNupkgPath))
using (var sourceStream = File.OpenRead(_runtimeNupkgPath))
{
using (var archive = new ZipArchive(sourceStream, ZipArchiveMode.Read))
{
root.Operations.ExtractNupkg(archive, TargetPath);
}
}
using (var sourceStream = File.OpenRead(_dotnetNupkgPath))
using (var sourceStream = File.OpenRead(_runtimeNupkgPath))
{
using (var targetStream = new FileStream(targetNupkgPath, FileMode.Create, FileAccess.Write, FileShare.None))
{
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.Framework.Project/CrossGenManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ private void Sort(AssemblyInformation node, List<AssemblyInformation> output, Ha

public static string ResolveProcessorArchitecture(string runtimePath)
{
var dotnetFullName = new DirectoryInfo(runtimePath).Name;
var dotnetName = dotnetFullName.Substring(0, dotnetFullName.IndexOf('.'));
var arch = dotnetName.Substring(dotnetName.LastIndexOf('-') + 1);
var runtimeFullName = new DirectoryInfo(runtimePath).Name;
var runtimeName = runtimeFullName.Substring(0, runtimeFullName.IndexOf('.'));
var arch = runtimeName.Substring(runtimeName.LastIndexOf('-') + 1);
return arch;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ public static int ExecKCommand(
IDictionary<string, string> environment = null,
string workingDir = null)
{
var dotnetRoot = Directory.EnumerateDirectories(Path.Combine(dotnetHomePath, "packages"), "dotnet-*").First();
var runtimeRoot = Directory.EnumerateDirectories(Path.Combine(dotnetHomePath, "packages"), "dotnet-*").First();
string program, commandLine;
if (PlatformHelper.IsMono)
{
program = Path.Combine(dotnetRoot, "bin", "k");
program = Path.Combine(runtimeRoot, "bin", "k");
commandLine = string.Format("{0} {1}", subcommand, arguments);
}
else
{
program = "cmd";
var kCmdPath = Path.Combine(dotnetRoot, "bin", "k.cmd");
var kCmdPath = Path.Combine(runtimeRoot, "bin", "k.cmd");
commandLine = string.Format("/C {0} {1} {2}", kCmdPath, subcommand, arguments);
}

Expand Down
16 changes: 8 additions & 8 deletions test/Microsoft.Framework.FunctionalTestUtils/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public static string GetBuildArtifactsFolder()
public static DisposableDir GetRuntimeHomeDir(string flavor, string architecture)
{
var buildArtifactDir = GetBuildArtifactsFolder();
var dotnetNupkg = Directory.GetFiles(
var runtimeNupkg = Directory.GetFiles(
buildArtifactDir,
string.Format("dotnet-{0}-{1}.*.nupkg", flavor, architecture),
SearchOption.TopDirectoryOnly) .First();
var dotnetHomePath = CreateTempDir();
var dotnetName = Path.GetFileNameWithoutExtension(dotnetNupkg);
var dotnetRoot = Path.Combine(dotnetHomePath, "packages", dotnetName);
System.IO.Compression.ZipFile.ExtractToDirectory(dotnetNupkg, dotnetRoot);
File.Copy(dotnetNupkg, Path.Combine(dotnetRoot, dotnetName + ".nupkg"));
var runtimeName = Path.GetFileNameWithoutExtension(runtimeNupkg);
var runtimeRoot = Path.Combine(dotnetHomePath, "packages", runtimeName);
System.IO.Compression.ZipFile.ExtractToDirectory(runtimeNupkg, runtimeRoot);
File.Copy(runtimeNupkg, Path.Combine(runtimeRoot, runtimeName + ".nupkg"));
return dotnetHomePath;
}

Expand Down Expand Up @@ -158,9 +158,9 @@ private static string GetDefaultMSBuildPath()

public static string GetRuntimeVersion()
{
var dotnetNupkg = Directory.EnumerateFiles(GetBuildArtifactsFolder(), "dotnet-*.nupkg").FirstOrDefault();
var dotnetName = Path.GetFileNameWithoutExtension(dotnetNupkg);
var segments = dotnetName.Split(new[] { '.' }, 2);
var runtimeNupkg = Directory.EnumerateFiles(GetBuildArtifactsFolder(), "dotnet-*.nupkg").FirstOrDefault();
var runtimeName = Path.GetFileNameWithoutExtension(runtimeNupkg);
var segments = runtimeName.Split(new[] { '.' }, 2);
return segments[1];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ public void GenerateBatchFilesAndBashScriptsWithoutPackedRuntime(DisposableDir d
public void GenerateBatchFilesAndBashScriptsWithPackedRuntime(DisposableDir dotnetHomeDir)
{
// Each runtime home only contains one runtime package, which is the one we are currently testing against
var dotnetRoot = Directory.EnumerateDirectories(Path.Combine(dotnetHomeDir, "packages"), "dotnet-*").First();
var dotnetName = new DirectoryInfo(dotnetRoot).Name;
var runtimeRoot = Directory.EnumerateDirectories(Path.Combine(dotnetHomeDir, "packages"), "dotnet-*").First();
var runtimeName = new DirectoryInfo(runtimeRoot).Name;

var projectStructure = @"{
'.': ['project.json'],
Expand All @@ -894,10 +894,10 @@ public void GenerateBatchFilesAndBashScriptsWithPackedRuntime(DisposableDir dotn
}
},
'packages': {
'DOTNET_PACKAGE_NAME': {}
'RUNTIME_PACKAGE_NAME': {}
}
}
}".Replace("PROJECT_NAME", _projectName).Replace("DOTNET_PACKAGE_NAME", dotnetName);
}".Replace("PROJECT_NAME", _projectName).Replace("RUNTIME_PACKAGE_NAME", runtimeName);

using (var testEnv = new KpmTestEnvironment(dotnetHomeDir, _projectName, _outputDirName))
{
Expand Down Expand Up @@ -925,22 +925,22 @@ public void GenerateBatchFilesAndBashScriptsWithPackedRuntime(DisposableDir dotn
dotnetHomeDir,
subcommand: "pack",
arguments: string.Format("--out {0} --runtime {1}",
testEnv.PackOutputDirPath, dotnetName),
testEnv.PackOutputDirPath, runtimeName),
environment: environment,
workingDir: testEnv.ProjectPath);
Assert.Equal(0, exitCode);

var dotnetNupkgSHA = TestUtils.ComputeSHA(Path.Combine(dotnetRoot, dotnetName + ".nupkg"));
var runtimeSubDir = DirTree.CreateFromDirectory(dotnetRoot)
.WithFileContents(dotnetName + ".nupkg.sha512", dotnetNupkgSHA)
var runtimeNupkgSHA = TestUtils.ComputeSHA(Path.Combine(runtimeRoot, runtimeName + ".nupkg"));
var runtimeSubDir = DirTree.CreateFromDirectory(runtimeRoot)
.WithFileContents(runtimeName + ".nupkg.sha512", runtimeNupkgSHA)
.RemoveFile("[Content_Types].xml")
.RemoveFile(Path.Combine("_rels", ".rels"))
.RemoveFile(Path.Combine("bin", "lib", "Microsoft.Framework.PackageManager",
"bin", "profile", "startup.prof"))
.RemoveSubDir("package");

var batchFileBinPath = string.Format(@"%~dp0approot\packages\{0}\bin\", dotnetName);
var bashScriptBinPath = string.Format("$DIR/approot/packages/{0}/bin/", dotnetName);
var batchFileBinPath = string.Format(@"%~dp0approot\packages\{0}\bin\", runtimeName);
var bashScriptBinPath = string.Format("$DIR/approot/packages/{0}/bin/", runtimeName);

var expectedOutputDir = DirTree.CreateFromJson(expectedOutputStructure)
.WithFileContents(Path.Combine("approot", "src", testEnv.ProjectName, "project.json"), @"{
Expand All @@ -963,7 +963,7 @@ public void GenerateBatchFilesAndBashScriptsWithPackedRuntime(DisposableDir dotn
BashScriptTemplate, testEnv.ProjectName, bashScriptBinPath, "run")
.WithFileContents("kestrel",
BashScriptTemplate, testEnv.ProjectName, bashScriptBinPath, "kestrel")
.WithSubDir(Path.Combine("approot", "packages", dotnetName), runtimeSubDir);
.WithSubDir(Path.Combine("approot", "packages", runtimeName), runtimeSubDir);

Assert.True(expectedOutputDir.MatchDirectoryOnDisk(testEnv.PackOutputDirPath,
compareFileContents: true));
Expand Down
Loading

0 comments on commit 1698e09

Please sign in to comment.