Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
From William Deegan:
- Fix SCons Docbook schema to work with lxml > 5
- Update pyproject.toml to support Python 3.14 and remove restrictions on lxml version install
- MSVS: Fix msvs project file creation to work with scons-local packages, and with windows scoop.sh
package manager installed SCons. (Based on work by Joseph Brill and Marcel Admiraal)

From Mats Wichmann:
- Introduce some unit tests for the file locking utility routines
Expand Down
3 changes: 3 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ IMPROVEMENTS
an override. Also, if override dict is empty, don't even call the
Override factory function.

- MSVS: Fix msvs project file creation to work with scons-local packages, and with windows scoop.sh
package manager installed SCons. (Based on work by Joseph Brill and Marcel Admiraal)

- Test runner reworked to use Python logging; the portion of the test suite
which tests the runner was adjusted to match.

Expand Down
5 changes: 4 additions & 1 deletion SCons/Script/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,11 +1478,14 @@ def lookupmodule(self, filename: str) -> str | None:
_main(parser)


def main() -> None:
def main(script_path) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Bugs of omission?

SCons/SCript/Main main function now takes a required script_path argument.

Missing:

  • SCons/__main__.py needs to pass a script_path argument.
  • The bin/scons-test.py function do_nothing needs to accept a script_path argument.

I could be wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Updating.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How'd you find those? Are we missing some tests which should catch such? (python -m scons ?)

Copy link
Contributor

@jcbrill jcbrill Jan 28, 2026

Choose a reason for hiding this comment

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

