File: build.sh

package info (click to toggle)
node-dtrace-provider 0.8.8-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 336 kB
  • sloc: cpp: 391; sh: 51; makefile: 2
file content (80 lines) | stat: -rw-r--r-- 2,257 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash

fail() {
    if [ -z "$NODE_DTRACE_PROVIDER_REQUIRE" -a -z "$V" ]; then
        echo "-----------------------------------------------------------------"
        echo "Building dtrace-provider failed with exit code $1, falling back"
        echo "on stub implementation."
        echo ""
        echo "Re-run install with V set in your environment to see the build"
        echo "output, or NODE_DTRACE_PROVIDER_REQUIRE=hard to force an"
        echo "installation failure."
        echo "-----------------------------------------------------------------"
    fi

    if test "$NODE_DTRACE_PROVIDER_REQUIRE" = "hard"; then
        exit 1
    else
        exit 0
    fi
}

buildUSDT() {
    if [ -z "$NODE_DTRACE_PROVIDER_REQUIRE" -a -z "$V" ]; then
        exec 1> /dev/null
        exec 2> /dev/null
    fi

    # GYP's MAKEFLAGS confuses libusdt's Makefile
    unset MAKEFLAGS

    # Ask node what architecture it's been built for ("target_arch" in
    # config.gypi), and build libusdt to match.
    #
    # We use node from the path; npm will have adjusted PATH for us if
    # necessary, otherwise we assume the user did so when building by
    # hand.
    #
    # (This will need to change at the point that GYP is able to build
    # node extensions universal on the Mac - for now we'll go with x86_64
    # on a 64 bit Mac, because that's the default architecture in that
    # situation.)
    export ARCH=`node -e "console.log(process.arch === 'x64' ? 'x86_64' : 'i386')"`
    echo "Building libusdt for ${ARCH}"

    # Respect a MAKE variable if set
    if [ -z $MAKE ]; then
        # Default to `gmake` first if available, because we require GNU make
        # and `make` isn't GNU make on some plats.
        MAKE=`which gmake`
        if [ -z $MAKE ]; then
            MAKE=make
        fi
    fi

    # Build libusdt.
    $MAKE -C libusdt clean all
}

buildNDTP() {
    if [ -z "$NODE_DTRACE_PROVIDER_REQUIRE" -a -z "$V" ]; then
        exec 1> /dev/null
        exec 2> /dev/null
    fi

    node-gyp rebuild -C src
}

(buildUSDT)
LIBUSDT_STATUS=$?
if [ "$LIBUSDT_STATUS" -ne 0 ]; then
    fail $LIBUSDT_STATUS
fi

(buildNDTP)
NODE_GYP_STATUS=$?
if [ "$NODE_GYP_STATUS" -ne 0 ]; then
    fail $NODE_GYP_STATUS
fi

exit 0