|
|
Created:
6 years, 9 months ago by etienneb Modified:
6 years, 8 months ago CC:
gyp-developer_googlegroups.com Base URL:
http://gyp.googlecode.com/svn/trunk Visibility:
Public. |
DescriptionFix None target type with Ninja build.
GYP doesn't produce a valid Ninja rule for 'none' target type.
These targets are used to make fake dependencies.
Here is a minimal GYP file to show the issue:
{
'targets': [
{
'target_name': 'dummy',
'type': 'none',
'sources': [
'test.h',
],
},
],
}
There is a dummy.ninja file, but there is no rules named 'dummy'.
When using the 'msvs-ninja' build, MSVS complains about a missing target
and fails to compile the project.
Patch from etienneb@chromium.org.
BUG=
R=scottmg@chromium.org
Committed: https://code.google.com/p/gyp/source/detail?r=1883
Patch Set 1 #
Total comments: 4
Patch Set 2 : fix scottmg comments #Patch Set 3 : fix nits #Patch Set 4 : return to patch 1 #Patch Set 5 : remove sources #
Total comments: 2
Patch Set 6 : fix nits #Patch Set 7 : nits #Patch Set 8 : fix unittests. #Patch Set 9 : nits #Patch Set 10 : fix unittests #
Messages
Total messages: 15 (0 generated)
PTAL. Could you launch the try bot. And if it's ok, commit it.
https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py File pylib/gyp/generator/ninja.py (left): https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py... pylib/gyp/generator/ninja.py:1150: # TODO(evan): don't call this function for 'none' target types, as i think it would be better to write the phony here, does that work ok?
toughs? https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py File pylib/gyp/generator/ninja.py (left): https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py... pylib/gyp/generator/ninja.py:1150: # TODO(evan): don't call this function for 'none' target types, as Nop, because none get filtered before by if link_deps or self.target.actions_stamp or actions_depends: We may change the previous condition to accept 'none' and hoist the code into the WriteTarget. That will works too. On 2014/03/19 19:46:56, scottmg wrote: > i think it would be better to write the phony here, does that work ok?
https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py File pylib/gyp/generator/ninja.py (left): https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py... pylib/gyp/generator/ninja.py:1150: # TODO(evan): don't call this function for 'none' target types, as On 2014/03/19 19:53:34, etienneb wrote: > Nop, because none get filtered before by > if link_deps or self.target.actions_stamp or actions_depends: > > We may change the previous condition to accept 'none' and > hoist the code into the WriteTarget. That will works too. ok, i'm not sure what the best way to get to WriteTarget is, but i think the phony should be in the subninja, rather than in the toplevel ninja anyway. > > On 2014/03/19 19:46:56, scottmg wrote: > > i think it would be better to write the phony here, does that work ok? >
Here is the second version like you may prefer it. I do not have any preferences on it. https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py File pylib/gyp/generator/ninja.py (left): https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py... pylib/gyp/generator/ninja.py:1150: # TODO(evan): don't call this function for 'none' target types, as I don't get this one. It's inside the subninja. On 2014/03/19 20:04:43, scottmg wrote: > On 2014/03/19 19:53:34, etienneb wrote: > > Nop, because none get filtered before by > > if link_deps or self.target.actions_stamp or actions_depends: > > > > We may change the previous condition to accept 'none' and > > hoist the code into the WriteTarget. That will works too. > > ok, i'm not sure what the best way to get to WriteTarget is, but i think the > phony should be in the subninja, rather than in the toplevel ninja anyway. > > > > > On 2014/03/19 19:46:56, scottmg wrote: > > > i think it would be better to write the phony here, does that work ok? > > > >
On 2014/03/19 20:21:10, etienneb wrote: > Here is the second version like you may prefer it. > I do not have any preferences on it. > > https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py > File pylib/gyp/generator/ninja.py (left): > > https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py... > pylib/gyp/generator/ninja.py:1150: # TODO(evan): don't call this function for > 'none' target types, as > I don't get this one. > It's inside the subninja. Oh, I'm sorry, I thought that's why you were getting the abs_sources. ps#1 looks better then, but just change it to be self.ninja.build(spec['target_name'], 'phony') There's no need to depend on the unused 'sources' in a 'none'. > > > On 2014/03/19 20:04:43, scottmg wrote: > > On 2014/03/19 19:53:34, etienneb wrote: > > > Nop, because none get filtered before by > > > if link_deps or self.target.actions_stamp or actions_depends: > > > > > > We may change the previous condition to accept 'none' and > > > hoist the code into the WriteTarget. That will works too. > > > > ok, i'm not sure what the best way to get to WriteTarget is, but i think the > > phony should be in the subninja, rather than in the toplevel ninja anyway. > > > > > > > > On 2014/03/19 19:46:56, scottmg wrote: > > > > i think it would be better to write the phony here, does that work ok? > > > > > > >
Revert to patch one. And I disagree with removing the sources. Here is the output with and without the dependencies: D:\src\syzygy\src>ninja -C out\Default dummy ninja: Entering directory `out\Default' ninja: error: '..\..\test.h', needed by 'dummy', missing and no known rule to make it D:\src\syzygy\src>ninja -C out\Default dummy ninja: Entering directory `out\Default' ninja: no work to do. It's supposed to be an error to have a missing file. This is NOT validated gyp-generation time. By looking at the "phony rules" at http://martine.github.io/ninja/manual.html. "phony can also be used to create dummy targets for files which may not exist at build time. If a phony build statement is written without any dependencies, the target will be considered out of date if it does not exist. Without a phony build statement, Ninja will report an error if the file does not exist and is required by the build." Thus, the sources may NOT exists at static time and can be generated, BUT must be present when the rules is executed. On 2014/03/19 20:46:27, scottmg wrote: > On 2014/03/19 20:21:10, etienneb wrote: > > Here is the second version like you may prefer it. > > I do not have any preferences on it. > > > > https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py > > File pylib/gyp/generator/ninja.py (left): > > > > > https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py... > > pylib/gyp/generator/ninja.py:1150: # TODO(evan): don't call this function for > > 'none' target types, as > > I don't get this one. > > It's inside the subninja. > > Oh, I'm sorry, I thought that's why you were getting the abs_sources. ps#1 looks > better then, but just change it to be > > self.ninja.build(spec['target_name'], 'phony') > > There's no need to depend on the unused 'sources' in a 'none'. > > > > > > > On 2014/03/19 20:04:43, scottmg wrote: > > > On 2014/03/19 19:53:34, etienneb wrote: > > > > Nop, because none get filtered before by > > > > if link_deps or self.target.actions_stamp or actions_depends: > > > > > > > > We may change the previous condition to accept 'none' and > > > > hoist the code into the WriteTarget. That will works too. > > > > > > ok, i'm not sure what the best way to get to WriteTarget is, but i think the > > > phony should be in the subninja, rather than in the toplevel ninja anyway. > > > > > > > > > > > On 2014/03/19 19:46:56, scottmg wrote: > > > > > i think it would be better to write the phony here, does that work ok? > > > > > > > > > >
On 2014/03/20 14:15:04, etienneb wrote: > Revert to patch one. > And I disagree with removing the sources. > > Here is the output with and without the dependencies: > > D:\src\syzygy\src>ninja -C out\Default dummy > ninja: Entering directory `out\Default' > ninja: error: '..\..\test.h', needed by 'dummy', missing and no known rule to > make it > > D:\src\syzygy\src>ninja -C out\Default dummy > ninja: Entering directory `out\Default' > ninja: no work to do. > > > It's supposed to be an error to have a missing file. > This is NOT validated gyp-generation time. It's my understanding that 'sources' doesn't have any meaning in a 'type': 'none' target. So, if you want it to error out somewhere, it should be during parsing the gyp input on seeing 'sources', not when running ninja. But, as there shouldn't be sources in there, having ninja generate dependencies on them doesn't make sense. > > By looking at the "phony rules" at > http://martine.github.io/ninja/manual.html. > > "phony can also be used to create dummy targets for files which may not > exist at build time. If a phony build statement is written without any > dependencies, the target will be considered out of date if it does not > exist. Without a phony build statement, Ninja will report an error if > the file does not exist and is required by the build." > > Thus, the sources may NOT exists at static time and can be generated, > BUT must be present when the rules is executed. > > > On 2014/03/19 20:46:27, scottmg wrote: > > On 2014/03/19 20:21:10, etienneb wrote: > > > Here is the second version like you may prefer it. > > > I do not have any preferences on it. > > > > > > > https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py > > > File pylib/gyp/generator/ninja.py (left): > > > > > > > > > https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py... > > > pylib/gyp/generator/ninja.py:1150: # TODO(evan): don't call this function > for > > > 'none' target types, as > > > I don't get this one. > > > It's inside the subninja. > > > > Oh, I'm sorry, I thought that's why you were getting the abs_sources. ps#1 > looks > > better then, but just change it to be > > > > self.ninja.build(spec['target_name'], 'phony') > > > > There's no need to depend on the unused 'sources' in a 'none'. > > > > > > > > > > > On 2014/03/19 20:04:43, scottmg wrote: > > > > On 2014/03/19 19:53:34, etienneb wrote: > > > > > Nop, because none get filtered before by > > > > > if link_deps or self.target.actions_stamp or actions_depends: > > > > > > > > > > We may change the previous condition to accept 'none' and > > > > > hoist the code into the WriteTarget. That will works too. > > > > > > > > ok, i'm not sure what the best way to get to WriteTarget is, but i think > the > > > > phony should be in the subninja, rather than in the toplevel ninja anyway. > > > > > > > > > > > > > > On 2014/03/19 19:46:56, scottmg wrote: > > > > > > i think it would be better to write the phony here, does that work ok? > > > > > > > > > > > > >
On 2014/03/20 17:07:16, scottmg wrote: > On 2014/03/20 14:15:04, etienneb wrote: > > Revert to patch one. > > And I disagree with removing the sources. > > > > Here is the output with and without the dependencies: > > > > D:\src\syzygy\src>ninja -C out\Default dummy > > ninja: Entering directory `out\Default' > > ninja: error: '..\..\test.h', needed by 'dummy', missing and no known rule to > > make it > > > > D:\src\syzygy\src>ninja -C out\Default dummy > > ninja: Entering directory `out\Default' > > ninja: no work to do. > > > > > > It's supposed to be an error to have a missing file. > > This is NOT validated gyp-generation time. > > It's my understanding that 'sources' doesn't have any meaning in a 'type': > 'none' target. So, if you want it to error out somewhere, it should be during > parsing the gyp input on seeing 'sources', not when running ninja. > > But, as there shouldn't be sources in there, having ninja generate dependencies > on them doesn't make sense. > > > > > By looking at the "phony rules" at > > http://martine.github.io/ninja/manual.html. > > > > "phony can also be used to create dummy targets for files which may not > > exist at build time. If a phony build statement is written without any > > dependencies, the target will be considered out of date if it does not > > exist. Without a phony build statement, Ninja will report an error if > > the file does not exist and is required by the build." > > > > Thus, the sources may NOT exists at static time and can be generated, > > BUT must be present when the rules is executed. > > > > > > On 2014/03/19 20:46:27, scottmg wrote: > > > On 2014/03/19 20:21:10, etienneb wrote: > > > > Here is the second version like you may prefer it. > > > > I do not have any preferences on it. > > > > > > > > > > https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py > > > > File pylib/gyp/generator/ninja.py (left): > > > > > > > > > > > > > > https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py... > > > > pylib/gyp/generator/ninja.py:1150: # TODO(evan): don't call this function > > for > > > > 'none' target types, as > > > > I don't get this one. > > > > It's inside the subninja. > > > > > > Oh, I'm sorry, I thought that's why you were getting the abs_sources. ps#1 > > looks > > > better then, but just change it to be > > > > > > self.ninja.build(spec['target_name'], 'phony') > > > > > > There's no need to depend on the unused 'sources' in a 'none'. > > > > > > > > > > > > > > > On 2014/03/19 20:04:43, scottmg wrote: > > > > > On 2014/03/19 19:53:34, etienneb wrote: > > > > > > Nop, because none get filtered before by > > > > > > if link_deps or self.target.actions_stamp or actions_depends: > > > > > > > > > > > > We may change the previous condition to accept 'none' and > > > > > > hoist the code into the WriteTarget. That will works too. > > > > > > > > > > ok, i'm not sure what the best way to get to WriteTarget is, but i think > > the > > > > > phony should be in the subninja, rather than in the toplevel ninja > anyway. > > > > > > > > > > > > > > > > > On 2014/03/19 19:46:56, scottmg wrote: > > > > > > > i think it would be better to write the phony here, does that work > ok? > > > > > > > > > > > > > > > > In that case, the above example should give a gyp-time error because test.h doesn't exists. Which is not the case. Thus, the build silently ignore the missing input file at gyp-time and at ninja-time.
On 2014/03/20 17:18:38, etienneb wrote: > On 2014/03/20 17:07:16, scottmg wrote: > > On 2014/03/20 14:15:04, etienneb wrote: > > > Revert to patch one. > > > And I disagree with removing the sources. > > > > > > Here is the output with and without the dependencies: > > > > > > D:\src\syzygy\src>ninja -C out\Default dummy > > > ninja: Entering directory `out\Default' > > > ninja: error: '..\..\test.h', needed by 'dummy', missing and no known rule > to > > > make it > > > > > > D:\src\syzygy\src>ninja -C out\Default dummy > > > ninja: Entering directory `out\Default' > > > ninja: no work to do. > > > > > > > > > It's supposed to be an error to have a missing file. > > > This is NOT validated gyp-generation time. > > > > It's my understanding that 'sources' doesn't have any meaning in a 'type': > > 'none' target. So, if you want it to error out somewhere, it should be during > > parsing the gyp input on seeing 'sources', not when running ninja. > > > > But, as there shouldn't be sources in there, having ninja generate > dependencies > > on them doesn't make sense. > > > > > > > > By looking at the "phony rules" at > > > http://martine.github.io/ninja/manual.html. > > > > > > "phony can also be used to create dummy targets for files which may not > > > exist at build time. If a phony build statement is written without any > > > dependencies, the target will be considered out of date if it does not > > > exist. Without a phony build statement, Ninja will report an error if > > > the file does not exist and is required by the build." > > > > > > Thus, the sources may NOT exists at static time and can be generated, > > > BUT must be present when the rules is executed. > > > > > > > > > On 2014/03/19 20:46:27, scottmg wrote: > > > > On 2014/03/19 20:21:10, etienneb wrote: > > > > > Here is the second version like you may prefer it. > > > > > I do not have any preferences on it. > > > > > > > > > > > > > > https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py > > > > > File pylib/gyp/generator/ninja.py (left): > > > > > > > > > > > > > > > > > > > > https://codereview.chromium.org/203303011/diff/1/pylib/gyp/generator/ninja.py... > > > > > pylib/gyp/generator/ninja.py:1150: # TODO(evan): don't call this > function > > > for > > > > > 'none' target types, as > > > > > I don't get this one. > > > > > It's inside the subninja. > > > > > > > > Oh, I'm sorry, I thought that's why you were getting the abs_sources. ps#1 > > > looks > > > > better then, but just change it to be > > > > > > > > self.ninja.build(spec['target_name'], 'phony') > > > > > > > > There's no need to depend on the unused 'sources' in a 'none'. > > > > > > > > > > > > > > > > > > > On 2014/03/19 20:04:43, scottmg wrote: > > > > > > On 2014/03/19 19:53:34, etienneb wrote: > > > > > > > Nop, because none get filtered before by > > > > > > > if link_deps or self.target.actions_stamp or actions_depends: > > > > > > > > > > > > > > We may change the previous condition to accept 'none' and > > > > > > > hoist the code into the WriteTarget. That will works too. > > > > > > > > > > > > ok, i'm not sure what the best way to get to WriteTarget is, but i > think > > > the > > > > > > phony should be in the subninja, rather than in the toplevel ninja > > anyway. > > > > > > > > > > > > > > > > > > > > On 2014/03/19 19:46:56, scottmg wrote: > > > > > > > > i think it would be better to write the phony here, does that work > > ok? > > > > > > > > > > > > > > > > > > > > > In that case, the above example should give a gyp-time error because test.h > doesn't exists. > Which is not the case. Thus, the build silently ignore the missing input file at > gyp-time and at ninja-time. As pointed out by Scott, msvs backend does not check the sources. So, I move to the same semantic.
otherwise, LGTM https://codereview.chromium.org/203303011/diff/80001/test/ninja/none-rules/no... File test/ninja/none-rules/none-rules.gyp (right): https://codereview.chromium.org/203303011/diff/80001/test/ninja/none-rules/no... test/ninja/none-rules/none-rules.gyp:10: 'sources': [ 'readme.cc' ], remove this and the file i guess?
done. But, you need to launch try bots, and commit when it's green. I'm not a committer. https://codereview.chromium.org/203303011/diff/80001/test/ninja/none-rules/no... File test/ninja/none-rules/none-rules.gyp (right): https://codereview.chromium.org/203303011/diff/80001/test/ninja/none-rules/no... test/ninja/none-rules/none-rules.gyp:10: 'sources': [ 'readme.cc' ], On 2014/03/20 19:14:22, scottmg wrote: > remove this and the file i guess? Done.
Message was sent while issue was closed.
Committed patchset #10 manually as r1883 (presubmit successful).
Message was sent while issue was closed.
The gyp-win32 bot has been failing two tests most of the time (but not 100% of the time) since this CL landed, and the trybot results on the patch also show the same failure. I really need to roll gyp into chromium for unrelated reasons, so I'm going to revert this change and see if it fixes the win32 tests.
Message was sent while issue was closed.
On 2014/04/09 11:24:25, Torne wrote: > The gyp-win32 bot has been failing two tests most of the time (but not 100% of > the time) since this CL landed, and the trybot results on the patch also show > the same failure. I really need to roll gyp into chromium for unrelated reasons, > so I'm going to revert this change and see if it fixes the win32 tests. Sorry, forgot to paste the failing tests: Failed the following 2 tests: test\ninja\solibs_avoid_relinking\gyptest-solibs-avoid-relinking.py test\win\gyptest-link-restat-importlib.py |