Skip to content

Commit

Permalink
feat(builtin): added support of linux ppc64le
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishidha Panpaliya authored and alexeagle committed Aug 19, 2021
1 parent 4e91a60 commit 582ecc1
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Toolchains allow us to support cross-compilation, e.g. building a linux binary f
- `@build_bazel_rules_nodejs//toolchains/node:linux_amd64`
- `@build_bazel_rules_nodejs//toolchains/node:linux_arm64`
- `@build_bazel_rules_nodejs//toolchains/node:linux_s390x`
- `@build_bazel_rules_nodejs//toolchains/node:linux_ppc64le`
- `@build_bazel_rules_nodejs//toolchains/node:darwin_amd64`
- `@build_bazel_rules_nodejs//toolchains/node:windows_amd64`

Expand Down
5 changes: 4 additions & 1 deletion internal/common/os_name.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ OS_ARCH_NAMES = [
("linux", "amd64"),
("linux", "arm64"),
("linux", "s390x"),
("linux", "ppc64le"),
]

OS_NAMES = ["_".join(os_arch_name) for os_arch_name in OS_ARCH_NAMES]
Expand Down Expand Up @@ -55,6 +56,8 @@ def os_name(rctx):
return OS_NAMES[4]
elif arch == "s390x":
return OS_NAMES[5]
elif arch == "ppc64le":
return OS_NAMES[6]

fail("Unsupported operating system {} architecture {}".format(os_name, arch))

Expand All @@ -67,7 +70,7 @@ def is_darwin_os(rctx):

def is_linux_os(rctx):
name = os_name(rctx)
return name == OS_NAMES[3] or name == OS_NAMES[4] or name == OS_NAMES[5]
return name == OS_NAMES[3] or name == OS_NAMES[4] or name == OS_NAMES[5] or name == OS_NAMES[6]

def node_exists_for_os(node_version, os_name):
"Whether a node binary is available for this platform"
Expand Down
1 change: 1 addition & 0 deletions internal/node/launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ else
case "${unameArch}" in
aarch64*) readonly node_toolchain="nodejs_linux_arm64/bin/nodejs/bin/node" ;;
s390x*) readonly node_toolchain="nodejs_linux_s390x/bin/nodejs/bin/node" ;;
ppc64le*) readonly node_toolchain="nodejs_linux_ppc64le/bin/nodejs/bin/node" ;;
*) readonly node_toolchain="nodejs_linux_amd64/bin/nodejs/bin/node" ;;
esac
;;
Expand Down
1 change: 1 addition & 0 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ BUILT_IN_NODE_PLATFORMS = [
"linux_arm64",
"windows_amd64",
"linux_s390x",
"linux_ppc64le",
]

NODE_EXTRACT_DIR = "bin/nodejs"
Expand Down
242 changes: 242 additions & 0 deletions internal/node/node_versions.bzl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/node/test/nodejs_toolchain_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fi

_ATTRS = {
"platform": attr.string(
values = ["linux_amd64", "linux_arm64", "linux_s390x", "darwin_amd64", "darwin_arm64", "windows_amd64"],
values = ["linux_amd64", "linux_arm64", "linux_s390x", "linux_ppc64le", "darwin_amd64", "darwin_arm64", "windows_amd64"],
),
}

Expand Down
17 changes: 17 additions & 0 deletions packages/concatjs/devserver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ filegroup(
visibility = ["//visibility:public"],
)

filegroup(
name = "devserver_linux_ppc64le",
srcs = ["devserver-linux_ppc64le"],
# Don't build on CI
tags = ["manual"],
visibility = ["//visibility:public"],
)

config_setting(
name = "darwin_x64",
constraint_values = [
Expand Down Expand Up @@ -111,6 +119,14 @@ config_setting(
],
)

config_setting(
name = "linux_ppc64le",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:ppc",
],
)

filegroup(
name = "devserver",
srcs = select({
Expand All @@ -119,6 +135,7 @@ filegroup(
":linux_s390x": [":devserver_linux_s390x"],
":linux_x64": [":devserver_linux_amd64"],
":windows_x64": [":devserver_windows_amd64"],
":linux_ppc64le": [":devserver_linux_ppc64le"],
}),
# Don't build on CI
tags = ["manual"],
Expand Down
1 change: 1 addition & 0 deletions scripts/update-nodejs-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const REPOSITORY_TYPES = {
"linux-arm64.tar.xz": "linux_arm64",
"linux-s390x.tar.xz": "linux_s390x",
"win-x64.zip": "windows_amd64",
"linux-ppc64le.tar.xz": "linux_ppc64le",
};

function getText(url) {
Expand Down
20 changes: 20 additions & 0 deletions toolchains/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ platform(
],
)

platform(
name = "linux_ppc64le",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:ppc",
],
)

bzl_library(
name = "bzl",
srcs = glob(["*.bzl"]),
Expand Down Expand Up @@ -94,6 +102,7 @@ alias(
"@bazel_tools//src/conditions:linux_s390x": "@nodejs_linux_s390x_config//:toolchain",
"@bazel_tools//src/conditions:linux_x86_64": "@nodejs_linux_amd64_config//:toolchain",
"@bazel_tools//src/conditions:windows": "@nodejs_windows_amd64_config//:toolchain",
"@bazel_tools//src/conditions:linux_ppc64le": "@nodejs_linux_ppc64le_config//:toolchain",
"//conditions:default": "@nodejs_linux_amd64_config//:toolchain",
}),
visibility = ["//visibility:public"],
Expand All @@ -108,6 +117,7 @@ alias(
"@bazel_tools//src/conditions:linux_aarch64": "@nodejs_linux_arm64//:node_bin",
"@bazel_tools//src/conditions:linux_s390x": "@nodejs_linux_s390x//:node_bin",
"@bazel_tools//src/conditions:linux_x86_64": "@nodejs_linux_amd64//:node_bin",
"@bazel_tools//src/conditions:linux_ppc64le": "@nodejs_linux_ppc64le//:node_bin",
"@bazel_tools//src/conditions:windows": "@nodejs_windows_amd64//:node_bin",
"//conditions:default": "@nodejs_linux_amd64//:node_bin",
}),
Expand Down Expand Up @@ -173,3 +183,13 @@ toolchain(
toolchain = "@nodejs_linux_s390x_config//:toolchain",
toolchain_type = ":toolchain_type",
)

toolchain(
name = "node_linux_ppc64le_toolchain",
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:ppc",
],
toolchain = "@nodejs_linux_ppc64le_config//:toolchain",
toolchain_type = ":toolchain_type",
)

0 comments on commit 582ecc1

Please sign in to comment.