Skip to content

Commit 028843e

Browse files
committed
refactor(component): move archive/bundle/pkgconfig/rename out of tools
Post-install helpers are component oficios, not activatable tools. Keep BUILDMASTER_RENAME_VARIANTS and _BM_PC_* names. Rename functions to _bm_component_{archive,rename,pkgconfig}_*.
1 parent bbea8a1 commit 028843e

18 files changed

Lines changed: 87 additions & 88 deletions
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# =============================================================================
2-
# tools/archive/find_archiver.cmake — static archiver resolution (shared)
2+
# component/archive/find_archiver.cmake — static archiver resolution (shared)
33
# =============================================================================
44

55
## @brief Resolve the static archiver for this toolchain/host.
@@ -19,8 +19,8 @@
1919
## @note Missing archiver is fatal (`_bm_log_message(ARCHIVE FATAL …)`).
2020
## @note Safe to include from `cmake -P` scripts after `log.cmake` (the archive
2121
## helpers stub already does that).
22-
function(_bm_tools_archive_find out_path out_style)
23-
_bm_log_message(ARCHIVE LOWLEVEL "Entering _bm_tools_archive_find")
22+
function(_bm_component_archive_find out_path out_style)
23+
_bm_log_message(ARCHIVE LOWLEVEL "Entering _bm_component_archive_find")
2424
if(ARGC GREATER 2)
2525
set(_hint "${ARGV2}")
2626
else()
@@ -64,7 +64,7 @@ function(_bm_tools_archive_find out_path out_style)
6464

6565
if(_found STREQUAL "")
6666
_bm_log_message(ARCHIVE FATAL
67-
"_bm_tools_archive_find: no archiver found (CMAKE_AR, ENV{AR}, llvm-lib/lib, llvm-ar/gcc-ar/ar)")
67+
"_bm_component_archive_find: no archiver found (CMAKE_AR, ENV{AR}, llvm-lib/lib, llvm-ar/gcc-ar/ar)")
6868
endif()
6969

7070
get_filename_component(_name "${_found}" NAME)
@@ -79,5 +79,5 @@ function(_bm_tools_archive_find out_path out_style)
7979
_bm_log_message(ARCHIVE DEBUG "archiver=${_found} style=${_style}")
8080
set(${out_path} "${_found}" PARENT_SCOPE)
8181
set(${out_style} "${_style}" PARENT_SCOPE)
82-
_bm_log_message(ARCHIVE LOWLEVEL "Exiting _bm_tools_archive_find")
82+
_bm_log_message(ARCHIVE LOWLEVEL "Exiting _bm_component_archive_find")
8383
endfunction()
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# =============================================================================
2-
# tools/archive/helpers.cmake — include stub
2+
# component/archive/helpers.cmake — include stub
33
# =============================================================================
44
# Usable from configure-time helpers and from cmake -P scripts (pass
55
# BUILDMASTER_SRCDIR and include this file). Implementation lives next to
66
# this stub. Including strip_msvc_res.cmake is safe from other -P scripts
77
# because that file only runs its CLI body when it is the -P entry point.
88

99
if(DEFINED BUILDMASTER_SRCDIR AND EXISTS "${BUILDMASTER_SRCDIR}/log.cmake")
10-
include("${BUILDMASTER_SRCDIR}/log.cmake")
10+
include("${BUILDMASTER_SRCDIR}/log.cmake")
1111
elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../log.cmake")
12-
include("${CMAKE_CURRENT_LIST_DIR}/../../log.cmake")
12+
include("${CMAKE_CURRENT_LIST_DIR}/../../log.cmake")
1313
endif()
1414
if(COMMAND _bm_log_level_init)
15-
_bm_log_level_init()
15+
_bm_log_level_init()
1616
endif()
1717

