summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscottmg@chromium.org <scottmg@chromium.org@78cadc50-ecff-11dd-a971-7dbc132099af>2014-08-12 03:35:56 +0000
committerscottmg@chromium.org <scottmg@chromium.org@78cadc50-ecff-11dd-a971-7dbc132099af>2014-08-12 03:35:56 +0000
commited274e3ea5885bc28cf6249e848cf696d0e89263 (patch)
treefd66e8a8c03339a80634079c329dd63313b59e71
parent474e6f6c6772675e4aa0a076af5206021756d7d2 (diff)
downloadgyp-ed274e3ea5885bc28cf6249e848cf696d0e89263.tar.gz
Provide a way to suppress implicit MIDL generation rules for actions
For IDL files, GYP ninja normally generates rules to build MIDL unless there are explicit rules. This special casing only works for rules, but not actions. In blink, we are going to add an action which runs blink's IDL compiler to generate IDL dictionary implementation .h/.cpp files, which means that we need a way to similar logic for actions. This CL introduces 'explicit_idl_action' flag for such purpose. Patch from bashi@chromium.org. R=scottmg@chromium.org Review URL: https://codereview.chromium.org/440293002 git-svn-id: http://gyp.googlecode.com/svn/trunk@1964 78cadc50-ecff-11dd-a971-7dbc132099af
-rw-r--r--pylib/gyp/generator/ninja.py2
-rw-r--r--pylib/gyp/msvs_emulation.py14
-rw-r--r--test/win/idl-rules/Window.idl9
-rw-r--r--test/win/idl-rules/basic-idl.gyp109
-rw-r--r--test/win/idl-rules/idl_compiler.py17
5 files changed, 104 insertions, 47 deletions
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index 3d33d0ac..4eafb71c 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -530,7 +530,7 @@ class NinjaWriter:
def WriteWinIdlFiles(self, spec, prebuild):
"""Writes rules to match MSVS's implicit idl handling."""
assert self.flavor == 'win'
- if self.msvs_settings.HasExplicitIdlRules(spec):
+ if self.msvs_settings.HasExplicitIdlRulesOrActions(spec):
return []
outputs = []
for source in filter(lambda x: x.endswith('.idl'), spec['sources']):
diff --git a/pylib/gyp/msvs_emulation.py b/pylib/gyp/msvs_emulation.py
index 1b82adba..5f71e9e1 100644
--- a/pylib/gyp/msvs_emulation.py
+++ b/pylib/gyp/msvs_emulation.py
@@ -760,10 +760,16 @@ class MsvsSettings(object):
return True
return False
- def HasExplicitIdlRules(self, spec):
- """Determine if there's an explicit rule for idl files. When there isn't we
- need to generate implicit rules to build MIDL .idl files."""
- return self._HasExplicitRuleForExtension(spec, 'idl')
+ def _HasExplicitIdlActions(self, spec):
+ """Determine if an action should not run midl for .idl files."""
+ return any([action.get('explicit_idl_action', 0)
+ for action in spec.get('actions', [])])
+
+ def HasExplicitIdlRulesOrActions(self, spec):
+ """Determine if there's an explicit rule or action for idl files. When
+ there isn't we need to generate implicit rules to build MIDL .idl files."""
+ return (self._HasExplicitRuleForExtension(spec, 'idl') or
+ self._HasExplicitIdlActions(spec))
def HasExplicitAsmRules(self, spec):
"""Determine if there's an explicit rule for asm files. When there isn't we
diff --git a/test/win/idl-rules/Window.idl b/test/win/idl-rules/Window.idl
new file mode 100644
index 00000000..d8ea01be
--- /dev/null
+++ b/test/win/idl-rules/Window.idl
@@ -0,0 +1,9 @@
+// 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.
+
+[
+ WillBeGarbageCollected,
+] interface Window {
+ void alert();
+};
diff --git a/test/win/idl-rules/basic-idl.gyp b/test/win/idl-rules/basic-idl.gyp
index 9c083275..b74622ad 100644
--- a/test/win/idl-rules/basic-idl.gyp
+++ b/test/win/idl-rules/basic-idl.gyp
@@ -1,42 +1,67 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
- 'variables': {
- 'midl_out_dir': '<(SHARED_INTERMEDIATE_DIR)',
- },
- 'target_defaults': {
- 'configurations': {
- 'Debug': {
- 'msvs_configuration_platform': 'Win32',
- },
- 'Debug_x64': {
- 'inherit_from': ['Debug'],
- 'msvs_configuration_platform': 'x64',
- },
- },
- },
- 'targets': [
- {
- 'target_name': 'idl_test',
- 'type': 'executable',
- 'sources': [
- 'history_indexer.idl',
- '<(midl_out_dir)/history_indexer.h',
- '<(midl_out_dir)/history_indexer_i.c',
- 'history_indexer_user.cc',
- ],
- 'libraries': ['ole32.lib'],
- 'include_dirs': [
- '<(midl_out_dir)',
- ],
- 'msvs_settings': {
- 'VCMIDLTool': {
- 'OutputDirectory': '<(midl_out_dir)',
- 'HeaderFileName': '<(RULE_INPUT_ROOT).h',
- },
- },
- },
- ],
-}
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'variables': {
+ 'midl_out_dir': '<(SHARED_INTERMEDIATE_DIR)',
+ },
+ 'target_defaults': {
+ 'configurations': {
+ 'Debug': {
+ 'msvs_configuration_platform': 'Win32',
+ },
+ 'Debug_x64': {
+ 'inherit_from': ['Debug'],
+ 'msvs_configuration_platform': 'x64',
+ },
+ },
+ },
+ 'targets': [
+ {
+ 'target_name': 'idl_test',
+ 'type': 'executable',
+ 'sources': [
+ 'history_indexer.idl',
+ '<(midl_out_dir)/history_indexer.h',
+ '<(midl_out_dir)/history_indexer_i.c',
+ 'history_indexer_user.cc',
+ ],
+ 'libraries': ['ole32.lib'],
+ 'include_dirs': [
+ '<(midl_out_dir)',
+ ],
+ 'msvs_settings': {
+ 'VCMIDLTool': {
+ 'OutputDirectory': '<(midl_out_dir)',
+ 'HeaderFileName': '<(RULE_INPUT_ROOT).h',
+ },
+ },
+ },
+ {
+ 'target_name': 'idl_explicit_action',
+ 'type': 'none',
+ 'sources': [
+ 'Window.idl',
+ ],
+ 'actions': [{
+ 'action_name': 'blink_idl',
+ 'explicit_idl_action': 1,
+ 'msvs_cygwin_shell': 0,
+ 'inputs': [
+ 'Window.idl',
+ 'idl_compiler.py',
+ ],
+ 'outputs': [
+ 'Window.cpp',
+ 'Window.h',
+ ],
+ 'action': [
+ 'python',
+ 'idl_compiler.py',
+ 'Window.idl',
+ ],
+ }],
+ },
+ ],
+}
diff --git a/test/win/idl-rules/idl_compiler.py b/test/win/idl-rules/idl_compiler.py
new file mode 100644
index 00000000..a12b274d
--- /dev/null
+++ b/test/win/idl-rules/idl_compiler.py
@@ -0,0 +1,17 @@
+#!/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.
+
+# mock, just outputs empty .h/.cpp files
+
+import os
+import sys
+
+if len(sys.argv) == 2:
+ basename, ext = os.path.splitext(sys.argv[1])
+ with open('%s.h' % basename, 'w') as f:
+ f.write('// %s.h\n' % basename)
+ with open('%s.cpp' % basename, 'w') as f:
+ f.write('// %s.cpp\n' % basename)