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

Commit

Permalink
Removing usages of DNX_APPBASE - we have --appbase param
Browse files Browse the repository at this point in the history
  • Loading branch information
moozzyk committed Sep 22, 2015
1 parent 9a75ce0 commit e87f53d
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 64 deletions.
1 change: 0 additions & 1 deletion src/Microsoft.Dnx.Runtime.Sources/Impl/EnvironmentNames.cs
Expand Up @@ -13,7 +13,6 @@ internal static class EnvironmentNames
public const string CompilationServerPort = "DNX_COMPILATION_SERVER_PORT";
public const string Home = "DNX_HOME";
public const string GlobalPath = "DNX_GLOBAL_PATH";
public const string AppBase = "DNX_APPBASE";
public const string Configuration = "DNX_CONFIGURATION";
public const string BuildKeyFile = "DNX_BUILD_KEY_FILE";
public const string BuildDelaySign = "DNX_BUILD_DELAY_SIGN";
Expand Down
5 changes: 1 addition & 4 deletions src/Microsoft.Dnx.Tooling/Publish/PublishRoot.cs
Expand Up @@ -155,9 +155,7 @@ private void GenerateBashScripts()
done
DIR=""$( cd -P ""$( dirname ""$SOURCE"" )"" && pwd )""
export SET {0}=""$DIR/{1}""
exec ""{2}{3}"" --appbase ""${0}"" Microsoft.Dnx.ApplicationHost --configuration {4} {5} ""$@""";
exec ""{1}{2}"" --appbase ""$DIR/{0}"" Microsoft.Dnx.ApplicationHost --configuration {3} {4} ""$@""";

