File: build.earth

package info (click to toggle)
mongo-c-driver 2.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 49,532 kB
  • sloc: ansic: 197,163; python: 7,890; cpp: 2,343; sh: 693; makefile: 77
file content (183 lines) | stat: -rw-r--r-- 6,569 bytes parent folder | download
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
VERSION --arg-scope-and-set --pass-args 0.7

init-env:
    ARG --required from
    FROM $from
    DO --pass-args +INIT

# An image just to bundle the scripts for this directory.
tools-dir:
    # ("scratch" is the special container image that contains nothing at all)
    FROM scratch
    COPY --chmod=755 . /
    SAVE ARTIFACT /*

INIT:
    COMMAND
    COPY +tools-dir/__alias /usr/local/bin/__alias
    COPY +tools-dir/__boolstr /usr/local/bin/__boolstr
    LET is_alpine = $(__boolstr test -f /etc/alpine-release)
    LET is_ubuntu = $(__boolstr grep -qF UBUNTU_CODENAME /etc/os-release)
    LET is_archlinux = $(__boolstr test -f /etc/arch-release)
    RUN __alias __is_alpine $is_alpine
    RUN __alias __is_ubuntu $is_ubuntu
    RUN __alias __is_archlinux $is_archlinux
    COPY +tools-dir/__install /usr/local/bin/__install
    COPY +tools-dir/__str /usr/local/bin/__str
    COPY +tools-dir/__fail /usr/local/bin/__fail

# ADD_C_OMPILER :
#   Add a C compiler to the environment. Requires a --c_compiler argument to be given.
ADD_C_COMPILER:
    COMMAND
    ARG --required c_compiler
    ARG gcc_pkg=gcc
    ARG clang_pkg=clang
    ARG cc_pkg
    IF test "$cc_pkg" != ""
        # Caller has provided a package name
    ELSE IF test "$c_compiler" = gcc
        LET cc_pkg = $gcc_pkg
    ELSE IF test "$c_compiler" = clang
        LET cc_pkg = $clang_pkg
    ELSE
        RUN __fail "Unable to infer package name for --c_compiler “$%s” (check spelling or pass a “--cc_pkg” argument)" "$c_compiler"
    END
    RUN __install $cc_pkg
    ENV CC=$c_compiler

# ADD_CXX_COMPILER :
#   Add a C++ compiler to the environment. Requires a --cxx_compiler argument to be provied.
ADD_CXX_COMPILER:
    COMMAND
    ARG --required cxx_compiler
    # Remap the names "gcc" and "clang" to their compiler names
    IF test "$cxx_compiler" = gcc
        LET cxx_compiler = g++
    ELSE IF test "$cxx_compiler" = clang
        LET cxx_compiler = clang++
    END
    ARG cxx_compiler_bin=$cxx_compiler
    ARG cxx_pkg
    IF test "$cxx_pkg" != ""
        # Nothing to infer
    ELSE IF __is_archlinux
        # Arch bundles the C and C++ compilers in the same package
        IF test "$cxx_compiler" = g++
            LET cxx_pkg = "gcc"
        ELSE IF test "$cxx_compiler" = clang++
            LET cxx_pkg = clang
        END
    ELSE IF __is_ubuntu
        IF test "$cxx_compiler" = g++
            LET cxx_pkg = "gcc"
        ELSE IF test "$cxx_compiler" = clang++
            LET cxx_pkg = "clang"
        END
        SET cxx_pkg = "$cxx_pkg build-essential"
    ELSE IF __is_alpine
        IF test "$cxx_compiler" = g++
            LET cxx_pkg = $cxx_compiler
        ELSE IF test "$cxx_compiler" = clang++
            # Alpine bundles clang and clang++ together.
            # Old Alpine 3.16 bundles libstdc++ in g++, so we need to pull GCC along anyway
            LET cxx_pkg = clang g++
        END
    ELSE IF test -f /etc/redhat-release
        IF test "$cxx_compiler" = g++
            LET cxx_pkg = "gcc-c++"
        ELSE IF test "$cxx_compiler" = clang++
            LET cxx_pkg = clang gcc-c++
        END
    END
    IF test "$cxx_pkg" = ""
        RUN __fail "Unable to infer package name for --cxx_compiler “%s” on this platform (check spelling or pass a “--cxx_pkg” argument)" "$cxx_compiler"
    END
    RUN __install $cxx_pkg
    ENV CXX=$cxx_compiler_bin

# ADD_SASL :
#   Add SASL libraries to the environment. Requires --sasl and --purpose arguments to be
#   provided. The package names will be inferred from the environment, but can be explicitly
#   provided by passing --cyrus_dev_pkg and --cyrus_rt_pkg arguments
ADD_SASL:
    COMMAND
    ARG --required sasl
    ARG --required purpose
    ARG cyrus_dev_pkg
    ARG cyrus_rt_pkg
    LET to_install=""
    IF __str test "$sasl" -ieq Cyrus
        # Detect package names
        IF test "$cyrus_dev_pkg$cyrus_rt_pkg" != ""
            # Nothing to infer
        ELSE IF __is_ubuntu
            LET cyrus_dev_pkg = libsasl2-dev
            LET cyrus_rt_pkg = libsasl2-2
        ELSE IF __is_alpine
            LET cyrus_dev_pkg = cyrus-sasl-dev
            LET cyrus_rt_pkg = cyrus-sasl
        ELSE
            RUN __fail "Cannot infer the Cyrus SASL library package names. Set --cyrus_dev_pkg and --cyrus_rt_pkg or update the ADD_SASL utility"
        END
        # Set install targets
        IF test "$purpose" = test
            SET to_install = $cyrus_rt_pkg
        ELSE IF test "$purpose" = build
            SET to_install = $cyrus_dev_pkg $cyrus_rt_pkg
        END
    ELSE IF __str test "$sasl" -ieq off
        # Do nothing
    ELSE
        RUN __fail "Unknown value for --sasl “%s” (Expect one of “Cyrus” or “off”)" "$sasl"
    END
    IF test "$to_install" != ""
        RUN __install $to_install
    END

# ADD_TLS :
#   Add TLS libraries to the environment. Requires --tls and --purpose arguments to be
#   given. The package names can be inferred from the environment or can be provided explicitly
#   with the --openssl_dev_pkg, --openssl_rt_pkg
#   command arguments.
ADD_TLS:
    COMMAND
    ARG --required tls
    ARG --required purpose
    ARG openssl_dev_pkg
    ARG openssl_rt_pkg
    LET to_install=""
    IF __str test "$tls" -ieq OpenSSL
        # Detect package names
        IF test "$openssl_dev_pkg$openssl_rt_pkg" != ""
            # Nothing to infer
        ELSE IF __is_alpine
            LET openssl_dev_pkg = openssl-dev
            LET openssl_rt_pkg = openssl
        ELSE IF __is_ubuntu
            LET openssl_dev_pkg = libssl-dev
            # APT will handle this as a regex to match a libssl runtime package:
            LET openssl_rt_pkg = libssl1.[0-9]
        ELSE IF __is_archlinux
            LET openssl_dev_pkg = openssl
            LET openssl_rt_pkg = openssl
        ELSE
            RUN __fail "Cannot infer the OpenSSL TLS library package names. Set --openssl_dev_pkg and --openssl_rt_pkg or update the ADD_TLS utility"
        END
        # Set install targets
        IF test "$purpose" = build
            SET to_install = $openssl_dev_pkg $openssl_rt_pkg
        ELSE IF test "$purpose" = test
            SET to_install = $openssl_rt_pkg
        ELSE
            RUN __fail "Unknown --purpose value “%s”" "$purpose"
        END
    ELSE IF __str test "$tls" -ieq "off"
        # Nothing to do
    ELSE
        RUN __fail "Unknown --tls value “%s” (Expect one of “OpenSSL” or “off”)" "$tls"
    END
    # Perform the install
    IF test "$to_install" != ""
        RUN __install $to_install
    END