Skip to content

Commit 0606ae3

Browse files
committed
Added Clang resource directory to the runtime package.
Related: MochiLibraries/Biohazrd#201
1 parent 042df9b commit 0606ae3

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

.github/workflows/ClangSharp.Pathogen.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
- os: ubuntu-18.04
3535
name: Linux
3636
lib-path: build-linux/lib/libclang.so
37+
clang-resource-dir: build-linux/lib/clang/
3738
build-command: ./build-native.sh
3839
artifact-name: LlvmBuildOutputs-Linux
3940
name: Build LLVM - ${{matrix.name}}
@@ -61,10 +62,13 @@ jobs:
6162
id: cached-llvm
6263
uses: actions/cache@v2
6364
with:
64-
key: llvm-output-${{runner.os}}-${{steps.llvm.outputs.revision}}
65+
# Bumped to -2 to include the Clang resource directory
66+
key: llvm-output-${{runner.os}}-${{steps.llvm.outputs.revision}}-2
6567
# These are the paths of the external files required in ClangSharp.Pathogen.Runtime.csproj
6668
# (Make sure this is syncronized with "Archive LLVM Outputs" below)
67-
path: ${{matrix.lib-path}}
69+
path: |
70+
${{matrix.lib-path}}
71+
${{matrix.clang-resource-dir}}
6872
6973
- name: Checkout LLVM
7074
if: steps.cached-llvm.outputs.cache-hit != 'true'
@@ -116,7 +120,9 @@ jobs:
116120
name: ${{matrix.artifact-name}}
117121
if-no-files-found: error
118122
# The paths listed here must match "Load cached LLVM build outputs" above
119-
path: ${{matrix.lib-path}}
123+
path: |
124+
${{matrix.lib-path}}
125+
${{matrix.clang-resource-dir}}
120126
121127
build-dotnet:
122128
name: Build ClangSharp.Pathogen

ClangSharp.Pathogen.Runtime/ClangSharp.Pathogen.Runtime.csproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<LibClangPathogenPathWindows>$(MSBuildThisFileDirectory)../build/bin/libclang.dll</LibClangPathogenPathWindows>
1010
<LibClangPathogenPathLinux>$(MSBuildThisFileDirectory)../build-linux/lib/libclang.so</LibClangPathogenPathLinux>
1111
<PathogenExtensionsCppPath>$(MSBuildThisFileDirectory)../external/llvm-project/clang/tools/libclang/PathogenExtensions.cpp</PathogenExtensionsCppPath>
12+
<ClangResourceDirectoryPath>$(MSBuildThisFileDirectory)../build-linux/lib/clang/10.0.0/</ClangResourceDirectoryPath>
1213
<LicenseFilePath>$(MSBuildThisFileDirectory)../external/llvm-project/clang/LICENSE.TXT</LicenseFilePath>
1314

1415
<!-- Package Info -->
@@ -45,11 +46,32 @@
4546
<Pack>true</Pack>
4647
<PackagePath>runtimes/linux-x64/native/libclang-pathogen.so</PackagePath>
4748
</None>
49+
<None Include="$(ClangResourceDirectoryPath)**/*" LinkBase="clang-resources" Condition="Exists('$(ClangResourceDirectoryPath)')">
50+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
51+
<Pack>true</Pack>
52+
<!--
53+
We use MSBuild to copy the Clang resource directory to the build output of dependents using MSBuild instead of ContentFiles primarily to avoid having them pollute Solution Explorer:
54+
https://github.com/NuGet/Home/issues/4856
55+
-->
56+
<PackagePath>clang-resources/</PackagePath>
57+
</None>
58+
<None Update="ClangSharp.Pathogen.Runtime.props">
59+
<Pack>true</Pack>
60+
<!--
61+
buildTransitive is required to ensure the resource directory is also copied to indirect dependents
62+
We put the props file in both build and buildTransitive for legacy compatibility even though we don't really expect legacy consumers. (IE: Visual Studio 2017)
63+
NuGet will only use the one from buildTransitive when it's buildTransitive-aware.
64+
https://github.com/NuGet/Home/wiki/Allow-package%2D-authors-to-define-build-assets-transitive-behavior
65+
-->
66+
<PackagePath>build;buildTransitive</PackagePath>
67+
</None>
4868
</ItemGroup>
4969
<!-- Error if native runtime needs to be built or llvm-project is missing -->
5070
<Target Name="_NativeRuntimeChecks" BeforeTargets="Build;Pack">
5171
<Error Text="PathogenExtensions.cpp is missing, ensure Git submodules are up-to-date." Condition="!Exists('$(PathogenExtensionsCppPath)')" />
5272
<Error Text="Clang LICENSE.TXT is missing, ensure Git submodules are up-to-date." Condition="!Exists('$(LicenseFilePath)')" />
73+
<!-- Check for resource directory on CI builds -->
74+
<Error Text="Clang resource directory is missing." Condition="'$(ContinuousIntegrationBuild)' == 'true' and !Exists('$(ClangResourceDirectoryPath)')" />
5375

5476
<PropertyGroup>
5577
<_AllRuntimesPresent>true</_AllRuntimesPresent>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<ItemGroup>
3+
<None Include="$(MSBuildThisFileDirectory)../clang-resources/**/*" LinkBase="clang-resources" Visible="false" CopyToOutputDirectory="PreserveNewest" />
4+
</ItemGroup>
5+
</Project>

ClangSharp.Pathogen/ClangSharp.Pathogen.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
Do not use ReferenceOutputAssembly="false" here even though the reference isn't needed (and ClangSharp.Pathogen.Runtime.dll is essentially empty.)
2222
The reference to the assembly will be dropped during emit, and this needs to be a normal reference so that the generated NuGet package depends on the ClangSharp.Pathogen.Runtime package.
2323
-->
24-
<ProjectReference Include="..\ClangSharp.Pathogen.Runtime\ClangSharp.Pathogen.Runtime.csproj" />
24+
<ProjectReference Include="..\ClangSharp.Pathogen.Runtime\ClangSharp.Pathogen.Runtime.csproj" PrivateAssets="none" />
2525
</ItemGroup>
2626
<ItemGroup>
2727
<None Include="..\LICENSE.txt" Pack="true" PackagePath="" Visible="false" />

tooling/Versioning.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ These versions may seem obnoxiously verbose, but the build metadata is usually s
7575
<DevelopmentVersionCacheFilePath>$(MSBuildProjectDirectory)/obj/DevelopmentVersionNumber</DevelopmentVersionCacheFilePath>
7676

7777
<!-- Load the development build version number from the cache -->
78-
<DevelopmentVersionNumber Condition="Exists('$(DevelopmentVersionCacheFilePath)')">$([System.IO.File]::ReadAllText(`$(DevelopmentVersionCacheFilePath)`).Trim())</DevelopmentVersionNumber>
78+
<DevelopmentVersionNumber Condition="'$(DevelopmentVersionNumber)' == '' and Exists('$(DevelopmentVersionCacheFilePath)')">$([System.IO.File]::ReadAllText(`$(DevelopmentVersionCacheFilePath)`).Trim())</DevelopmentVersionNumber>
7979

8080
<!--
8181
If there was no cache, generate a new version number

0 commit comments

Comments
 (0)