-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[Offload] Don't check in generated files #141982
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,46 @@ | ||
| # The OffloadGenerate target is used to regenerate the generated files in the | ||
| # include directory. These files are checked in with the rest of the source, | ||
| # therefore it is only needed when making changes to the API. | ||
| # We want to clang-format the generated files if possible, since OffloadAPI.h is | ||
| # the main public header for liboffload. Generate them in a temporary location, | ||
| # then clang-format and copy them to the proper location. If clang-format is | ||
| # missing just copy them. | ||
| # Ideally we'd just clang-format them in place and avoid the copy but cmake | ||
| # gets confused about the same path being a byproduct of two custom commands. | ||
|
|
||
| find_program(CLANG_FORMAT clang-format PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) | ||
| if (CLANG_FORMAT) | ||
| set(LLVM_TARGET_DEFINITIONS ${CMAKE_CURRENT_SOURCE_DIR}/OffloadAPI.td) | ||
| set(LLVM_TARGET_DEFINITIONS ${CMAKE_CURRENT_SOURCE_DIR}/OffloadAPI.td) | ||
| set(files_to_copy "") | ||
|
|
||
| tablegen(OFFLOAD OffloadAPI.h -gen-api) | ||
| tablegen(OFFLOAD OffloadEntryPoints.inc -gen-entry-points) | ||
| tablegen(OFFLOAD OffloadFuncs.inc -gen-func-names) | ||
| tablegen(OFFLOAD OffloadImplFuncDecls.inc -gen-impl-func-decls) | ||
| tablegen(OFFLOAD OffloadPrint.hpp -gen-print-header) | ||
| tablegen(OFFLOAD OffloadErrcodes.inc -gen-errcodes) | ||
| macro(offload_tablegen file) | ||
| tablegen(OFFLOAD generated/${file}.gen ${ARGN}) | ||
| list(APPEND files_to_copy ${file}) | ||
| endmacro() | ||
|
|
||
| set(FILES_TO_COPY "OffloadAPI.h;OffloadEntryPoints.inc;OffloadFuncs.inc;OffloadImplFuncDecls.inc;OffloadPrint.hpp") | ||
| set(GEN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include/generated) | ||
| add_public_tablegen_target(OffloadGenerate) | ||
| add_custom_command(TARGET OffloadGenerate POST_BUILD COMMAND ${CLANG_FORMAT} | ||
| -i ${TABLEGEN_OUTPUT}) | ||
| add_custom_command(TARGET OffloadGenerate POST_BUILD COMMAND ${CMAKE_COMMAND} | ||
| -E copy_if_different ${FILES_TO_COPY} ${GEN_DIR}) | ||
| add_custom_command(TARGET OffloadGenerate POST_BUILD COMMAND ${CMAKE_COMMAND} | ||
| -E copy_if_different OffloadErrcodes.inc "${LIBOMPTARGET_INCLUDE_DIR}/Shared/OffloadErrcodes.inc") | ||
| offload_tablegen(OffloadAPI.h -gen-api) | ||
| offload_tablegen(OffloadEntryPoints.inc -gen-entry-points) | ||
| offload_tablegen(OffloadFuncs.inc -gen-func-names) | ||
| offload_tablegen(OffloadImplFuncDecls.inc -gen-impl-func-decls) | ||
| offload_tablegen(OffloadPrint.hpp -gen-print-header) | ||
|
|
||
| add_public_tablegen_target(OffloadGenerate) | ||
|
|
||
| add_custom_target(OffloadAPI DEPENDS OffloadGenerate) | ||
| find_program(clang_format clang-format PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) | ||
| if (clang_format) | ||
| foreach(file IN LISTS files_to_copy) | ||
| add_custom_command( | ||
| OUTPUT ${file} | ||
| COMMAND ${clang_format} -i generated/${file}.gen | ||
| COMMAND ${CMAKE_COMMAND} -E copy_if_different generated/${file}.gen ${CMAKE_CURRENT_BINARY_DIR}/${file} | ||
| DEPENDS generated/${file}.gen | ||
| ) | ||
| add_custom_target(OffloadAPI.${file} DEPENDS ${file}) | ||
| add_dependencies(OffloadAPI OffloadAPI.${file}) | ||
| endforeach() | ||
| else() | ||
| message(WARNING "clang-format was not found, so the OffloadGenerate target\ | ||
| will not be available. Offload will still build, but you will not be\ | ||
| able to make changes to the API.") | ||
| message(WARNING "clang-format not found, the generated Offload API headers will not be formatted") | ||
| foreach(file IN LISTS files_to_copy) | ||
| add_custom_command( | ||
| OUTPUT ${file} | ||
| COMMAND ${CMAKE_COMMAND} -E copy_if_different generated/${file}.gen ${CMAKE_CURRENT_BINARY_DIR}/${file} | ||
| DEPENDS generated/${file}.gen | ||
| ) | ||
| endforeach() | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it still find the error codes? Those were in
shared/because it needs to be used by the plugins as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it seems to work fine, the
${CMAKE_CURRENT_BINARY_DIR}/../includeline below means it findsShared/OffloadErrcodes.incThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I do wonder if it should be getting the dependency on the shared header from the plugins themselves rather than libomptarget
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a missing dependency between liboffload and the LibomptargetOffloadErrcodes target, I've fixed that now