8000 oac-tree: refactor to use oac-tree bundle 1.3 by ralphlange · Pull Request #75 · epics-training/training-vm · GitHub
[go: up one dir, main page]

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 0 additions & 135 deletions ansible/roles/oac-tree/tasks/build_module.yml

This file was deleted.

104 changes: 97 additions & 7 deletions ansible/roles/oac-tree/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
loop:
- .flag
- oac-tree.sh.d
- lib/oac-tree/plugins
- "{{ distro.lib_dirname }}/oac-tree/plugins"
- src
become: true

Expand Down Expand Up @@ -36,6 +36,11 @@
become: true
when: is_redhat

- name: "Check global rebuild flag"
stat:
path: "{{ oactree_install_path }}/.flag/REBUILD"
register: oactree_rebuild_flag

- name: "Clear global rebuild flag"
ansible.builtin.file:
path: "{{ oactree_install_path }}/.flag/REBUILD"
Expand All @@ -50,10 +55,95 @@
become: true
loop:
- "{{ oactree_install_path }}/{{ distro.lib_dirname }}"
- "{{ oactree_install_path }}/lib/oac-tree/plugins"
- "/opt/epics/base-7.0.9/lib/linux-{{ ansible_facts['architecture'] }}"
- "/opt/epics/pvxs-1.3.1/lib/linux-{{ ansible_facts['architecture'] }}"
- "{{ oactree_install_path }}/{{ distro.lib_dirname }}/oac-tree/plugins"
- "{{ epics_install_path }}/base-{{ epics_base_version }}/lib/linux-{{ ansible_facts['architecture'] }}"
- "{{ epics_install_path }}/pvxs-{{ pvxs_version }}/lib/linux-{{ ansible_facts['architecture'] }}"

- name: "Check bundle source directory"
stat:
path: "{{ oactree_install_path }}/src/oac-tree-bundle"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If flags are to be used, I think it would be good to variable-ise them. e.g. {{ oactree_build_flag }}

register: oactree_bundle_dir
Comment on lines +62 to +65
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could likely come after the clone and anything that depends on this could instead depend on whether or not that task is changed. This is probably a better way to handle this in that this only checks if the src dir exists; with this other method you would actually know if the source had changed.


- name: "Clear bundle build flag"
ansible.builtin.file:
path: "{{ oactree_install_path }}/.flag/oac-tree-bundle"
state: absent
become: true
when: oactree_rebuild_flag.stat.exists == true or oactree_bundle_dir.stat.exists == false

- name: "Check bundle build flag"
stat:
path: "{{ oactree_install_path }}/.flag/oac-tree-bundle"
register: oactree_bundle_flag

- name: "Build oac-tree modules and plugins"
include_tasks: build_module.yml
loop: "{{ oactree_modules_list }}"
- name: "Set global rebuild flag if needed"
ansible.builtin.file:
path: "{{ oactree_install_path }}/.flag/REBUILD"
state: touch
modification_time: preserve
access_time: preserve
become: true
when: oactree_bundle_flag.stat.exists == false
Comment on lines +79 to +86
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand what exactly is happening with this logic. I don't see anywhere outside of this task that modifies this flag. Moreover, as I read the logic:

  • We first check if REBUILD is set
  • If it is not (or the source is missing) we will clear the "bundle build flag"
  • We then check if it exists.
    ** This means that either REBUILD being set or source missing means we trigger the build steps
  • The build steps then create the REBUILD flag
  • At the end, they also set the "bundle build flag"

The problem as I see it is that the order suggests that this will re-run the build every time: since we are building we set the rebuild flag, and hence next time we trigger a rebuild, etc. etc.

Am I missing something? Is there an external way to set this rebuild flag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a left-over from building the modules separately (without the bundle parent dir).
(Same logic is used for the EPICS modules.)

You have a number of modules that are built in a specific order (flattened dependency tree).
As soon as one module is being rebuilt, all following modules also need to be rebuilt (changed or not) as they are further down the list, i.e., downstream dependencies.


- name: "Clone oac-tree-bundle repository"
ansible.builtin.git:
repo: "{{ oactree_bundle_repo }}"
dest: "{{ oactree_install_path }}/src/oac-tree-bundle"
version: "{{ oactree_bundle_version }}"
recursive: true
become: true
when: oactree_bundle_flag.stat.exists == false

- name: "Create build directory"
ansible.builtin.file:
path: "{{ oactree_install_path }}/src/oac-tree-bundle/build"
state: directory
become: true
when: oactree_bundle_flag.stat.exists == false

