Sly14 / gyp

Automatically exported from code.google.com/p/gyp
0 stars 0 forks source link

MSVS: Actions are not re-run when their arguments change #262

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If I change the arguments to a Gyp action, the action does not get re-run when 
building the Gyp file with MS Visual Studio.

Here is an example Gyp file that reproduces the problem:

{
  'includes': [
    '../build/common.gypi',
  ],
  'targets': [
    {
      'target_name': 'fooprog',
      'type': 'none',
      'variables': {'contents': 'arg1'},
      'actions': [
        {
          'action_name': 'do foo',
          'msvs_cygwin_shell': 0,
          # It makes no difference whether dummy_file.txt exists.
          'inputs': ['dummy_file.txt'],
          'outputs': ['>(PRODUCT_DIR)/foo.out'],
          'action': ['echo >(contents) > >(PRODUCT_DIR)/foo.out'],
        },
      ],
    },
  ],
}

$ ../tools/gyp/gyp -I build/configs.gypi --depth=.. tmp/foo.gyp

$ devenv.com 'tmp\\foo.sln' /build Debug /project fooprog
Microsoft (R) Visual Studio Version 9.0.30729.1.
Copyright (C) Microsoft Corp. All rights reserved.
1>------ Build started: Project: fooprog, Configuration: Debug Win32 ------
1>do foo
1>Build log was saved at 
"file://c:\cygwin\home\mseaborn\devel\nacl\native_client\native_client\build\Deb
ug\obj\fooprog\BuildLog.htm"
1>fooprog - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

$ cat build/Debug/foo.out
arg1

# Now edit foo.gyp to change "arg1" to "arg2"

$ ../tools/gyp/gyp -I build/configs.gypi --depth=.. tmp/foo.gyp

$ devenv.com 'tmp\\foo.sln' /build Debug /project fooprog
Microsoft (R) Visual Studio Version 9.0.30729.1.
Copyright (C) Microsoft Corp. All rights reserved.
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
$ cat build/Debug/foo.out
arg1

Note that if the "inputs" field is empty, this problem goes away.

This problem is blocking me from committing 
http://codereview.chromium.org/10221026/ because it breaks the incremental 
build of ppapi_nacl_tests.nexe.  If I add an already-existing file 
(test_audio.cc) to the list of files to be built into ppapi_nacl_tests.nexe, 
this .nexe file does not get rebuilt, and the test fails.

Original issue reported on code.google.com by mseaborn@chromium.org on 2 May 2012 at 1:39

GoogleCodeExporter commented 9 years ago
The reason the problem goes away when the "inputs" field is empty is that 
msvs.py contains this hack in _AddActions():

    # Attach actions to the gyp file if nothing else is there.
    inputs = a.get('inputs') or [relative_path_of_gyp_file]

So when "inputs" is empty, if the .gyp file is changed, it forces the action to 
be re-run, even if the action command didn't change.  This does not help if the 
action command was changed as a result of a .gypi file changing, though (which 
is the case for my change above, http://codereview.chromium.org/10221026/).

Original comment by mseaborn@chromium.org on 2 May 2012 at 4:45

GoogleCodeExporter commented 9 years ago
Commit: b5965b0c90a4c6baf306d57bd3bcefba26c7676d
 Email: mseaborn@chromium.org@78cadc50-ecff-11dd-a971-7dbc132099af

MSVS 2008: Fix to ensure that actions are re-run when the command changes

There was some code to re-run an action, but it only worked if the
command change came from a change to a .gyp file, and only if the
"inputs" list was empty.  It didn't work if the command change came
from a change to a .gypi file.

To fix this, we create "*.gypcmd" stamp files that contain the command
text, and when the command text changes we update these files'
timestamps.

If a Gyp target contains multiple actions, this should rerun only the
actions that changed.

BUG=http://code.google.com/p/gyp/issues/detail?id=262
TEST=test/actions-args-change

Review URL: https://chromiumcodereview.appspot.com/10375015

git-svn-id: http://gyp.googlecode.com/svn/trunk@1362 
78cadc50-ecff-11dd-a971-7dbc132099af

M   pylib/gyp/generator/msvs.py
A   test/actions-args-change/gyptest-all.py
A   test/actions-args-change/src/arg-action.gyp
A   test/actions-args-change/src/arg-action.gypi
A   test/actions-args-change/src/dummy-fixed-input.txt
A   test/actions-args-change/src/write_file.py

Original comment by bugdroid1@chromium.org on 8 May 2012 at 8:11

GoogleCodeExporter commented 9 years ago
This is fixed and rolled into Chromium, and I was able to commit the change 
that was broken by this bug.

Original comment by mseaborn@chromium.org on 9 May 2012 at 12:33

GoogleCodeExporter commented 9 years ago
Re-opening because I am reverting the change because the .gypcmd files get 
deleted by the Chromium bots.

Original comment by mseaborn@chromium.org on 16 May 2012 at 6:19

GoogleCodeExporter commented 9 years ago
Commit: 18c2a16fdfd8b0aba4b691ceca6cabb839614abb
 Email: mseaborn@chromium.org@78cadc50-ecff-11dd-a971-7dbc132099af

Revert r1362: MSVS 2008: Fix to ensure that actions are re-run when the command 
changes

This change caused a performance regression in the Windows incremental
build on the Chromium bots, because the bots are deleting the new
.gypcmd files from the source tree between runs, which triggers a lot
of rebuilding.

It's not practical to add the .gypcmd files to all the svn:ignore
lists, so I'm reverting the change until we find a better solution.

BUG=http://code.google.com/p/gyp/issues/detail?id=262
TEST=trybots

Review URL: https://chromiumcodereview.appspot.com/10377171

git-svn-id: http://gyp.googlecode.com/svn/trunk@1383 
78cadc50-ecff-11dd-a971-7dbc132099af

M   pylib/gyp/generator/msvs.py
D   test/actions-args-change/gyptest-all.py
D   test/actions-args-change/src/arg-action.gyp
D   test/actions-args-change/src/arg-action.gypi
D   test/actions-args-change/src/dummy-fixed-input.txt
D   test/actions-args-change/src/write_file.py

Original comment by bugdroid1@chromium.org on 17 May 2012 at 4:06