Skip to content

Commit e4e59dd

Browse files
committed
Merge branch 'raspi2'
2 parents 129042c + d3a036c commit e4e59dd

7 files changed

Lines changed: 100 additions & 81 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
},
2626
"homepage": "https://github.com/NodeOS/nodejs#readme",
2727
"dependencies": {
28-
"nodeos-cross-toolchain": "^1.0.0-RC2.11",
28+
"nodeos-cross-toolchain": "^1.0.0-RC3",
2929
"prebuild-install": "1.0.2"
3030
},
3131
"devDependencies": {
32-
"buho": "0.1.0",
32+
"buho": "^0.1.0",
3333
"ci-publish": "^1.3.0",
3434
"minimist": "^1.2.0",
35-
"prebuild": "^4.3.0",
35+
"prebuild": "^4.5.0",
3636
"qemu": "^2.6.0",
3737
"suppose": "^0.6.1"
3838
}

scripts/BigRedButton

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bash
22

33

4-
npm run build && npm test || exit 1
5-
#PLATFORM=pc_qemu_32 npm run build && npm test || exit 1
6-
#PLATFORM=pc_qemu_64 npm run build && npm test || exit 2
4+
npm run build -M pc -b 32 && npm test || exit 1
5+
npm run build -M pc -b 64 && npm test || exit 2
6+
npm run build -M raspi2 && npm test || exit 3
77

88

99
#

scripts/build

Lines changed: 32 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,26 @@ source $TOOLCHAIN/scripts/adjustEnvVars.sh || exit $?
1616
PATH=$TOOLCHAIN/bin:$PATH
1717

1818

19-
if [[ -z $JOBS ]]; then
20-
JOBS=$((`getconf _NPROCESSORS_ONLN` + 1))
21-
fi
22-
23-
if [[ -z $MACHINE ]]; then
24-
MACHINE=`uname -m`
25-
fi
26-
case $MACHINE in
27-
i[345678]86)
28-
ARCH=ia32
29-
# CC="cc -m32"
30-
# CXX="cpp -m32"
31-
;;
32-
33-
x86_64)
34-
ARCH=x64
35-
# CC="cc -m64"
36-
# CXX="cpp -m64"
37-
;;
38-
39-
*)
40-
echo Unknown MACHINE "$MACHINE"
41-
exit 1
42-
;;
43-
esac
19+
# Build cross-compiler (if needed)
20+
(
21+
cd $TOOLCHAIN
22+
BITS=$BITS CPU=$CPU MACHINE=$MACHINE npm install --production || exit $?
23+
) || exit $?
4424

4525

4626
if [[ -z $OS ]]; then
4727
OS="`uname`"
4828
fi
29+
4930
case $OS in
50-
'AIX') PLATFORM=aix ;;
51-
# 'Android') PLATFORM=android ;;
52-
'Darwin') PLATFORM=mac ;;
53-
'FreeBSD') PLATFORM=freebsd ;;
54-
'Linux') PLATFORM=linux ;;
55-
# 'OpenBSD') PLATFORM=Openbsd ;;
56-
'SunOS') PLATFORM=solaris ;;
57-
'WindowsNT') PLATFORM=win ;;
31+
'AIX') NODE_PLATFORM=aix ;;
32+
# 'Android') NODE_PLATFORM=android ;;
33+
'Darwin') NODE_PLATFORM=mac ;;
34+
'FreeBSD') NODE_PLATFORM=freebsd ;;
35+
'Linux') NODE_PLATFORM=linux ;;
36+
# 'OpenBSD') NODE_PLATFORM=Openbsd ;;
37+
'SunOS') NODE_PLATFORM=solaris ;;
38+
'WindowsNT') NODE_PLATFORM=win ;;
5839

5940
*)
6041
echo Unknown OS "$OS"
@@ -63,18 +44,6 @@ case $OS in
6344
esac
6445

6546

