version: 2
jobs:
  build:
    docker:
      - image: danieluranga/leela_chess_zero-lc0_ubuntu_builder:0.0.8
    steps:
      - checkout
      - run:
          name: "Pull Submodules"
          command: |
            git submodule init
            git submodule update --remote
      - run:
          name: Create Meson build dirs
          command: mkdir build-gcc && mkdir build-clang
      - run:
          name: Meson Clang
          environment:
            CC: clang
            CXX: clang++
          command: meson build-clang
      - run:
          name: Meson GCC
          environment:
            CC: gcc-8
            CXX: g++-8
          command: meson build-gcc
      - run:
          name: Build Clang
          command: |
            cd build-clang
            ninja
      - run:
          name: Build GCC
          command: |
            cd build-gcc
            ninja -j 4
      - run:
          command: cp build-clang/lc0 /tmp/lc0-clang
      - run:
          command: cp build-gcc/lc0 /tmp/lc0-g++
      - store_artifacts:
          path: /tmp/lc0-clang
          destination: lc0-ubuntu-18-04-clang
      - store_artifacts:
          path: /tmp/lc0-g++
          destination: lc0-ubuntu-18-04-g++
