#!/bin/sh

## Post Build procedure:  create distribution zip files
##

if [ $# != 1 ] ; then 
  echo "Usage: $0 version"
  exit 1
fi

VER=$1



ORIGROOT=./XBUILD
DISTROOT=./XBUILD/distribution

rm -rf ${DISTROOT}
mkdir -p ${DISTROOT}
cp  -r ${ORIGROOT}/tclMuPDF ${DISTROOT}/BasePkg
for pltf in win-x64 linux-x64 darwin-x64 ; do
  rm -rf ${DISTROOT}/BasePkg/$pltf
done


assembleAndZip() {
  label=$1
  platforms=$2

  workDir=tclMuPDF-${label}-${VER}
  cp -r ${DISTROOT}/BasePkg ${DISTROOT}/${workDir}
  for pltf in ${platforms} ; do
     ### ln -s ${ORIGROOT}/tclMuPDF/${pltf} ${DISTROOT}/${workDir}/${pltf}
     cp -r ${ORIGROOT}/tclMuPDF/${pltf} ${DISTROOT}/${workDir}/${pltf}
  done
  (
   cd ${DISTROOT}
   zip -r ${workDir}.zip ${workDir}
  )
  rm -rf ${DISTROOT}/${workDir}
}

 # -- full pack 
assembleAndZip full "win-x64 linux-x64 darwin-x64"

 # -- win64 pack 
assembleAndZip win64 "win-x64"

 # -- linux64 pack 
assembleAndZip linux64 "linux-x64"

 # -- mac64 pack 
assembleAndZip mac64 "darwin-x64"

