프로젝트

일반

사용자정보

통계
| 개정판:

root / HServer / 00.Server / 00.Program / node_modules / dtrace-provider / build.sh

이력 | 보기 | 이력해설 | 다운로드 (2.28 KB)

1
#!/usr/bin/env bash
2

    
3
set -o pipefail
4

    
5
if [[ -n "$V" ]]; then
6
    set -o xtrace
7
fi
8

    
9
fail() {
10
    if [[ -z "$NODE_DTRACE_PROVIDER_REQUIRE" && -z "$V" ]]; then
11
        echo "-----------------------------------------------------------------"
12
        echo "Building dtrace-provider failed with exit code $1, falling back"
13
        echo "on stub implementation."
14
        echo ""
15
        echo "Re-run install with V set in your environment to see the build"
16
        echo "output, or NODE_DTRACE_PROVIDER_REQUIRE=hard to force an"
17
        echo "installation failure."
18
        echo "-----------------------------------------------------------------"
19
    fi
20

    
21
    if [[ "$NODE_DTRACE_PROVIDER_REQUIRE" == "hard" ]]; then
22
        exit 1
23
    else
24
        exit 0
25
    fi
26
}
27

    
28
buildUSDT() {
29
    if [[ -z "$NODE_DTRACE_PROVIDER_REQUIRE" && -z "$V" ]]; then
30
        exec 1> /dev/null
31
        exec 2> /dev/null
32
    fi
33

    
34
    # GYP's MAKEFLAGS confuses libusdt's Makefile
35
    unset MAKEFLAGS
36

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

    
51
    # Respect a MAKE variable if set
52
    if [[ -z $MAKE ]]; then
53
        # Default to `gmake` first if available, because we require GNU make
54
        # and `make` isn't GNU make on some plats.
55
        MAKE=`which gmake`
56
        if [[ -z $MAKE ]]; then
57
            MAKE=make
58
        fi
59
    fi
60

    
61
    # Build libusdt.
62
    $MAKE -C libusdt clean all
63
}
64

    
65
buildNDTP() {
66
    if [[ -z "$NODE_DTRACE_PROVIDER_REQUIRE" && -z "$V" ]]; then
67
        exec 1> /dev/null
68
        exec 2> /dev/null
69
    fi
70

    
71
    node-gyp rebuild -C src
72
}
73

    
74
(buildUSDT)
75
LIBUSDT_STATUS=$?
76
if [[ "$LIBUSDT_STATUS" -ne 0 ]]; then
77
    fail $LIBUSDT_STATUS
78
fi
79

    
80
(buildNDTP)
81
NODE_GYP_STATUS=$?
82
if [[ "$NODE_GYP_STATUS" -ne 0 ]]; then
83
    fail $NODE_GYP_STATUS
84
fi
85

    
86
exit 0