#!/bin/bash
[% c("var/set_default_env") -%]
distdir="/var/tmp/dist/[% project %]"

[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf [% project %]-[% c("version") %].tar.gz
cd /var/tmp/build/[% project %]-[% c("version") %]

[% IF c("var/windows-i686") -%]
  make x86
[% ELSE -%]
  make x64
[% END -%]

mkdir -p $distdir/bin/
cp fxc2.exe $distdir/bin/
[% IF c("var/windows-i686") -%]
  cp dll/d3dcompiler_47_32.dll $distdir/bin/d3dcompiler_47.dll
[% ELSE -%]
  cp dll/d3dcompiler_47.dll $distdir/bin/
[% END -%]

cd /var/tmp/dist

[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]
