-
Notifications
You must be signed in to change notification settings - Fork 88
/
npm-base.bbclass
121 lines (84 loc) · 3.29 KB
/
npm-base.bbclass
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
DEPENDS += " node-native"
inherit nodejs-arch
PACKAGE_DEBUG_SPLIT_STYLE = "debug-file-directory"
CCACHE = ""
NPM_REGISTRY ?= "https://registry.npmjs.org/"
NPM_IGNORE = "${WORKDIR}/.npmignore"
NPM ?= "npm"
NPM_CACHE_DIR = "${TMPDIR}/npm_cache/${PF}"
NPM_HOME_DIR = "${TMPDIR}/npm_home/${PF}"
NPM_ARCH ?= "${@nodejs_map_dest_cpu(d.getVar('TARGET_ARCH', True), d)}"
NPM_LD ?= "${CXX}"
NPM_FLAGS ?= ""
NPM_FLAGS_append_class-nativesdk = " --unsafe-perm"
# Target npm
oe_runnpm() {
if [ "${NPM_ARCH}" != "allarch" ]; then
ARCH_FLAGS="--arch=${NPM_ARCH} --target_arch=${NPM_ARCH}"
else
ARCH_FLAGS=""
fi
echo "/temp/" >> "${NPM_IGNORE}"
echo "/pseudo/" >> "${NPM_IGNORE}"
echo "/sstate*/" >> "${NPM_IGNORE}"
echo "/license-destdir/" >> "${NPM_IGNORE}"
echo "/image/" >> "${NPM_IGNORE}"
echo "/patches/" >> "${NPM_IGNORE}"
echo ".npmignore" >> "${NPM_IGNORE}"
echo "/.*/" >> "${NPM_IGNORE}"
mkdir -p "${NPM_HOME_DIR}"
export NPM_CONFIG_CACHE="${NPM_CACHE_DIR}"
export NPM_CONFIG_DEV="false"
bbnote NPM target architecture: ${NPM_ARCH}
bbnote NPM home directory: ${NPM_HOME_DIR}
bbnote NPM cache directory: ${NPM_CONFIG_CACHE}
bbnote NPM registry: ${NPM_REGISTRY}
bbnote NPM workdir .npmignore: ${NPM_IGNORE}
bbnote ${NPM} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS} "$@"
export JOBS=${@oe.utils.cpu_count()}
export http_proxy="${http_proxy}"
export https_proxy="${https_proxy}"
export no_proxy="${no_proxy}"
export HOME="${NPM_HOME_DIR}"
${NPM} cache clean || die "oe_runnpm failed (cache clean)"
LD="${NPM_LD}" ${NPM} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS} "$@" || die "oe_runnpm failed (install)"
}
# Native npm
NPM_NATIVE ?= "npm"
NPM_CACHE_DIR_NATIVE = "${TMPDIR}/npm_cache_native/${PF}"
NPM_HOME_DIR_NATIVE = "${TMPDIR}/npm_home_native/${PF}"
NPM_ARCH_NATIVE ?= "${@nodejs_map_dest_cpu(d.getVar('BUILD_ARCH', True), d)}"
NPM_LD_NATIVE ?= "${BUILD_CXX}"
NPM_FLAGS_NATIVE ?= ""
NPM_FLAGS_NATIVE_append_class-nativesdk = " --unsafe-perm"
oe_runnpm_native() {
if [ "${NPM_ARCH_NATIVE}" != "allarch" ]; then
ARCH_FLAGS="--arch=${NPM_ARCH_NATIVE} --target_arch=${NPM_ARCH_NATIVE}"
else
ARCH_FLAGS=""
fi
echo "/temp/" >> "${NPM_IGNORE}"
echo "/pseudo/" >> "${NPM_IGNORE}"
echo "/sstate*/" >> "${NPM_IGNORE}"
echo "/license-destdir/" >> "${NPM_IGNORE}"
echo "/image/" >> "${NPM_IGNORE}"
echo "/patches/" >> "${NPM_IGNORE}"
echo ".npmignore" >> "${NPM_IGNORE}"
echo "/.*/" >> "${NPM_IGNORE}"
mkdir -p "${NPM_HOME_DIR_NATIVE}"
export NPM_CONFIG_CACHE="${NPM_CACHE_DIR_NATIVE}"
export NPM_CONFIG_DEV="false"
bbnote NPM native architecture: ${NPM_ARCH_NATIVE}
bbnote NPM home directory: ${NPM_HOME_DIR_NATIVE}
bbnote NPM cache directory: ${NPM_CONFIG_CACHE}
bbnote NPM registry: ${NPM_REGISTRY}
bbnote NPM workdir .npmignore: ${NPM_IGNORE}
bbnote ${NPM_NATIVE} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS_NATIVE} "$@"
export JOBS=${@oe.utils.cpu_count()}
export http_proxy="${http_proxy}"
export https_proxy="${https_proxy}"
export no_proxy="${no_proxy}"
export HOME="${NPM_HOME_DIR_NATIVE}"
${NPM} cache clean || die "oe_runnpm_native failed (cache clean)"
LD="${NPM_LD_NATIVE}" ${NPM_NATIVE} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS_NATIVE} "$@" || die "oe_runnpm_native failed (install)"
}