1818
include("${CMAKE_CURRENT_LIST_DIR}/find_archiver.cmake")
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# =============================================================================
2-
# tools/archive/strip_msvc_res.cmake
2+
# component/archive/strip_msvc_res.cmake
33
# =============================================================================
4-
# Function: _bm_ar_strip_msvc_res(lib)
4+
# Function: _bm_component_archive_strip_msvc_res(lib)
55
# Script: cmake -DLIB=<archive.lib> -DBUILDMASTER_SRCDIR=<root>
6-
# [-DCMAKE_AR=…] -P tools/archive/strip_msvc_res.cmake
6+
# [-DCMAKE_AR=…] -P component/archive/strip_msvc_res.cmake
77
#
88
# After RENAME: list members of a static MSVC/clang-cl archive and
99
# /REMOVE every member whose basename ends in .res (case-insensitive).
1010
# Missing archive, non-msvc_lib archiver, empty list, or already-stripped
1111
# members are not fatal.
1212
#
13-
# This file is also included from tools/archive/helpers.cmake so install_exec
13+
# This file is also included from component/archive/helpers.cmake so install_exec
1414
# and other -P scripts can call the function. Script-mode body MUST only run
1515
# when *this* file is the -P entry point. CMAKE_SCRIPT_MODE_FILE is set for
1616
# *any* cmake -P (e.g. merge_static_archives.cmake); comparing against
@@ -27,13 +27,13 @@ if(NOT COMMAND buildmaster_message)
2727
endif()
2828
endif()
2929

30-
if(NOT COMMAND _bm_tools_archive_find)
30+
if(NOT COMMAND _bm_component_archive_find)
3131
include("${CMAKE_CURRENT_LIST_DIR}/find_archiver.cmake")
3232
endif()
3333

3434
## @brief Strip `*.res` members from one MSVC/clang-cl static archive.
3535
## @param[in] lib Absolute path to the `.lib` (canonical name, post-RENAME).
36-
## @note Resolves the archiver via `_bm_tools_archive_find`. If the style
36+
## @note Resolves the archiver via `_bm_component_archive_find`. If the style
3737
## is not `msvc_lib` (Unix `ar` / `llvm-ar`), this is a silent no-op.
3838
## @note Lists members with `/LIST`. A member is removed only when its
3939
## basename matches `*.res` / `*.RES` (case-insensitive). Paths such
@@ -42,27 +42,27 @@ endif()
4242
## @note `/REMOVE` uses the member string exactly as `/LIST` printed it.
4343
## @note Missing `lib`, failed `/LIST`, or failed `/REMOVE` of one member
4444
## do not abort the parent install (`WARNING` / `DEBUG` only).
45-
function(_bm_ar_strip_msvc_res lib)
46-
_bm_log_message(ARCHIVE LOWLEVEL "Entering _bm_ar_strip_msvc_res")
45+
function(_bm_component_archive_strip_msvc_res lib)
46+
_bm_log_message(ARCHIVE LOWLEVEL "Entering _bm_component_archive_strip_msvc_res")
4747
if("${lib}" STREQUAL "")
48-
_bm_log_message(ARCHIVE FATAL "_bm_ar_strip_msvc_res: empty lib path")
48+
_bm_log_message(ARCHIVE FATAL "_bm_component_archive_strip_msvc_res: empty lib path")
4949
endif()
5050

5151
if(NOT EXISTS "${lib}")
5252
_bm_log_message(ARCHIVE DEBUG "strip_msvc_res: missing ${lib} (skip)")
53-
_bm_log_message(ARCHIVE LOWLEVEL "Exiting _bm_ar_strip_msvc_res")
53+
_bm_log_message(ARCHIVE LOWLEVEL "Exiting _bm_component_archive_strip_msvc_res")
5454
return()
5555
endif()
5656

5757
set(_hint "")
5858
if(DEFINED CMAKE_AR AND NOT CMAKE_AR STREQUAL "")
5959
set(_hint "${CMAKE_AR}")
6060
endif()
61-
_bm_tools_archive_find(_bm_ar _bm_style "${_hint}")
61+
_bm_component_archive_find(_bm_ar _bm_style "${_hint}")
6262
if(NOT _bm_style STREQUAL "msvc_lib")
6363
_bm_log_message(ARCHIVE DEBUG
6464
"strip_msvc_res: archiver style '${_bm_style}' is not msvc_lib (skip)")
65-
_bm_log_message(ARCHIVE LOWLEVEL "Exiting _bm_ar_strip_msvc_res")
65+
_bm_log_message(ARCHIVE LOWLEVEL "Exiting _bm_component_archive_strip_msvc_res")
6666
return()
6767
endif()
6868

@@ -76,7 +76,7 @@ function(_bm_ar_strip_msvc_res lib)
7676
if(NOT _rc EQUAL 0)
7777
_bm_log_message(ARCHIVE WARNING
7878
"strip_msvc_res: /LIST failed on ${lib} (${_rc}): ${_err}")
79-
_bm_log_message(ARCHIVE LOWLEVEL "Exiting _bm_ar_strip_msvc_res")
79+
_bm_log_message(ARCHIVE LOWLEVEL "Exiting _bm_component_archive_strip_msvc_res")
8080
return()
8181
endif()
8282

