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

Add ARM support for resolve-version #1321

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions lib/binaries.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# Compiled from: https://github.com/heroku/buildpacks-nodejs/blob/main/common/nodejs-utils/src/bin/resolve_version.rs
RESOLVE="$BP_DIR/lib/vendor/resolve-version-$(get_os)"
RESOLVE="$BP_DIR/lib/vendor/resolve-version-$(get_platform)"

resolve() {
local binary="$1"
Expand Down Expand Up @@ -90,7 +90,7 @@ install_nodejs() {

echo "Downloading and installing node $number..."

if [[ "$number" == "22.5.0" ]]; then
if [[ "$number" == "22.5.0" ]]; then
warn_about_node_version_22_5_0
fi
fi
Expand Down
18 changes: 13 additions & 5 deletions lib/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ get_os() {
}

get_cpu() {
if [[ "$(uname -p)" = "i686" ]]; then
echo "x86"
else
echo "x64"
fi
arch=$(uname -p)
case $arch in
aarch64 | arm*)
echo "arm"
;;
x86_64)
echo "x64"
;;
*)
echo "Error: Unknown architecture: ${arch}"
exit 1
;;
esac
}

get_platform() {
Expand Down
Binary file modified lib/vendor/resolve-version-darwin
Binary file not shown.
Binary file added lib/vendor/resolve-version-darwin-arm
Binary file not shown.
Binary file added lib/vendor/resolve-version-darwin-x64
Binary file not shown.
Binary file modified lib/vendor/resolve-version-linux
Binary file not shown.
Binary file added lib/vendor/resolve-version-linux-arm
Binary file not shown.
Binary file added lib/vendor/resolve-version-linux-x64
Binary file not shown.
Binary file added lib/vendor/yq-darwin-arm
Binary file not shown.
Binary file added lib/vendor/yq-linux-arm
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/yarn-2.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

YQ="$BP_DIR/lib/vendor/yq-$(get_os)"
YQ="$BP_DIR/lib/vendor/yq-$(get_platform)"

detect_yarn_2() {
local uses_yarn="$1"
Expand Down Expand Up @@ -54,7 +54,7 @@ use_yarn_app_cache() {
node_modules_enabled() {
local build_dir="$1"
local node_linker

node_linker=$($YQ r "$build_dir/.yarnrc.yml" nodeLinker 2>&1)

[[ "$node_linker" == "node-modules" ]]
Expand Down
12 changes: 11 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
build-resolvers: build-resolver-linux build-resolver-darwin
build-resolvers: build-resolver-linux build-resolver-darwin build-resolver-linux-arm build-resolver-darwin-arm

.build:
mkdir -p .build
build-resolver-darwin: .build
cargo install heroku-nodejs-utils --root .build --bin resolve_version --git https://github.com/heroku/buildpacks-nodejs --target x86_64-apple-darwin --profile release
mv .build/bin/resolve_version lib/vendor/resolve-version-darwin
cp lib/vendor/resolve-version-darwin lib/vendor/resolve-version-darwin-x64

build-resolver-darwin-arm: .build
cargo install heroku-nodejs-utils --root .build --bin resolve_version --git https://github.com/heroku/buildpacks-nodejs --target aarch64-apple-darwin --profile release
mv .build/bin/resolve_version lib/vendor/resolve-version-darwin-arm

build-resolver-linux: .build
cargo install heroku-nodejs-utils --root .build --bin resolve_version --git https://github.com/heroku/buildpacks-nodejs --target x86_64-unknown-linux-musl --profile release
mv .build/bin/resolve_version lib/vendor/resolve-version-linux
cp lib/vendor/resolve-version-linux lib/vendor/resolve-version-linux-x64

build-resolver-linux-arm: .build
cargo install heroku-nodejs-utils --root .build --bin resolve_version --git https://github.com/heroku/buildpacks-nodejs --target aarch64-unknown-linux-musl --profile release
mv .build/bin/resolve_version lib/vendor/resolve-version-linux-arm

test: heroku-22-build heroku-20-build heroku-24-build

Expand Down