-
-
Notifications
You must be signed in to change notification settings - Fork 341
MSVS: update generation of the vcxproj embedded python script #4818
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
base: master
Are you sure you want to change the base?
Conversation
Changes:
* Replace the existing two code paths that generate the msvs tool vcxproj file with a single code path that generates the one-line python script string compatible with all cases. Prior to this change, the default test runs would not test the alternate path as SCONS_LIB_DIR is set in the test os environment.
* The msvs test case SCons version string was changed from `self.scons_version` to `SCons.__version__`. Depending on the tests run, the test framework version may not match the SCons library version being tested (e.g., retaining packaging version). The test now matches what the msvs tool uses.
* Modify the embedded vcxproj script and generated python executable string for consistency with each other with respect to SCons env and os.environ usage.
* Modify the embedded vcxproj script to retrieve SCONS_HOME and SCONS_LIB_DIR from the environment if needed.
* Priority order for msvs tool SCons library specification:
1. env['SCONS_HOME'] literal path when generated if True
2. os.environ.get('SCONS_HOME', <os.environ['SCONS_HOME'] path when generated>) if True
3. os.environ.get('SCONS_LIB_DIR', <os.environ['SCONS_LIB_DIR'] path when generated>) if True
4. <SCons parent when generated> if exists and is valid SCons library
5. first in list of generated locations that exists and is valid SCons library
* Modify generation of python executable path order:
1. env['PYTHON_ROOT'] literal path if True
2. $(PYTHON_ROOT) if os.environ['PYTHON_ROOT'] is True
3. sys.executable literal path
* Add bare asterisk after second argument in msvs_substitute function in testing/framework/TestSConsMSVS.py requiring keyword argument specifications for all optional arguments. The first two arguments are by position the remaining seven arguments must be keyword specified.
|
One (hopefully unrelated) AppVeyor test failed: Image: Visual Studio 2022; Environment: WINPYTHON=Python313: |
since it only failed on one of the four appveyor runs, it seems likely to be unrelated. Let's keep an eye on it. |
|
Did you miss #4817 ? ;) |
No. |
|
So if I understand the impact of your changes, rather than fix the location of SCons when generating the project file, you've changed the logic so it can be impacted by user's shell env variables when run via msvs which could be different than when the project file was generated? |
Your understanding is correct. In a nutshell, the generated vcxproj SCons library location logic is equivalent to that of the msvs tool. Background:
This PR attempts to achieve:
Here's an example used during testing (the diff format is used to show the source of the library path definition):
If one wants to ALWAYS generate a path that is used, the easiest way is to define import os.path
import SCons
env = Environment(
SCONS_HOME=os.path.abspath(os.path.join(os.path.dirname(SCons.__file__), "..")),
)
sources = ['hello.cpp']
program = env.Program(
target='hello.exe',
source=sources,
CPPFLAGS=['/EHsc'],
)
env.MSVSProject(
target='Hello' + env['MSVSPROJECTSUFFIX'],
srcs=sources,
buildtarget=program,
variant='Release',
)The proposed PR is more adaptive than it was before and there is only "one" generated script instead of two. Is it foolproof? No. Even if this PR is not accepted, there are plenty of reasons to adapt this PR to the equivalent code in #4817 (i.e., unify both code generation paths in a single script). I hope that answers the question and provides some background and rationale.
|
|
@jcbrill they only take a long time when there as thorough as you usually are! :) A few thoughts/notes:
|
Changes: * Change SCons/Tool/msvs.py function comment before getExecScriptMain and replace with docstring. Taken from PR SCons#4817. * Revert python executable code * Generate scons_home (user env, SCONS_HOME, or SCONS_LIB_DIR path specification) and scons_path (currently executing SCons module path) paths in unified script in SCons/Tool/msvs.py and testing/framework/TestSConsMSVS.py. Similar to the two code paths in PR SCons#4817. * Set the SCONS_HOME variable in the testenv as is done with SCONS_LIB_DIR. Add SCONS_HOME to testing/framework/TestSConsMSVS.py.
|
@bdbaddog The latest commit should be functionally equivalent to #4817. I need to do some more local testing. There was an earlier version of the generated script that detected when the generated SCons path would not be used and printed warnings: While it "appears" to work, the VS output console looked a little odd. It may have been interpreting the print statement as a command. I can't be sure. It was simple enough to force both warnings to be printed. I'm not wild about an SCons being picked up which is not the SCons at the generated path without some kind of feedback to the user. |
Changes: * Add check that the generated path contains SCons. * Add the generated path to the python system path only when it contains SCons. * Print an alert message when the generated path does not contain SCons. * Print an alert message when the generated path does not contain SCons and SCons was found on python system path.
|
It appears that printing a message with the word "warning" from the embedded python script triggers different behavior. |
Alternative fix for #4809 for discussion purposes.
Fixes some issues with the msvs tests.
Changes:
self.scons_versiontoSCons.__version__. Depending on the tests run, the test framework version may not match the SCons library version being tested (e.g., retaining packaging version). The test now matches what the msvs tool uses.Locally, passes msvc/msvs tests for all supported versions of VS using python 3.9. Passes scoop tests with SCons installed as an application and SCons installed via python.
Contributor Checklist:
CHANGES.txtandRELEASE.txt(and read theREADME.rst).