- name: "Run cmake"
command:
chdir: "{{ oactree_install_path }}/src/oac-tree-bundle/build"
cmd: "cmake -DCMAKE_INSTALL_PREFIX={{ oactree_install_path }} -DCMAKE_PREFIX_PATH={{ oactree_install_path }} .."
environment:
EPICS_BASE: "{{ epics_install_path }}/base-{{ epics_base_version }}"
EPICS_HOST_ARCH: "linux-{{ ansible_facts['architecture'] }}"
PVXS_DIR: "{{ epics_install_path }}/pvxs-{{ pvxs_version }}"
CMAKE_PREFIX_PATH: "{{ oactree_install_path }}"
become: true
when: oactree_bundle_flag.stat.exists == false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these might be better suited to be in a block, as they are consecutive tasks that depend on a common condition.


- name: "Run make (build and install everything - this may take a while)"
command: make -j {{ ansible_facts.processor_vcpus }} -C {{ oactree_install_path }}/src/oac-tree-bundle/build
register: build_result
environment:
EPICS_BASE: "{{ epics_install_path }}/base-{{ epics_base_version }}"
EPICS_HOST_ARCH: "linux-{{ ansible_facts['architecture'] }}"
PVXS_DIR: "{{ epics_install_path }}/pvxs-{{ pvxs_version }}"
CMAKE_PREFIX_PATH: "{{ oactree_install_path }}"
become: true
when: oactree_bundle_flag.stat.exists == false

- name: "Update linker configuration"
ansible.builtin.command: ldconfig
become: true
when: oactree_bundle_flag.stat.exists == false and build_result.rc | default(0) == 0

- name: "Create oac-tree.sh fragment"
copy:
content: "PATH={{ oactree_install_path }}/bin:$PATH\n"
dest: "{{ oactree_install_path }}/oac-tree.sh.d/00-oac-tree"
become: true

- name: "Update (re-assemble) oac-tree.sh"
assemble:
src: "{{ oactree_install_path }}/oac-tree.sh.d"
dest: "/etc/profile.d/oac-tree.sh"
become: true

- name: "Create bundle build flag"
copy:
content: ""
dest: "{{ oactree_install_path }}/.flag/oac-tree-bundle"
become: true
when: build_result.rc | default(0) == 0 and oactree_bundle_flag.stat.exists == false
Comment on lines +144 to +149
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can do this more cleanly using the file module and state touch, see https://docs.ansible.com/projects/ansible/latest/collections/ansible/builtin/file_module.html

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Will do.
I worked on this before merging the EPICS modules refactor - this is old stuff creeping in.

71 changes: 4 additions & 67 deletions ansible/roles/oac-tree/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,12 @@

oactree_install_path: "/opt/oac-tree"

oactree_modules_list:
- sup_dto
- sup_utils
- oac_tree
- oac_tree_control
- sup_di
- sup_protocol
- sup_epics
- sup_mathexpr
- oac_tree_epics
- oac_tree_mathexpr
- oac_tree_server
# GUI
- sup_gui_extra
- sup_mvvm
- sup_gui_core
- oac_tree_gui
oactree_bundle_repo: "https://github.com/oac-tree/oac-tree-bundle.git"
oactree_bundle_version: "v1.4"

required_debs:
- unzip
- cmake
- git
- libgtest-dev
- libgmock-dev
- libxml2-dev
Expand All @@ -34,8 +19,8 @@ required_debs:
- adwaita-qt6

required_rpms:
- unzip
- cmake
- git
- gtest-devel
- gmock-devel
- libxml2-devel
Expand All @@ -44,51 +29,3 @@ required_rpms:
- qt6-qtcharts-devel
- qt6-qttools-devel
- adwaita-qt6

oactree_modules:
oac_tree:
name: "core library"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/oac-tree.zip"
sup_dto:
name: "sup-dto library"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/sup-dto.zip"
sup_utils:
name: "sup-utils library"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/sup-utils.zip"
oac_tree_control:
name: "control plugin"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/oac-tree-control.zip"
sup_di:
name: "sup-di library"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/sup-di.zip"
sup_protocol:
name: "sup-protocol library"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/sup-protocol.zip"
sup_epics:
name: "sup-epics library"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/sup-epics.zip"
sup_mathexpr:
name: "sup-mathexpr library"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/sup-mathexpr.zip"
oac_tree_epics:
name: "EPICS plugin"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/oac-tree-epics.zip"
oac_tree_mathexpr:
name: "Mathexpr plugin"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/oac-tree-mathexpr.zip"
oac_tree_server:
name: "Server plugin"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/oac-tree-server.zip"
# GUI
sup_gui_extra:
name: "sup-gui-extra library"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/sup-gui-extra.zip"
sup_mvvm:
name: "sup-mvvm library"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/sup-mvvm.zip"
sup_gui_core:
name: "sup-gui-core library"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/sup-gui-core.zip"
oac_tree_gui:
name: "GUI application"
url: "https://github.com/epics-training/oac-tree-zips/raw/refs/heads/main/oac-tree-gui.zip"
Loading
0