mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
before this change, add_version_library() is a single function
which accomplishes two tasks:
1. build scylla-version target using
2. add an object library
but this has two problems:
1. we should run `SCYLLA-VERSION-GEN` at configure time, instead
of at build time. otherwise the targets which read from the
SCYLLA-{VERSION, RELEASE, PRODUCT}-FILE cannot access them,
unless they are able to read them in their build rules. but
they always use `file(STRINGS ..)` to read them, and thsee
`file()` command is executed at configure time. so, this
is a dead end.
2. we repeat the `file(STRING ..)` multiple places. this is
not ideal if we want to minimize the repeatings.
so, to address this problem, in this change:
1. use `execute_process()` instead of `add_custom_command()`
for generating these *-FILE files. so they are always ready
at build time. this partially reverts bb7d99ad37.
2. extract `generate_scylla_version()` out of `add_version_library()`.
so we can call the former much earlier than the latter.
this would allow us to reference the variables defined by
the `generate_scylla_version()` much earlier.
3. define cached strings in the extracted function, so that
they can consumed by other places.
4. reference the cached variables in `build_submodule.cmake`.
also, take this opportunity to fix the version string
used in build_submodule.cmake: we should have used
`scylla_version_tilde`.
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
Closes #14769
24 lines
999 B
CMake
24 lines
999 B
CMake
function(build_submodule name dir)
|
|
string(REPLACE "-" "~" scylla_version_tilde ${Scylla_VERSION})
|
|
set(scylla_version
|
|
"${Scylla_PRODUCT}-${scylla_version_tilde}-${Scylla_RELEASE}")
|
|
set(reloc_pkg "${dir}/build/${name}-${scylla_version}.noarch.tar.gz")
|
|
set(working_dir ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
|
|
add_custom_command(
|
|
OUTPUT ${reloc_pkg}
|
|
COMMAND reloc/build_reloc.sh --version ${scylla_version} --nodeps ${ARGN}
|
|
WORKING_DIRECTORY "${working_dir}"
|
|
COMMENT "Generating submodule ${name} in ${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}
|
|
WORKING_DIRECTORY "${working_dir}")
|
|
add_custom_target(dist-${name}-deb
|
|
COMMAND reloc/build_deb.sh --reloc-pkg ${reloc_pkg}
|
|
WORKING_DIRECTORY "${working_dir}")
|
|
add_custom_target(dist-${name}
|
|
DEPENDS dist-${name}-tar dist-${name}-rpm dist-${name}-deb)
|
|
endfunction()
|