summaryrefslogtreecommitdiffstats
path: root/exlibs/mozilla-app.exlib
blob: cee6ff100e95e849c3a31a42a29b1ce8fae85ef0 (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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# Copyright 2011-2014 Quentin "Sardem FF7" Glidic <sardemff7@exherbo.org>
# Distributed under the terms of the GNU General Public License v2

myexparam application
myexparam -b comm=false

exparam -v MOZ_APPLICATION application

require flag-o-matic

if ever is_scm; then
    MOZ_HG_BASE_URI="http://hg.mozilla.org"

    # Default to mozilla-central, you may want
    # to use mozilla-aurora
    MOZ_HG_MODULE_XULRUNNER=mozilla-central

    MOZ_HG_MODULE_COMM=${MOZ_HG_MODULE_XULRUNNER/mozilla/comm}
    MOZ_HG_MODULE_LDAP_SDKS=projects/ldap-sdks

    SCM_REPOSITORY="https://github.com/mozilla/gecko-dev"
    SCM_CHECKOUT_TO=moz_gecko
    SCM_moz_comm_REPOSITORY="https://github.com/mozilla/releases-comm-central"
    SCM_moz_comm_UNPACK_TO=${WORK}/comm
    SCM_moz_ldap_sdks_REPOSITORY=${MOZ_HG_BASE_URI}/${MOZ_HG_MODULE_LDAP_SDKS}
    SCM_moz_ldap_sdks_TYPE=hg

    exparam -b comm && SCM_SECONDARY_REPOSITORIES="moz_comm ${SCM_SECONDARY_REPOSITORIES}"
    #exparam -b comm && SCM_SECONDARY_REPOSITORIES="moz_comm moz_ldap_sdks ${SCM_SECONDARY_REPOSITORIES}"

    require autotools [ supported_autoconf=[ 2.1 ] supported_automake=[ none ] ]
    require scm-git

    # It is really quicker and we do not need a full repo here
    scm-hg_do_unpack() {
        scm-hg_hg archive \
            --rev=$(scm-hg_revision_spec) \
            "$(scm_get_var UNPACK_TO)"
    }
fi

require cargo [ rust_minimum_version=1.37.0 ]

export_exlib_phases pkg_setup src_configure src_compile src_test src_install

LICENCES="MPL-2.0"
SLOT="0"

MYOPTIONS="
    bindist [[ description = [ Disable official branding, allowing binary redistribution ] ]]
    dbus
    pulseaudio
    raw                  [[ description = [ RAW image formats ] ]]
    startup-notification
    wayland
    wifi
    ( providers: jpeg-turbo [[ description = [ Build with system jpeg ] ]] )
    gtk2-plugin-support [[ description = [ Build a libmozgtk to support GTK+ 2 plugins ] ]]
"
if exparam -b comm; then
    MYOPTIONS+="
        lightning [[ description = [ Install the calendar extension 'Lightning' ] ]]
    "
fi

DEPENDENCIES="
    build:
        app-arch/zip
        dev-lang/python:2.7[sqlite]
        dev-lang/yasm[>=1.1]
        dev-rust/cbindgen[>=0.9.1]
        virtual/pkg-config
    build+run:
        app-arch/unzip
        dev-lang/clang:*
        dev-lang/node
        dev-libs/expat
        dev-libs/glib:2
        dev-libs/icu:=[>=59.1]
        dev-libs/libevent:=[>=1.4.7]
        dev-libs/libffi
        dev-libs/libIDL[>=0.8.0]
        dev-libs/nss[>=3.33]
        media-libs/libvpx:=[>=1.0.0]
        sys-devel/binutils[>=2.16.1]
        sys-libs/zlib[>=1.1.4]
        sys-sound/alsa-lib
        x11-libs/cairo[X][>=1.10.2]
        x11-libs/gtk+:3
        x11-libs/libXmu
        x11-libs/libXrender
        x11-libs/libXt
        x11-libs/pango[>=1.10.1]
        x11-libs/pixman

        dbus? ( dev-libs/dbus-glib[>=0.72] )
        gtk2-plugin-support? ( x11-libs/gtk+:2[>=2.14.0] )
        providers:jpeg-turbo? ( media-libs/libjpeg-turbo )
        startup-notification? ( x11-libs/startup-notification )
        wifi? ( net-wireless/wireless_tools )
    recommendation:
        x11-libs/libnotify [[ description = [ Provide system integrated notification ] ]]
"

# Needed for comm
# Should be fixed upstream
#DEFAULT_SRC_COMPILE_PARAMS=(
#    MKDIR=mkdir
#    RANLIB=$(exhost --tool-prefix)ranlib
#)

mozilla-app_pkg_setup() {
    if option bindist; then
        if [[ -d ${MOZ_APPLICATION}/branding/unofficial ]]; then
            MOZ_BRANDING=${MOZ_APPLICATION}/branding/unofficial
        else
            MOZ_BRANDING=${MOZ_APPLICATION}/branding/nightly
        fi
    elif ever is_scm; then
        MOZ_BRANDING=${MOZ_APPLICATION}/branding/nightly
    else
        case ${MOZ_APPLICATION} in
            comm/mail)
                MOZ_BRANDING=${MOZ_APPLICATION}/branding/${PN}
            ;;
            *)
                MOZ_BRANDING=${MOZ_APPLICATION}/branding/official
            ;;
        esac
    fi
    export MOZ_BRANDING
}

