Skip to content

Incremental build is broken for external packages with patches #1520

@ViktorHofer

Description

@ViktorHofer

<Target Name="PrepareInnerClone">
<ItemGroup>
<RepoFileToCopy Include="$(OriginalProjectDirectory)**\*"
Exclude="$(OriginalProjectDirectory)artifacts\**\*" />
</ItemGroup>
<Copy SourceFiles="@(RepoFileToCopy)" DestinationFolder="$(ProjectDirectory)%(RecursiveDir)" SkipUnchangedFiles="true" />
</Target>
<Target Name="ApplyPatches"
Condition="'@(PatchToApply)' != '' and '$(SkipPatches)' != 'true'"
DependsOnTargets="PrepareInnerClone"
Inputs="@(PatchToApply)"
Outputs="$(BaseIntermediateOutputPath)ApplyPatches.complete" >
<PropertyGroup>
<PatchCommand>git --work-tree=$(ProjectDirectory) apply --ignore-whitespace --whitespace=nowarn</PatchCommand>
</PropertyGroup>
<!-- in the installer tarball, we want to remove the objects directory from the .gitdir to save space.
This causes a problem specifically in the combination of submodules which have redirected .gitdirs
when we are applying patches in the current directory (which is required due to the way Git
interprets the paths in a patch). GIT_DIR=/dev/null short-circuits the .gitdir discovery process
and lets Git treat the directory like any non-Git-controlled directory instead. -->
<Exec Command="$(PatchCommand) %(PatchToApply.Identity)"
WorkingDirectory="$(ProjectDirectory)"
Condition="'@(PatchToApply)' != ''"
EnvironmentVariables="GIT_DIR=/dev/null" />
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
<Touch Files="$(BaseIntermediateOutputPath)ApplyPatches.complete" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>

  1. The PrepareInnerClone target always runs but skips unchanged files.
  2. The ApplyPatches target which runs after PrepareInnerClone only runs once successfully as it then creates an output marker file.

If something fails in the SBRP repo and I run the build again, the PrepareInnerClone target runs again and overwrites the patched files but the ApplyPatches target doesn't run anymore.

Metadata

Metadata

Assignees

Labels

untriagedNeeds to be triaged

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions