Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions Sharpmake.UnitTests/UtilTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,27 @@ public void LeavesEmptyStringsUntouched()
public void LeavesVariablesUntouched()
{
string expectedResult = "$(Console_SdkPackagesRoot)";
if (!Util.IsRunningInMono())
expectedResult = expectedResult.ToLower();
Assert.That(Util.PathMakeStandard("$(Console_SdkPackagesRoot)"), Is.EqualTo(expectedResult));
}

[Test]
public void ProcessesPathWithTrailingBackslash()
{
string expectedResult = Path.Combine("rd", "project", "dev", "projects", "sharpmake", "..", "..", "extern", "Geometrics");
if (!Util.IsRunningInMono())
expectedResult = expectedResult.ToLower();
Assert.That(Util.PathMakeStandard(@"rd\project\dev\projects\sharpmake\..\..\extern\Geometrics\"), Is.EqualTo(expectedResult));
}

[Test]
public void ProcessesPathWithTrailingBackslashAndADot()
{
var expectedResult = Path.Combine("rd", "project", "dev", "projects", "sharpmake", "..", "..", "extern", "Microsoft.CNG", "Lib");
if (!Util.IsRunningInMono())
expectedResult = expectedResult.ToLower();
Assert.That(Util.PathMakeStandard(@"rd\project\dev\projects\sharpmake\..\..\extern\Microsoft.CNG\Lib\"), Is.EqualTo(expectedResult));
}

[Test]
public void ProcessesPathWithMultipleTrailingBackslashes()
{
var expectedResult = Path.Combine("rd", "project", "dev", "projects", "sharpmake", "..", "..", "extern", "Microsoft.CNG", "Lib");
if (!Util.IsRunningInMono())
expectedResult = expectedResult.ToLower();
Assert.That(Util.PathMakeStandard(@"rd\project\dev\projects\sharpmake\..\..\extern\Microsoft.CNG\Lib\\\"), Is.EqualTo(expectedResult));
}

Expand All @@ -108,9 +100,6 @@ public void ProcessesWithAListAsArgument()
};
var expectedList = listString;

if (!Util.IsRunningInMono())
expectedList = expectedList.Select((p) => p.ToLower()).ToList();

Util.PathMakeStandard(listString);

Assert.AreEqual(expectedList, listString);
Expand Down Expand Up @@ -753,7 +742,7 @@ public void CanBeComputedFromOutputPath()
var referenceFileFullPath = outputFileFullPath.ReplaceHeadPath(outputPath, referencePath);

Assert.That(referenceFileFullPath, Is.EqualTo(
Util.PathMakeStandard(@"F:\OnePath\With\Reference\with\a\file.cs", false)));
Util.PathMakeStandard(@"F:\OnePath\With\Reference\with\a\file.cs")));
}

[Test]
Expand All @@ -766,7 +755,7 @@ public void IsCaseInsensitiveButPreservesCase()
var referenceFileFullPath = outputFileFullPath.ReplaceHeadPath(outputPath, referencePath);

Assert.That(referenceFileFullPath, Is.EqualTo(
Util.PathMakeStandard(@"F:\OnePath\with\Reference\with\a\File.cs", false)));
Util.PathMakeStandard(@"F:\OnePath\with\Reference\with\a\File.cs")));
}

[Test]
Expand All @@ -779,7 +768,7 @@ public void AcceptsOutputPathWithoutTrailingSlash()
var referenceFileFullPath = outputFileFullPath.ReplaceHeadPath(outputPath, referencePath);

Assert.That(referenceFileFullPath, Is.EqualTo(
Util.PathMakeStandard(@"F:\OnePath\With\Reference\with\a\file.cs", false)));
Util.PathMakeStandard(@"F:\OnePath\With\Reference\with\a\file.cs")));
}
}

Expand Down Expand Up @@ -1000,7 +989,7 @@ public void PathGetAbsoluteStringsReturnList()
string filename = Path.GetFileName(mockPath);
string stringsSource = Path.GetDirectoryName(mockPath);

Assert.AreEqual(Path.Combine(stringsSource.ToLower(), filename), Util.PathGetAbsolute(stringsSource, new Strings(filename))[0]);
Assert.AreEqual(Path.Combine(stringsSource, filename), Util.PathGetAbsolute(stringsSource, new Strings(filename))[0]);

File.Delete(mockPath);
}
Expand All @@ -1015,7 +1004,7 @@ public void PathGetAbsoluteStringsReturnString()
var separator = Path.DirectorySeparatorChar;
string stringsSource = mockPath.Substring(0, mockPath.IndexOf(separator));
string stringsDest = mockPath.Substring(mockPath.IndexOf(separator, mockPath.IndexOf(separator) + 1));
string expectedOutputPath = stringsSource.ToLower() + stringsDest;
string expectedOutputPath = stringsSource + stringsDest;
//v
Assert.AreEqual(expectedOutputPath, Util.PathGetAbsolute(stringsSource, stringsDest));

Expand All @@ -1032,7 +1021,6 @@ public void ResolvePathString()
Strings paths = new Strings(Path.GetDirectoryName(mockPath));
string root = mockPath.Substring(0, mockPath.IndexOf(Path.DirectorySeparatorChar));
Strings expectedOutputPath = new Strings(paths.Select((p) => Path.Combine(root, p)));
expectedOutputPath.ToLower();

Util.ResolvePath(root, ref paths);

Expand All @@ -1057,7 +1045,7 @@ public void ResolvePathOrderableString()
mockPath3.Substring(mockPath3.IndexOf(Path.DirectorySeparatorChar)),
};
string root = mockPath1.Substring(0, mockPath1.IndexOf(Path.DirectorySeparatorChar));
OrderableStrings expectedOutputPath = new OrderableStrings(paths.Select((p) => (root + p).ToLower()));
OrderableStrings expectedOutputPath = new OrderableStrings(paths.Select((p) => (root + p)));

Util.ResolvePath(root, ref paths);
expectedOutputPath.Sort();
Expand Down Expand Up @@ -1114,8 +1102,8 @@ public void PathGetRelativeOrderableStrings()
Util.PathMakeStandard(stringsDest);
OrderableStrings listResult = Util.PathGetRelative(stringsSource, stringsDest, false);

Assert.AreEqual(Util.PathMakeStandard(@"..\Sharpmake.Generators\Generic", !Util.IsRunningInMono()), listResult[0]);
Assert.AreEqual(Util.PathMakeStandard(@"subdir\test.txt", !Util.IsRunningInMono()), listResult[1]);
Assert.AreEqual(Util.PathMakeStandard(@"..\Sharpmake.Generators\Generic"), listResult[0]);
Assert.AreEqual(Util.PathMakeStandard(@"subdir\test.txt"), listResult[1]);
Assert.AreEqual("test2.txt", listResult[2]);
}

Expand Down Expand Up @@ -1192,11 +1180,11 @@ public void GetConvertedRelativePathRoot()
var root = @"C:\SharpMake\sharpmake\Sharpmake.Application\Properties";

var newRelativeToFullPath = "";
Assert.AreEqual(Path.Combine(absolutePath.ToLower(), fileName), Util.GetConvertedRelativePath(absolutePath, fileName, newRelativeToFullPath, false, null));
Assert.AreEqual(Path.Combine(absolutePath, fileName), Util.GetConvertedRelativePath(absolutePath, fileName, newRelativeToFullPath, false, null));
Assert.AreEqual(mockPath, Util.GetConvertedRelativePath(absolutePath, mockPath, newRelativeToFullPath, false, root));
Assert.AreEqual(Path.Combine(absolutePath.ToLower(), fileName), Util.GetConvertedRelativePath(absolutePath, fileName, newRelativeToFullPath, false, ""));
Assert.AreEqual(Path.Combine(absolutePath, fileName), Util.GetConvertedRelativePath(absolutePath, fileName, newRelativeToFullPath, false, ""));
Assert.AreEqual(absolutePath, Util.GetConvertedRelativePath(absolutePath, null, newRelativeToFullPath, false, null));
Assert.AreEqual(Path.Combine(root.ToLower(), Path.GetTempPath()), Util.GetConvertedRelativePath(root, Path.GetTempPath(), newRelativeToFullPath, false, null));
Assert.AreEqual(Path.Combine(root, Path.GetTempPath()), Util.GetConvertedRelativePath(root, Path.GetTempPath(), newRelativeToFullPath, false, null));

File.Delete(mockPath);
}
Expand Down
14 changes: 4 additions & 10 deletions Sharpmake/PathUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,10 @@ public static void PathMakeStandard(IList<string> paths)
}

public static string PathMakeStandard(string path)
{
return PathMakeStandard(path, !Util.IsRunningOnUnix());
}

public static string PathMakeStandard(string path, bool forceToLower)
{
// cleanup the path by replacing the other separator by the correct one for this OS
// then trim every trailing separators
var standardPath = path.Replace(OtherSeparator, Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar);
return forceToLower ? standardPath.ToLower() : standardPath;
return path.Replace(OtherSeparator, Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar);
}