if ever is_scm; then
    export_exlib_phases src_prepare

    mozilla-scm_patch_baseconfig() {
        # Exherbo install dirs
        edo sed -i \
            -e "/^installdir/ c installdir = /usr/$(exhost --target)/lib/${PN}" \
            -e "/^includedir/ c includedir = /usr/$(exhost --target)/include/${PN}" \
            -e "/^idldir/ c idldir = /usr/share/idl/${PN}" \
            -e "/^sdkdir/ c sdkdir = /usr/$(exhost --target)/lib/${PN}-devel" \
            config/baseconfig.mk
    }

    mozilla-app_src_prepare() {
        default

        if exparam -b comm; then
            if option !gtk2-plugin-support; then
                edo sed -i \
                    -e '\|/gtk2/|d' \
                    comm/mail/installer/package-manifest.in
            fi
        fi

        if option !gtk2-plugin-support; then
            edo sed -i \
                -e '/MOZ_GTK2_CFLAGS=/d' \
                -e '/PKG_CHECK_MODULES(MOZ_GTK2/i\MOZ_GTK2_CFLAGS=${MOZ_GTK3_CFLAGS}' \
                -e '/PKG_CHECK_MODULES(MOZ_GTK2/i\MOZ_GTK2_LIBS=${MOZ_GTK3_LIBS}' \
                -e '/PKG_CHECK_MODULES(MOZ_GTK2/i\AC_SUBST_LIST([MOZ_GTK2_CFLAGS])' \
                -e '/PKG_CHECK_MODULES(MOZ_GTK2/i\AC_SUBST_LIST([MOZ_GTK2_LIBS])' \
                -e '/PKG_CHECK_MODULES(MOZ_GTK2/d' \
                old-configure.in
            edo sed -i \
                -e '/gtkxtbin/s:DIRS:None #DIRS:' \
                widget/moz.build
            edo sed -i \
                -e '\|/gtk2/|d' \
                browser/installer/package-manifest.in
            edo sed -i \
                -e "/DIRS/s:'gtk2', ::" \
                widget/gtk/mozgtk/moz.build
        fi

        mozilla-scm_patch_baseconfig

        # Force symbols file to be regenerated
        edo sed -i \
            -e '/MAPFILE =/s/def/sym/' \
            security/nss/lib/ckfw/builtins/manifest.mn \
            security/nss/lib/ckfw/capi/manifest.mn \
            security/nss/lib/nss/manifest.mn \
            security/nss/lib/ssl/manifest.mn \
            security/nss/lib/util/manifest.mn \
            security/nss/lib/smime/manifest.mn \
            security/nss/lib/freebl/manifest.mn \
            security/nss/lib/sqlite/manifest.mn \
            security/nss/lib/softoken/legacydb/manifest.mn \
            security/nss/lib/softoken/manifest.mn

        edo sed -i \
            -e "/^AR/s/ar/$(exhost --tool-prefix)ar/" \
            security/nss/coreconf/UNIX.mk

        edo sed -i \
            -e "/cmd =/s/'nm'/'$(exhost --tool-prefix)nm'/" \
            config/check_vanilla_allocations.py

        eautoconf

        edo pushd nsprpub

        edo sed -i \
            -e "/AC_PATH_PROGS(AR/d" \
            -e "/AC_PATH_PROGS(AS/d" \
            -e "/AC_PATH_PROGS(LD/d" \
            -e "/AC_PATH_PROGS(STRIP/d" \
            configure.in

        WANT_AUTOCONF=2.5 eautoconf

        edo popd

        edo pushd js/src

        edo mkdir .deps

        eautoconf

        edo popd
    }
