Skip to content

Commit 79ad1bf

Browse files
authored
[MLIR][Python] quiet stubgen (llvm#160368)
Silence all stdout from stubgen unless `VERBOSE` is passed to `mlir_generate_type_stubs`.
1 parent 7be3c3a commit 79ad1bf

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

mlir/cmake/modules/AddMLIRPython.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ endfunction()
113113
# DEPENDS_TARGET_SRC_DEPS: List of cpp sources for extension library (for generating a DEPFILE).
114114
# IMPORT_PATHS: List of paths to add to PYTHONPATH for stubgen.
115115
# PATTERN_FILE: (Optional) Pattern file (see https://nanobind.readthedocs.io/en/latest/typing.html#pattern-files).
116+
# VERBOSE: Emit logging/status messages during stub generation (default: OFF).
116117
# Outputs:
117118
# NB_STUBGEN_CUSTOM_TARGET: The target corresponding to generation which other targets can depend on.
118119
function(mlir_generate_type_stubs)
119120
cmake_parse_arguments(ARG
120-
""
121+
"VERBOSE"
121122
"MODULE_NAME;OUTPUT_DIR;PATTERN_FILE"
122123
"IMPORT_PATHS;DEPENDS_TARGETS;OUTPUTS;DEPENDS_TARGET_SRC_DEPS"
123124
${ARGN})
@@ -152,6 +153,9 @@ function(mlir_generate_type_stubs)
152153
--include-private
153154
--output-dir
154155
"${ARG_OUTPUT_DIR}")
156+
if(NOT ARG_VERBOSE)
157+
list(APPEND _nb_stubgen_cmd "--quiet")
158+
endif()
155159
if(ARG_PATTERN_FILE)
156160
list(APPEND _nb_stubgen_cmd "-p;${ARG_PATTERN_FILE}")
157161
list(APPEND ARG_DEPENDS_TARGETS "${ARG_PATTERN_FILE}")
@@ -166,7 +170,9 @@ function(mlir_generate_type_stubs)
166170
file(GENERATE OUTPUT "${_depfile}" CONTENT "${_depfiles}")
167171
endif()
168172

169-
message(DEBUG "Generating type-stubs outputs ${_generated_type_stubs}")
173+
if(ARG_VERBOSE)
174+
message(STATUS "Generating type-stubs outputs ${_generated_type_stubs}")
175+
endif()
170176
add_custom_command(
171177
OUTPUT ${_generated_type_stubs}
172178
COMMAND ${_nb_stubgen_cmd}

mlir/examples/standalone/python/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ if(NOT EXTERNAL_PROJECT_BUILD)
9292
OUTPUTS "${_core_type_stub_sources}"
9393
DEPENDS_TARGET_SRC_DEPS "${_core_extension_srcs}"
9494
IMPORT_PATHS "${StandalonePythonModules_ROOT_PREFIX}/_mlir_libs"
95+
VERBOSE
9596
)
9697
set(_mlir_typestub_gen_target "${NB_STUBGEN_CUSTOM_TARGET}")
9798

0 commit comments

Comments
 (0)