I just searched the source code for combinations of Script.main (e.g. regex Script\.main\( most likely).

Potential issues:

  • The change from main() to main(script_path) can/will break user code.

    Basically anyone doing the same thing: import SCons.Script; SCons.Script.main().

  • Isn't main the entry point when building the wheel wrapper executables for Windows?

    [console_scripts]
    scons = SCons.Script.Main:main
    scons-configure-cache = SCons.Utilities.ConfigureCache:main
    sconsign = SCons.Utilities.sconsign:main
    

    I thought that the entry point was not supposed to take arguments but I certainly could be wrong. A required argument could be problematic.

  • scons.py is not the only way SCons will be called.

    For example, the zipapp (e.g., scons-local-4.10.1.pyz) will be called via __main__.py.

    However, adding os.path.abspath(__file__) will not work for the zippapp. An invocation like S:\SCons\test-4809\scons-local-4.10.1.pyz\__main__.py will fail.

    Something like os.path.dirname(os.path.abspath(__file__)) would be needed to use the name of the zipapp file itself. An invocation like S:\SCons\test-4809\scons-local-4.10.1.pyz should work.

  • Changing the default generated msvs script code path from using PYTHON_ROOT and PYTHONPATH which has allowed deferred evaluation of the location of python and SCons since version 1.0 to a hard-coded absolute path could break some user code.

    Both PYTHON_ROOT (or something similar) and PYTHONPATH were/are useful when using python and SCons from a USB stick and/or when physically moving folders between computers as it avoids hard-coded absolute paths.

    Edit: This is a different animal when actually launching the VS GUI which can be done via batch file(s) via the SCons project root to open the generated .sln in the appropriate build folder.

Don't shoot the messenger.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not shooting the messenger, just wanted to see what I should have done to catch those.

global OptionsParser
global exit_status
global first_command_start
global ENABLE_JSON
global SCONS_SCRIPT_PATH

SCONS_SCRIPT_PATH = script_path

# Check up front for a Python version we do not support. We
# delay the check for deprecated Python versions until later,
Expand Down
65 changes: 34 additions & 31 deletions SCons/Tool/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@

tool_name = 'msvs'


# The string for the Python executable we tell the Project file to use
# is either sys.executable or, if an external PYTHON_ROOT environment
# variable exists, $(PYTHON)ROOT\\python.exe (generalized a little to
# pluck the actual executable name from sys.executable).
try:
python_root = os.environ['PYTHON_ROOT']
except KeyError:
python_executable = sys.executable
else:
python_executable = os.path.join('$$(PYTHON_ROOT)',
os.path.split(sys.executable)[1])

##############################################################################
# Below here are the classes and functions for generation of
# DSP/DSW/SLN/VCPROJ files.
Expand Down Expand Up @@ -152,40 +165,30 @@ def msvs_parse_version(s):
num, suite = version_re.match(s).groups()
return float(num), suite

# This is how we re-invoke SCons from inside MSVS Project files.
# The problem is that we might have been invoked as either scons.bat
# or scons.py. If we were invoked directly as scons.py, then we could
# use sys.argv[0] to find the SCons "executable," but that doesn't work
# if we were invoked as scons.bat, which uses "python -c" to execute
# things and ends up with "-c" as sys.argv[0]. Consequently, we have
# the MSVS Project file invoke SCons the same way that scons.bat does,
# which works regardless of how we were invoked.
def getExecScriptMain(env, xml=None):
if 'SCONS_HOME' not in env:
env['SCONS_HOME'] = os.environ.get('SCONS_HOME')
scons_home = env.get('SCONS_HOME')
if not scons_home and 'SCONS_LIB_DIR' in os.environ:
scons_home = os.environ['SCONS_LIB_DIR']
if scons_home:
exec_script_main = "from os.path import join; import sys; sys.path = [ r'%s' ] + sys.path; import SCons.Script; SCons.Script.main()" % scons_home
else:
version = SCons.__version__
exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-%(version)s'), join(sys.prefix, 'scons-%(version)s'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" % locals()

def get_msvs_scons(env, xml=None):
"""
This is how we re-invoke SCons from inside MSVS Project files.

Simplifying old logic.
Now there are two paths:
1 - MSVS_SCONS is set in env (or os.environ) us that scons.py
2 - otherwise we use the current running scons.py which is
available in SCons.Script.Main.SCONS_SCRIPT_PATH
"""
if 'MSVS_SCONS' not in env:
env['MSVS_SCONS'] = os.environ.get('MSVS_SCONS')
scons_script_path = env.get('MSVS_SCONS')
if not scons_script_path:
scons_script_path = SCons.Script.Main.SCONS_SCRIPT_PATH

exec_script_main = f'"{python_executable}" "{scons_script_path}"'

if xml:
exec_script_main = xmlify(exec_script_main)
return exec_script_main

# The string for the Python executable we tell the Project file to use
# is either sys.executable or, if an external PYTHON_ROOT environment
# variable exists, $(PYTHON)ROOT\\python.exe (generalized a little to
# pluck the actual executable name from sys.executable).
try:
python_root = os.environ['PYTHON_ROOT']
except KeyError:
python_executable = sys.executable
else:
python_executable = os.path.join('$$(PYTHON_ROOT)',
os.path.split(sys.executable)[1])


class Config:
pass
Expand Down Expand Up @@ -2147,7 +2150,7 @@ def generate(env) -> None:
# MSVSSCONSFLAGS. This helps support consumers who use wrapper scripts to
# invoke scons.
if 'MSVSSCONS' not in env:
env['MSVSSCONS'] = '"%s" -c "%s"' % (python_executable, getExecScriptMain(env))
env['MSVSSCONS'] = get_msvs_scons(env)
if 'MSVSSCONSFLAGS' not in env:
env['MSVSSCONSFLAGS'] = '-C "${MSVSSCONSCRIPT.dir.get_abspath()}" -f ${MSVSSCONSCRIPT.name}'

Expand Down
2 changes: 1 addition & 1 deletion scripts/scons.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@

# this does all the work, and calls sys.exit
# with the proper exit status when done.
SCons.Script.main()
SCons.Script.main(os.path.abspath(__file__))
8 changes: 4 additions & 4 deletions test/MSVS/common-prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
\t\t\t>
\t\t\t<Tool
\t\t\t\tName="VCNMakeTool"
\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
\t\t\t\tOutput="Test.exe"
\t\t\t\tPreprocessorDefinitions=""
\t\t\t\tIncludeSearchPath=""
Expand Down Expand Up @@ -137,7 +137,7 @@
test.must_exist(test.workpath('work1', 'Test.vcproj'))
vcproj = test.read(['work1', 'Test.vcproj'], 'r')
expected_vcprojfile = vcproj_template % locals()
expect = test.msvs_substitute(expected_vcprojfile, '8.0', 'work1', 'SConstruct')
expect = test.msvs_substitute(expected_vcprojfile, '8.0', subdir='work1', sconscript='SConstruct')
# don't compare the pickled data
assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)