fi

mozilla-app_src_configure() {
    # Optimization CFLAG
    local x opt=-O2 debug=disable
    # Set optimization level based on CFLAGS
    for x in ${CFLAGS} ${CXXFLAGS}; do
        case ${x} in
            -g*) debug=enable ;;
            -O3) opt=-O2 ;;
            -O0|-01|-O2|-Os) opt=${x} ;;
        esac
    done

    # Now filter -O from CFLAGS/CXXFLAGS to avoid a duplicate in the resulting
    # compile string.
    filter-flags '-O*'

    # Ensure we do not fail on i{3,5,7} processors that support -mavx
    append-flags -mno-avx

    # Fix for widevine gmp loading
    append-flags "-Wl,-rpath=/usr/$(exhost --target)/lib/${PN}"

    local mozconfig_params=(
        PKG_SKIP_STRIP=1
        CROSS_COMPILE=1
        MOZ_TELEMETRY_REPORTING=1
        TOOLCHAIN_PREFIX=$(exhost --tool-prefix)
        MOZ_CO_PROJECT=${MOZ_APPLICATION}
        MOZ_MAKE_FLAGS=-j${EXJOBS:-1}
        MOZ_OBJDIR="${WORKBASE}"/build

        --prefix=/usr/$(exhost --target)
        --host=$(exhost --build)
        --target=$(exhost --target)

        # CFLAGS
        --enable-optimize=${opt}
        --disable-strip
        --disable-install-strip
        --disable-warnings-as-errors

        # We don’t want debug
        --enable-release
        --${debug}-debug
        --${debug}-debug-symbols
        --disable-tests

        # Exherbo system
        --with-distribution-id=org.exherbo
        --with-branding=${MOZ_BRANDING}

        # Disable auto-distribution stuff
        --disable-updater

        # Use system libs
        --with-clang-path=/usr/$(exhost --build)/bin/$(exhost --tool-prefix)clang++
        $(option_with providers:jpeg-turbo system-jpeg)
        --with-system-bz2
        # --enable-system-cairo # causes crashes: https://github.com/voidlinux/void-packages/issues/2308
        --enable-system-ffi
        --with-system-icu
        #--with-system-libevent=/usr/$(exhost --target)
        --with-system-libvpx
        --enable-system-pixman
        --x-includes=/usr/$(exhost --target)/include
        --x-libraries=/usr/$(exhost --target)/lib
        --with-system-zlib

        # Exheres defaults and options
        --enable-chrome-format=omni
        --enable-default-toolkit=cairo-gtk3$(option wayland -wayland)
        #--with-gl-provider=EGL
        --disable-crashreporter
        --disable-gconf
        #--disable-nodejs
        --enable-ffmpeg
        $(option_enable dbus)
        $(option_enable pulseaudio)
        $(option_enable raw)
        $(option_enable startup-notification)
        $(option_enable wifi necko-wifi)

        # Application defaults
        --enable-application=${MOZ_APPLICATION}
        --enable-extensions=default
    )

    # Dev tools
    #export MOZ_DEVTOOLS=server
    #edo sed -i \
    #    -e s/MOZ_DEVTOOLS=all/MOZ_DEVTOOLS=server/ \
    #    ${MOZ_APPLICATION}/confvars.sh

    if exparam -b comm; then
        mozconfig_params+=(
            $(option_enable lightning calendar)
        )
    fi

    local x
    edo tee .mozconfig <<EOF
    $(for x in "${mozconfig_params[@]}" "${@}"; do
        case "${x}" in
            --*)
                echo ac_add_options "${x}"
            ;;
            *)
                echo export "${x}"
                echo mk_add_options "${x}"
            ;;
        esac
    done)
