forked from dotnet/macios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dotnet] Prevent linking out code referenced by P/Invoke (dotnet#10182)
* [dotnet] Generate references.mm to prevent linking out code referenced by P/Invoke * Address PR feedback: Namespaces.Foundation -> "Foundation." * Address PR feedback: Simplify hasSymbols * Reuse ListExportedSymbols step, respect App.SymbolMode * Address PR feedback * Workaround for tvOS
- Loading branch information
1 parent
14e3282
commit 17722de
Showing
5 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
|
||
using Mono.Cecil; | ||
|
||
using Xamarin.Bundler; | ||
using Xamarin.Linker; | ||
|
||
namespace Xamarin { | ||
|
||
public class GenerateReferencesStep : ConfigurationAwareStep { | ||
protected override string Name { get; } = "Generate References"; | ||
protected override int ErrorCode { get; } = 2320; | ||
|
||
protected override void TryEndProcess () | ||
{ | ||
base.TryEndProcess (); | ||
|
||
var app = Configuration.Application; | ||
var required_symbols = Configuration.DerivedLinkContext.RequiredSymbols; | ||
var items = new List<MSBuildItem> (); | ||
|
||
switch (app.SymbolMode) { | ||
case SymbolMode.Ignore: | ||
break; | ||
case SymbolMode.Code: | ||
string reference_m = Path.Combine (Configuration.CacheDirectory, "reference.m"); | ||
reference_m = Configuration.Target.GenerateReferencingSource (reference_m, required_symbols); | ||
if (!string.IsNullOrEmpty (reference_m)) { | ||
var item = new MSBuildItem { Include = reference_m }; | ||
items.Add (item); | ||
} | ||
Configuration.WriteOutputForMSBuild ("_ReferencesFile", items); | ||
break; | ||
case SymbolMode.Linker: | ||
foreach (var symbol in required_symbols) { | ||
var item = new MSBuildItem { Include = "-u" + symbol.Prefix + symbol.Name }; | ||
items.Add (item); | ||
} | ||
Configuration.WriteOutputForMSBuild ("_ReferencesLinkerFlags", items); | ||
break; | ||
default: | ||
throw ErrorHelper.CreateError (99, Errors.MX0099, $"invalid symbol mode: {app.SymbolMode}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters