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

[vcpkg scripts] Use ninja from vcpkg fetch #43309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Neumann-A
Copy link
Contributor

No description provided.

endif()
if(NOT NINJA)
vcpkg_execute_in_download_mode(
COMMAND "$ENV{VCPKG_COMMAND}" fetch ninja
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could also be:

Suggested change
COMMAND "$ENV{VCPKG_COMMAND}" fetch ninja
COMMAND "$ENV{VCPKG_COMMAND}" fetch "${program_name}"

if we want to generalize this pattern somehow?

Comment on lines +2 to +10
if(NOT NINJA)
vcpkg_execute_in_download_mode(
COMMAND "$ENV{VCPKG_COMMAND}" fetch ninja
RESULT_VARIABLE error_code
OUTPUT_VARIABLE NINJA
WORKING_DIRECTORY "${DOWNLOADS}"
)
string(STRIP "${NINJA}" NINJA)
set(NINJA "${NINJA}" CACHE STRING "" FORCE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't testing and setting NINJA the responsibility of the vfap.cmake script?
Should this script just return the directory in paths_to_search?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't testing and setting NINJA the responsibility of the vfap.cmake script?

In general yes but:

  • vcpkg fetch ninja should always return the correct minimum version -> see CMake
  • NINJA needs to be overwritable by the user from a triplet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't testing and setting NINJA the responsibility of the vfap.cmake script?

In general yes but:

  • vcpkg fetch ninja should always return the correct minimum version -> see CMake

This is vcpkg fetch responsibility now, and it works AFAICS on my computer.

  • NINJA needs to be overwritable by the user from a triplet.

It is AFAICS.

function(vcpkg_find_acquire_program program)
if(${program})
return()
endif()

These per-program scripts are really meant to just provide the most specific part of the implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These per-program scripts are really meant to just provide the most specific part of the implementation.

So you want:

vcpkg_execute_in_download_mode(
    COMMAND "$ENV{VCPKG_COMMAND}" fetch ninja
    RESULT_VARIABLE error_code
    OUTPUT_VARIABLE NINJA
    WORKING_DIRECTORY "${DOWNLOADS}"
)
string(STRIP "${NINJA}" NINJA)
set(NINJA "${NINJA}" CACHE STRING "" FORCE)
return() # so that the rest of vcpkg_find_acquire_program is not executed. 

?

or even

set(program_name ninja)
set(use_vcpkg_fetch ON)

some impl. doing vcpkg fetch in vcpkg_find_acquire_program?

I don't see a reason to do the last one yet.

I mean the only goal here is to not duplicate the ninja information and keep vcpkg_find_acquire_program(NINJA) intact.

Copy link
Contributor

Choose a reason for hiding this comment

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

More like

set(program_name ninja)
vcpkg_execute_in_download_mode(
    COMMAND "$ENV{VCPKG_COMMAND}" fetch ninja
    RESULT_VARIABLE error_code
    OUTPUT_VARIABLE ninja
    OUTPUT_STRIP_TRAILING_WHITESPACE
    WORKING_DIRECTORY "${DOWNLOADS}"
)
cmake_path(GET ninja PARENT_PATH paths_to_search)

but I see that we already have the ultimate NINJA at that point. It is just that it is not clear from which scope we would be return()ing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is just that it is not clear from which scope we would be return()ing.

The return is actually not needed. Just an unnecessary early return, so we could go without it.

@JonLiu1993 JonLiu1993 changed the title Use ninja from vcpkg fetch [vcpkg scripts] Use ninja from vcpkg fetch Jan 17, 2025
@JonLiu1993 JonLiu1993 added the category:tool-update The issue is with build tool or build script, which requires update or should be executed correctly label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:tool-update The issue is with build tool or build script, which requires update or should be executed correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants