summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org>2014-09-04 23:59:54 +0000
committersky@chromium.org <sky@chromium.org>2014-09-04 23:59:54 +0000
commit1ff523f4eccd38fb9f73e60dddd895736ce90346 (patch)
treec29cc25e500a58669da104a3111058fea495bf44
parent6760f5b1a4852fd6ccbe4ffc409d73edac445744 (diff)
downloadgyp-1ff523f4eccd38fb9f73e60dddd895736ce90346.tar.gz
Changes the ninja generator to output phony targets for uninteresting targets
This way you can pass these targets to the build system and not get errors. BUG=410410 TEST=covered by test now R=thakis@chromium.org Review URL: https://codereview.chromium.org/543743003 git-svn-id: http://gyp.googlecode.com/svn/trunk@1973 78cadc50-ecff-11dd-a971-7dbc132099af
-rw-r--r--pylib/gyp/generator/ninja.py15
-rw-r--r--test/empty-target/empty-target.gyp12
-rw-r--r--test/empty-target/gyptest-empty-target.py18
3 files changed, 45 insertions, 0 deletions
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index 3336a896..f5e1be96 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -2150,6 +2150,10 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
# objects.
target_short_names = {}
+ # short name of targets that were skipped because they didn't contain anything
+ # interesting.
+ empty_target_names = []
+
for qualified_target in target_list:
# qualified_target is like: third_party/icu/icu.gyp:icui18n#target
build_file, name, toolset = \
@@ -2193,6 +2197,8 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
target_outputs[qualified_target] = target
if qualified_target in all_targets:
all_outputs.add(target.FinalOutput())
+ else:
+ empty_target_names.append(name)
if target_short_names:
# Write a short name to build this target. This benefits both the
@@ -2204,6 +2210,15 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in
target_short_names[short_name]])
+ if empty_target_names:
+ # Write out any targets that were skipped because they didn't contain
+ # anything interesting. This way the targets can still be built without
+ # causing build errors.
+ master_ninja.newline()
+ master_ninja.comment('Empty targets (output for completeness).')
+ for name in sorted(empty_target_names):
+ master_ninja.build(name, 'phony')
+
if all_outputs:
master_ninja.newline()
master_ninja.build('all', 'phony', list(all_outputs))
diff --git a/test/empty-target/empty-target.gyp b/test/empty-target/empty-target.gyp
new file mode 100644
index 00000000..feefa280
--- /dev/null
+++ b/test/empty-target/empty-target.gyp
@@ -0,0 +1,12 @@
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'empty_target',
+ 'type': 'none',
+ },
+ ],
+}
diff --git a/test/empty-target/gyptest-empty-target.py b/test/empty-target/gyptest-empty-target.py
new file mode 100644
index 00000000..ecadd4a8
--- /dev/null
+++ b/test/empty-target/gyptest-empty-target.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Verifies building a target with nothing succeeds.
+"""
+
+import os
+import sys
+import TestGyp
+
+test = TestGyp.TestGyp()
+test.run_gyp('empty-target.gyp')
+test.build('empty-target.gyp', target='empty_target')
+test.pass_test()