Skip to content

Commit c9fcb3d

Browse files
committed
Allow to set config from npm architecture
1 parent 46a2067 commit c9fcb3d

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

scripts/adjustEnvVars.sh

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ case $PLATFORM in
2929
;;
3030
esac
3131

32-
while getopts ":b:c:M:" opt; do
32+
while getopts ":b:c:M:-:" opt; do
3333
case $opt in
3434
b)
3535
BITS="$OPTARG" # 32, 64
@@ -55,6 +55,39 @@ while getopts ":b:c:M:" opt; do
5555
esac
5656
done
5757

58+
# Get architecture from the `npm` environment variables to set the other ones
59+
if [[ -z "$BITS" && -z "$CPU" && -z "$MACHINE" && -z "$NODE_ARCH" ]]; then
60+
NODE_ARCH=$npm_config_arch
61+
fi
62+
63+
case $NODE_ARCH in
64+
"")
65+
;;
66+
67+
arm)
68+
CPU=cortex-a7
69+
;;
70+
71+
arm64)
72+
CPU=cortex-a53
73+
;;
74+
75+
ia32)
76+
BITS=32
77+
MACHINE=pc
78+
;;
79+
80+
x64)
81+
BITS=64
82+
MACHINE=pc
83+
;;
84+
85+
*)
86+
echo "Unknown architecture $NODE_ARCH"
87+
exit 1
88+
;;
89+
esac
90+
5891
# Default machine
5992
if [[ -z "$MACHINE" ]]; then
6093
MACHINE=pc

0 commit comments

Comments
 (0)