Skip to content

Commit b2b553f

Browse files
matteodgcursoragent
andcommitted
wip! Print hdf5_h_2.java and SYMBOL_LOOKUP debug output when the jextract needle patch fails so macOS CI logs can be used to update needle-macos.txt.
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 6031e92 commit b2b553f

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

java/CMakeLists.txt

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,49 @@ if (Java_VERSION_STRING VERSION_GREATER_EQUAL "25.0.0")
242242
endif ()
243243
endforeach ()
244244
if (NOT _HDF5_h2_patched)
245+
set (_HDF5_HDF5_H_2_LEGACY "${JEXTRACT_OUTPUT_DIR}/org/hdfgroup/javahdf5/hdf5_h_2.java")
246+
if (EXISTS "${_HDF5_HDF5_H_2_LEGACY}")
247+
file (READ "${_HDF5_HDF5_H_2_LEGACY}" _HDF5_h2_legacy_head LIMIT 8192)
248+
string (REPLACE "\r\n" "\n" _HDF5_h2_legacy_head "${_HDF5_h2_legacy_head}")
249+
message (
250+
STATUS
251+
"FFM jextract patch debug: beginning of hdf5_h_2.java "
252+
"(use to update needle-macos.txt on macOS if needed):\n"
253+
"${_HDF5_h2_legacy_head}"
254+
)
255+
else ()
256+
message (
257+
STATUS
258+
"FFM jextract patch debug: hdf5_h_2.java not found at "
259+
"${_HDF5_HDF5_H_2_LEGACY}"
260+
)
261+
endif ()
262+
file (READ "${_HDF5_HDF5_H_2}" _HDF5_h2_patch_head LIMIT 8192)
263+
string (REPLACE "\r\n" "\n" _HDF5_h2_patch_head "${_HDF5_h2_patch_head}")
264+
message (
265+
STATUS
266+
"FFM jextract patch debug: beginning of patch target "
267+
"${_HDF5_HDF5_H_2}:\n${_HDF5_h2_patch_head}"
268+
)
269+
string (
270+
FIND "${_HDF5_h2_src}"
271+
"static final SymbolLookup SYMBOL_LOOKUP"
272+
_HDF5_h2_lookup_pos
273+
)
274+
if (NOT _HDF5_h2_lookup_pos EQUAL -1)
275+
string (SUBSTRING "${_HDF5_h2_src}" ${_HDF5_h2_lookup_pos} 600 _HDF5_h2_lookup_snippet)
276+
message (
277+
STATUS
278+
"FFM jextract patch debug: SYMBOL_LOOKUP block from patch target "
279+
"(exact needle candidate):\n${_HDF5_h2_lookup_snippet}"
280+
)
281+
endif ()
245282
message (
246283
FATAL_ERROR
247284
"Post-jextract patch of ${_HDF5_HDF5_H_2} failed (needle not found). "
248285
"jextract output may have changed; update a platform needle under "
249-
"${_HDF5_FFM_JEXTRACT_PATCH_DIR}."
286+
"${_HDF5_FFM_JEXTRACT_PATCH_DIR}. See STATUS lines above for "
287+
"hdf5_h_2.java / SYMBOL_LOOKUP debug output."
250288
)
251289
endif ()
252290
message (STATUS "Patched ${_HDF5_HDF5_H_2} using ${_HDF5_h2_needle_used}")

java/cmake/ffm-jextract-hdf5_h_2/README.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ replacement.txt — shared patched block (createHdf5SymbolLookup + helpers).
1111
CMake picks the first hdf5_h*.java that contains SYMBOL_LOOKUP (jextract may
1212
place it in hdf5_h_2, hdf5_h_3, etc. depending on declaration split count),
1313
then tries the host OS needle first and falls back to the other platform needles.
14+
If the patch fails, CMake prints STATUS debug lines with the beginning of
15+
hdf5_h_2.java and the SYMBOL_LOOKUP block from the patch target so macOS CI
16+
logs can be used to update needle-macos.txt.
1417
If jextract changes its emitted SYMBOL_LOOKUP block, update the matching
1518
needle-*.txt and keep replacement.txt semantically in sync.

0 commit comments

Comments
 (0)