@@ -112,7 +112,7 @@ function(_bm_ar_strip_msvc_res lib)
112112

113113
_bm_log_message(ARCHIVE DEBUG
114114
"strip_msvc_res: removed ${_removed} .res member(s) from ${lib}")
115-
_bm_log_message(ARCHIVE LOWLEVEL "Exiting _bm_ar_strip_msvc_res")
115+
_bm_log_message(ARCHIVE LOWLEVEL "Exiting _bm_component_archive_strip_msvc_res")
116116
endfunction()
117117

118118
if(CMAKE_SCRIPT_MODE_FILE AND CMAKE_SCRIPT_MODE_FILE STREQUAL CMAKE_CURRENT_LIST_FILE)
@@ -123,5 +123,5 @@ if(CMAKE_SCRIPT_MODE_FILE AND CMAKE_SCRIPT_MODE_FILE STREQUAL CMAKE_CURRENT_LIST
123123
message(FATAL_ERROR "strip_msvc_res: need -DLIB=")
124124
endif()
125125
endif()
126-
_bm_ar_strip_msvc_res("${LIB}")
126+
_bm_component_archive_strip_msvc_res("${LIB}")
127127
endif()

tools/bundle/merge_static_archives.cmake renamed to component/bundle/merge_static_archives.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ endforeach()
2929
get_filename_component(_out_dir "${OUTPUT}" DIRECTORY)
3030
file(MAKE_DIRECTORY "${_out_dir}")
3131

32-
include("${BUILDMASTER_SRCDIR}/tools/archive/helpers.cmake")
33-
_bm_tools_archive_find(_ar _style)
32+
include("${BUILDMASTER_SRCDIR}/component/archive/helpers.cmake")
33+
_bm_component_archive_find(_ar _style)
3434

3535
# Apple ar has no MRI (-M). Prefer libtool -static.
3636
if(APPLE)

component/helpers.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ include("${CMAKE_CURRENT_LIST_DIR}/toolchain_inherit.cmake")
2727
# Static archive merge (REPACK on buildmaster_meta).
2828
include("${CMAKE_CURRENT_LIST_DIR}/repack.cmake")
2929

30+
# Post-install helpers (were under tools/).
31+
include("${CMAKE_CURRENT_LIST_DIR}/archive/helpers.cmake")
32+
include("${CMAKE_CURRENT_LIST_DIR}/rename/variants.cmake")
33+
include("${CMAKE_CURRENT_LIST_DIR}/pkgconfig/helpers.cmake")
34+
3035
# Deferred materialize + fragment emit + finalize.
3136
include("${CMAKE_CURRENT_LIST_DIR}/materialize.cmake")
3237

component/materialize/fragment.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
## (`OUTPUT <file>` `DEPENDS` `<id>_install`) for each extra.
2323
## @note `_BM_STRIPRES_ENABLED` is `1` only for static mode when STRIPRES is on
2424
## (default ON). Shared/headers never strip; install_exec is a no-op there.
25-
## @note `_BM_PC_*` comes from `_bm_pc_fill_vars` (tools/pkgconfig).
26-
## ENABLED is `1` only when `PC={…}` is on and not BUILDONLY (already FATAL
27-
## at _bm_graph_create).
25+
## @note `_BM_PC_*` comes from `_bm_component_pkgconfig_fill_vars`
26+
## (`component/pkgconfig`). ENABLED is `1` only when `PC={…}` is on and
27+
## not BUILDONLY (already FATAL at _bm_graph_create).
2828
function(_bm_materialize_collect_outputs _component)
2929
_bm_log_message(COMPONENT LOWLEVEL "Entering _bm_materialize_collect_outputs")
3030
get_property(_library_mode GLOBAL PROPERTY BUILDMASTER_COMPONENT_${_component}_MODE)
@@ -58,7 +58,7 @@ function(_bm_materialize_collect_outputs _component)
5858
set(_BM_STRIPRES_ENABLED "0")
5959
endif()
6060

61-
_bm_pc_fill_vars("${_component}")
61+
_bm_component_pkgconfig_fill_vars("${_component}")
6262

6363
set(_LIBRARY_COMPONENT_NAMES "")
6464
set(_LIBRARY_COMPONENT_FILES "")
@@ -302,7 +302,7 @@ function(_bm_materialize_write_fragment _component _deferred)
302302
VERBATIM
303303
)
304304
_bm_log_message(COMPONENT DEBUG
305-
"Ninja file rule for spec-link '${_file}' via '${_component}_install'")
305+
"Ninja file rule for spec-link '${_file}' via '${_component}_install")
306306
endforeach()
307307
endif()
308308

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# =============================================================================
2-
# tools/pkgconfig/fields.cmake — helper .pc field assembly
2+
# component/pkgconfig/fields.cmake — helper .pc field assembly
33
# =============================================================================
44

