echo on

mkdir build
pushd build
  REM remove GL flag for now
  set "CXXFLAGS=-MD"
  :: -DLLVM_CCACHE_BUILD=yes is broken on Windows:
  ::  CCACHE_CPP2=yes CCACHE_HASHDIR=yes C:/opt/conda/conda-bld/llvm-package-10.0.1_6/_build_env/bin/ccache.exe C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe
  set "CC=cl.exe"
  set "CXX=cl.exe"

  cmake -G "Ninja" ^
    -DCMAKE_BUILD_TYPE="Release" ^
    -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -DCMAKE_INSTALL_PREFIX:PATH=%LIBRARY_PREFIX% ^
    -DLLVM_USE_INTEL_JITEVENTS=ON ^
    -DLLVM_INCLUDE_TESTS=ON ^
    -DLLVM_BUILD_TESTS=ON ^
    -DLLVM_INCLUDE_EXAMPLES=OFF ^
    -DLLVM_INCLUDE_UTILS=ON ^
    -DLLVM_INSTALL_UTILS=ON ^
    -DLLVM_UTILS_INSTALL_DIR=libexec\llvm ^
    -DLLVM_INCLUDE_DOCS=OFF ^
    -DLLVM_ENABLE_RTTI=ON ^
    -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly ^
    -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON ^
    -DLLVM_ENABLE_LIBXML2=OFF ^
    -DLLVM_ENABLE_ZLIB=ON ^
    -DLLVM_BUILD_LLVM_C_DYLIB=no ^
    %SRC_DIR%
  if errorlevel 1 exit 1

  cmake --build .
  if errorlevel 1 exit 1

  cmake --build . --target check-llvm-unit
  if errorlevel 1 exit 1

  bin\opt.exe -S -vector-library=SVML -mcpu=haswell -O3 %RECIPE_DIR%\numba-3016.ll | bin\FileCheck %RECIPE_DIR%\numba-3016.ll
  if errorlevel 1 exit 1

  pushd ..\test
    %BUILD_PREFIX%\python.exe ..\build\bin\llvm-lit.py -vv Transforms ExecutionEngine Analysis CodeGen/X86
  popd
popd
