From d1ad77d44196c2f35a1de1ed076952a14c636498 Mon Sep 17 00:00:00 2001 From: Jerome Haltom Date: Sun, 7 Apr 2024 13:10:47 -0500 Subject: [PATCH] Okay. Big changes. Reset to bin and obj output. Break down paths a bit differently. Static/Shared distinction on outputtype for libraries. Static libraries emit no bin output. But do emit Library output. LibraryOutput and ExecutableOutput represent whether a particular thing exists, but may in fact be the same thing. Windows, for instance, outputs a dll and a lib for shared. While linux outputs a .so and no lib for shared. But static on both outputs only a lib. --- .../SharedLibrary1/SharedLibrary1.clangproj | 5 +- .../Project/SharedLibrary1/hello1.c | 2 + .../SharedLibrary2/SharedLibrary2.clangproj | 2 +- .../StaticLibrary1/StaticLibrary1.clangproj | 16 + .../Project/StaticLibrary1/statichello1.c | 5 + .../Project/StaticLibrary1/statichello1.h | 1 + src/IKVM.Clang.Sdk.Tests/ProjectTests.cs | 11 +- .../Sdk/targets/IKVM.Clang.Core.targets | 352 +++++++----------- .../targets/IKVM.Clang.CurrentVersion.targets | 4 +- .../Sdk/targets/IKVM.Clang.Sdk.targets | 1 - .../Sdk/targets/IKVM.Clang.props | 1 - 11 files changed, 180 insertions(+), 220 deletions(-) create mode 100644 src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/StaticLibrary1.clangproj create mode 100644 src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/statichello1.c create mode 100644 src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/statichello1.h diff --git a/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary1/SharedLibrary1.clangproj b/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary1/SharedLibrary1.clangproj index ef66a30..409ced1 100644 --- a/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary1/SharedLibrary1.clangproj +++ b/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary1/SharedLibrary1.clangproj @@ -4,7 +4,7 @@ f511e617-3e18-4dc6-9936-8746f3060663 - Library + Shared x86_64-pc-windows-msvc;i686-pc-windows-msvc;thumbv7-pc-windows-msvc;aarch64-pc-windows-msvc true @@ -12,6 +12,9 @@ true + + true + diff --git a/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary1/hello1.c b/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary1/hello1.c index 2339c04..4d8fcf7 100644 --- a/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary1/hello1.c +++ b/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary1/hello1.c @@ -1,9 +1,11 @@ #include +#include #include #include "hello1.h" EXPORT void hello1() { hello2(); + statichello1(); printf(STRING); } diff --git a/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary2/SharedLibrary2.clangproj b/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary2/SharedLibrary2.clangproj index cd05e50..c493c54 100644 --- a/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary2/SharedLibrary2.clangproj +++ b/src/IKVM.Clang.Sdk.Tests/Project/SharedLibrary2/SharedLibrary2.clangproj @@ -4,7 +4,7 @@ f511e617-3e18-4dc6-9936-8746f3060663 - Library + Shared x86_64-pc-windows-msvc;i686-pc-windows-msvc;thumbv7-pc-windows-msvc;aarch64-pc-windows-msvc true diff --git a/src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/StaticLibrary1.clangproj b/src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/StaticLibrary1.clangproj new file mode 100644 index 0000000..f090b41 --- /dev/null +++ b/src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/StaticLibrary1.clangproj @@ -0,0 +1,16 @@ + + + + f511e617-3e18-4dc6-9936-8746f3060663 + + + Static + x86_64-pc-windows-msvc;i686-pc-windows-msvc;thumbv7-pc-windows-msvc;aarch64-pc-windows-msvc + true + + + +
+ + + \ No newline at end of file diff --git a/src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/statichello1.c b/src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/statichello1.c new file mode 100644 index 0000000..85f260f --- /dev/null +++ b/src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/statichello1.c @@ -0,0 +1,5 @@ +#include "statichello1.h" + +void statichello1() { + +} diff --git a/src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/statichello1.h b/src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/statichello1.h new file mode 100644 index 0000000..e1c1f42 --- /dev/null +++ b/src/IKVM.Clang.Sdk.Tests/Project/StaticLibrary1/statichello1.h @@ -0,0 +1 @@ +void statichello1(); diff --git a/src/IKVM.Clang.Sdk.Tests/ProjectTests.cs b/src/IKVM.Clang.Sdk.Tests/ProjectTests.cs index 12040d7..051e873 100644 --- a/src/IKVM.Clang.Sdk.Tests/ProjectTests.cs +++ b/src/IKVM.Clang.Sdk.Tests/ProjectTests.cs @@ -125,7 +125,8 @@ public static void ClassInitialize(TestContext context) options.TargetsToBuild.Clear(); options.TargetsToBuild.Add("Clean"); options.TargetsToBuild.Add("Restore"); - options.Arguments.Add("/v:d"); + options.Arguments.Add("/v:diag"); + var result = analyzer.Build(options); context.AddResultFile(Path.Combine(WorkRoot, "msbuild.binlog")); result.OverallSuccess.Should().Be(true); @@ -167,21 +168,21 @@ public void CanBuildTestProject(EnvironmentPreference env, string tid, string li options.TargetsToBuild.Clear(); options.TargetsToBuild.Add("Clean"); options.TargetsToBuild.Add("Build"); - options.Arguments.Add("/v:d"); + options.Arguments.Add("/v:diag"); var result = analyzer.Build(options); TestContext.AddResultFile(Path.Combine(WorkRoot, $"{tid}-msbuild.binlog")); result.OverallSuccess.Should().BeTrue(); - var binDir = Path.Combine(TestRoot, "Executable", "dist", "Debug", tid, "bin"); + var binDir = Path.Combine(TestRoot, "Executable", "bin", "Debug", tid); File.Exists(Path.Combine(binDir, string.Format(exeName, "Executable"))).Should().BeTrue(); File.Exists(Path.Combine(binDir, string.Format(symName, "Executable"))).Should().BeTrue(); - var libDir1 = Path.Combine(TestRoot, "SharedLibrary1", "dist", "Debug", tid, "lib"); + var libDir1 = Path.Combine(TestRoot, "SharedLibrary1", "bin", "Debug", tid); File.Exists(Path.Combine(libDir1, string.Format(libName, "SharedLibrary1"))).Should().BeTrue(); File.Exists(Path.Combine(libDir1, string.Format(symName, "SharedLibrary1"))).Should().BeTrue(); - var libDir2 = Path.Combine(TestRoot, "SharedLibrary2", "dist", "Debug", tid, "lib"); + var libDir2 = Path.Combine(TestRoot, "SharedLibrary2", "bin", "Debug", tid); File.Exists(Path.Combine(libDir2, string.Format(libName, "SharedLibrary2"))).Should().BeTrue(); File.Exists(Path.Combine(libDir2, string.Format(symName, "SharedLibrary2"))).Should().BeTrue(); } diff --git a/src/IKVM.Clang.Sdk/Sdk/targets/IKVM.Clang.Core.targets b/src/IKVM.Clang.Sdk/Sdk/targets/IKVM.Clang.Core.targets index 84d48e2..4305841 100644 --- a/src/IKVM.Clang.Sdk/Sdk/targets/IKVM.Clang.Core.targets +++ b/src/IKVM.Clang.Sdk/Sdk/targets/IKVM.Clang.Core.targets @@ -4,59 +4,82 @@ - Library + $(MSBuildProjectName) + Shared $(TargetIdentifier) clang.exe clang - true true + .pdb + .g + .dsym - - .exe + + .exe + + .dll + .so + .dylib + $(ExecutablePrefix)$(TargetName)$(ExecutableExt) + $(IntermediateOutputPath)$(ExecutableFileName) + console true + lld - - - lib - lib - .dll - .so - .dylib + + + + lib + lib + + .dll + .so + .dylib + $(ExecutablePrefix)$(TargetName)$(ExecutableExt) + $(IntermediateOutputPath)$(ExecutableFileName) + lib + lib + .lib + .so + .dylib + $(LibraryPrefix)$(TargetName)$(LibraryExt) + $(IntermediateOutputPath)$(LibraryFileName) + lib + lib false + lld - - .obj - .o - - - + + + + + $(IntermediateOutputPath)$(ExecutableFileName) + lib + lib .lib - .a - - - - .pdb - .g - .dsym + .a + .a + $(LibraryPrefix)$(TargetName)$(LibraryExt) + $(IntermediateOutputPath)$(LibraryFileName) + lib + lib + false + llvm-lib + lld - $(ProjectName) - $(TargetPrefix)$(TargetName)$(TargetExt) - $(TargetPrefix)$(TargetName)$(LibraryExt) - $(TargetPrefix)$(TargetName)$(DebugSymbolsExt) - - - lib\ - bin\ - include\ - $(LibraryPathName) - $(BinaryPathName) + .obj + .o + $(DebugSymbolsPrefix)$(TargetName)$(DebugSymbolsExt) + $(IntermediateOutputPath)$(DebugSymbolsFileName) + headers\ + $(IntermediateOutputPath)$(HeadersPathName) - + - + $(TargetIdentifier) $(TargetName) $(TargetTriple) - $([System.IO.Path]::GetFullPath('$(OutputPath)$(LibraryPathName)$(LibraryFileName)')) - $([System.IO.Path]::GetFullPath('$(OutputPath)$(TargetPathName)$(DebugSymbolsFileName)')) - $([System.IO.Path]::GetFullPath('$(OutputPath)$(IncludePathName)')) + $([System.IO.Path]::GetFullPath('$(ExecutableIntermediateOutputPath)')) + $([System.IO.Path]::GetFullPath('$(LibraryIntermediateOutputPath)')) + $([System.IO.Path]::GetFullPath('$(DebugSymbolsIntermediateOutputPath)')) + $([System.IO.Path]::GetFullPath('$(HeadersIntermediateOutputPath)')) $(Version) @(CopyUpToDateMarker) - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - + + - + - - $(ImportTransitiveProjectReferenceItemsDependsOn); + + $(ImportProjectReferenceItemsDependsOn); AssignProjectConfiguration; - GetTransitiveClangTargetItems; - GetTransitiveClangIncludeDirectories; - GetTransitiveClangLibraryDirectories; - GetTransitiveClangDependencies; - + GetProjectReferenceTargetItems; + - - - - - + - <_GetTransitiveTargetItems Include="@(GetTransitiveTargetItems->'%(LibraryPath)')" /> - - - - + + <_LibraryDirectories Remove="@(_LibraryDirectories)" /> + <_LibraryDirectories Include="@(GetProjectReferenceTargetItems->'%(LibraryPath)')" /> + + @@ -362,7 +268,7 @@ --> - + @@ -385,7 +291,7 @@ $(CoreCompileDependsOn); ResolveProjectReferences; - ImportTransitiveProjectReferenceItems; + ImportProjectReferenceItems; PrepareCompile; @@ -462,7 +368,6 @@ <_IncludeDirectories Include="%(Compile.IncludeDirectories)" /> <_IncludeDirectories Include="@(IncludeDirectories)" /> <_IncludeDirectories Include="$(IncludeDirectories)" /> - <_IncludeDirectories Include="@(ImportedIncludeDirectories)" /> <_IncludeDirectoriesTemp Remove="@(_IncludeDirectoriesTemp)" /> <_IncludeDirectoriesTemp Include="@(_IncludeDirectories->Distinct())" /> <_IncludeDirectoriesArgs Remove="@(_IncludeDirectoriesArgs)" /> @@ -509,20 +414,25 @@ $(CoreLinkDependsOn); Compile; - ImportTransitiveProjectReferenceItems; + ImportProjectReferenceItems; + + + <_OutputPath Condition=" '$(LibraryIntermediateOutputPath)' != '' ">$(LibraryIntermediateOutputPath) + <_OutputPath Condition=" '$(ExecutableIntermediateOutputPath)' != '' ">$(ExecutableIntermediateOutputPath) + <_Args Remove="@(_Args)" /> - <_Args Include="-shared" Condition=" '$(OutputType)' == 'library' " /> - <_Args Include="-static" Condition=" '$(OutputType)' == 'staticlibrary' " /> + <_Args Include="-shared" Condition=" '$(OutputType)' == 'shared' " /> + <_Args Include="-static" Condition=" '$(OutputType)' == 'static' " /> <_Args Include="-v" Condition=" '$(Verbose)' == 'true' " /> <_Args Include="--target" Value="$(TargetTriple)" Separator="=" /> - <_Args Include="-fuse-ld" Value="lld" Separator="=" Condition=" '$(UseLld)' == 'true' " /> + <_Args Include="-fuse-ld" Value="$(UseLd)" Separator="=" Condition=" '$(UseLd)' != '' " /> <_Args Include="-g" Condition=" '$(DebugSymbols)' == 'true' " /> <_Args Include="-Wl,/subsystem:$(Subsystem)" Condition=" '$(Subsystem)' != '' " /> @@ -550,7 +460,6 @@ <_LibraryDirectories Remove="@(_LibraryDirectories)" /> <_LibraryDirectories Include="@(LibraryDirectories)" /> <_LibraryDirectories Include="$(LibraryDirectories)" /> - <_LibraryDirectories Include="@(ImportedLibraryDirectories)" /> <_LibraryDirectoriesTemp Remove="@(_LibraryDirectoriesTemp)" /> <_LibraryDirectoriesTemp Include="@(_LibraryDirectories->Distinct())" /> <_LibraryDirectoriesArgs Remove="@(_LibraryDirectoriesArgs)" /> @@ -560,7 +469,6 @@ <_Dependencies Remove="@(_Dependencies)" /> <_Dependencies Include="@(Dependencies)" /> <_Dependencies Include="$(Dependencies)" /> - <_Dependencies Include="@(ImportedDependencies)" /> <_DependenciesTemp Remove="@(_DependenciesTemp)" /> <_DependenciesTemp Include="@(_Dependencies->Distinct())" /> <_DependenciesArgs Remove="@(_DependenciesArgs)" /> @@ -574,19 +482,57 @@ <_Args Include="@(Compile->'%(ObjectPath)')" /> - <_Args Include="-o" Value="$(IntermediateOutputPath)$(TargetFileName)" Separator=" " /> + <_Args Include="-o" Value="$(_OutputPath)" Separator=" " /> - - - + + + + + + + + +
+ %(RecursiveDir)%(Filename)%(Extension) +
+
+
+ + + + $(CopyHeadersDependsOn); + PrepareCopyHeaders; + + + + + + + +