66-
function rmStep(){
67-
rm -rf "$@"
68-
rmdir -p --ignore-fail-on-non-empty `dirname "$@"`
69-
}
70-
71-
# Clean object dir and return the input error
72-
function err(){
73-
rmStep $STEP_DIR
74-
exit $1
75-
}
76-
77-
7847
#
7948
# Define steps paths
8049
#
@@ -84,7 +53,7 @@ SRC_DIR=`pwd`/deps/node
8453
OBJ_DIR=build/$MACHINE
8554
OUT_DIR=`pwd`
8655
PRODUCTS=(bin include share)
87-
PREBUILD=prebuilds/$PLATFORM-$ARCH.tar.gz
56+
PREBUILD=prebuilds/$NODE_PLATFORM-$NODE_ARCH.tar.gz
8857

8958

9059
#
@@ -97,8 +66,9 @@ if [[ ! -f $STEP_DIR ]]; then
9766
rmStep $SRC_DIR
9867

9968
(
100-
mkdir -p `dirname $STEP_DIR` &&
101-
cd `dirname $STEP_DIR` || exit 3
69+
DIR=`dirname $STEP_DIR`
70+
71+
mkdir -p $DIR && cd $DIR || exit 3
10272

10373
wget $NODEJS_URL || exit 4
10474

@@ -138,25 +108,25 @@ if [[ ! -f $STEP_DIR ]]; then
138108
cd $SRC_DIR && $MAKE clean # Node.js don't support out-of-tree builds yet
139109

140110
# Configure
141-
# CROSS_COMPILE="$TARGET-" \
142-
CC=$TARGET-gcc \
143-
CXX=$TARGET-g++ \
144-
$SRC_DIR/configure \
145-
--prefix=$OUT_DIR \
146-
--dest-cpu=$ARCH \
147-
--dest-os=$PLATFORM \
148-
--without-dtrace \
149-
--without-intl \
150-
--without-npm \
151-
--without-snapshot || exit 8
111+
# CROSS_COMPILE="$TARGET-" \
112+
CC=$TARGET-gcc \
113+
CXX=$TARGET-g++ \
114+
$SRC_DIR/configure \
115+
--prefix=$OUT_DIR \
116+
--dest-cpu=$NODE_ARCH \
117+
--dest-os=$NODE_PLATFORM \
118+
--without-dtrace \
119+
--without-intl \
120+
--without-npm \
121+
--without-snapshot || exit 8
152122

153123
make -j$JOBS &&
154124
make install || exit 9
155125
) || err $?
156126

157-
mv bin/node bin/$CPU &&
158-
ln -s $CPU bin/node &&
159-
strip bin/node || exit 10
127+
mv bin/node bin/$CPU &&
128+
ln -s $CPU bin/node &&
129+
$TARGET-strip bin/node || exit 10
160130
fi
161131

162132

scripts/install

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,39 @@
22

33
URL=https://github.com/NodeOS/nodejs/releases/download/v{version}/{platform}-{arch}.tar.gz
44

5-
prebuild-install $@ -d $URL || npm run build -- $@
5+
6+
while getopts ":-:" opt; do
7+
case $opt in
8+
-)
9+
case "${OPTARG}" in
10+
arch=*)
11+
NODE_ARCH=${OPTARG#*=}
12+
;;
13+
esac
14+
::
15+
esac
16+
done
17+
18+
19+
case $NODE_ARCH in
20+
arm)
21+
CPU=cortex-a7
22+
;;
23+
24+
arm64)
25+
CPU=cortex-a53
26+
;;
27+
28+
ia32)
29+
BITS=32
30+
MACHINE=pc
31+
;;
32+
33+
x64)
34+
BITS=64
35+
MACHINE=pc
36+
;;
37+
esac
38+
39+
40+
prebuild-install $@ -d $URL || BITS=$BITS CPU=$CPU MACHINE=$MACHINE npm run build

scripts/processArguments.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,20 @@ function processArguments(argv)
2020