55
## @brief Drop include-path tokens from a flag string.
66
## @param[in] flags Space-separated compiler flags.
77
## @param[out] out_var Parent-scope string without `-I`, `/I`, `-isystem`.
88
## @note Those paths belong to the BM prefix env, not to a helper .pc.
99
## @note Empty `flags` yields an empty string.
10-
function(_bm_pc_drop_include_tokens flags out_var)
11-
_bm_log_message(COMPONENT LOWLEVEL "Entering _bm_pc_drop_include_tokens")
10+
function(_bm_component_pkgconfig_drop_include_tokens flags out_var)
11+
_bm_log_message(COMPONENT LOWLEVEL "Entering _bm_component_pkgconfig_drop_include_tokens")
1212
set(_keep "")
1313
separate_arguments(_toks UNIX_COMMAND "${flags}")
1414
foreach(_t IN LISTS _toks)
@@ -23,16 +23,16 @@ function(_bm_pc_drop_include_tokens flags out_var)
2323
string(REPLACE ";" " " _joined "${_keep}")
2424
string(STRIP "${_joined}" _joined)
2525
set(${out_var} "${_joined}" PARENT_SCOPE)
26-
_bm_log_message(COMPONENT LOWLEVEL "Exiting _bm_pc_drop_include_tokens")
26+
_bm_log_message(COMPONENT LOWLEVEL "Exiting _bm_component_pkgconfig_drop_include_tokens")
2727
endfunction()
2828

2929
## @brief Tokens in `child` that are not in `parent`.
3030
## @param[in] parent Parent job flags (space-separated).
3131
## @param[in] child Component flags (space-separated).
3232
## @param[out] out_var Parent-scope leftover string.
3333
## @note Comparison is exact token match after `separate_arguments`.
34-
function(_bm_pc_subtract_parent parent child out_var)
35-
_bm_log_message(COMPONENT LOWLEVEL "Entering _bm_pc_subtract_parent")
34+
function(_bm_component_pkgconfig_subtract_parent parent child out_var)
35+
_bm_log_message(COMPONENT LOWLEVEL "Entering _bm_component_pkgconfig_subtract_parent")
3636
separate_arguments(_p UNIX_COMMAND "${parent}")
3737
separate_arguments(_c UNIX_COMMAND "${child}")
3838
set(_out "")
@@ -52,16 +52,16 @@ function(_bm_pc_subtract_parent parent child out_var)
5252
string(REPLACE ";" " " _joined "${_out}")
5353
string(STRIP "${_joined}" _joined)
5454
set(${out_var} "${_joined}" PARENT_SCOPE)
55-
_bm_log_message(COMPONENT LOWLEVEL "Exiting _bm_pc_subtract_parent")
55+
_bm_log_message(COMPONENT LOWLEVEL "Exiting _bm_component_pkgconfig_subtract_parent")
5656
endfunction()
5757

5858
## @brief Pull C/C++ flag strings out of a component option list.
5959
## @param[in] options Semicolon list (`-DCMAKE_C_FLAGS=…`, `-Dc_args=…`, …).
6060
## @param[out] out_var Parent-scope combined flag string.
6161
## @note Recognized prefixes: `-DCMAKE_C_FLAGS=`, `-DCMAKE_CXX_FLAGS=`,
6262
## `-Dc_args=`, `-Dcpp_args=`. Other options are ignored.
63-
function(_bm_pc_options_flags options out_var)
64-
_bm_log_message(COMPONENT LOWLEVEL "Entering _bm_pc_options_flags")
63+
function(_bm_component_pkgconfig_options_flags options out_var)
64+
_bm_log_message(COMPONENT LOWLEVEL "Entering _bm_component_pkgconfig_options_flags")
6565
set(_acc "")
6666
foreach(_opt IN LISTS options)
6767
if(_opt MATCHES "^-DCMAKE_C_FLAGS=(.*)$")
@@ -76,10 +76,10 @@ function(_bm_pc_options_flags options out_var)
7676
endforeach()
7777
string(STRIP "${_acc}" _acc)
7878
set(${out_var} "${_acc}" PARENT_SCOPE)
79-
_bm_log_message(COMPONENT LOWLEVEL "Exiting _bm_pc_options_flags")
79+
_bm_log_message(COMPONENT LOWLEVEL "Exiting _bm_component_pkgconfig_options_flags")
8080
endfunction()
8181

