#!/bin/bash
[% c("var/set_default_env") -%]
distdir="/var/tmp/dist/[% project %]"
mkdir -p "$distdir"
tar xjf [% c('input_files_by_name/SDK') %]
mv MacOSX10.11.sdk "$distdir/SDK"
tar xf [% c('input_files_by_name/llvm') %]
mv llvm "$distdir/clang"
tar -C $distdir -xf [% c('input_files_by_name/cctools') %]
cd $distdir/cctools/bin
ln -s ../../clang/bin/clang x86_64-apple-darwin11-clang
ln -s ../../clang/bin/clang++ x86_64-apple-darwin11-clang++
# "go link", libevent, and the jemalloc cross-compilation during the Rust build
# expect to find a program called "dsymutil" exactly.
ln -s ../../clang/bin/llvm-dsymutil dsymutil

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