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

[execute_process] Don't strip embedded semicolons #12926

Merged
merged 30 commits into from
Sep 9, 2020

Conversation

jgehw
Copy link
Contributor

@jgehw jgehw commented Aug 15, 2020

The existing implementation totally screwed up commands if the command's arguments contained semicolons (this is the case, e.g., in the FindPython modules of the cmake distribution).

Fixes #12922.

The existing implementation totally screwed up commands if the command's arguments contained semicolons (this is the case, e.g., in the FindPython modules of the cmake distribution).
@jgehw
Copy link
Contributor Author

jgehw commented Aug 17, 2020

Added support for execute_process with multiple COMMANDs as there actually are use cases in both vcpkg itself and some ports.

incorporate changes from microsoft:master
@JackBoosY JackBoosY added category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) requires:discussion labels Aug 18, 2020
@@ -13,8 +13,75 @@ if (NOT DEFINED OVERRIDEN_EXECUTE_PROCESS)
message(FATAL_ERROR "This command cannot be executed in Download Mode.\nHalting portfile execution.\n")
endmacro()
else()
Copy link
Member

@BillyONeal BillyONeal Aug 20, 2020

Choose a reason for hiding this comment

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

In this else case could we just do nothing (and leave the default execute_process) instead? We are concerned about changes to execute_process in differing versions of cmake and emulating all such behaviors correctly.

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 must admit I couldn't imagine that just leaving away the else case could work. But as I understand your concerns, I just verified it, to make sure we didn't miss such an easy solution. The result is: no. vcpkg then fails already at a very early stage when detecting the compiler hash:
[DEBUG] CreateProcessW("C:\Program Files\CMake\bin\cmake.exe" -DCURRENT_PORT_DIR=C:/work/tools/vcpkg/scripts/detect_compiler -DCURRENT_BUILDTREES_DIR=C:/work/tools/vcpkg/buildtrees/detect_compiler -DCURRENT_PACKAGES_DIR=C:/work/tools/vcpkg/packages/detect_compiler_x64-windows-static -DCMD=BUILD -DTARGET_TRIPLET=x64-windows-static "-DTARGET_TRIPLET_FILE=C:\work\tools\vcpkg\triplets\x64-windows-static.cmake" -DVCPKG_PLATFORM_TOOLSET=v142 -DDOWNLOADS=C:/work/tools/vcpkg/downloads -DVCPKG_CONCURRENCY=9 "-DGIT=C:/Program Files/Git/cmd/git.exe" -DVCPKG_ROOT_DIR=C:/work/tools/vcpkg -DPACKAGES_DIR=C:/work/tools/vcpkg/packages -DBUILDTREES_DIR=C:/work/tools/vcpkg/buildtrees -D_VCPKG_INSTALLED_DIR=C:/work/tools/vcpkg/installed -DDOWNLOADS=C:/work/tools/vcpkg/downloads -DVCPKG_MANIFEST_INSTALL=OFF -P "C:\work\tools\vcpkg\scripts\ports.cmake")
[DEBUG] -- Configuring x64-windows-static
[DEBUG] CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:50 (_execute_process):
[DEBUG] Unknown CMake command "_execute_process".
[DEBUG] Call Stack (most recent call first):
[DEBUG] scripts/cmake/vcpkg_configure_cmake.cmake:300 (vcpkg_execute_required_process)
[DEBUG] scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake)
[DEBUG] scripts/ports.cmake:79 (include)

Copy link
Contributor

Choose a reason for hiding this comment

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

After hitting escaping issues myself, I think I found the third way:

if (NOT DEFINED OVERRIDEN_EXECUTE_PROCESS)
  set(OVERRIDEN_EXECUTE_PROCESS ON)

  if (DEFINED VCPKG_DOWNLOAD_MODE)
    macro(execute_process)
      message(FATAL_ERROR "This command cannot be executed in Download Mode.\nHalting portfile execution.\n")
    endmacro()
  else()
    macro(_execute_process)
      execute_process(${ARGV})
    endmacro()
  endif()
