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_setup_pkgconfig_path] Fix backup/restore #25361

Merged
merged 11 commits into from
Jun 29, 2022

Conversation

dg0yt
Copy link
Contributor

@dg0yt dg0yt commented Jun 21, 2022

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You have modified or added at least one vcpkg.json where you should check the license field.

If you feel able to do so, please consider adding a "license" field to the following files:

  • scripts/test_ports/unit-test-cmake/vcpkg.json

Valid values for the license field can be found in the documentation

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You have modified or added at least one vcpkg.json where you should check the license field.

If you feel able to do so, please consider adding a "license" field to the following files:

  • scripts/test_ports/unit-test-cmake/vcpkg.json

Valid values for the license field can be found in the documentation

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You have modified or added at least one vcpkg.json where you should check the license field.

If you feel able to do so, please consider adding a "license" field to the following files:

  • scripts/test_ports/unit-test-cmake/vcpkg.json

Valid values for the license field can be found in the documentation

@dg0yt
Copy link
Contributor Author

dg0yt commented Jun 21, 2022

NB: CI run only the unit tests.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You have modified or added at least one vcpkg.json where you should check the license field.

If you feel able to do so, please consider adding a "license" field to the following files:

  • scripts/test_ports/unit-test-cmake/vcpkg.json

Valid values for the license field can be found in the documentation

@JackBoosY JackBoosY added the category:tool-update The issue is with build tool or build script, which requires update or should be executed correctly label Jun 22, 2022
@@ -1,11 +1,27 @@
function(vcpkg_backup_env_variables)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "VARS")
macro(vcpkg_backup_env_variables)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should provide a function to other modules instead of a macro.

Copy link
Contributor Author

@dg0yt dg0yt Jun 22, 2022

Choose a reason for hiding this comment

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

A function cannot write to the parent scope of the parent scope. That's why I changed the user-facing command into a macro. The main work is still implemented in a function, as an implementation detail of the macro.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any other way we can solve this?
Consider this: it would be a disaster if a C++ module provided a macro containing a function for other modules to call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there any other way we can solve this?

Not within this command. The only alternative is yet another tighly coupled command. See the individual commits.

Consider this: it would be a disaster if a C++ module provided a macro containing a function for other modules to call.

The script mode command names vcpkg_backup_env_variables/z_vcpkg_backup_env_variables are clearly owned by vcpkg, no matter if macro or function. No room for collision.
There is only one variable always overwritten in calling scope: z_vcpkg_backup_env_variables_arg_vars. Ownership should be clear here, too. What should be added is unsetting the variable before leaving the macro.

github-actions[bot]
github-actions bot previously approved these changes Jun 22, 2022
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You have modified or added at least one vcpkg.json where you should check the license field.

If you feel able to do so, please consider adding a "license" field to the following files:

  • scripts/test_ports/unit-test-cmake/vcpkg.json

Valid values for the license field can be found in the documentation

JackBoosY
JackBoosY previously approved these changes Jun 22, 2022
@JackBoosY
Copy link
Contributor

I personally don't agree with this, need other guys to review it further.

@JackBoosY JackBoosY added info:reviewed Pull Request changes follow basic guidelines requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. and removed requires:author-response labels Jun 22, 2022
@ras0219-msft
Copy link
Contributor

Given the triviality of the function and the fact that the only use case with this issue is in an internal z_ function, I think adding an additional public switch is not warranted. It would be much, much simpler for z_vcpkg_setup_pkgconfig_path to just inline the function for its particular use.

If we're intending to solve the general problem of scope management, this isn't a great solution because it only works for exactly one layer. A general solution should work for arbitrary scoping, which probably means it would add a way to get the list of variables required such that the caller could propagate them appropriately. For composition, it would also likely need to add a custom prefix to the variable names as well, so that multiple callers can be correctly nested.

All of this said, I don't think we should attempt to solve this general problem at this time -- instead we should simply fix z_vcpkg_setup_pkgconfig_path in the simple way.

Thanks for the PR!

@dan-shaw dan-shaw added requires:author-response and removed info:reviewed Pull Request changes follow basic guidelines requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. labels Jun 23, 2022
@dg0yt dg0yt dismissed stale reviews from JackBoosY and github-actions[bot] via dd27f0d June 27, 2022 18:19
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You have modified or added at least one vcpkg.json where you should check the license field.

If you feel able to do so, please consider adding a "license" field to the following files:

  • scripts/test_ports/unit-test-cmake/vcpkg.json

Valid values for the license field can be found in the documentation

@dg0yt
Copy link
Contributor Author

dg0yt commented Jun 27, 2022

just inline the function for its particular use.

Done. Using the same variable names as vcpkg_backup_env_variables/z_vcpkg_restore_env_variables.

@JackBoosY JackBoosY added the info:reviewed Pull Request changes follow basic guidelines label Jun 28, 2022
@dan-shaw dan-shaw merged commit 69cd340 into microsoft:master Jun 29, 2022
@dg0yt dg0yt deleted the pkgconfig_path branch June 30, 2022 03:41
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 info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants