#!/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') %]
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.[% c('compress_tar') %]
cd /var/tmp/build/[% project %]-[% c('version') %]
cmake . -GNinja -DCMAKE_BUILD_TYPE=Release
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 => '-caf ' _ dest_dir _ '/' _ c('filename'),
    }) %]