endif()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which possible problems concerning different cmake versions do you see? I only see the problem that more options could get added to execute_process() in the future. This wouldn't break anything, because nobody could be using such options as they didn't exist before. Only someone starting to use such options in new or updated ports would run into an error, and would need to add the new option to the list in my 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.

@ras0219 yeah, your suggestion actually works. I breaks _execute_process() instead of execute_process(), which would be fine with me as _execute_process() is only used a couple of times in: vcpkg_acquire_msys, vcpkg_apply_patches, vcpkg_download_distfile, vcpkg_execute_required_process, vcpkg_find_acquire_program, vcpkg_from_github, and vcpkg_from_gitlab. So, your solution would fix all execute_process() usages within the cmake distribution.

Copy link
Contributor

@ras0219 ras0219 Aug 22, 2020

Choose a reason for hiding this comment

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

The issue is just that we're duplicating the "signature" of execute process and maintaining that moving forward is a burden; less code is best code after all :)

In the future, we might move away from this approach for handling DOWNLOAD_MODE entirely if we can more reliably get every port to call vcpkg_execute_required_process().

@BillyONeal BillyONeal changed the title fix execute process macro [execute_process] Don't strip embedded semicolons Aug 20, 2020
@BillyONeal
Copy link
Member

@jgehw Can you make it work like ras0219@b76640e (as discussed above)?

@jgehw
Copy link
Contributor Author

jgehw commented Aug 22, 2020

@jgehw Can you make it work like ras0219@b76640e (as discussed above)?

@BillyONeal yes, as I said [ras0219/vcpkg@b76640e] just leaves _execute_process() behind broken, but execute_process() works. This is fine with me, as I only need execute_process() as it's internally used by cmake API. Do you want me to replace my fix with his implementation?

@jgehw
Copy link
Contributor Author

jgehw commented Aug 24, 2020

Why did you close this PR? #12977 is no fix for this case. We either need this fix or [ras0219/vcpkg@b76640e].

@BillyONeal BillyONeal reopened this Aug 24, 2020
@BillyONeal
Copy link
Member

@jgehw I didn't actively try to close this, GitHub does that itself if a PR is merged that mentions another issue or PR with a hot phrase like "fixes 1234" in the discussion / history.

@BillyONeal
Copy link
Member

(Specifically that PR had "fixed #12926" in the description which causes GitHub to link them together and close one when the other is merged)

@jgehw
Copy link
Contributor Author

jgehw commented Aug 24, 2020

@BillyONeal Ahh, I see, I'll pay attention to avoid such phrasing next time.

@jgehw
Copy link
Contributor Author

jgehw commented Sep 2, 2020

arm_uwp and x64_uwp CI failing on json5-parser port downloading https://bitbucket.com/wlandry/json5_parser/get/1.0.0.tar.gz. When viewing in a browser, I get "Repository wlandry/json5_parser not found". So, not related to this PR.

@BillyONeal
Copy link
Member

Yeah, upstream is gone.

@BillyONeal
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jgehw
Copy link
Contributor Author

jgehw commented Sep 3, 2020

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 12926 in repo microsoft/vcpkg

@strega-nil
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jgehw
Copy link
Contributor Author

jgehw commented Sep 4, 2020

upstream is gone again... please re-run once upstream is fixed

@JackBoosY
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@BillyONeal BillyONeal merged commit 8b7e946 into microsoft:master Sep 9, 2020
@jgehw jgehw deleted the fix-execute-process-macro2 branch September 10, 2020 09:46
jgehw pushed a commit to jgehw/vcpkg that referenced this pull request Oct 10, 2020
jgehw pushed a commit to jgehw/vcpkg that referenced this pull request Oct 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

show-stopper: vcpkg screwing up cmake by removing semicolons
5 participants