Index: pylib/gyp/generator/msvs.py |
diff --git a/pylib/gyp/generator/msvs.py b/pylib/gyp/generator/msvs.py |
index c61142ea9748f9e6975d8cfb8ee3898be5c3983b..be092f5baef27f3f372bd72fd212121954138451 100644 |
--- a/pylib/gyp/generator/msvs.py |
+++ b/pylib/gyp/generator/msvs.py |
@@ -242,7 +242,7 @@ def _ConfigFullName(config_name, config_data): |
def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path, |
- quote_cmd): |
+ quote_cmd, do_setup_env=True): |
jeanluc1
2012/05/16 17:46:26
I would not provide a default but force caller to
scottmg
2012/05/16 17:56:37
Done.
|
if [x for x in cmd if '$(InputDir)' in x]: |
input_dir_preamble = ( |
@@ -273,9 +273,9 @@ def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path, |
#direct_cmd = gyp.common.EncodePOSIXShellList(direct_cmd) |
direct_cmd = ' '.join(direct_cmd) |
# TODO(quote): regularize quoting path names throughout the module |
- cmd = ( |
- 'call "$(ProjectDir)%(cygwin_dir)s\\setup_env.bat" && ' |
- 'set CYGWIN=nontsec&& ') |
+ cmd = 'call "$(ProjectDir)%(cygwin_dir)s\\setup_env.bat" && ' \ |
+ if do_setup_env else '' |
jeanluc1
2012/05/16 17:46:26
I don't understand what this line does. do_setup_
scottmg
2012/05/16 17:56:37
It's like ?: in C (in a misguided attempt to terse
|
+ cmd += 'set CYGWIN=nontsec&& ' |
if direct_cmd.find('NUMBER_OF_PROCESSORS') >= 0: |
cmd += 'set /a NUMBER_OF_PROCESSORS_PLUS_1=%%NUMBER_OF_PROCESSORS%%+1&& ' |
if direct_cmd.find('INTDIR') >= 0: |
@@ -307,7 +307,7 @@ def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path, |
return input_dir_preamble + ' '.join(command + arguments) |
-def _BuildCommandLineForRule(spec, rule, has_input_path): |
+def _BuildCommandLineForRule(spec, rule, has_input_path, do_setup_env=True): |
# Find path to cygwin. |
cygwin_dir = _FixPath(spec.get('msvs_cygwin_dirs', ['.'])[0]) |
@@ -322,7 +322,7 @@ def _BuildCommandLineForRule(spec, rule, has_input_path): |
mcs = int(mcs) |
quote_cmd = int(rule.get('msvs_quote_cmd', 1)) |
return _BuildCommandLineForRuleRaw(spec, rule['action'], mcs, has_input_path, |
- quote_cmd) |
+ quote_cmd, do_setup_env=do_setup_env) |
def _AddActionStep(actions_dict, inputs, outputs, description, command): |
@@ -1444,8 +1444,12 @@ def _HandlePreCompiledHeaders(p, sources, spec): |
def _AddActions(actions_to_add, spec, relative_path_of_gyp_file): |
# Add actions. |
actions = spec.get('actions', []) |
+ # Don't setup_env every time, or when all the actions are run together in |
jeanluc1
2012/05/16 17:46:26
--> Don't setup_env every time. When
scottmg
2012/05/16 17:56:37
Done.
|
+ # one batch file in VS, the PATH will grow too long. |
+ first_action = True |
for a in actions: |
- cmd = _BuildCommandLineForRule(spec, a, has_input_path=False) |
+ cmd = _BuildCommandLineForRule(spec, a, has_input_path=False, |
+ do_setup_env=first_action) |
# Attach actions to the gyp file if nothing else is there. |
inputs = a.get('inputs') or [relative_path_of_gyp_file] |
# Add the action. |
@@ -1454,6 +1458,7 @@ def _AddActions(actions_to_add, spec, relative_path_of_gyp_file): |
outputs=a.get('outputs', []), |
description=a.get('message', a['action_name']), |
command=cmd) |
+ first_action = False |
def _WriteMSVSUserFile(project_path, version, spec): |
@@ -3021,7 +3026,13 @@ def _GenerateActionsForMSBuild(spec, actions_to_add): |
commands.append(cmd) |
# Add the custom build action for one input file. |
description = ', and also '.join(descriptions) |
- command = ' && '.join(commands) |
+ |
+ # We can't join the commands simply with && because the command line will |
+ # get too long. See also _AddActions: cygwin's setup_env mustn't be called |
+ # for every invocation or the command that sets the PATH will grow too |
+ # long. |
+ command = ( |
+ '\r\nif %errorlevel% neq 0 exit /b %errorlevel%\r\n'.join(commands)) |
_AddMSBuildAction(spec, |
primary_input, |
inputs, |