Expand Down
6 changes: 3 additions & 3 deletions test/MSVS/runfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
\t\t\t>
\t\t\t<Tool
\t\t\t\tName="VCNMakeTool"
\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
\t\t\t\tOutput="runfile.exe"
\t\t\t\tPreprocessorDefinitions=""
\t\t\t\tIncludeSearchPath=""
Expand Down
1 change: 1 addition & 0 deletions test/MSVS/vs-mult-auto-vardir.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
vcproj = test.read(['src', project_file_1], 'r')
expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1)
# don't compare the pickled data

assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)

test.must_exist(test.workpath('src', project_file_2))
Expand Down
55 changes: 29 additions & 26 deletions testing/framework/TestSConsMSVS.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ""
# PROP BASE Intermediate_Dir ""
# PROP BASE Cmd_Line "echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
# PROP BASE Rebuild_Opt "-c && echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
# PROP BASE Cmd_Line "echo Starting SCons && "<PYTHON>" "<SCONS_SCRIPT_PATH>" -C "<WORKPATH>" -f SConstruct "Test.exe""
# PROP BASE Rebuild_Opt "-c && echo Starting SCons && "<PYTHON>" "<SCONS_SCRIPT_PATH>" -C "<WORKPATH>" -f SConstruct "Test.exe""
# PROP BASE Target_File "Test.exe"
# PROP BASE Bsc_Name ""
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ""
# PROP Intermediate_Dir ""
# PROP Cmd_Line "echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
# PROP Rebuild_Opt "-c && echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
# PROP Cmd_Line "echo Starting SCons && "<PYTHON>" "<SCONS_SCRIPT_PATH>" -C "<WORKPATH>" -f SConstruct "Test.exe""
# PROP Rebuild_Opt "-c && echo Starting SCons && "<PYTHON>" "<SCONS_SCRIPT_PATH>" -C "<WORKPATH>" -f SConstruct "Test.exe""
# PROP Target_File "Test.exe"
# PROP Bsc_Name ""
# PROP Target_Dir ""
Expand Down Expand Up @@ -263,9 +263,9 @@
\t\t\tATLMinimizesCRunTimeLibraryUsage="FALSE">
\t\t\t<Tool
\t\t\t\tName="VCNMakeTool"
\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
\t\t\t\tOutput="Test.exe"/>
\t\t</Configuration>
\t</Configurations>
Expand Down Expand Up @@ -388,9 +388,9 @@
\t\t\tATLMinimizesCRunTimeLibraryUsage="FALSE">
\t\t\t<Tool
\t\t\t\tName="VCNMakeTool"
\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
\t\t\t\tOutput="Test.exe"/>
\t\t</Configuration>
\t</Configurations>
Expand Down Expand Up @@ -513,9 +513,9 @@
\t\t\t>
\t\t\t<Tool
\t\t\t\tName="VCNMakeTool"
\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;%(PROJECT_BASENAME)s.exe&quot;"
\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;%(PROJECT_BASENAME)s.exe&quot;"
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;%(PROJECT_BASENAME)s.exe&quot;"
\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;%(PROJECT_BASENAME)s.exe&quot;"
\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;%(PROJECT_BASENAME)s.exe&quot;"
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;%(PROJECT_BASENAME)s.exe&quot;"
\t\t\t\tOutput="%(PROJECT_BASENAME)s.exe"
\t\t\t\tPreprocessorDefinitions="DEF1;DEF2;DEF3=1234"
\t\t\t\tIncludeSearchPath="%(INCLUDE_DIRS)s"
Expand Down Expand Up @@ -607,9 +607,9 @@
\t<PropertyGroup Label="UserMacros" />
\t<PropertyGroup>
\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
\t\t<NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;%(PROJECT_BASENAME)s.exe&quot;</NMakeBuildCommandLine>
\t\t<NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;%(PROJECT_BASENAME)s.exe&quot;</NMakeReBuildCommandLine>
\t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;%(PROJECT_BASENAME)s.exe&quot;</NMakeCleanCommandLine>
\t\t<NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;%(PROJECT_BASENAME)s.exe&quot;</NMakeBuildCommandLine>
\t\t<NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;%(PROJECT_BASENAME)s.exe&quot;</NMakeReBuildCommandLine>
\t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; &quot;<SCONS_SCRIPT_PATH>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;%(PROJECT_BASENAME)s.exe&quot;</NMakeCleanCommandLine>
\t\t<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PROJECT_BASENAME)s.exe</NMakeOutput>
\t\t<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">DEF1;DEF2;DEF3=1234</NMakePreprocessorDefinitions>
\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(INCLUDE_DIRS)s</NMakeIncludeSearchPath>
Expand Down Expand Up @@ -899,17 +899,19 @@ def msvs_substitute(
if project_guid is None:
project_guid = PROJECT_GUID

if 'SCONS_LIB_DIR' in os.environ:
exec_script_main = f"from os.path import join; import sys; sys.path = [ r'{os.environ['SCONS_LIB_DIR']}' ] + sys.path; import SCons.Script; SCons.Script.main()"
if 'MSVS_SCONS' in os.environ:
exec_script_main = f'{os.environ['MSVS_SCONS']}'
else:
exec_script_main = f"from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-{self.scons_version}'), join(sys.prefix, 'scons-{self.scons_version}'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()"
exec_script_main = f'{self.program}'


exec_script_main_xml = exec_script_main.replace("'", "&apos;")

result = input.replace(r'<WORKPATH>', workpath)
result = result.replace(r'<PYTHON>', python)
result = result.replace(r'<SCONSCRIPT>', sconscript)
result = result.replace(r'<SCONS_SCRIPT_MAIN>', exec_script_main)
result = result.replace(r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
result = result.replace(r'<SCONS_SCRIPT_PATH>', exec_script_main)
result = result.replace(r'<SCONS_SCRIPT_PATH_XML>', exec_script_main_xml)
result = result.replace(r'<PROJECT_GUID>', project_guid)
result = result.replace('<SCC_VCPROJ_INFO>\n', vcproj_sccinfo)
result = result.replace('<SCC_SLN_INFO>\n', sln_sccinfo)
Expand Down Expand Up @@ -1176,17 +1178,18 @@ def msvs_substitute_projects(
if solution_guid_2 is None:
solution_guid_2 = SOLUTION_GUID_2

if 'SCONS_LIB_DIR' in os.environ:
exec_script_main = f"from os.path import join; import sys; sys.path = [ r'{os.environ['SCONS_LIB_DIR']}' ] + sys.path; import SCons.Script; SCons.Script.main()"
if 'MSVS_SCONS' in os.environ:
exec_script_main = f'{os.environ['MSVS_SCONS']}'
else:
exec_script_main = f"from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-{self.scons_version}'), join(sys.prefix, 'scons-{self.scons_version}'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()"
exec_script_main = f'{self.program}'

exec_script_main_xml = exec_script_main.replace("'", "&apos;")

result = input.replace(r'<WORKPATH>', workpath)
result = result.replace(r'<PYTHON>', python)
result = result.replace(r'<SCONSCRIPT>', sconscript)
result = result.replace(r'<SCONS_SCRIPT_MAIN>', exec_script_main)
result = result.replace(r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
result = result.replace(r'<SCONS_SCRIPT_PATH>', exec_script_main)
result = result.replace(r'<SCONS_SCRIPT_PATH_XML>', exec_script_main_xml)
result = result.replace(r'<PROJECT_GUID_1>', project_guid_1)
result = result.replace(r'<PROJECT_GUID_2>', project_guid_2)
result = result.replace(r'<SOLUTION_GUID_1>', solution_guid_1)
Expand Down
Loading