public static string EnsureTrailingSeparator(string path)
Expand Down Expand Up @@ -797,9 +791,9 @@ internal static string ConvertToMountedUnixPath(string path)
public static string ReplaceHeadPath(this string fullInputPath, string inputHeadPath, string replacementHeadPath)
{
// Normalize paths before comparing and combining them, to prevent false mismatch between '\\' and '/'.
fullInputPath = Util.PathMakeStandard(fullInputPath, false);
inputHeadPath = Util.PathMakeStandard(inputHeadPath, false);
replacementHeadPath = Util.PathMakeStandard(replacementHeadPath, false);
fullInputPath = PathMakeStandard(fullInputPath);
inputHeadPath = PathMakeStandard(inputHeadPath);
replacementHeadPath = PathMakeStandard(replacementHeadPath);

inputHeadPath = EnsureTrailingSeparator(inputHeadPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>output\vs2017\v4_6_2\debug</OutputPath>
<IntermediateOutputPath>temp\othercsharpproj\vs2017\v4_6_2\debug</IntermediateOutputPath>
<OutputPath>output\vs2017\v4_6_2\Debug</OutputPath>
<IntermediateOutputPath>temp\OtherCSharpProj\vs2017\v4_6_2\Debug</IntermediateOutputPath>
<DefineConstants>DEBUG;TRACE;WIN32</DefineConstants>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -29,8 +29,8 @@
<DebugSymbols>false</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>output\vs2017\v4_6_2\release</OutputPath>
<IntermediateOutputPath>temp\othercsharpproj\vs2017\v4_6_2\release</IntermediateOutputPath>
<OutputPath>output\vs2017\v4_6_2\Release</OutputPath>
<IntermediateOutputPath>temp\OtherCSharpProj\vs2017\v4_6_2\Release</IntermediateOutputPath>
<DefineConstants>TRACE;WIN32</DefineConstants>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>output\vs2019\v4_7_2\debug</OutputPath>
<IntermediateOutputPath>temp\othercsharpproj\vs2019\v4_7_2\debug</IntermediateOutputPath>
<OutputPath>output\vs2019\v4_7_2\Debug</OutputPath>
<IntermediateOutputPath>temp\OtherCSharpProj\vs2019\v4_7_2\Debug</IntermediateOutputPath>
<DefineConstants>DEBUG;TRACE;WIN32</DefineConstants>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -29,8 +29,8 @@
<DebugSymbols>false</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>output\vs2019\v4_7_2\release</OutputPath>
<IntermediateOutputPath>temp\othercsharpproj\vs2019\v4_7_2\release</IntermediateOutputPath>
<OutputPath>output\vs2019\v4_7_2\Release</OutputPath>
<IntermediateOutputPath>temp\OtherCSharpProj\vs2019\v4_7_2\Release</IntermediateOutputPath>
<DefineConstants>TRACE;WIN32</DefineConstants>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>output\vs2017\v4_6_2\debug</OutputPath>
<IntermediateOutputPath>temp\testcsharpconsole\vs2017\v4_6_2\debug</IntermediateOutputPath>
<OutputPath>output\vs2017\v4_6_2\Debug</OutputPath>
<IntermediateOutputPath>temp\TestCSharpConsole\vs2017\v4_6_2\Debug</IntermediateOutputPath>
<DefineConstants>DEBUG;TRACE;WIN32</DefineConstants>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -29,8 +29,8 @@
<DebugSymbols>false</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>output\vs2017\v4_6_2\release</OutputPath>
<IntermediateOutputPath>temp\testcsharpconsole\vs2017\v4_6_2\release</IntermediateOutputPath>
<OutputPath>output\vs2017\v4_6_2\Release</OutputPath>
<IntermediateOutputPath>temp\TestCSharpConsole\vs2017\v4_6_2\Release</IntermediateOutputPath>
<DefineConstants>TRACE;WIN32</DefineConstants>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>output\vs2019\v4_7_2\debug</OutputPath>
<IntermediateOutputPath>temp\testcsharpconsole\vs2019\v4_7_2\debug</IntermediateOutputPath>
<OutputPath>output\vs2019\v4_7_2\Debug</OutputPath>
<IntermediateOutputPath>temp\TestCSharpConsole\vs2019\v4_7_2\Debug</IntermediateOutputPath>
<DefineConstants>DEBUG;TRACE;WIN32</DefineConstants>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -29,8 +29,8 @@
<DebugSymbols>false</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>output\vs2019\v4_7_2\release</OutputPath>
<IntermediateOutputPath>temp\testcsharpconsole\vs2019\v4_7_2\release</IntermediateOutputPath>
<OutputPath>output\vs2019\v4_7_2\Release</OutputPath>
<IntermediateOutputPath>temp\TestCSharpConsole\vs2019\v4_7_2\Release</IntermediateOutputPath>
<DefineConstants>TRACE;WIN32</DefineConstants>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
32 changes: 16 additions & 16 deletions samples/CPPCLI/reference/projects/clrcppproj.vs2017.v4_6_2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>clrcppproj</TargetName>
<OutDir>output\win32\debug\</OutDir>
<IntDir>temp\clrcppproj\vs2017\v4_6_2\debug\</IntDir>
<OutDir>output\win32\Debug\</OutDir>
<IntDir>temp\CLRCPPProj\vs2017\v4_6_2\Debug\</IntDir>
<TargetExt>.dll</TargetExt>
<GenerateManifest>true</GenerateManifest>
<LinkIncremental>false</LinkIncremental>
<OutputFile>output\win32\debug\clrcppproj.dll</OutputFile>
<OutputFile>output\win32\Debug\clrcppproj.dll</OutputFile>
<IgnoreImportLibrary>false</IgnoreImportLibrary>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>clrcppproj</TargetName>
<OutDir>output\win32\release\</OutDir>
<IntDir>temp\clrcppproj\vs2017\v4_6_2\release\</IntDir>
<OutDir>output\win32\Release\</OutDir>
<IntDir>temp\CLRCPPProj\vs2017\v4_6_2\Release\</IntDir>
<TargetExt>.dll</TargetExt>
<GenerateManifest>true</GenerateManifest>
<LinkIncremental>false</LinkIncremental>
<OutputFile>output\win32\release\clrcppproj.dll</OutputFile>
<OutputFile>output\win32\Release\clrcppproj.dll</OutputFile>
<IgnoreImportLibrary>false</IgnoreImportLibrary>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down Expand Up @@ -110,17 +110,17 @@
<CallingConvention>Cdecl</CallingConvention>
<CompileAs>Default</CompileAs>
<AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
<ProgramDatabaseFileName>temp\clrcppproj\vs2017\v4_6_2\debug\clrcppproj_compiler.pdb</ProgramDatabaseFileName>
<ProgramDatabaseFileName>temp\CLRCPPProj\vs2017\v4_6_2\Debug\CLRCPPProj_compiler.pdb</ProgramDatabaseFileName>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<OutputFile>output\win32\debug\clrcppproj.dll</OutputFile>
<OutputFile>output\win32\Debug\clrcppproj.dll</OutputFile>
<ShowProgress>NotSet</ShowProgress>
<AdditionalLibraryDirectories>output\win32\debug</AdditionalLibraryDirectories>
<ProgramDatabaseFile>output\win32\debug\clrcppproj.pdb</ProgramDatabaseFile>
<AdditionalLibraryDirectories>output\win32\Debug</AdditionalLibraryDirectories>
<ProgramDatabaseFile>output\win32\Debug\CLRCPPProj.pdb</ProgramDatabaseFile>
<GenerateMapFile>true</GenerateMapFile>
<MapExports>false</MapExports>
<SwapRunFromCD>false</SwapRunFromCD>
Expand All @@ -145,7 +145,7 @@
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries></IgnoreSpecificDefaultLibraries>
<LargeAddressAware>true</LargeAddressAware>
<MapFileName>output\win32\debug\clrcppproj.map</MapFileName>
<MapFileName>output\win32\Debug\clrcppproj.map</MapFileName>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand Down Expand Up @@ -193,17 +193,17 @@
<CallingConvention>Cdecl</CallingConvention>
<CompileAs>Default</CompileAs>
<AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
<ProgramDatabaseFileName>temp\clrcppproj\vs2017\v4_6_2\release\clrcppproj_compiler.pdb</ProgramDatabaseFileName>
<ProgramDatabaseFileName>temp\CLRCPPProj\vs2017\v4_6_2\Release\CLRCPPProj_compiler.pdb</ProgramDatabaseFileName>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
<OutputFile>output\win32\release\clrcppproj.dll</OutputFile>
<OutputFile>output\win32\Release\clrcppproj.dll</OutputFile>
<ShowProgress>NotSet</ShowProgress>
<AdditionalLibraryDirectories>output\win32\release</AdditionalLibraryDirectories>
<ProgramDatabaseFile>output\win32\release\clrcppproj.pdb</ProgramDatabaseFile>
<AdditionalLibraryDirectories>output\win32\Release</AdditionalLibraryDirectories>
<ProgramDatabaseFile>output\win32\Release\CLRCPPProj.pdb</ProgramDatabaseFile>
<GenerateMapFile>true</GenerateMapFile>
<MapExports>false</MapExports>
<SwapRunFromCD>false</SwapRunFromCD>
Expand All @@ -228,7 +228,7 @@
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries></IgnoreSpecificDefaultLibraries>
<LargeAddressAware>true</LargeAddressAware>
<MapFileName>output\win32\release\clrcppproj.map</MapFileName>
<MapFileName>output\win32\Release\clrcppproj.map</MapFileName>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
Loading