:: Set the path to your FreeCAD executable here
set FREECAD=C:\Program Files\FreeCAD 0.21\bin\freecad.exe

set SCRIPT_DIR=%~dp0
echo %SCRIPT_DIR% >>%TMP%\toto.txt
cd %script_dir%
echo %cd% >>%TMP%\toto.txt

cd ..
echo %cd% >>%TMP%\toto.txt
:: rm -rf ./dist

:: Check script syntax before starting freecad
:: python3 -m py_compile tools/export-all-parts.py

:: Export all versioned files
:: mkdir -p dist/FCStd
:: git archive HEAD . | tar -x -C dist/FCStd

:: Start freecad to run the script. We must start freecad with GUI (otherwise we can't export colors). We start it hidden in a virtual framebuffer (xvfb) so that it can run cleanly in the background.
:: xvfb-run $FREECAD tools/export-all-parts.py
:: %freecad%/freecad.exe tools/export-all-parts.py
echo %freecad%
start "" "%freecad%" tools/export-all-parts.py