Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
technical:recipes:git-cmake-valet-package [2021-11-04 11:56] – [Managing multiple versions of revision-controlled repositories] anita | technical:recipes:git-cmake-valet-package [2021-11-18 17:58] (current) – frey | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Managing multiple versions of revision-controlled repositories ====== | ||
+ | Revision-controlled source code retains a historical record of the changes that a project has gone through. | ||
+ | |||
+ | In the more typical release strategy, a separate source code archive (e.g. a '' | ||
+ | |||
+ | In this document, the management of a Git-based software package is outlined. | ||
+ | |||
+ | ====== Setup the Hierarchy ====== | ||
+ | |||
+ | The software package, [[https:// | ||
+ | |||
+ | Outside of the tagged revisions, a build could be performed on any commit in the history. | ||
+ | |||
+ | To create the package' | ||
+ | |||
+ | <code bash> | ||
+ | [(workgroup: | ||
+ | [(workgroup: | ||
+ | [(workgroup: | ||
+ | [(workgroup: | ||
+ | [(workgroup: | ||
+ | </ | ||
+ | |||
+ | The Git repository now resides in the path '' | ||
+ | |||
+ | ====== Build a Release ====== | ||
+ | |||
+ | First, examine the tagged commits available: | ||
+ | |||
+ | <code bash> | ||
+ | [(workgroup: | ||
+ | v1 | ||
+ | v2 | ||
+ | : | ||
+ | v17 | ||
+ | v18 | ||
+ | </ | ||
+ | |||
+ | A build of the '' | ||
+ | |||
+ | <code bash> | ||
+ | [(workgroup: | ||
+ | [(workgroup: | ||
+ | </ | ||
+ | |||
+ | The documentation mentions the CMake flags what will be necessary for a build using the Intel compilers and MPI. To keep track of the steps involved, a script fragment will be created: | ||
+ | |||
+ | <code bash> | ||
+ | [(workgroup: | ||
+ | # | ||
+ | # v18 build | ||
+ | # | ||
+ | vpkg_require cmake/ | ||
+ | ( cd .. ; git checkout v18 ) | ||
+ | cmake \ | ||
+ | -DCMAKE_BUILD_TYPE=Release \ | ||
+ | -DCMAKE_INSTALL_PREFIX=" | ||
+ | -DCMAKE_C_COMPILER=icc \ | ||
+ | -DCMAKE_CXX_COMPILER=icpc \ | ||
+ | -DCMAKE_Fortran_COMPILER=ifort \ | ||
+ | -DMPI_C=mpicc \ | ||
+ | -DMPI_CXX=mpic++ \ | ||
+ | -DMPI_Fortran=mpifort \ | ||
+ | -DCMAKE_Fortran_FLAGS=" | ||
+ | .. | ||
+ | EOT | ||
+ | </ | ||
+ | |||
+ | Note the '' | ||
+ | |||
+ | At this point, the build can be configured: | ||
+ | |||
+ | <code bash> | ||
+ | [(workgroup: | ||
+ | Adding package `cmake/ | ||
+ | Adding dependency `intel/ | ||
+ | Adding dependency `libfabric/ | ||
+ | Adding package `openmpi/ | ||
+ | : | ||
+ | HEAD is now at 9201476... Merge branch ' | ||
+ | : | ||
+ | -- The C compiler identification is Intel 18.0.3.20180410 | ||
+ | -- The CXX compiler identification is Intel 18.0.3.20180410 | ||
+ | -- The Fortran compiler identification is Intel 18.0.3.20180410 | ||
+ | -- Detecting C compiler ABI info | ||
+ | -- Detecting C compiler ABI info - done | ||
+ | -- Check for working C compiler: / | ||
+ | -- Detecting C compile features | ||
+ | -- Detecting C compile features - done | ||
+ | -- Detecting CXX compiler ABI info | ||
+ | -- Detecting CXX compiler ABI info - done | ||
+ | -- Check for working CXX compiler: / | ||
+ | -- Detecting CXX compile features | ||
+ | -- Detecting CXX compile features - done | ||
+ | -- Detecting Fortran compiler ABI info | ||
+ | -- Detecting Fortran compiler ABI info - done | ||
+ | -- Check for working Fortran compiler: / | ||
+ | -- Checking whether / | ||
+ | -- Checking whether / | ||
+ | : | ||
+ | -- Build files have been written to: / | ||
+ | </ | ||
+ | |||
+ | At this point the software can be built and installed according to the documentation: | ||
+ | |||
+ | <code bash> | ||
+ | [(workgroup: | ||
+ | [ 3%] Creating directories for ' | ||
+ | [ 3%] Creating directories for ' | ||
+ | [ 3%] Creating directories for ' | ||
+ | [ 6%] Creating directories for ' | ||
+ | [ 6%] Creating directories for ' | ||
+ | [ 7%] Creating directories for ' | ||
+ | [ 10%] Performing download step (verify and extract) for ' | ||
+ | [ 10%] Performing download step (verify and extract) for ' | ||
+ | : | ||
+ | [(workgroup: | ||
+ | total 21 | ||
+ | drwxr-sr-x 7 user workgroup | ||
+ | drwxr-sr-x 8 user workgroup 12 Nov 4 10:53 src | ||
+ | [(workgroup: | ||
+ | total 100 | ||
+ | drwxr-sr-x 2 user workgroup | ||
+ | drwxr-sr-x 3 user workgroup 111 Nov 4 09:55 include | ||
+ | drwxr-xr-x 3 user workgroup | ||
+ | drwxr-sr-x 4 user workgroup | ||
+ | drwxr-sr-x 5 user workgroup | ||
+ | </ | ||
+ | |||
+ | ====== Build the Current HEAD ====== | ||
+ | |||
+ | The build directory for the desired commit must be created first: | ||
+ | |||
+ | <code bash> | ||
+ | [(workgroup: | ||
+ | [(workgroup: | ||
+ | Switched to branch ' | ||
+ | [(workgroup: | ||
+ | [(workgroup: | ||
+ | 9201476247a9ac94d6f0f4a91657fe19c9c64945 | ||
+ | [(workgroup: | ||
+ | [(workgroup: | ||
+ | </ | ||
+ | |||
+ | Again to keep track of the steps involved, a script fragment will be created: | ||
+ | |||
+ | <code bash> | ||
+ | [(workgroup: | ||
+ | # | ||
+ | # 2021-11-04 build of HEAD of repository | ||
+ | # | ||
+ | vpkg_require cmake/ | ||
+ | ( cd .. ; git checkout ${VERSION_ID} ) | ||
+ | cmake \ | ||
+ | -DCMAKE_BUILD_TYPE=Release \ | ||
+ | -DCMAKE_INSTALL_PREFIX=" | ||
+ | -DCMAKE_C_COMPILER=icc \ | ||
+ | -DCMAKE_CXX_COMPILER=icpc \ | ||
+ | -DCMAKE_Fortran_COMPILER=ifort \ | ||
+ | -DMPI_C=mpicc \ | ||
+ | -DMPI_CXX=mpic++ \ | ||
+ | -DMPI_Fortran=mpifort \ | ||
+ | -DCMAKE_Fortran_FLAGS=" | ||
+ | .. | ||
+ | EOT | ||
+ | </ | ||
+ | |||
+ | The configuration and build proceeds as before, with the finished software present in a new directory: | ||
+ | |||
+ | <code bash> | ||
+ | [(workgroup: | ||
+ | total 21 | ||
+ | drwxr-sr-x 7 user workgroup | ||
+ | drwxr-sr-x 7 user workgroup | ||
+ | drwxr-sr-x 8 user workgroup 12 Nov 4 10:53 src | ||
+ | [(workgroup: | ||
+ | total 100 | ||
+ | drwxr-sr-x 2 user workgroup | ||
+ | drwxr-sr-x 3 user workgroup 111 Nov 4 10:30 include | ||
+ | drwxr-xr-x 3 user workgroup | ||
+ | drwxr-sr-x 4 user workgroup | ||
+ | drwxr-sr-x 5 user workgroup | ||
+ | </ | ||
+ | |||
+ | ====== VALET Package Definition ====== | ||
+ | |||
+ | A VALET package definition is used to encapsulate the dependencies and environment setup tasks associated with using the versions built. | ||
+ | |||
+ | <file yaml truchas-tpl.vpkg_yaml> | ||
+ | # | ||
+ | # VALET package definition for truchas-tpl builds | ||
+ | # | ||
+ | truchas-tpl: | ||
+ | prefix: / | ||
+ | description: | ||
+ | url: " | ||
+ | | ||
+ | default-version: | ||
+ | | ||
+ | versions: | ||
+ | " | ||
+ | description: | ||
+ | dependencies: | ||
+ | - openmpi/ | ||
+ | " | ||
+ | alias-to: " | ||
+ | " | ||
+ | alias-to: " | ||
+ | | ||
+ | " | ||
+ | description: | ||
+ | dependencies: | ||
+ | - openmpi/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | <note important> | ||
+ | |||
+ | With that file created and installed in '' | ||
+ | |||
+ | <code bash> | ||
+ | [(it_nss: | ||
+ | |||
+ | Available versions in package (* = default version): | ||
+ | |||
+ | [/ | ||
+ | truchas-tpl | ||
+ | 18 commit tag v18 | ||
+ | * 2021-11-04 | ||
+ | 9201476 | ||
+ | 9201476247a9ac94d6f0f4a91657fe19c9c64945 | ||
+ | |||
+ | [(it_nss: | ||
+ | [truchas-tpl/ | ||
+ | contexts: all | ||
+ | dependencies: | ||
+ | openmpi/ | ||
+ | } | ||
+ | commit tag v18 | ||
+ | prefix: / | ||
+ | standard paths: { | ||
+ | bin: / | ||
+ | lib: / | ||
+ | man: / | ||
+ | include: / | ||
+ | pkgConfig: / | ||
+ | } | ||
+ | } | ||
+ | |||
+ | [(it_nss: | ||
+ | Adding dependency `intel/ | ||
+ | Adding dependency `libfabric/ | ||
+ | Adding dependency `openmpi/ | ||
+ | Adding package `truchas-tpl/ | ||
+ | |||
+ | [(it_nss: | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | ===== Configure for Development ===== | ||
+ | |||
+ | VALET can also add environment variables that assist in building software that depends on this package when used with '' | ||
+ | |||
+ | <code bash> | ||
+ | [(it_nss: | ||
+ | [(it_nss: | ||
+ | Adding dependency `intel/ | ||
+ | Adding dependency `libfabric/ | ||
+ | Adding dependency `openmpi/ | ||
+ | Adding package `truchas-tpl/ | ||
+ | |||
+ | [(it_nss: | ||
+ | -L/ | ||
+ | |||
+ | [(it_nss: | ||
+ | -I/ | ||
+ | |||
+ | [(it_nss: | ||
+ | icc | ||
+ | |||
+ | [(it_nss: | ||
+ | mpicc | ||
+ | </ |