Skip to content

Commit

Permalink
Differentiate between resolve_buck failing due to bad buck version an…
Browse files Browse the repository at this point in the history
…d failing from unexpected error (#2696)

Summary: Pull Request resolved: #2696

Differential Revision: D55391962

Pulled By: GregoryComer
  • Loading branch information
GregoryComer authored and facebook-github-bot committed Mar 26, 2024
1 parent 265a5e8 commit cf7cee3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
17 changes: 13 additions & 4 deletions build/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,22 @@ function(resolve_buck2)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE)

message("${resolve_buck2_exit_code}")

if(resolve_buck2_exit_code EQUAL 0)
set(BUCK2 ${resolve_buck2_output} PARENT_SCOPE)
message(STATUS "Resolved buck2 as ${resolve_buck2_output}.")
else()
elseif(resolve_buck2_exit_code EQUAL 2)
# Wrong buck version used. Stop here to ensure that the user sees
# the error.
message(FATAL_ERROR "Failed to resolve buck2.")
message(FATAL_ERROR ${resolve_buck2_error})
message(FATAL_ERROR "Failed to resolve buck2.\n${resolve_buck2_error}")
else()
# Unexpected failure of the script. Warn.
message(WARNING "Failed to resolve buck2.")
message(WARNING "${resolve_buck2_error}")

if("${BUCK2}" STREQUAL "")
set(BUCK2 "buck2" PARENT_SCOPE)
endif()
endif()
endfunction()
endfunction()
6 changes: 4 additions & 2 deletions build/resolve_buck.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ def resolve_buck2(args: argparse.Namespace) -> Union[str, int]:
)

# Return an error, since the build will fail later. This lets us
# give the user a more useful error message.
return -1
# give the user a more useful error message. Note that an exit
# code of 2 allows us to distinguish from an unexpected error,
# such as a failed import, which exits with 1.
return 2
else:
# Look for system buck2 and check version. Note that this can return
# None.
Expand Down

0 comments on commit cf7cee3

Please sign in to comment.