Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Add support for extra dependencies to messages ids check function and make odb and cts use it #6468

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/cmake/messages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@
# SOURCE_DIR <dir>: the directory to search for sources from
# [defaults to OUTPUT_DIR]
# LOCAL: don't recurse [defaults to false]
# DEPENDS: <dep1 ...>: Add extra dependencies [optional]

function(messages)

# Parse args
set(options LOCAL)
set(oneValueArgs TARGET OUTPUT_DIR SOURCE_DIR)
set(multiValueArgs "")
set(multiValueArgs DEPENDS)

cmake_parse_arguments(
ARG # prefix on the parsed args
Expand All @@ -72,8 +73,10 @@ function(messages)

if (DEFINED ARG_OUTPUT_DIR)
set(OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_OUTPUT_DIR})
set(OUTPUT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OUTPUT_DIR})
else()
set(OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(OUTPUT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()

if (DEFINED ARG_SOURCE_DIR)
Expand All @@ -86,12 +89,27 @@ function(messages)
set(local '--local')
endif()

add_custom_command(
TARGET ${ARG_TARGET}
POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/etc/find_messages.py
if (NOT DEFINED ARG_DEPENDS)
add_custom_command(
TARGET ${ARG_TARGET}
POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/etc/find_messages.py
${local}
> ${OUTPUT_DIR}/messages.txt
WORKING_DIRECTORY ${SOURCE_DIR}
)
WORKING_DIRECTORY ${SOURCE_DIR}
)
else()
add_custom_command(
OUTPUT messages_checked
COMMAND ${CMAKE_SOURCE_DIR}/etc/find_messages.py
${local}
> ${OUTPUT_DIR}/messages.txt
&& touch ${OUTPUT_BUILD_DIR}/messages_checked
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need messages_checked ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed for odb as it is an interface library without physical target file as explained in #5704 (comment).
Maybe it's not needed for non interface library. I'll check.

Copy link
Contributor Author

@titan73 titan73 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't get dependencies to work for a non interface library. Adding a DEPENDS argument does not change anything.

    add_custom_command(
      TARGET ${ARG_TARGET}
      POST_BUILD
      COMMAND ${CMAKE_SOURCE_DIR}/etc/find_messages.py
        ${local}
        > ${OUTPUT_DIR}/messages.txt
      WORKING_DIRECTORY ${SOURCE_DIR}
      DEPENDS ${ARG_DEPENDS}
    )

So we have to rely on the intermediate file messages_check as done for interface libraries like odb.

WORKING_DIRECTORY ${SOURCE_DIR}
DEPENDS ${ARG_DEPENDS}
)
add_custom_target(${ARG_TARGET}_messages DEPENDS messages_checked)
add_dependencies(${ARG_TARGET} ${ARG_TARGET}_messages)
endif()

endfunction()
1 change: 1 addition & 0 deletions src/cts/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ target_link_libraries(cts
messages(
TARGET cts
OUTPUT_DIR ..
DEPENDS cts_lib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be needed on every tool?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should automate it in the cmake so the clients don't need to specify it or add it as needed in the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to automate it for #5704 but didn't end up with something very clean.
I'll give another try. Thanks for the review.

Copy link
Contributor Author

@titan73 titan73 Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a patch to detect dependencies within tools module.
Here are the detected dependencies for all tools:

odb: db;cdl;defin;defout;lefin;lefout;zutil;gdsin;gdsout
dbSta: dbSta_lib
rsz: rsz_lib
stt: stt_lib
dpl: dpl_lib
ppl: Munkres
cts: cts_lib
grt: grt_lib;FastRoute4.1
mpl: ParquetFP
rcx: rcx_lib
ant: ant_lib
utl: utl_lib
dft: dft_cells_lib;dft_architect_lib;dft_config_lib;dft_replace_lib;dft_clock_domain_lib;dft_utils_lib;dft_stitch_lib

All the related files triggers the messages ids checking now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any news on this PR?

)

if (Python3_FOUND AND BUILD_PYTHON)
Expand Down
10 changes: 2 additions & 8 deletions src/odb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ if(ENABLE_TESTS)
)
endif()

add_custom_command(
OUTPUT messages_checked
COMMAND ${CMAKE_SOURCE_DIR}/etc/find_messages.py > messages.txt && touch ${CMAKE_CURRENT_BINARY_DIR}/messages_checked
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
messages(
TARGET odb
DEPENDS
db
cdl
Expand All @@ -99,7 +97,3 @@ add_custom_command(
gdsin
gdsout
)

add_custom_target(odb_messages DEPENDS messages_checked)

add_dependencies(odb odb_messages)
Loading