2121
switch(cpu)
2222
{
23-
case 'armv6j':
23+
case 'arm1176jzf-s':
24+
cpu_family = 'arm'
25+
libc = 'musleabihf'
26+
// machine = 'vexpress-a15'
27+
machine = 'versatilepb'
28+
break
29+
30+
case 'cortex-a7':
31+
cpu_family = 'arm'
32+
libc = 'musleabihf'
33+
machine = 'raspi2'
34+
break
35+
36+
case 'cortex-a53':
2437
cpu_family = 'arm'
2538
libc = 'musleabihf'
2639
// machine = 'vexpress-a15'

scripts/start

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var spawn = require('child_process').spawn
55
var processArguments = require('./processArguments')
66

77

8-
//const QEMU = require('qemu')+'/bin/qemu-'
8+
const QEMU = require('qemu')+'/bin/qemu-'
99

1010

1111
var args = processArguments(process.argv.slice(2))
@@ -14,15 +14,16 @@ var cpu = args.cpu
1414

1515

1616
// [Hack] Can't be able to use x86_64 as generic x86 64 bits CPU
17-
var toolchainCpu = (cpu === 'nocona') ? 'x86_64' : cpu
17+
var toolchainCpu = (cpu === 'nocona') ? 'x86_64' : args.cpu_family ? 'armv7' : cpu
1818

1919
const LD_LIBRARY_PATH = require('nodeos-cross-toolchain')+'/'+toolchainCpu+'-nodeos-linux-'+args.libc+'/lib'
2020

2121
process.env.LD_LIBRARY_PATH = LD_LIBRARY_PATH
22-
//var command = QEMU+args.cpu_family
22+
var command = QEMU+args.cpu_family
23+
var argv = [LD_LIBRARY_PATH+'/libc.so', 'bin/node']
2324
//var argv = [LD_LIBRARY_PATH+'/libc.so', 'bin/node', '--interactive']
24-
var command = LD_LIBRARY_PATH+'/libc.so'
25-
var argv = ['bin/node']
25+
//var command = LD_LIBRARY_PATH+'/libc.so'
26+
//var argv = ['bin/node']
2627

2728
if(args.argv)
2829
argv = argv.concat(args.argv)

scripts/test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var suppose = require('suppose')
55
var processArguments = require('./processArguments')
66

77

8-
//const QEMU = require('qemu')+'/bin/qemu-'
8+
const QEMU = require('qemu')+'/bin/qemu-'
99
const TIMEOUT = 15
1010

1111

@@ -24,15 +24,15 @@ var timeout = setTimeout(function()
2424

2525

2626
// [Hack] Can't be able to use x86_64 as generic x86 64 bits CPU
27-
var toolchainCpu = (cpu === 'nocona') ? 'x86_64' : cpu
27+
var toolchainCpu = (cpu === 'nocona') ? 'x86_64' : args.cpu_family ? 'armv7' : cpu
2828

2929
const LD_LIBRARY_PATH = require('nodeos-cross-toolchain')+'/'+toolchainCpu+'-nodeos-linux-'+args.libc+'/lib'
3030

3131
process.env.LD_LIBRARY_PATH = LD_LIBRARY_PATH
32-
//var command = QEMU+args.cpu_family
33-
//var argv = [LD_LIBRARY_PATH+'/libc.so', 'bin/node', '--interactive']
34-
var command = LD_LIBRARY_PATH+'/libc.so'
35-
var argv = ['bin/node', '--interactive']
32+
var command = QEMU+args.cpu_family
33+
var argv = [LD_LIBRARY_PATH+'/libc.so', 'bin/node', '--interactive']
34+
//var command = LD_LIBRARY_PATH+'/libc.so'
35+
//var argv = ['bin/node', '--interactive']
3636
//var argv = ['-cpu', 'arm1176', LD_LIBRARY_PATH+'/libc.so', 'obj/'+cpu+'/node', '--interactive']
3737

3838
exe = suppose(command, argv)

0 commit comments

Comments
 (0)