Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building on arm Mac, Linux environments #1790

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
node_modules

bazel-*

Expand Down
3 changes: 0 additions & 3 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ nodejs_binary(
name = "pbjs",
data = PROTOBUF_DEPS,
entry_point = "@npm//:node_modules/protobufjs-cli/bin/pbjs",
install_source_map_support = False,
)

nodejs_binary(
name = "pbts",
data = PROTOBUF_DEPS,
entry_point = "@npm//:node_modules/protobufjs-cli/bin/pbts",
install_source_map_support = False,
)

nodejs_binary(
Expand All @@ -49,7 +47,6 @@ nodejs_binary(
"@npm//tslint",
],
entry_point = "@npm//:node_modules/tslint/bin/tslint",
install_source_map_support = False,
templated_args = ["--node_options=--preserve-symlinks"],
)

Expand Down
14 changes: 4 additions & 10 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ protobuf_deps()

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "d14076339deb08e5460c221fae5c5e9605d2ef4848eee1f0c81c9ffdc1ab31c1",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.6.1/rules_nodejs-1.6.1.tar.gz"],
sha256 = "e79c08a488cc5ac40981987d862c7320cee8741122a2649e9b08e850b6f20442",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.8.0/rules_nodejs-3.8.0.tar.gz"],
)

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")

