Skip to content

Commit

Permalink
Add musl/alpine packs (#429)
Browse files Browse the repository at this point in the history
## What?
* Adds runtime/apphost packs for musl/alpine
* Makes the apphost/runtime transitions handle rids that only have packs for child rids
  • Loading branch information
purkhusid authored Apr 4, 2024
1 parent 84487de commit c42412a
Show file tree
Hide file tree
Showing 12 changed files with 386 additions and 2 deletions.
22 changes: 22 additions & 0 deletions dotnet/private/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,28 @@ def get_highest_compatible_target_framework(incoming_tfm, tfms):

return None

def get_highest_compatible_runtime_identifier(incoming_rid, rids):
"""Returns the highest compatible runtime identifier for the incoming_rid.
Args:
incoming_rid: The runtime identifier to compare to
rids: A list of runtime identifiers to choose from
Returns:
The highest compatible runtime identifier
"""
if incoming_rid in rids:
return incoming_rid

compatible_rids = RUNTIME_GRAPH.get(incoming_rid)
if compatible_rids == None:
return None

for compatible_rid in compatible_rids:
if compatible_rid in rids:
return compatible_rid

return None

def get_nuget_relative_path(file):
"""Returns NuGet package relative path of a file that is part of a NuGet package
Expand Down
12 changes: 12 additions & 0 deletions dotnet/private/sdk/apphost_packs/apphost_pack_lookup_table.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,35 @@ apphost_pack_lookup_table = {
"netcoreapp3.0": {
"linux-x64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.0_linux-x64",
"linux-arm64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.0_linux-arm64",
"linux-musl-x64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.0_linux-musl-x64",
"linux-musl-arm64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.0_linux-musl-arm64",
"osx-x64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.0_osx-x64",
"win-x64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.0_win-x64",
"win-arm64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.0_win-arm64",
},
"netcoreapp3.1": {
"linux-x64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.1_linux-x64",
"linux-arm64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.1_linux-arm64",
"linux-musl-x64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.1_linux-musl-x64",
"linux-musl-arm64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.1_linux-musl-arm64",
"osx-x64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.1_osx-x64",
"win-x64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.1_win-x64",
"win-arm64": "//dotnet/private/sdk/apphost_packs:netcoreapp3.1_win-arm64",
},
"net5.0": {
"linux-x64": "//dotnet/private/sdk/apphost_packs:net5.0_linux-x64",
"linux-arm64": "//dotnet/private/sdk/apphost_packs:net5.0_linux-arm64",
"linux-musl-x64": "//dotnet/private/sdk/apphost_packs:net5.0_linux-musl-x64",
"linux-musl-arm64": "//dotnet/private/sdk/apphost_packs:net5.0_linux-musl-arm64",
"osx-x64": "//dotnet/private/sdk/apphost_packs:net5.0_osx-x64",
"win-x64": "//dotnet/private/sdk/apphost_packs:net5.0_win-x64",
"win-arm64": "//dotnet/private/sdk/apphost_packs:net5.0_win-arm64",
},
"net6.0": {
"linux-x64": "//dotnet/private/sdk/apphost_packs:net6.0_linux-x64",
"linux-arm64": "//dotnet/private/sdk/apphost_packs:net6.0_linux-arm64",
"linux-musl-x64": "//dotnet/private/sdk/apphost_packs:net6.0_linux-musl-x64",
"linux-musl-arm64": "//dotnet/private/sdk/apphost_packs:net6.0_linux-musl-arm64",
"osx-x64": "//dotnet/private/sdk/apphost_packs:net6.0_osx-x64",
"osx-arm64": "//dotnet/private/sdk/apphost_packs:net6.0_osx-arm64",
"win-x64": "//dotnet/private/sdk/apphost_packs:net6.0_win-x64",
Expand All @@ -33,6 +41,8 @@ apphost_pack_lookup_table = {
"net7.0": {
"linux-x64": "//dotnet/private/sdk/apphost_packs:net7.0_linux-x64",
"linux-arm64": "//dotnet/private/sdk/apphost_packs:net7.0_linux-arm64",
"linux-musl-x64": "//dotnet/private/sdk/apphost_packs:net7.0_linux-musl-x64",
"linux-musl-arm64": "//dotnet/private/sdk/apphost_packs:net7.0_linux-musl-arm64",
"osx-x64": "//dotnet/private/sdk/apphost_packs:net7.0_osx-x64",
"osx-arm64": "//dotnet/private/sdk/apphost_packs:net7.0_osx-arm64",
"win-x64": "//dotnet/private/sdk/apphost_packs:net7.0_win-x64",
Expand All @@ -41,6 +51,8 @@ apphost_pack_lookup_table = {
"net8.0": {
"linux-x64": "//dotnet/private/sdk/apphost_packs:net8.0_linux-x64",
"linux-arm64": "//dotnet/private/sdk/apphost_packs:net8.0_linux-arm64",
"linux-musl-x64": "//dotnet/private/sdk/apphost_packs:net8.0_linux-musl-x64",
"linux-musl-arm64": "//dotnet/private/sdk/apphost_packs:net8.0_linux-musl-arm64",
"osx-x64": "//dotnet/private/sdk/apphost_packs:net8.0_osx-x64",
"osx-arm64": "//dotnet/private/sdk/apphost_packs:net8.0_osx-arm64",
"win-x64": "//dotnet/private/sdk/apphost_packs:net8.0_win-x64",
Expand Down
4 changes: 3 additions & 1 deletion dotnet/private/sdk/apphost_packs/apphost_pack_transition.bzl
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"A transition that transitions between compatible target frameworks"

load("//dotnet/private:common.bzl", "get_highest_compatible_runtime_identifier")
load(":apphost_pack_lookup_table.bzl", "apphost_pack_lookup_table")

def _impl(settings, _attr):
incoming_target_framework = settings["//dotnet:target_framework"]
incoming_rid = settings["//dotnet:rid"]

supported_rids = apphost_pack_lookup_table.get(incoming_target_framework)
highest_compatible_rid = get_highest_compatible_runtime_identifier(incoming_rid, supported_rids.keys())
if supported_rids:
apphost_pack = supported_rids.get(incoming_rid)
apphost_pack = supported_rids.get(highest_compatible_rid)
if apphost_pack:
return {"//dotnet/private/sdk/apphost_packs:apphost_pack": apphost_pack}

Expand Down
12 changes: 12 additions & 0 deletions dotnet/private/sdk/apphost_packs/apphost_packs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,45 @@ def apphost_packs():

apphost_pack(name = "netcoreapp3.0_linux-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-x64.v3.0.3", target_framework = "netcoreapp3.0", runtime_identifier = "linux-x64")
apphost_pack(name = "netcoreapp3.0_linux-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-arm64.v3.0.3", target_framework = "netcoreapp3.0", runtime_identifier = "linux-arm64")
apphost_pack(name = "netcoreapp3.0_linux-musl-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-x64.v3.0.3", target_framework = "netcoreapp3.0", runtime_identifier = "linux-musl-x64")
apphost_pack(name = "netcoreapp3.0_linux-musl-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-arm64.v3.0.3", target_framework = "netcoreapp3.0", runtime_identifier = "linux-musl-arm64")
apphost_pack(name = "netcoreapp3.0_osx-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.osx-x64.v3.0.3", target_framework = "netcoreapp3.0", runtime_identifier = "osx-x64")
apphost_pack(name = "netcoreapp3.0_win-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-x64.v3.0.3", target_framework = "netcoreapp3.0", runtime_identifier = "win-x64")
apphost_pack(name = "netcoreapp3.0_win-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-arm64.v3.0.3", target_framework = "netcoreapp3.0", runtime_identifier = "win-arm64")
apphost_pack(name = "netcoreapp3.1_linux-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-x64.v3.1.32", target_framework = "netcoreapp3.1", runtime_identifier = "linux-x64")
apphost_pack(name = "netcoreapp3.1_linux-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-arm64.v3.1.32", target_framework = "netcoreapp3.1", runtime_identifier = "linux-arm64")
apphost_pack(name = "netcoreapp3.1_linux-musl-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-x64.v3.1.32", target_framework = "netcoreapp3.1", runtime_identifier = "linux-musl-x64")
apphost_pack(name = "netcoreapp3.1_linux-musl-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-arm64.v3.1.32", target_framework = "netcoreapp3.1", runtime_identifier = "linux-musl-arm64")
apphost_pack(name = "netcoreapp3.1_osx-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.osx-x64.v3.1.32", target_framework = "netcoreapp3.1", runtime_identifier = "osx-x64")
apphost_pack(name = "netcoreapp3.1_win-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-x64.v3.1.32", target_framework = "netcoreapp3.1", runtime_identifier = "win-x64")
apphost_pack(name = "netcoreapp3.1_win-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-arm64.v3.1.32", target_framework = "netcoreapp3.1", runtime_identifier = "win-arm64")
apphost_pack(name = "net5.0_linux-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-x64.v5.0.17", target_framework = "net5.0", runtime_identifier = "linux-x64")
apphost_pack(name = "net5.0_linux-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-arm64.v5.0.17", target_framework = "net5.0", runtime_identifier = "linux-arm64")
apphost_pack(name = "net5.0_linux-musl-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-x64.v5.0.17", target_framework = "net5.0", runtime_identifier = "linux-musl-x64")
apphost_pack(name = "net5.0_linux-musl-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-arm64.v5.0.17", target_framework = "net5.0", runtime_identifier = "linux-musl-arm64")
apphost_pack(name = "net5.0_osx-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.osx-x64.v5.0.17", target_framework = "net5.0", runtime_identifier = "osx-x64")
apphost_pack(name = "net5.0_win-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-x64.v5.0.17", target_framework = "net5.0", runtime_identifier = "win-x64")
apphost_pack(name = "net5.0_win-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-arm64.v5.0.17", target_framework = "net5.0", runtime_identifier = "win-arm64")
apphost_pack(name = "net6.0_linux-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-x64.v6.0.28", target_framework = "net6.0", runtime_identifier = "linux-x64")
apphost_pack(name = "net6.0_linux-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-arm64.v6.0.28", target_framework = "net6.0", runtime_identifier = "linux-arm64")
apphost_pack(name = "net6.0_linux-musl-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-x64.v6.0.28", target_framework = "net6.0", runtime_identifier = "linux-musl-x64")
apphost_pack(name = "net6.0_linux-musl-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-arm64.v6.0.28", target_framework = "net6.0", runtime_identifier = "linux-musl-arm64")
apphost_pack(name = "net6.0_osx-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.osx-x64.v6.0.28", target_framework = "net6.0", runtime_identifier = "osx-x64")
apphost_pack(name = "net6.0_osx-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.osx-arm64.v6.0.28", target_framework = "net6.0", runtime_identifier = "osx-arm64")
apphost_pack(name = "net6.0_win-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-x64.v6.0.28", target_framework = "net6.0", runtime_identifier = "win-x64")
apphost_pack(name = "net6.0_win-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-arm64.v6.0.28", target_framework = "net6.0", runtime_identifier = "win-arm64")
apphost_pack(name = "net7.0_linux-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-x64.v7.0.17", target_framework = "net7.0", runtime_identifier = "linux-x64")
apphost_pack(name = "net7.0_linux-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-arm64.v7.0.17", target_framework = "net7.0", runtime_identifier = "linux-arm64")
apphost_pack(name = "net7.0_linux-musl-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-x64.v7.0.17", target_framework = "net7.0", runtime_identifier = "linux-musl-x64")
apphost_pack(name = "net7.0_linux-musl-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-arm64.v7.0.17", target_framework = "net7.0", runtime_identifier = "linux-musl-arm64")
apphost_pack(name = "net7.0_osx-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.osx-x64.v7.0.17", target_framework = "net7.0", runtime_identifier = "osx-x64")
apphost_pack(name = "net7.0_osx-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.osx-arm64.v7.0.17", target_framework = "net7.0", runtime_identifier = "osx-arm64")
apphost_pack(name = "net7.0_win-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-x64.v7.0.17", target_framework = "net7.0", runtime_identifier = "win-x64")
apphost_pack(name = "net7.0_win-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-arm64.v7.0.17", target_framework = "net7.0", runtime_identifier = "win-arm64")
apphost_pack(name = "net8.0_linux-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-x64.v8.0.3", target_framework = "net8.0", runtime_identifier = "linux-x64")
apphost_pack(name = "net8.0_linux-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-arm64.v8.0.3", target_framework = "net8.0", runtime_identifier = "linux-arm64")
apphost_pack(name = "net8.0_linux-musl-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-x64.v8.0.3", target_framework = "net8.0", runtime_identifier = "linux-musl-x64")
apphost_pack(name = "net8.0_linux-musl-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.linux-musl-arm64.v8.0.3", target_framework = "net8.0", runtime_identifier = "linux-musl-arm64")
apphost_pack(name = "net8.0_osx-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.osx-x64.v8.0.3", target_framework = "net8.0", runtime_identifier = "osx-x64")
apphost_pack(name = "net8.0_osx-arm64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.osx-arm64.v8.0.3", target_framework = "net8.0", runtime_identifier = "osx-arm64")
apphost_pack(name = "net8.0_win-x64", pack = "@dotnet.apphost_packs//microsoft.netcore.app.host.win-x64.v8.0.3", target_framework = "net8.0", runtime_identifier = "win-x64")
Expand Down
Loading

0 comments on commit c42412a

Please sign in to comment.