---
- name: Fetch and unpack TensorFlow IO source archive
  when: tensorflow_io_version != 'git'
  block:
    - name: Fetch TensorFlow IO {{ tensorflow_io_version }} source
      ansible.builtin.get_url:
        url: "https://github.com/tensorflow/io/archive/refs/tags/v{{ tensorflow_io_version }}.tar.gz"
        dest: "{{ build_dir }}/io-{{ tensorflow_io_version }}.tar.gz"
        mode: 0600

    - name: Unpack TensorFlow IO {{ tensorflow_io_version }} source
      ansible.builtin.unarchive:
        src: "{{ build_dir }}/io-{{ tensorflow_io_version }}.tar.gz"
        dest: "{{ build_dir }}/"
        remote_src: true

- name: Fetch TensorFlow IO from git
  ansible.builtin.git:
    repo: "https://github.com/tensorflow/io.git"  # noqa latest[git]
    dest: "{{ build_dir }}/io-{{ tensorflow_io_version }}/"
    depth: 1
    recursive: true
    force: true
    version: "{{ tensorflow_io_git_version }}"
  when: tensorflow_io_version == 'git'

  # https://github.com/tensorflow/io/issues/1510
- name: Make libwebp buildable with gcc 10
  ansible.builtin.lineinfile:
    regexp: "^.*WEBP_EXTERN.*$"
    state: absent
    path: "{{ build_dir }}/io-{{ tensorflow_io_version }}/third_party/libwebp.BUILD"
