-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
csharp_binary needs to become a rule which emits a cc_binary that invokes "dotnet <foo>", where "<foo>" is the actual *.dll that we compile, to solve #71. Eventually <foo> will become a wrapper C# exe that tweaks assembly loading to solve #9. So all of this requires the wrapper to provide a default argv[1]. For stuff like dotnet vstest (#51) we will have argv[1] = vstest, so we also need support for baking in argv[2].
- Loading branch information
Showing
3 changed files
with
81 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
An action that generates code for the C++ dotnet wrapper. | ||
""" | ||
|
||
def write_wrapper_main_cc(ctx, name, template, dotnetexe, argv1 = None, argv2 = None): | ||
"""Create the *.main.cc file which wraps dotnet.exe. | ||
Args: | ||
ctx: Rule context | ||
name: The name of the associated target for this actione | ||
template: The template .cc file | ||
dotnetexe: The File object for dotnet.exe | ||
argv1: (Optional) a value to inject as argv1 | ||
argv2: (Optional) a value to inject as argv2 | ||
Returns: | ||
A File object to be used in a cc_binary target. | ||
""" | ||
|
||
main_cc = ctx.actions.declare_file("%s.main.cc" % name) | ||
|
||
# Trim leading "../" | ||
# e.g. ../netcore-sdk-osx/dotnet | ||
dotnetexe_path = dotnetexe.short_path[3:] | ||
|
||
ctx.actions.expand_template( | ||
template = template, | ||
output = main_cc, | ||
substitutions = { | ||
"{DotnetExe}": dotnetexe_path, | ||
"{Argv1}": argv1 or "", | ||
"{Argv2}": argv2 or "", | ||
}, | ||
) | ||
|
||
return main_cc |
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