node_repositories(
node_repositories = {
"16.16.0-darwin_amd64": ("node-v16.16.0-darwin-x64.tar.gz", "node-v16.16.0-darwin-x64", "982edd0fad364ad6e2d72161671544ab9399bd0ca8c726bde3cd07775c4c709a"),
"16.16.0-darwin_arm64": ("node-v16.16.0-darwin-arm64.tar.gz", "node-v16.16.0-darwin-arm64", "167721c2d72402e54adc0f8c87ca840796216c4d98946509d73221b771ad3e4c"),
"16.16.0-linux_amd64": ("node-v16.16.0-linux-x64.tar.xz", "node-v16.16.0-linux-x64", "edcb6e9bb049ae365611aa209fc03c4bfc7e0295dbcc5b2f1e710ac70384a8ec"),
"16.16.0-linux_arm64": ("node-v16.16.0-linux-arm64.tar.xz", "node-v16.16.0-linux-arm64", "6cb8f1353480646c1cd8ab9911995e5591e1a97811f43ea4ab3e946a57e7c80e"),
"16.16.0-windows_amd64": ("node-v16.16.0-win-x64.zip", "node-v16.16.0-win-x64", "c657acc98af55018c8fd6113c7e08d67c8083af75ba0306f9561b0117abc39d4"),
},
node_version = "16.16.0",
Expand All @@ -59,14 +61,6 @@ yarn_install(
yarn_lock = "//:yarn.lock",
)

load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")

install_bazel_dependencies()

load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")

ts_setup_workspace()

# Go/Gazelle requirements/dependencies.
http_archive(
name = "io_bazel_rules_go",
Expand Down
5 changes: 4 additions & 1 deletion cli/vm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@ nodejs_binary(
"@npm//source-map-support",
],
entry_point = ":compile.ts",
templated_args = ["--node_options=--require=source-map-support/register"],
templated_args = [
"--node_options=--require=source-map-support/register",
"--bazel_patch_module_resolver",
],
)
5 changes: 4 additions & 1 deletion common/errors/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ ts_test_suite(
data = [
"@npm//source-map-support",
],
templated_args = ["--node_options=--require=source-map-support/register"],
templated_args = [
"--node_options=--require=source-map-support/register",
"--bazel_patch_module_resolver",
],
deps = [
":errors",
"@df//testing",
Expand Down
5 changes: 4 additions & 1 deletion common/promises/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ ts_test_suite(
data = [
"@npm//source-map-support",
],
templated_args = ["--node_options=--require=source-map-support/register"],
templated_args = [
"--node_options=--require=source-map-support/register",
"--bazel_patch_module_resolver",
],
deps = [
":promises",
"@df//testing",
Expand Down
5 changes: 4 additions & 1 deletion common/strings/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ ts_test_suite(
data = [
"@npm//source-map-support",
],
templated_args = ["--node_options=--require=source-map-support/register"],
templated_args = [
"--node_options=--require=source-map-support/register",
"--bazel_patch_module_resolver",
],
deps = [
":strings",
"@df//testing",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"@bazel/hide-bazel-files": "1.0.0",
"@bazel/ibazel": "^0.9.1",
"@bazel/labs": "^0.42.3",
"@bazel/rollup": "^1.6.0",
"@bazel/typescript": "^1.1.0",
"@bazel/rollup": "^3.0.0",
"@bazel/typescript": "^3.0.0",
"@google-cloud/bigquery": "^5.6.0",
"@google-cloud/storage": "^5.8.2",
"@rollup/plugin-node-resolve": "^7.1.3",
Expand Down Expand Up @@ -37,7 +37,6 @@
"fs-extra": "^9.0.0",
"glob": "^10.3.3",
"google-sql-syntax-ts": "^1.0.3",
"grpc": "^1.24.0",
"js-beautify": "^1.10.2",
"js-yaml": "^4.1.0",
"jsdoc": "^3.6.11",
Expand All @@ -57,6 +56,7 @@
"rollup": "^2.7.3",
"rollup-plugin-dts": "^1.4.0",
"semver": "^7.5.2",
"source-map-support": "^0.5.21",
"tarjan-graph": "^2.0.0",
"tmp": "^0.2.0",
"ts-loader": "^5.3.1",
Expand Down
5 changes: 4 additions & 1 deletion packages/@dataform/cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ nodejs_binary(
"@npm//source-map-support",
],
entry_point = ":index.ts",
templated_args = ["--node_options=--require=source-map-support/register"],
templated_args = [
"--node_options=--require=source-map-support/register",
"--bazel_patch_module_resolver",
],
)

externals = [
Expand Down
5 changes: 4 additions & 1 deletion packages/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ ts_library(

nodejs_binary(
name = "gen-package-json-bin",
templated_args = ["--node_options=--require=source-map-support/register"],
templated_args = [
"--node_options=--require=source-map-support/register",
"--bazel_patch_module_resolver",
],
data = [
":gen-package-json",
"@npm//source-map-support",
Expand Down
2 changes: 1 addition & 1 deletion packages/index.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@npm_bazel_rollup//:index.bzl", "rollup_bundle")
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
load(":rollup_bundle_dts.bzl", "rollup_bundle_dts")
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")

Expand Down
4 changes: 2 additions & 2 deletions testing/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def ts_test(name, entry_point, args = [], templated_args = [], data = [], tags =
],
entry_point = entry_point,
args = args,
templated_args = ["--node_options=--async-stack-traces"] + templated_args,
templated_args = ["--node_options=--async-stack-traces", "--bazel_patch_module_resolver"] + templated_args,
tags = tags,
)

Expand All @@ -37,6 +37,6 @@ def ts_test_suite(name, srcs, args = [], templated_args = [], data = [], tags =
],
entry_point = ":" + src,
args = args,
templated_args = ["--node_options=--async-stack-traces"] + templated_args,
templated_args = ["--node_options=--async-stack-traces", "--bazel_patch_module_resolver"] + templated_args,
tags = tags,
)
22 changes: 18 additions & 4 deletions testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,26 @@ export * from "df/testing/suite";
export * from "df/testing/test";
export * from "df/testing/runner";

export const platformPath =
os.platform() === "darwin" ? "nodejs_darwin_amd64" : "nodejs_linux_amd64";

export const platformPath = () => {
if (os.platform() === "darwin") {
if (os.arch() === "arm64") {
return "nodejs_darwin_arm64";
} else {
return "nodejs_darwin_amd64";
}
} else {
if (os.arch() === 'arm64') {
return "nodejs_linux_arm64";
} else {
return "nodejs_linux_amd64";
}
}
}

// Note: it would be more correct for these to be injected by blaze at run time.
export const nodePath = `external/${platformPath}/bin/node`;
export const npmPath = `external/${platformPath}/bin/npm`;
export const nodePath = `external/${platformPath()}/bin/node`;
export const npmPath = `external/${platformPath()}/bin/npm`;
export const corePackageTarPath = "packages/@dataform/core/package.tar.gz";

export async function getProcessResult(childProcess: ChildProcess) {
Expand Down
5 changes: 4 additions & 1 deletion tools/gcloud/repository_rules.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
def _gcloud_sdk_impl(ctx):
os_build_name = "linux"
os_platform = 'x86_64'
if ctx.os.name.startswith("mac"):
os_build_name = "darwin"
if ctx.os.arch.startswith('aarch'):
os_platform = 'arm'
ctx.download_and_extract(
"https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-%s-%s-x86_64.tar.gz" % (ctx.attr.version, os_build_name),
"https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-%s-%s-%s.tar.gz" % (ctx.attr.version, os_build_name, os_platform),
stripPrefix = "google-cloud-sdk",
)
ctx.file("BUILD", 'exports_files(glob(["bin/*"]))')
Expand Down
5 changes: 4 additions & 1 deletion tools/gen-package-json/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")

nodejs_binary(
name = "bin",
templated_args = ["--node_options=--require=source-map-support/register"],
templated_args = [
"--node_options=--require=source-map-support/register",
"--bazel_patch_module_resolver",
],
data = [
":json-merge",
"@npm//source-map-support",
Expand Down
2 changes: 1 addition & 1 deletion tools/ts_library.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@npm_bazel_typescript//:index.bzl", native_ts_library = "ts_library")
load("@npm//@bazel/typescript:index.bzl", native_ts_library = "ts_library")

def ts_library(**kwargs):
native_ts_library(
Expand Down
12 changes: 10 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@
"dom"
],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
"esModuleInterop": true,
"plugins": [
{
"name": "@bazel/tsetse",
"disabledRules": [
"must-type-assert-json-parse"
]
}
]
},
"exclude": [
"bazel-*",
"node_modules"
]
}
}
Loading