---
- name: Set TensorFlow and other package versions
  ansible.builtin.set_fact:
    tensorflow_version: "{{ tf_ver.value.tensorflow_version }}"
    bazel_version: "{{ tf_ver.value.bazel_version }}"
    onednn_ut_exclude: '{{ "-" + tf_ver.value.onednn_ut_exclude | join(" -") if onednn_enable_opt and tf_ver.value.onednn_ut_exclude else "" }}'
    clang_ut_exclude: '{{ "-" + tf_ver.value.unit_tests_clang_exclude | join(" -") if clang_build and tf_ver.value.unit_tests_clang_exclude else "" }}'
    gcc_ut_exclude: '{{ "-" + tf_ver.value.unit_tests_gcc_exclude | join(" -") if not clang_build and tf_ver.value.unit_tests_gcc_exclude else "" }}'
    image_prefix: "{{ tf_ver.value.image_prefix }}"

- name: Set build dir for TensorFlow{{ variant_name }} {{ tensorflow_version }}
  ansible.builtin.set_fact:
    tensorflow_build_dir: "{{ build_dir }}/tensorflow{{ variant_name }}-{{ tensorflow_version }}"

- name: Remove TensorFlow{{ variant_name }} {{ tensorflow_version }} sources from previous build
  ansible.builtin.file:
    path: "{{ tensorflow_build_dir }}/"
    state: absent

- name: Fetch TensorFlow
  ansible.builtin.include_tasks:
    file: fetch.yml

- name: Build TensorFlow for each Python version (dual abi)
  ansible.builtin.include_role:
    name: tensorflow_in_container
    tasks_from: dual-abi-build.yml
  loop: "{{ tf_ver.value.python_versions }}"
  loop_control:
    loop_var: py_ver
