#!/bin/bash
[% c("var/set_default_env") -%]
distdir=/var/tmp/dist/[% project %]
mkdir -p /var/tmp/dist
tar -C /var/tmp/dist -xf [% c('input_files_by_name/cmake') %]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/ninja') %]
[% IF c("container/global_disable") -%]
  tar -C /var/tmp/dist -xf [% c('input_files_by_name/openssl-1.0.2') %]
[% END -%]
export PATH="/var/tmp/dist/ninja:/var/tmp/dist/cmake/bin:$PATH"

mkdir /var/tmp/build
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
cd /var/tmp/build/[% project %]-[% c('version') %]
patch -p1 < "$rootdir/libdmg.patch"
cmake . -GNinja -DCMAKE_BUILD_TYPE=Release [% c("var/cmake_opts") %]
ninja -j[% c("num_procs") %] -v

mkdir $distdir
# We take only dmg and hfsplus like Mozilla does
cp dmg/dmg hfs/hfsplus $distdir/
cd /var/tmp/dist
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]