82-
## @brief Fill `_BM_PC_*` for `install_exec` / `_bm_tools_*_stages`.
82+
## @brief Fill `_BM_PC_*` for `install_exec` / create_*_stages.
8383
## @param[in] id Registered component id.
8484
## @note Parent-scope: `_BM_PC_ENABLED` (`1`/`0`), `_BM_PC_NAME`,
8585
## `_BM_PC_VERSION`, `_BM_PC_DESCRIPTION`, `_BM_PC_LIBS`,
@@ -88,8 +88,8 @@ endfunction()
8888
## components with PC enabled (not metas). Cflags are component
8989
## extras minus parent `CMAKE_C{,XX}_FLAGS`, minus include tokens.
9090
## @note When PC is off, all string outs are empty and ENABLED is `0`.
91-
function(_bm_pc_fill_vars id)
92-
_bm_log_message(COMPONENT LOWLEVEL "Entering _bm_pc_fill_vars")
91+
function(_bm_component_pkgconfig_fill_vars id)
92+
_bm_log_message(COMPONENT LOWLEVEL "Entering _bm_component_pkgconfig_fill_vars")
9393
get_property(_on GLOBAL PROPERTY BUILDMASTER_COMPONENT_${id}_PC)
9494
if(NOT _on)
9595
set(_BM_PC_ENABLED "0" PARENT_SCOPE)
@@ -100,7 +100,7 @@ function(_bm_pc_fill_vars id)
100100
set(_BM_PC_REQUIRES "" PARENT_SCOPE)
101101
set(_BM_PC_CFLAGS "" PARENT_SCOPE)
102102
set(_BM_PC_OUT "" PARENT_SCOPE)
103-
_bm_log_message(COMPONENT LOWLEVEL "Exiting _bm_pc_fill_vars")
103+
_bm_log_message(COMPONENT LOWLEVEL "Exiting _bm_component_pkgconfig_fill_vars")
104104
return()
105105
endif()
106106

@@ -153,10 +153,10 @@ function(_bm_pc_fill_vars id)
153153
endif()
154154
string(REPLACE ";" ", " _req "${_req}")
155155

156-
_bm_pc_options_flags("${_opts}" _child_flags)
156+
_bm_component_pkgconfig_options_flags("${_opts}" _child_flags)
157157
set(_parent_flags "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
158-
_bm_pc_subtract_parent("${_parent_flags}" "${_child_flags}" _delta)
159-
_bm_pc_drop_include_tokens("${_delta}" _cflags)
158+
_bm_component_pkgconfig_subtract_parent("${_parent_flags}" "${_child_flags}" _delta)
159+
_bm_component_pkgconfig_drop_include_tokens("${_delta}" _cflags)
160160

161161
set(_out "${BUILDMASTER_INSTALL_LIBDIR}/pkgconfig/${_name}.pc")
162162

@@ -169,5 +169,5 @@ function(_bm_pc_fill_vars id)
169169
set(_BM_PC_CFLAGS "${_cflags}" PARENT_SCOPE)
170170
set(_BM_PC_OUT "${_out}" PARENT_SCOPE)
171171
_bm_log_message(COMPONENT DEBUG "PC fields for ${id}: ${_name} ${_ver}${_out}")
172-
_bm_log_message(COMPONENT LOWLEVEL "Exiting _bm_pc_fill_vars")
172+
_bm_log_message(COMPONENT LOWLEVEL "Exiting _bm_component_pkgconfig_fill_vars")
173173
endfunction()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# =============================================================================
2-
# tools/pkgconfig/helpers.cmake — include stub only
2+
# component/pkgconfig/helpers.cmake — include stub only
33
# =============================================================================
44

55
include("${CMAKE_CURRENT_LIST_DIR}/../../log.cmake")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# =============================================================================
2-
# tools/pkgconfig/write_pc.cmake
2+
# component/pkgconfig/write_pc.cmake
33
# =============================================================================
44
# cmake -DPC_NAME= -DPC_VERSION= -DPC_DESCRIPTION= -DPC_LIBS=
55
# -DPC_REQUIRES= -DPC_CFLAGS= -DPREFIX= -DLIBDIR= -DINCLUDEDIR=

0 commit comments

Comments
 (0)