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

[bootstrap-vcpkg.sh] restore removed eval call #37047

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

Osyotr
Copy link
Contributor

@Osyotr Osyotr commented Feb 29, 2024

As suggested in #37035 (comment)
cc @SchaichAlonso

Fixes #37035
Fixes #37045

@SchaichAlonso
Copy link
Contributor

LGTM (I'm not authoritative though)

@SchaichAlonso
Copy link
Contributor

SchaichAlonso commented Feb 29, 2024

Giving this a second, what's the point of using a cmake arguments variable (with or without nested quotes) here in the first place?

I'm not a ninja expert, so if I want concurrent compilation, I pass --parallel to cmake --build rather then manually setting up a job pool, and --parallel has always worked for me so far. In fact it also works w/o Ninja, e.g. with Unix Makefiles or msbuild, while the job pool stuff is ninja specific.

If the job pool stuff doesn't do anything that --parallel doesn't, then the code block handling the cmake arguments and cmake invokations, namely

cmakeConfigOptions="-DCMAKE_BUILD_TYPE=Release -G 'Ninja' -DVCPKG_DEVELOPMENT_WARNINGS=OFF"

if [ "${VCPKG_MAX_CONCURRENCY}" != "" ] ; then
        cmakeConfigOptions=" $cmakeConfigOptions '-DCMAKE_JOB_POOL_COMPILE:STRING=compile' '-DCMAKE_JOB_POOL_LINK:STRING=link' '-DCMAKE_JOB_POOLS:STRING=compile=$VCPKG_MAX_CONCURRENCY;link=$VCPKG_MAX_CONCURRENCY' "
fi

(cd "$buildDir" && eval cmake "$srcDir" $cmakeConfigOptions) || exit 1
(cd "$buildDir" && cmake --build .) || exit 1

could be

(cd "$buildDir" && eval cmake "$srcDir" -DCMAKE_BUILD_TYPE=Release -G Ninja -DVCPKG_DEVELOPMENT_WARNINGS=OFF) || exit 1
(cd "$buildDir" && cmake --build . --parallel ${VCPKG_MAX_CONCURRENCY:-1}) || exit 1

where the eval statement is redundand because there's no nested quotes any more.

Further, cmake 3.13 and newer have -S and -B arguments to specify the source and the build directories, allowing to invoke cmake outside of the build directory

(eval cmake -B "$buildDir" -S "$srcDir" -DCMAKE_BUILD_TYPE=Release -G Ninja -DVCPKG_DEVELOPMENT_WARNINGS=OFF) || exit 1
(cmake --build "$buildDir" --parallel ${VCPKG_MAX_CONCURRENCY:-1}) || exit 1

Without the cd statements we can then drop the brackets, and reorder the cmake arguments to not interleave the generator into varriable definitions, to get

eval cmake -B "$buildDir" -S "$srcDir" -G Ninja -DCMAKE_BUILD_TYPE=Release -DVCPKG_DEVELOPMENT_WARNINGS=OFF || exit 1
cmake --build "$buildDir" --parallel ${VCPKG_MAX_CONCURRENCY:-1} || exit 1

A preset defining CMAKE_BUILD_TYPE, VCPKG_DEVELOPMENT_WARNINGS, generator and buildDir can further clean this up. Preset Files are JSON, so we don't have to bother about whitespace escaping madness if the generator ever becomes "Ninja Multi-Config". vcpkg-tool already has a preset file, it just doesn't contain a preset storing the constants passed to the only cmake invokation that the boostrap-vcpkg script ever performs.

In case the job pool stuff doesn't do just simply the same thing --parallel does... then we can configure all the job pool variables in a preset, in addition to the non-ninja-specific variables, and branch between the job pool preset and the basic preset in the shell script, instead of appending cmake args.

Getting the Prefix into vcpkg-tool will take it's time though, so go ahead with this PR.

@vicroms
Copy link
Member

vicroms commented Feb 29, 2024

@SchaichAlonso comments aside, I'm taking this PR since it quickly fixes an issue right now.

@vicroms vicroms merged commit 3f966cf into microsoft:master Feb 29, 2024
16 checks passed
@Osyotr Osyotr deleted the patch-1 branch March 1, 2024 09:06
SchaichAlonso added a commit to PurpleFlowerGarden/vcpkg that referenced this pull request Nov 6, 2024
There's a [string escaping madness in bootstrap.sh's cmake invokation around line 217, making the script difficult to maintain.

I broke it before in PR microsoft#36828 which went into master undetected as it "worked over here" (tm) and isn't executed by the CI, but appearently it wouldn't work on arch linux' bash, resulting in PR microsoft#37047 .

microsoft/vcpkg-tool#1380 introduces a CMake Preset that can take over the cmake CLI variable setup.

This commit replaces the nested string composition by it's cmake-preset counterpart.
SchaichAlonso added a commit to PurpleFlowerGarden/vcpkg that referenced this pull request Nov 6, 2024
There's a [string escaping madness in bootstrap.sh's cmake invokation around line 217, making the script difficult to maintain.

I broke it before in PR microsoft#36828 which went into master undetected as it "worked over here" (tm) and isn't executed by the CI, but appearently it wouldn't work on arch linux' bash, resulting in PR microsoft#37047 .

microsoft/vcpkg-tool#1380 introduces a CMake Preset that can take over the cmake CLI variable setup.

This commit replaces the nested string composition by it's cmake-preset counterpart.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vcpkg build failure for arm64 platform bootstrap-vcpkg.sh from master branch fails on s390x alpine linux
3 participants