Skip to content

Commit

Permalink
Merge pull request #18 from ecmwf/feature/post-build-plugin-manifest
Browse files Browse the repository at this point in the history
Create plugin manifest atomically after library is built
  • Loading branch information
ChrisspyB authored Oct 15, 2024
2 parents b88b965 + 137d27a commit 57ff415
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
12 changes: 0 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,6 @@ if(HAVE_PYTHON_API_TESTS)
endif()

########################################################################################################################
# PLUGIN
# Write and install the manifest file for the plugin
set( gribjump_plugin_file share/plugins/gribjump-plugin.yml )
file( WRITE ${CMAKE_BINARY_DIR}/${gribjump_plugin_file} "plugin:\n" )
file( APPEND ${CMAKE_BINARY_DIR}/${gribjump_plugin_file} " name: gribjump-plugin\n" )
file( APPEND ${CMAKE_BINARY_DIR}/${gribjump_plugin_file} " namespace: int.ecmwf\n" )
file( APPEND ${CMAKE_BINARY_DIR}/${gribjump_plugin_file} " url: http://www.ecmwf.int\n" )
file( APPEND ${CMAKE_BINARY_DIR}/${gribjump_plugin_file} " version: ${${PROJECT_NAME}_VERSION}\n" )
file( APPEND ${CMAKE_BINARY_DIR}/${gribjump_plugin_file} " library: gribjump\n" )

install( FILES ${CMAKE_BINARY_DIR}/${gribjump_plugin_file} DESTINATION share/plugins )

### finalize

ecbuild_install_project( NAME gribjump )
Expand Down
22 changes: 22 additions & 0 deletions src/gribjump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,25 @@ ecbuild_add_library(
eckit_option
${SERVER_LIBS}
)

############################################################################################
# Plugin
# Must happen atomically, and only after the library has been built.
# NB: In future this will be added to the ecbuild_add_library call above

set( gribjump_plugin_file_in gribjump-plugin.yml.in )
set( gribjump_plugin_file_out ${CMAKE_BINARY_DIR}/share/plugins/int.ecmwf.gribjump-plugin.yml )
set( gribjump_plugin_file_tmp ${CMAKE_BINARY_DIR}/gribjump-plugin.yml.tmp)

# configure to temporary file
configure_file( ${gribjump_plugin_file_in} ${gribjump_plugin_file_tmp} @ONLY )

# move file atomically
add_custom_command( TARGET gribjump POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/share/plugins
COMMAND ${CMAKE_COMMAND} -E rename ${gribjump_plugin_file_tmp} ${gribjump_plugin_file_out}
)

install( FILES ${gribjump_plugin_file_out} DESTINATION share/plugins)

############################################################################################
6 changes: 6 additions & 0 deletions src/gribjump/gribjump-plugin.yml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
plugin:
name: gribjump-plugin
namespace: int.ecmwf
url: http://www.ecmwf.int
version: @gribjump_VERSION@
library: gribjump

0 comments on commit 57ff415

Please sign in to comment.