Files
scylladb/cmake/build_submodule.cmake
Kefu Chai 1186ddef16 build: cmake: use paths to be compatible with CI
our CI workflow for publishing the packages expects the tar balls
to be located under `build/$buildMode/dist/tar`, where `$buildMode`
is "release" or "debug".

before this change, the CMake building system puts the tar balls
under "build/dist" when the multi-config generator is used. and
`configure.py` uses multi-config generator.

in this change, we put the tar balls for redistribution under
`build/$<CONFIG>/dist/tar`, where `$<CONFIG>` is "RelWithDebInfo"
or "Debug", this works better with the CI workflow -- we just need
to map "release" and "debug" to "RelWithDebInfo" and "Debug" respectively.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-05-11 21:56:50 +08:00

51 lines
1.9 KiB
CMake

function(build_submodule name dir)
cmake_parse_arguments(parsed_args "NOARCH" "" "" ${ARGN})
set(version_release "${Scylla_VERSION}-${Scylla_RELEASE}")
set(product_version_release
"${Scylla_PRODUCT}-${Scylla_VERSION}-${Scylla_RELEASE}")
set(working_dir ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
if(parsed_args_NOARCH)
set(arch "noarch")
else()
set(arch "${CMAKE_SYSTEM_PROCESSOR}")
endif()
set(reloc_args ${parsed_args_UNPARSED_ARGUMENTS})
set(reloc_pkg "${working_dir}/build/${Scylla_PRODUCT}-${name}-${version_release}.${arch}.tar.gz")
add_custom_command(
OUTPUT ${reloc_pkg}
COMMAND reloc/build_reloc.sh --version ${product_version_release} --nodeps ${reloc_args}
WORKING_DIRECTORY "${working_dir}"
JOB_POOL submodule_pool)
add_custom_target(dist-${name}-tar
DEPENDS ${reloc_pkg})
add_custom_target(dist-${name}-rpm
COMMAND reloc/build_rpm.sh --reloc-pkg ${reloc_pkg}
DEPENDS ${reloc_pkg}
WORKING_DIRECTORY "${working_dir}")
add_custom_target(dist-${name}-deb
COMMAND reloc/build_deb.sh --reloc-pkg ${reloc_pkg}
DEPENDS ${reloc_pkg}
WORKING_DIRECTORY "${working_dir}")
add_custom_target(dist-${name} ALL
DEPENDS dist-${name}-tar dist-${name}-rpm dist-${name}-deb)
endfunction()
macro(dist_submodule name dir pkgs)
# defined as a macro, so that we can append the path to the dist tarball to
# specified "pkgs"
cmake_parse_arguments(parsed_args "NOARCH" "" "" ${ARGN})
if(parsed_args_NOARCH)
set(arch "noarch")
else()
set(arch "${CMAKE_SYSTEM_PROCESSOR}")
endif()
set(pkg_name "${Scylla_PRODUCT}-${name}-${Scylla_VERSION}-${Scylla_RELEASE}.${arch}.tar.gz")
set(reloc_pkg "${CMAKE_SOURCE_DIR}/tools/${dir}/build/${pkg_name}")
set(dist_pkg "${CMAKE_BINARY_DIR}/$<CONFIG>/dist/tar/${pkg_name}")
add_custom_command(
OUTPUT ${dist_pkg}
COMMAND ${CMAKE_COMMAND} -E copy ${reloc_pkg} ${dist_pkg}
DEPENDS dist-${name}-tar)
list(APPEND ${pkgs} "${dist_pkg}")
endmacro()