Skip to content

Commit

Permalink
Merge pull request #338 from udda1996/pass-arch-shell
Browse files Browse the repository at this point in the history
Add architecture identification logic for mac into shell level
  • Loading branch information
udda1996 authored Jan 10, 2024
2 parents 506678b + 297798b commit d246b00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions resources/bin/bal
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
then
$JAVA_COMMAND -jar $CURRENT_PATH/../lib/ballerina-command-@version@.jar build
else
if [ "$(uname)" == "Darwin" ]
then
# If it's macOS, set an environmental variable for architecture
export BALLERINA_MAC_ARCHITECTURE=$(uname -m)
fi
$JAVA_COMMAND -jar $CURRENT_PATH/../lib/ballerina-command-@version@.jar "$@"
EXIT_CODE=$?
fi
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/org/ballerinalang/command/util/OSUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,12 @@ private static boolean isSolaris() {
return OS.contains("sunos");
}

private static boolean isArmArchitecture() {
private static boolean isArmArchitecture() {
try {
Process process = Runtime.getRuntime().exec("uname -m");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String architecture = reader.readLine();
return architecture.contains("arm");
} catch (IOException e) {
String macArchitecture = System.getenv("BALLERINA_MAC_ARCHITECTURE");

return macArchitecture != null && macArchitecture.equals("arm64");
} catch (SecurityException e) {
return false;
}
}
Expand Down

0 comments on commit d246b00

Please sign in to comment.