#!/bin/bash

rm -rf emscripten/*
mkdir -p emscripten

cp -r ../flare-game/mods/fantasycore mods/fantasycore
cp -r ../flare-game/mods/empyrean_campaign mods/empyrean_campaign

cmake .

emcc \
    -Isrc/ \
    src/*.cpp \
    -O3 \
    -s ASSERTIONS=1 \
    -s ALLOW_MEMORY_GROWTH=1 \
    -s USE_SDL=2 \
    -s USE_SDL_IMAGE=2 \
    -s SDL2_IMAGE_FORMATS='["png"]' \
	-s USE_SDL_TTF=2 \
    --preload-file mods \
    -o emscripten/index.html

rm -rf mods/fantasycore
rm -rf mods/empyrean_campaign

cp distribution/emscripten_template.html emscripten/index.html
