Files
ansible_role_package/tasks/helpers/cargo_build.yml
Matthew Stobbs e231c6ae7a updating documentation
- giving things a better structure
- better documentation with the way things need to be as a standard
2026-02-04 22:26:15 -07:00

66 lines
2.1 KiB
YAML

# vim: set filetype=yaml.ansible :
---
- name: Cargo source install helper
block:
- name: Set build variables
ansible.builtin.set_fact:
git_path: "{{ d_tempdir.path }}/{{ pkg.name }}"
git_repo: "{{ pkg.repo }}"
git_depth: "{{ pkg.depth | default(1) }}"
git_recursive: "{{ pkg.recursive | default(true) }}"
git_version: "{{ pkg.version | default(omit) }}"
- name: Fetch git repo
ansible.builtin.include_tasks:
file: helpers/git.yml
- name: Build cargo release
ansible.builtin.command:
creates: "{{ pkg.bin_output }}"
chdir: "{{ pkg.path }}"
argv: "{{ [cargo, build] + pkg.build_flags }}"
- name: Install cargo release
block:
- name: Install binary
when:
- bin_name is defined
- bin_output is defined
become: true
ansible.builtin.copy:
backup: false
dest: "{{ install_prefix }}/bin/{{ bin_name }}"
owner: root
group: root
mode: "0755"
remote_src: true
src: "{{ git_path }}/{{ bin_output }}"
- name: Install additional files
when:
- install_files is defined
block:
- name: Create missing directories
loop: "{{ install_files | dict2items }}"
loop_control:
loop_var: file
ansible.builtin.file:
path: "{{ install_prefix }}/{{ file.value | dirname }}"
owner: root
group: root
mode: "0755"
state: directory
- name: Copy extra files
loop: "{{ install_files | dict2items }}"
loop_control:
loop_var: file
ansible.builtin.copy:
backup: false
dest: "{{ install_prefix }}/{{ file.value }}"
owner: root
group: root
mode: "0644"
remote_src: true
src: "{{ git_path }}/{{ file.key }}"