foreach (var commandName in _project.Commands.Keys)
{
Expand All @@ -171,7 +169,6 @@ private void GenerateBashScripts()
var scriptPath = Path.Combine(OutputPath, commandName);
File.WriteAllText(scriptPath,
string.Format(template,
EnvironmentNames.AppBase,
relativeAppBase,
runtimeFolder,
Runtime.Constants.BootstrapperExeName,
Expand Down
6 changes: 1 addition & 5 deletions src/dnx/dnx.cpp
Expand Up @@ -172,14 +172,10 @@ void FreeExpandedCommandLineArguments(size_t nArgc, dnx::char_t** ppszArgv)

bool GetApplicationBase(const dnx::xstring_t& currentDirectory, int argc, dnx::char_t* argv[], /*out*/ dnx::char_t* fullAppBasePath)
{
dnx::char_t buffer[MAX_PATH];
const dnx::char_t* appBase = dnx::utils::get_option_value(argc, argv, _X("--appbase"));

// Note: We use application base from DNX_APPBASE environment variable only if --appbase
// did not exist. if neither --appBase nor DNX_APPBASE existed we use current directory
if (!appBase)
{
appBase = GetAppBasePathFromEnvironment(buffer) ? buffer : currentDirectory.c_str();
appBase = currentDirectory.c_str();
}

// Prevent coreclr native bootstrapper from failing with relative appbase
Expand Down
5 changes: 0 additions & 5 deletions src/dnx/pal.h
Expand Up @@ -10,10 +10,5 @@
dnx::xstring_t GetNativeBootstrapperDirectory();
void WaitForDebuggerToAttach();
bool IsTracingEnabled();
bool GetAppBasePathFromEnvironment(dnx::char_t* szPath);
bool GetFullPath(const dnx::char_t* szPath, dnx::char_t* szFullPath);
int CallApplicationMain(const dnx::char_t* moduleName, const char* functionName, CALL_APPLICATION_MAIN_DATA* data, dnx::trace_writer& trace_writer);

#ifndef SetEnvironmentVariable
bool SetEnvironmentVariable(const dnx::char_t* lpName, const dnx::char_t* lpValue);
#endif //SetEnvironmentVariable
31 changes: 1 addition & 30 deletions src/dnx/pal.unix.cpp
Expand Up @@ -18,19 +18,6 @@ bool IsTracingEnabled()
return dnxTraceEnv != NULL && (strcmp(dnxTraceEnv, "1") == 0);
}

bool GetAppBasePathFromEnvironment(char* szPath)
{
char* appBaseEnv = getenv("DNX_APPBASE");

if (appBaseEnv != NULL && strlen(appBaseEnv) < PATH_MAX)
{
strcpy(szPath, appBaseEnv);
return true;
}

return false;
}

bool GetFullPath(const char* szPath, char* szNormalizedPath)
{
if (realpath(szPath, szNormalizedPath) == nullptr)
Expand Down Expand Up @@ -83,20 +70,4 @@ int CallApplicationMain(const char* moduleName, const char* functionName, CALL_A

throw;
}
}

bool SetEnvironmentVariable(const char* lpName, const char* lpValue)
{
int ret;

if (lpValue != nullptr)
{
ret = setenv(lpName, lpValue, 1);
}
else
{
ret = unsetenv(lpName);
}

return ret == 0;
}
}
6 changes: 0 additions & 6 deletions src/dnx/pal.win32.cpp
Expand Up @@ -42,12 +42,6 @@ bool IsTracingEnabled()
return GetEnvironmentVariable(L"DNX_TRACE", buff, 2) == 1 && buff[0] == L'1';
}

bool GetAppBasePathFromEnvironment(LPTSTR pszAppBase)
{
DWORD dwAppBase = GetEnvironmentVariable(_T("DNX_APPBASE"), pszAppBase, MAX_PATH);
return dwAppBase != 0 && dwAppBase < MAX_PATH;
}

bool GetFullPath(LPCTSTR szPath, LPTSTR pszNormalizedPath)
{
DWORD dwFullAppBase = GetFullPathName(szPath, MAX_PATH, pszNormalizedPath, nullptr);
Expand Down
12 changes: 5 additions & 7 deletions test/Microsoft.Dnx.Tooling.FunctionalTests/DnuPublishTests.cs
Expand Up @@ -35,9 +35,7 @@ public class DnuPublishTests
done
DIR=""$( cd -P ""$( dirname ""$SOURCE"" )"" && pwd )""
export SET {0}=""$DIR/approot/src/{1}""
exec ""{2}{3}"" --appbase ""${0}"" Microsoft.Dnx.ApplicationHost --configuration {4} {5} ""$@""".Replace("\r\n", "\n");
exec ""{1}{2}"" --appbase ""$DIR/approot/src/{0}"" Microsoft.Dnx.ApplicationHost --configuration {3} {4} ""$@""".Replace("\r\n", "\n");

private static readonly string BasicLockFileTemplate = @"{
""locked"": false,
Expand Down Expand Up @@ -1722,9 +1720,9 @@ public void GenerateBatchFilesAndBashScriptsWithoutPublishedRuntime(string flavo
.WithFileContents("run.cmd", BatchFileTemplate, string.Empty, Constants.BootstrapperExeName, testEnv.ProjectName, configuration, "run")
.WithFileContents("kestrel.cmd", BatchFileTemplate, string.Empty, Constants.BootstrapperExeName, testEnv.ProjectName, configuration, "kestrel")
.WithFileContents("run",
BashScriptTemplate, EnvironmentNames.AppBase, testEnv.ProjectName, string.Empty, Constants.BootstrapperExeName, configuration, "run")
BashScriptTemplate, testEnv.ProjectName, string.Empty, Constants.BootstrapperExeName, configuration, "run")
.WithFileContents("kestrel",
BashScriptTemplate, EnvironmentNames.AppBase, testEnv.ProjectName, string.Empty, Constants.BootstrapperExeName, configuration, "kestrel");
BashScriptTemplate, testEnv.ProjectName, string.Empty, Constants.BootstrapperExeName, configuration, "kestrel");

Assert.True(expectedOutputDir.MatchDirectoryOnDisk(testEnv.PublishOutputDirPath,
compareFileContents: true));
Expand Down Expand Up @@ -1843,9 +1841,9 @@ public void GenerateBatchFilesAndBashScriptsWithPublishedRuntime(string flavor,
.WithFileContents("run.cmd", BatchFileTemplate, batchFileBinPath, Constants.BootstrapperExeName, testEnv.ProjectName, configuration, "run")
.WithFileContents("kestrel.cmd", BatchFileTemplate, batchFileBinPath, Constants.BootstrapperExeName, testEnv.ProjectName, configuration, "kestrel")
.WithFileContents("run",
BashScriptTemplate, EnvironmentNames.AppBase, testEnv.ProjectName, bashScriptBinPath, Constants.BootstrapperExeName, configuration, "run")
BashScriptTemplate, testEnv.ProjectName, bashScriptBinPath, Constants.BootstrapperExeName, configuration, "run")
.WithFileContents("kestrel",
BashScriptTemplate, EnvironmentNames.AppBase, testEnv.ProjectName, bashScriptBinPath, Constants.BootstrapperExeName, configuration, "kestrel")
BashScriptTemplate, testEnv.ProjectName, bashScriptBinPath, Constants.BootstrapperExeName, configuration, "kestrel")
.WithSubDir(Path.Combine("approot", "runtimes", runtimeName), runtimeSubDir);

Assert.True(expectedOutputDir.MatchDirectoryOnDisk(testEnv.PublishOutputDirPath,
Expand Down
7 changes: 1 addition & 6 deletions test/dnx.tests/pal.tests.cpp
Expand Up @@ -11,10 +11,5 @@
dnx::xstring_t GetNativeBootstrapperDirectory() { return L""; }
void WaitForDebuggerToAttach() {}
bool IsTracingEnabled() { return true; }
bool GetAppBasePathFromEnvironment(wchar_t* /*szPath*/) { return false; };
bool GetFullPath(const wchar_t* /*szPath*/, wchar_t* /*szFullPath*/) { return false; }
int CallApplicationMain(const wchar_t* /*moduleName*/, const char* /*functionName*/, CALL_APPLICATION_MAIN_DATA* /*data*/, dnx::trace_writer& /*trace_writer*/) { return 3; }

#ifndef SetEnvironmentVariable
BOOL SetEnvironmentVariable(LPCTSTR lpName, LPCTSTR lpValue);
#endif //SetEnvironmentVariable
int CallApplicationMain(const wchar_t* /*moduleName*/, const char* /*functionName*/, CALL_APPLICATION_MAIN_DATA* /*data*/, dnx::trace_writer& /*trace_writer*/) { return 3; }

0 comments on commit e87f53d

Please sign in to comment.