-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.proj
129 lines (107 loc) · 5.76 KB
/
build.proj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<Project DefaultTargets="Pack">
<Import Project="LocalArtifacts.props" />
<Import Project="TargetFrameworks.props" />
<PropertyGroup>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' ">$(PackageTargetFrameworks)</TargetFrameworks>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<!-- Managed code -->
<SrcPath Condition=" '$(SrcPath)' == '' ">$(MSBuildThisFileDirectory)src\</SrcPath>
<BaseOutputPath Condition=" '$(BaseOutputPath)' == '' ">$(MSBuildThisFileDirectory)managed\</BaseOutputPath>
<OutputPath Condition=" '$(OutputPath)' == '' ">$(BaseOutputPath)$(Configuration)\</OutputPath>
<!-- Native code -->
<NativeBaseOutputPath Condition=" '$(NativeBaseOutputPath)' == '' ">$(MSBuildThisFileDirectory)native\</NativeBaseOutputPath>
<NativeOutputPath Condition=" '$(NativeOutputPath)' == '' ">$(NativeBaseOutputPath)$(Configuration)\</NativeOutputPath>
<!-- SwiftUIGlue -->
<SwiftUIGlueDir Condition=" '$(SwiftUIGlueDir)' == '' ">$(SrcPath)SwiftUIGlue\</SwiftUIGlueDir>
<SwiftUIGlueDylib Condition=" '$(SwiftUIGlueDylib)' == '' ">$(SwiftUIGlueDir).build\$(Configuration.ToLowerInvariant())\libSwiftUIGlue.dylib</SwiftUIGlueDylib>
<SwiftUIGlueXcodeproj Condition=" '$(SwiftUIGlueXcodeproj)' == '' ">$(SwiftUIGlueDir)SwiftUIGlue.xcodeproj</SwiftUIGlueXcodeproj>
</PropertyGroup>
<ItemGroup>
<SwiftUIGlueTargets Condition="$(TargetFrameworks.Contains('$(MacTargetFramework)'))" Include="SwiftUIGlueMac" />
<SwiftUIGlueTargets Condition="$(TargetFrameworks.Contains('$(iOSTargetFramework)'))" Include="SwiftUIGlueXcode" />
<SwiftUIGlueSources Include="$(SwiftUIGlueDir)*.swift" />
<!-- Mac -->
<!-- FIXME: Include dSYM? -->
<SwiftUIGlueDylibOutputs Include="$(SwiftUIGlueDylib)" />
<SwiftUIGlueMacOutputs Include="@(SwiftUIGlueDylibOutputs->'$(NativeOutputPath)$(MacTargetFramework)\%(RecursiveDir)%(Filename)%(Extension)')" />
<!-- All other platforms -->
<SwiftUIGlueSdks Condition="$(TargetFrameworks.Contains('$(iOSTargetFramework)'))" Include="iphoneos;iphonesimulator" TargetPlatformIdentifier="ios" TargetFramework="$(iOSTargetFramework)" />
<SwiftUIGlueSdks Update="@(SwiftUIGlueSdks)">
<ExtraArgs></ExtraArgs>
<IntermediateFrameworkDir>$(SwiftUIGlueDir)build\$(Configuration)-%(Identity)\SwiftUIGlue.framework\</IntermediateFrameworkDir>
<OutputFrameworkDir>$(NativeOutputPath)%(TargetFramework)\SwiftUIGlue.framework\</OutputFrameworkDir>
</SwiftUIGlueSdks>
<!-- HACK for Xcode 12 -->
<!-- FIXME: Revisit for Apple Silicon. Move to XCFramework if/when Xamarin supports it -->
<SwiftUIGlueSdks Update="iphonesimulator" ExtraArgs="EXCLUDED_ARCHS=arm64" />
</ItemGroup>
<Target Name="SwiftUIGlueXcode">
<Exec
Condition="!Exists('$(SwiftUIGlueXcodeproj)\project.pbxproj')"
Command="swift package generate-xcodeproj"
WorkingDirectory="$(SwiftUIGlueDir)" />
<Exec
Command="xcodebuild -project $(SwiftUIGlueXcodeproj) -configuration $(Configuration) -sdk %(SwiftUIGlueSdks.Identity) %(SwiftUIGlueSdks.ExtraArgs)"
WorkingDirectory="$(SwiftUIGlueDir)" />
<Copy
Condition="Exists('%(IntermediateFrameworkDir)\_CodeSignature\CodeResources')"
SourceFiles="%(IntermediateFrameworkDir)\_CodeSignature\CodeResources"
DestinationFolder="%(SwiftUIGlueSdks.OutputFrameworkDir)\_CodeSignature" />
<Copy
Condition="Exists('$(SwiftUIGlueDir)\%(SwiftUIGlueSdks.TargetPlatformIdentifier)\Info.plist')"
SourceFiles="$(SwiftUIGlueDir)\%(SwiftUIGlueSdks.TargetPlatformIdentifier)\Info.plist"
DestinationFolder="%(SwiftUIGlueSdks.OutputFrameworkDir)" />
<Exec
Command="lipo -create -output %(SwiftUIGlueSdks.OutputFrameworkDir)SwiftUIGlue @(SwiftUIGlueSdks->'%(IntermediateFrameworkDir)SwiftUIGlue', ' ')" />
</Target>
<Target Name="SwiftUIGlueMac" Inputs="@(SwiftUIGlueSources)" Outputs="@(SwiftUIGlueMacOutputs)">
<Exec
Command="swift build -c $(Configuration.ToLowerInvariant())"
WorkingDirectory="$(SwiftUIGlueDir)" />
<Copy
SourceFiles="@(SwiftUIGlueDylibOutputs)"
DestinationFiles="@(SwiftUIGlueMacOutputs)" />
</Target>
<Target Name="SwiftUIGlue" DependsOnTargets="@(SwiftUIGlueTargets)" />
<Target Name="Restore">
<MakeDir Directories="artifacts" />
<MSBuild
Projects="$(MSBuildThisFileDirectory)Xamarin.SwiftUI.sln"
Properties="Configuration=$(Configuration)" Targets="Restore" />
</Target>
<Target Name="Build" DependsOnTargets="SwiftUIGlue">
<ItemGroup>
<TargetFramework Include="$(TargetFrameworks)" />
</ItemGroup>
<MSBuild
Projects="$(SrcPath)SwiftUI\SwiftUI.csproj"
Properties="Configuration=$(Configuration);TargetFramework=%(TargetFramework.Identity)" Targets="Build" />
<MSBuild
Projects="$(SrcPath)SwiftUI.FSharp\SwiftUI.FSharp.fsproj"
Properties="Configuration=$(Configuration);TargetFramework=%(TargetFramework.Identity)" Targets="Build" />
</Target>
<Target Name="Pack" DependsOnTargets="Build">
<MakeDir Directories="$(ArtifactOutputPath)" />
<MSBuild
Projects="$(SrcPath)SwiftUI.Analyzers\SwiftUI.Analyzers.csproj"
Properties="Configuration=$(Configuration)" Targets="Build" />
<MSBuild
Projects="$(SrcPath)SwiftUI\SwiftUI.csproj"
Properties="Configuration=$(Configuration);NoBuild=true;TargetFrameworks=$(TargetFrameworks)" Targets="Pack" />
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(OutputPath);$(NativeOutputPath)" />
<Exec
Command="swift package clean"
WorkingDirectory="$(SwiftUIGlueDir)" />
<Exec
Condition="Exists('$(SwiftUIGlueXcodeproj)')"
Command="xcodebuild -project $(SwiftUIGlueXcodeproj) -configuration $(Configuration) -sdk %(SwiftUIGlueSdks.Identity) clean"
WorkingDirectory="$(SwiftUIGlueDir)" />
<RemoveDir Directories="$(SwiftUIGlueXcodeproj)" />
<MSBuild
Targets="Clean"
Projects="Xamarin.SwiftUI.sln"
Properties="Configuration=$(Configuration)" />
</Target>
</Project>