Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#31899: cmake: Exclude generated sources from tr…
Browse files Browse the repository at this point in the history
…anslation

ff4ddd3 Revert "cmake: Ensure generated sources are up to date for `translate` target" (Hennadii Stepanov)
03b3166 cmake: Exclude generated sources from translation (Hennadii Stepanov)

Pull request description:

  This PR fixes an error encountered when building the `translate` target:
  ```
  $ gmake -j $(nproc) -C depends MULTIPROCESS=1
  $ cmake -G "Unix Makefiles" --preset dev-mode --toolchain depends/x86_64-pc-linux-gnu/toolchain.cmake -DWITH_USDT=OFF
  $ cmake --build build_dev_mode -t translate
  gmake[3]: *** No rule to make target 'src/test/ipc_test.capnp.c++', needed by 'src/qt/CMakeFiles/translate'. Stop.
  gmake[2]: *** [CMakeFiles/Makefile2:1646: src/qt/CMakeFiles/translate.dir/all] Error 2
  gmake[1]: *** [CMakeFiles/Makefile2:1653: src/qt/CMakeFiles/translate.dir/rule] Error 2
  gmake: *** [Makefile:699: translate] Error 2
  ```

  The previous [attempt](bitcoin/bitcoin@864386a) to address this issue worked only with Ninja generators and has been reverted.

  Essentially, this PR modifies the `translate` target so that it ignores generated sources rather than attempting to update them.

  At present, multiprocess-specific sources do not contain any translatable strings. Nonetheless, it is prudent to maintain a general approach.

ACKs for top commit:
  TheCharlatan:
    ACK ff4ddd3
  pablomartin4btc:
    tACK ff4ddd3

Tree-SHA512: 6471498a33b145e073f76bd007591b0449e5d520f141c3e3afeca02a09c160fd0f572ec7172dd84703cdc2a1175ad8f3c91e8b0bf705d671338d760786765f56
  • Loading branch information
fanquake committed Feb 19, 2025
2 parents fd14995 + ff4ddd3 commit e606c57
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,13 @@ function(get_translatable_sources var)
get_target_property(target_source_dir ${target} SOURCE_DIR)
cmake_path(APPEND target_source_dir ${source} OUTPUT_VARIABLE source)
endif()
list(APPEND result ${source})
get_property(is_generated
SOURCE ${source} TARGET_DIRECTORY ${target}
PROPERTY GENERATED
)
if(NOT is_generated)
list(APPEND result ${source})
endif()
endforeach()
endif()
endforeach()
Expand Down Expand Up @@ -319,7 +325,6 @@ else()
COMMAND Qt5::lconvert -drop-translations -o ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.xlf -i ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.ts
COMMAND ${SED_EXECUTABLE} -i.old -e "s|source-language=\"en\" target-language=\"en\"|source-language=\"en\"|" -e "/<target xml:space=\"preserve\"><\\/target>/d" ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.xlf
COMMAND ${CMAKE_COMMAND} -E rm ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.xlf.old
DEPENDS ${translatable_sources}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
VERBATIM
)
Expand Down

0 comments on commit e606c57

Please sign in to comment.