Skip to content

Commit

Permalink
fix: Disable merging in uno debug builds, exclude Java.Interop for li…
Browse files Browse the repository at this point in the history
…nking issues
  • Loading branch information
jeromelaban committed Aug 26, 2022
1 parent c94d459 commit 4bf84f5
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
<AndroidPackageFormat>apk</AndroidPackageFormat>

<AndroidEnableMultiDex>true</AndroidEnableMultiDex>

<UnoXamlResourcesTrimming Condition="'$(Configuration)'!='Debug'">true</UnoXamlResourcesTrimming>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ private const MessageImportance DefaultLogMessageLevel
#endif

private List<string> _referencedAssemblies = new List<string>();
private string[] _searchPaths = Array.Empty<string>();
private DefaultAssemblyResolver? _assemblyResolver;

[Required]
Expand Down Expand Up @@ -128,7 +127,15 @@ private void RunLinker(string outputPath, string features)
{
var linkerPath = Path.Combine(ILLinkerPath, "illink.dll");

var linkerSearchPaths = string.Join(" ", _referencedAssemblies.Select(Path.GetDirectoryName).Distinct().Select(p => $"-d \"{p}\" "));
var referencedAssemblies = string.Join(" ", _referencedAssemblies
// Java interop does not link properly when included in our own
// set of parameters provided to the linker.
// As we're skipping unresolved symbols already, and that
// we do not need a functioning output, we can remove the assembly
// altogether.
.Where(r => !r.EndsWith("Java.Interop.dll"))
.Distinct()
.Select(r => $"-reference \"{r}\" "));

var parameters = new List<string>()
{
Expand All @@ -140,7 +147,7 @@ private void RunLinker(string outputPath, string features)
$"-b true",
$"-a {AssemblyPath}",
$"-out {outputPath}",
linkerSearchPaths,
referencedAssemblies,
features,
};

Expand All @@ -150,7 +157,7 @@ private void RunLinker(string outputPath, string features)

Directory.CreateDirectory(OutputPath);

var res = StartProcess("dotnet", $"{linkerPath} @{file}", CurrentProjectPath);
var res = StartProcess("dotnet", $"\"{linkerPath}\" @{file}", CurrentProjectPath);

if (!string.IsNullOrEmpty(res.error))
{
Expand Down Expand Up @@ -291,14 +298,14 @@ private void BuildReferences()
_referencedAssemblies.Add(RewriteReferencePath(referencePath.ItemSpec, unoUIPackageBasePath, UnoRuntimeIdentifier));
}

_searchPaths = ReferencePath
var searchPaths = ReferencePath
.Select(p => Path.GetDirectoryName(p.ItemSpec))
.Distinct()
.ToArray();

_assemblyResolver = new DefaultAssemblyResolver();

foreach (var assembly in _searchPaths)
foreach (var assembly in searchPaths)
{
_assemblyResolver.AddSearchDirectory(assembly);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Uno.UI.FluentTheme.v1/Uno.UI.FluentTheme.v1.net6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

<UseCommonOverridePackage>true</UseCommonOverridePackage>
<CommonOverridePackageId>Uno.UI</CommonOverridePackageId>

<UnoXamlResourcesTrimming Condition="'$(Configuration)'!='Debug'">true</UnoXamlResourcesTrimming>
</PropertyGroup>

<ItemGroup>
Expand All @@ -35,4 +37,5 @@
<Import Project="..\Uno.CrossTargetting.props" />
<Import Project="FluentMerge.targets" />

<Import Project="..\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets" Condition="'$(SkipUnoResourceGeneration)' == '' " />
</Project>
3 changes: 3 additions & 0 deletions src/Uno.UI.FluentTheme.v2/Uno.UI.FluentTheme.v2.net6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

<UseCommonOverridePackage>true</UseCommonOverridePackage>
<CommonOverridePackageId>Uno.UI</CommonOverridePackageId>

<UnoXamlResourcesTrimming Condition="'$(Configuration)'!='Debug'">true</UnoXamlResourcesTrimming>
</PropertyGroup>

<ItemGroup>
Expand All @@ -35,4 +37,5 @@
<Import Project="..\Uno.CrossTargetting.props" />
<Import Project="FluentMerge.targets" />

<Import Project="..\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets" Condition="'$(SkipUnoResourceGeneration)' == '' " />
</Project>
3 changes: 3 additions & 0 deletions src/Uno.UI.FluentTheme/Uno.UI.FluentTheme.net6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

<UseCommonOverridePackage>true</UseCommonOverridePackage>
<CommonOverridePackageId>Uno.UI</CommonOverridePackageId>

<UnoXamlResourcesTrimming Condition="'$(Configuration)'!='Debug'">true</UnoXamlResourcesTrimming>
</PropertyGroup>

<ItemGroup>
Expand All @@ -37,4 +39,5 @@
<Import Project="..\Uno.CrossTargetting.props" />
<Import Project="FluentMerge.targets" />

<Import Project="..\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets" Condition="'$(SkipUnoResourceGeneration)' == '' " />
</Project>
8 changes: 8 additions & 0 deletions src/Uno.UI.Toolkit/Uno.UI.Toolkit.net6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

<UseCommonOverridePackage>true</UseCommonOverridePackage>
<CommonOverridePackageId>Uno.UI</CommonOverridePackageId>

<UnoXamlResourcesTrimming Condition="'$(Configuration)'!='Debug'">true</UnoXamlResourcesTrimming>
</PropertyGroup>

<!--Workaround to prevent build to fail because the project has too many dependencies when checking support libraries versions.
Expand All @@ -42,6 +44,12 @@
<PackageReference Include="Uno.SourceGenerationTasks" />
</ItemGroup>

<PropertyGroup>
<UnoUIMSBuildTasksPath>$(MSBuildThisFileDirectory)..\SourceGenerators\Uno.UI.Tasks\bin\$(Configuration)_Shadow</UnoUIMSBuildTasksPath>
</PropertyGroup>

<Import Project="..\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets" Condition="'$(SkipUnoResourceGeneration)' == '' " />

<ItemGroup>
<ProjectReference Include="..\Uno.UI\Uno.UI.net6.csproj">
<Name>Uno.UI</Name>
Expand Down
2 changes: 2 additions & 0 deletions src/Uno.UI/Uno.UI.net6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

<!-- Disable WPF targets -->
<ImportFrameworkWinFXTargets>false</ImportFrameworkWinFXTargets>

<UnoXamlResourcesTrimming Condition="'$(Configuration)'!='Debug'">true</UnoXamlResourcesTrimming>
</PropertyGroup>

<Import Project="..\Uno.CrossTargetting.props" />
Expand Down

0 comments on commit 4bf84f5

Please sign in to comment.