EOF

    unset AS

    edo ./mach configure
}

mozilla-app_src_compile() {
    unset TARGETS

    edo ./mach build -j${EXJOBS:-1}
}

mozilla-app_src_test() {
    default
}

mozilla-app_src_install() {
    unset TARGETS

    edo cd "${WORKBASE}"/build

    default

    find "${IMAGE}" -type d -empty -printf "rmdir %P\n" -delete 1>&2

    local branding_path=${WORK}/${MOZ_BRANDING} icon name size

    source "${branding_path}"/configure.sh
    targeticonname="${MOZ_APP_DISPLAYNAME,,}"

    # Install icons
    for size in 16 22 24 32 48 64 72 96 128 256; do
        for name in default${size}.png mozicon${size}.png content/icon${size}.png; do
            local path=${branding_path}/${name}
            if [[ -f "${path}" ]]; then
                insinto /usr/share/icons/hicolor/${size}x${size}/apps
                newins "${path}" "${targeticonname}.png"
                # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs
                insinto /usr/share/pixmaps
                newins "${path}" "${targeticonname}.png"
                break
            fi
        done
    done

    # Install .desktop for menu entry
    insinto /usr/share/applications
    doins "${FILES}"/${PN}.desktop

    edo sed -i \
        -e "s:@NAME@:${MOZ_APP_DISPLAYNAME}:" \
        -e "s:@ICON@:${targeticonname}:" \
        "${IMAGE}"/usr/share/applications/${PN}.desktop

    option startup-notification || edo sed -i \
        -e '/StartupNotify=true/d' \
        "${IMAGE}"/usr/share/applications/${PN}.desktop

    # Plugins dir
    hereenvd 50${PN} <<EOF
MOZ_PLUGIN_PATH="/usr/host/lib/mozilla/plugins:/usr/host/lib/nsbrowser/plugins:/opt/nsbrowser/plugins:/opt/netscape/plugins"
COLON_SEPARATED="MOZ_PLUGIN_PATH"
EOF

    if exparam -b comm; then
        if option lightning; then
            mozilla-app_unpack_extension '{a62ef8ec-5fdc-40c2-873c-223b8a6925cc}' dist/xpi-stage/gdata-provider*.xpi
            mozilla-app_unpack_extension calendar-timezones@mozilla.org dist/xpi-stage/calendar-timezones*.xpi
            # Already done?
            #mozilla-app_unpack_extension '{e2fda1a4-762b-4020-b5ad-a41df1933103}' dist/xpi-stage/lightning*.xpi
        fi
    fi
}

mozilla-app_unpack_extension() {
    local emid=$1 xpi=$2 dir=usr/$(exhost --target)/lib/${PN}/extensions/${emid}
    [[ -d "${IMAGE}"${dir} ]] && return
    dodir /${dir}
    edo pushd "${IMAGE}"${dir}
    edo unzip "${WORK}"/${xpi}
    edo popd
}