summaryrefslogtreecommitdiff
path: root/packages/dev-lang/node/node.exlib
blob: 24db75d7f19554271359f81e3ae38506be45c971 (plain)
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
# Copyright 2011 Michael Thomas <aelmalinka@gmail.com>
# Copyright 2017 Arnaud Lefebvre <a.lefebvre@outlook.fr>
# Distributed under the terms of the GNU General Public License v2

MY_PV="v${PV}"
MY_PNV="${PN}-${MY_PV}"
WORK="${WORKBASE}/${MY_PNV}"

export_exlib_phases src_configure src_install src_test

DESCRIPTION="
Designed to provide an easy way to build scalable network applications, similar to Event Machine or
Twisted.
"
HOMEPAGE="https://nodejs.org"
DOWNLOADS="${HOMEPAGE}/dist/${MY_PV}/${MY_PNV}.tar.xz"

LICENCES="MIT"
SLOT="0"
MYOPTIONS="
    gdb [[ description = [ Enable GDB JIT interface for v8 ] ]]
    bundled-openssl [[
        description = [ Build node against the bundled OpenSSL instead of the system installed one ]
    ]]
"
# TODO(japaric) re-add libressl provider when libressl catches up with the new API in openssl 1.0.2
# OR when node officially supports libressl cf. https://github.com/nodejs/node/issues/428
# context: libressl is on API parity with openssl 1.0.1, but node uses the new API available in
# openssl 1.0.2 cf. https://github.com/nodejs/node/issues/2783
#   ( providers: libressl openssl  ) [[ number-selected = exactly-one  ]]

RESTRICT="test"

# See TODO above
#        providers:libressl? ( dev-libs/libressl )
#        providers:openssl? ( dev-libs/openssl  )
DEPENDENCIES="
    build+run:
        app-arch/brotli[>=1.0.9]
        dev-libs/icu:=[>=67.1]
        dev-libs/libuv[>=1.39.0]
        net-dns/c-ares[>=1.16.0]
        net-libs/nghttp2[>=1.41.0]
        sys-libs/zlib[>=1.2.11]
        !bundled-openssl? ( dev-libs/openssl[>=1.1.1g] )
"

if ever at_least 14.0.0; then
    DEPENDENCIES+="
        build:
            dev-lang/python:*
    "
else
    DEPENDENCIES+="
        build:
            dev-lang/python:2.7
        build+run:
            net-libs/http-parser[>=2.9.3]
    "
fi

DEFAULT_SRC_COMPILE_PARAMS=( V=1 LD="${CXX}" )

PATH="${TMPDIR}:${PATH}"

node_src_configure() {
    local myconf=(
        --prefix=/usr/$(exhost --target)
        --openssl-use-def-ca-store
        --shared-brotli
        --shared-cares
        --shared-libuv
        --shared-nghttp2
        --shared-zlib
        --with-intl=system-icu
        $(option gdb && echo --gdb)
        $(option !bundled-openssl && echo --shared-openssl)
    )

    if ! ever at_least 13.9.0; then
        myconf+=( --shared-http-parser )
    fi

    edo ./configure "${myconf[@]}"
}

node_src_install() {
    default

    # man files for node
    doman "${IMAGE}"/usr/$(exhost --target)/share/man/man1/*
    # man files for npm cli
    doman "${IMAGE}"/usr/$(exhost --target)/lib/node_modules/npm/man/man{1,5,7}/*.[157]

    edo mkdir -p "${IMAGE}"/usr/share/doc/"${PNVR}"/
    edo mv "${IMAGE}"/usr/$(exhost --target)/share/doc/${PN}/* "${IMAGE}"/usr/share/doc/"${PNVR}"/
    edo mv "${IMAGE}"/usr/{$(exhost --target)/,}share/systemtap
    edo rm -r "${IMAGE}"/usr/$(exhost --target)/{share/{doc/{${PN}/,},},lib/node_modules/npm/man}
}

node_src_test() {
    # rebuild certificates
    emake -j1 -C test/fixtures/keys clean
    emake -j1 -C test/fixtures/keys

    esandbox allow_net "inet:0.0.0.0@0"
    esandbox allow_net "inet:0.0.0.0@12346"
    esandbox allow_net "unix:${WORK}/test/tmp/test.sock"

    emake test
}