This repository has been archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 510
Automatic generation of method export file for shared libraries #5154
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9f615d8
add ExportedDefinitionsWriter (#4986)
tonerdo 0d17711
add automatic location of auto-generated definition file to build scr…
tonerdo 655be26
add support for generating OSX symbol export files (#4986)
tonerdo ea9e84c
rename ExportedDefinitionsWriter to ExportsWriter (#4986)
tonerdo cb11f1f
update buildscripts for OSX exports file location (#4986)
tonerdo 7443e76
rename ExportsWriter to ExportedMethodsWriter (#4986)
tonerdo f8106e1
restructure ExportedMethodsWriter class (#4986)
tonerdo 0fad626
remove exporting of internal nativecallable methods (#4986)
tonerdo 996bea2
only generate exports file during native library build (#4986)
tonerdo b5050e6
add generation and location of version-script on linux (#4986)
tonerdo 99435e1
make linux version script generation the default case (#4986)
tonerdo 2dbde95
move exported methods emission to ExportedMethodsRootProvider class (…
tonerdo 50b0686
set ExportsFile variable if not user defined and it's a shared lib bu…
tonerdo 7fc2d0d
make optimizations to exports file emission code (#4986)
tonerdo 3bad6d1
remove redundant info from exported definition files (#4986)
tonerdo 0c00f1a
ensure definition file is overwritten (#4986)
tonerdo 4f80359
add DefFileWriter class (#4986)
tonerdo b46e2c0
fix wasm build error caused by merge (#4986)
tonerdo 4b7424b
rename DefFileWriter to ExportsFileWriter (#4986)
tonerdo 7f7e1d7
restructure ExportedMethodsRootProvider class (#4986)
tonerdo 9d581df
refactor ExportedMethodsRootProvider class (#4986)
tonerdo a062443
improve performance of ExportedMethods property (#4986)
tonerdo f085583
fix typo (#4986)
tonerdo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,49 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
using Internal.TypeSystem; | ||
using Internal.TypeSystem.Ecma; | ||
|
||
namespace ILCompiler | ||
{ | ||
public class ExportsFileWriter | ||
{ | ||
private string _exportsFile; | ||
private List<EcmaMethod> _methods; | ||
private TypeSystemContext _context; | ||
|
||
public ExportsFileWriter(TypeSystemContext context, string exportsFile) | ||
{ | ||
_exportsFile = exportsFile; | ||
_context = context; | ||
_methods = new List<EcmaMethod>(); | ||
} | ||
|
||
public void AddExportedMethods(IEnumerable<EcmaMethod> methods) | ||
=> _methods.AddRange(methods.Where(m => m.Module != _context.SystemModule)); | ||
|
||
public void EmitExportedMethods() | ||
{ | ||
FileStream fileStream = new FileStream(_exportsFile, FileMode.Create); | ||
using (StreamWriter streamWriter = new StreamWriter(fileStream)) | ||
{ | ||
if (_context.Target.IsWindows) | ||
{ | ||
streamWriter.WriteLine("EXPORTS"); | ||
foreach (var method in _methods) | ||
streamWriter.WriteLine($" {method.GetNativeCallableExportName()}"); | ||
} | ||
else | ||
{ | ||
foreach (var method in _methods) | ||
streamWriter.WriteLine($"_{method.GetNativeCallableExportName()}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I though that
-shared
works on OSX too. Just for my education - why did you change this to-dynamiclib
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah I know it works. I guess I was just trying to be as platform accurate as possible, most Apple docs use
-dynamiclib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that's fine.