Skip to content

Commit

Permalink
Support for Source Link (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks authored Dec 18, 2023
1 parent 29c382b commit 8fcf427
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Setup MSBuild
uses: microsoft/setup-msbuild@1ff57057b5cfdc39105cd07a01d78e9b0ea0c14c
- name: Nuget Restore
run: nuget.exe restore templates/templates.sln
- name: Build
run: msbuild templates/templates.sln /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }}
Build:
Expand All @@ -36,5 +38,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Setup MSBuild
uses: microsoft/setup-msbuild@1ff57057b5cfdc39105cd07a01d78e9b0ea0c14c
- name: Nuget Restore
run: nuget.exe restore templates/templates.sln
- name: Build
run: msbuild templates/templates.sln /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

The goal of this project is to provide helpers for Windows components to build exactly as they would internally in the Windows OS repository, but without a lot of complicated manual steps.

This project provides two main components:
This project provides three main components:

- [windows.undocked.props](vs/windows.undocked.props) - Visual Studio property file to simplify components' project files.
- [windows.undocked.targets](vs/windows.undocked.targets) - Similar to the .props file, but only required if source link is being used.
- [build.yml](onebranch/v1/build.yml) - Azure Pipelines template to correctly build in OneBranch (Microsoft's **internal** Azure Pipelines sandbox).

## Usage
Expand Down
3 changes: 2 additions & 1 deletion templates/dll/dll.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
<UndockedType>dll</UndockedType>
<UndockedDir>$(SolutionDir)..\</UndockedDir>
<UndockedOut>$(SolutionDir)..\build\</UndockedOut>
<UndockedSourceLink>true</UndockedSourceLink>
</PropertyGroup>
<Import Project="$(UndockedDir)vs\windows.undocked.props" />
<ItemGroup>
<ClCompile Include="library.c" />
<ResourceCompile Include="dll.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="$(UndockedDir)vs\windows.undocked.targets" />
</Project>
3 changes: 2 additions & 1 deletion templates/exe/exe.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<UndockedType>exe</UndockedType>
<UndockedLoc>true</UndockedLoc>
<UndockedUseDriverToolset>true</UndockedUseDriverToolset>
<UndockedSourceLink>true</UndockedSourceLink>
<CharacterSet>Unicode</CharacterSet>
<UndockedDir>$(SolutionDir)..\</UndockedDir>
<UndockedOut>$(SolutionDir)..\build\</UndockedOut>
Expand All @@ -16,5 +17,5 @@
<ResourceCompile Include="exe.rc" />
<MessageCompile Include="localmsg.mc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="$(UndockedDir)vs\windows.undocked.targets" />
</Project>
3 changes: 2 additions & 1 deletion templates/lib/lib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<UndockedType>lib</UndockedType>
<UndockedDir>$(SolutionDir)..\</UndockedDir>
<UndockedOut>$(SolutionDir)..\build\</UndockedOut>
<UndockedSourceLink>true</UndockedSourceLink>
</PropertyGroup>
<Import Project="$(UndockedDir)vs\windows.undocked.props" />
<ItemGroup>
<ClCompile Include="static_library.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="$(UndockedDir)vs\windows.undocked.targets" />
</Project>
7 changes: 7 additions & 0 deletions templates/sys/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Build.Tasks.Git" version="1.0.0" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.AzureRepos.Git" version="1.0.0" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.Common" version="1.0.0" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.0.0" targetFramework="native" developmentDependency="true" />
</packages>
3 changes: 2 additions & 1 deletion templates/sys/sys.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
<UndockedType>sys</UndockedType>
<UndockedDir>$(SolutionDir)..\</UndockedDir>
<UndockedOut>$(SolutionDir)..\build\</UndockedOut>
<UndockedSourceLink>true</UndockedSourceLink>
</PropertyGroup>
<Import Project="$(UndockedDir)vs\windows.undocked.props" />
<ItemGroup>
<ClCompile Include="driver.c" />
<ResourceCompile Include="sys.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="$(UndockedDir)vs\windows.undocked.targets" />
</Project>
6 changes: 6 additions & 0 deletions vs/windows.undocked.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<UndockedDir Condition="'$(UndockedDir)' == ''">$(SolutionDir)undocked\</UndockedDir>
<UndockedOut Condition="'$(UndockedOut)' == ''">$(SolutionDir)build\</UndockedOut>
<UndockedLoc Condition="'$(UndockedLoc)' == ''">false</UndockedLoc>
<UndockedSourceLink Condition="'$(UndockedSourceLink)' == ''">false</UndockedSourceLink>
<UndockedVerFile Condition="'$(UndockedVerFile)' == ''">$(SolutionDir)version.json</UndockedVerFile>
<UndockedBuildId Condition="'$(UndockedBuildId)' == ''">0</UndockedBuildId>
<UndockedOfficial Condition="'$(UndockedOfficial)' == ''">false</UndockedOfficial>
Expand Down Expand Up @@ -88,6 +89,11 @@
<WinPlat Condition="'$(Platform)' == 'ARM64'">arm64</WinPlat>
<WinPlat Condition="'$(Platform)' == 'ARM64EC'">arm64ec</WinPlat>
</PropertyGroup>
<!--The following lines configure the properties needed for sourcelink support -->
<Import Project="$(SolutionDir)packages\Microsoft.SourceLink.AzureRepos.Git.1.0.0\build\Microsoft.SourceLink.AzureRepos.Git.props" Condition="$(UndockedSourceLink) AND Exists('$(SolutionDir)packages\Microsoft.SourceLink.AzureRepos.Git.1.0.0\build\Microsoft.SourceLink.AzureRepos.Git.props')" />
<Import Project="$(SolutionDir)packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props" Condition="$(UndockedSourceLink) AND Exists('$(SolutionDir)packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" />
<Import Project="$(SolutionDir)packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props" Condition="$(UndockedSourceLink) AND Exists('$(SolutionDir)packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props')" />
<Import Project="$(SolutionDir)packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props" Condition="$(UndockedSourceLink) AND Exists('$(SolutionDir)packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props')" />
<!-- Default global properties -->
<PropertyGroup>
<TargetVersion>Windows10</TargetVersion>
Expand Down
22 changes: 22 additions & 0 deletions vs/windows.undocked.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(SolutionDir)packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets" Condition="$(UndockedSourceLink) AND Exists('$(SolutionDir)packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets')" />
<Import Project="$(SolutionDir)packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets" Condition="$(UndockedSourceLink) AND Exists('$(SolutionDir)packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" />
<Import Project="$(SolutionDir)packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets" Condition="$(UndockedSourceLink) AND Exists('$(SolutionDir)packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" />
<Import Project="$(SolutionDir)packages\Microsoft.SourceLink.AzureRepos.Git.1.0.0\build\Microsoft.SourceLink.AzureRepos.Git.targets" Condition="$(UndockedSourceLink) AND Exists('$(SolutionDir)packages\Microsoft.SourceLink.AzureRepos.Git.1.0.0\build\Microsoft.SourceLink.AzureRepos.Git.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="$(UndockedSourceLink) AND !Exists('$(SolutionDir)packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props'))" />
<Error Condition="$(UndockedSourceLink) AND !Exists('$(SolutionDir)packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets'))" />
<Error Condition="$(UndockedSourceLink) AND !Exists('$(SolutionDir)packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props'))" />
<Error Condition="$(UndockedSourceLink) AND !Exists('$(SolutionDir)packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets'))" />
<Error Condition="$(UndockedSourceLink) AND !Exists('$(SolutionDir)packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props'))" />
<Error Condition="$(UndockedSourceLink) AND !Exists('$(SolutionDir)packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets'))" />
<Error Condition="$(UndockedSourceLink) AND !Exists('$(SolutionDir)packages\Microsoft.SourceLink.AzureRepos.Git.1.0.0\build\Microsoft.SourceLink.AzureRepos.Git.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.SourceLink.AzureRepos.Git.1.0.0\build\Microsoft.SourceLink.AzureRepos.Git.props'))" />
<Error Condition="$(UndockedSourceLink) AND !Exists('$(SolutionDir)packages\Microsoft.SourceLink.AzureRepos.Git.1.0.0\build\Microsoft.SourceLink.AzureRepos.Git.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.SourceLink.AzureRepos.Git.1.0.0\build\Microsoft.SourceLink.AzureRepos.Git.targets'))" />
</Target>
</Project>

0 comments on commit 8fcf427

Please sign in to comment.