Description:Insatll npm modules into target except npm
[scm/bb/meta-tizen.git] / meta-tizen-micro / classes / npm.bbclass
1 #DEPENDS += " node-native"
2
3 #RDEPENDS_${PN} += " node"
4
5 PACKAGE_DEBUG_SPLIT_STYLE = "debug-file-directory"
6
7 CCACHE = ""
8
9 NPM ?= "npm"
10 NPM_CACHE_DIR = "${WORKDIR}/npm_cache"
11 NPM_ARCH ?= "${TARGET_ARCH}"
12 NPM_LD ?= "${CXX}"
13 NPM_FLAGS ?= ""
14
15 # Target npm
16
17 oe_runnpm() {
18
19         export NPM_CONFIG_CACHE="${NPM_CACHE_DIR}"
20
21         [ -n "${http_proxy}" ] && export NPM_CONFIG_PROXY="${http_proxy}"
22         [ -n "${https_proxy}" ] && export NPM_CONFIG_HTTPS_PROXY="${https_proxy}"
23         [ -n "${HTTP_PROXY}" ] && export NPM_CONFIG_PROXY="${HTTP_PROXY}"
24         [ -n "${HTTPS_PROXY}" ] && export NPM_CONFIG_HTTPS_PROXY="${HTTPS_PROXY}"
25
26         bbnote NPM target architecture: ${NPM_ARCH}
27         bbnote NPM cache directory: ${NPM_CONFIG_CACHE}
28         bbnote NPM HTTP proxy: ${NPM_CONFIG_PROXY}
29         bbnote NPM HTTPS proxy: ${NPM_CONFIG_HTTPS_PROXY}
30
31         bbnote ${NPM} --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} ${NPM_FLAGS} "$@"
32
33         LD="${NPM_LD}" ${NPM} --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} ${NPM_FLAGS} "$@" || die "oe_runnpm failed"
34
35 }
36
37 # Native npm
38
39 NPM_NATIVE ?= "npm"
40 NPM_CACHE_DIR_NATIVE = "${WORKDIR}/npm_cache"
41 NPM_ARCH_NATIVE ?= "${BUILD_ARCH}"
42 NPM_LD_NATIVE ?= "${BUILD_CXX}"
43 NPM_FLAGS_NATIVE ?= ""
44
45 oe_runnpm_native() {
46
47         export NPM_CONFIG_CACHE="${NPM_CACHE_DIR_NATIVE}"
48
49         [ -n "${http_proxy}" ] && export NPM_CONFIG_PROXY="${http_proxy}"
50         [ -n "${https_proxy}" ] && export NPM_CONFIG_HTTPS_PROXY="${https_proxy}"
51         [ -n "${HTTP_PROXY}" ] && export NPM_CONFIG_PROXY="${HTTP_PROXY}"
52         [ -n "${HTTPS_PROXY}" ] && export NPM_CONFIG_HTTPS_PROXY="${HTTPS_PROXY}"
53
54         bbnote NPM native architecture: ${NPM_ARCH_NATIVE}
55         bbnote NPM cache directory: ${NPM_CONFIG_CACHE}
56         bbnote NPM HTTP proxy: ${NPM_CONFIG_PROXY}
57         bbnote NPM HTTPS proxy: ${NPM_CONFIG_HTTPS_PROXY}
58
59         bbnote ${NPM_NATIVE} --arch=${NPM_ARCH_NATIVE} --target_arch=${NPM_ARCH_NATIVE} ${NPM_FLAGS_NATIVE} "$@"
60
61         LD="${NPM_LD_NATIVE}" ${NPM_NATIVE} --arch=${NPM_ARCH_NATIVE} --target_arch=${NPM_ARCH_NATIVE} ${NPM_FLAGS_NATIVE} "$@" || die "oe_runnpm_native failed"
62
63 }