summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscottmg@chromium.org <scottmg@chromium.org>2014-09-25 16:48:09 +0000
committerscottmg@chromium.org <scottmg@chromium.org>2014-09-25 16:48:09 +0000
commitf79c483443249fec12a981babdbcce24f23d20c3 (patch)
treeab238e138d78ede1c9f2890e46f313934a62bb99
parent0f464a10fcfd14e5fca0a8a9c59a53d36327c452 (diff)
downloadgyp-f79c483443249fec12a981babdbcce24f23d20c3.tar.gz
Added msvs_enable_winrt to enable creating Windows Store compatible projects for .dlls that are consumed by WinRT applications.
Patch from coopp@microsoft.com. BUG= R=scottmg@chromium.org Review URL: https://codereview.chromium.org/607553002 git-svn-id: http://gyp.googlecode.com/svn/trunk@1985 78cadc50-ecff-11dd-a971-7dbc132099af
-rw-r--r--pylib/gyp/generator/msvs.py43
-rw-r--r--pylib/gyp/msvs_emulation.py6
-rw-r--r--test/win/enable-winrt/dllmain.cc30
-rw-r--r--test/win/enable-winrt/enable-winrt.gyp39
-rw-r--r--test/win/gyptest-link-enable-winrt.py32
5 files changed, 139 insertions, 11 deletions
diff --git a/pylib/gyp/generator/msvs.py b/pylib/gyp/generator/msvs.py
index 80e3104f..517ce3c6 100644
--- a/pylib/gyp/generator/msvs.py
+++ b/pylib/gyp/generator/msvs.py
@@ -83,6 +83,9 @@ generator_additional_non_configuration_keys = [
'msvs_external_builder_build_cmd',
'msvs_external_builder_clean_cmd',
'msvs_external_builder_clcompile_cmd',
+ 'msvs_enable_winrt',
+ 'msvs_requires_importlibrary',
+ 'msvs_enable_winphone',
]
@@ -2595,15 +2598,26 @@ def _GetMSBuildProjectConfigurations(configurations):
def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name):
namespace = os.path.splitext(gyp_file_name)[0]
- return [
+ properties = [
['PropertyGroup', {'Label': 'Globals'},
- ['ProjectGuid', guid],
- ['Keyword', 'Win32Proj'],
- ['RootNamespace', namespace],
- ['IgnoreWarnCompileDuplicatedFilename', 'true'],
+ ['ProjectGuid', guid],
+ ['Keyword', 'Win32Proj'],
+ ['RootNamespace', namespace],
+ ['IgnoreWarnCompileDuplicatedFilename', 'true'],
]
- ]
+ ]
+
+ if spec.get('msvs_enable_winrt'):
+ properties[0].append(['DefaultLanguage', 'en-US'])
+ properties[0].append(['AppContainerApplication', 'true'])
+ properties[0].append(['ApplicationTypeRevision', '8.1'])
+
+ if spec.get('msvs_enable_winphone'):
+ properties[0].append(['ApplicationType', 'Windows Phone'])
+ else:
+ properties[0].append(['ApplicationType', 'Windows Store'])
+ return properties
def _GetMSBuildConfigurationDetails(spec, build_file):
properties = {}
@@ -2614,8 +2628,9 @@ def _GetMSBuildConfigurationDetails(spec, build_file):
_AddConditionalProperty(properties, condition, 'ConfigurationType',
msbuild_attributes['ConfigurationType'])
if character_set:
- _AddConditionalProperty(properties, condition, 'CharacterSet',
- character_set)
+ if 'msvs_enable_winrt' not in spec :
+ _AddConditionalProperty(properties, condition, 'CharacterSet',
+ character_set)
return _GetMSBuildPropertyGroup(spec, 'Configuration', properties)
@@ -2974,6 +2989,13 @@ def _FinalizeMSBuildSettings(spec, configuration):
'PrecompiledHeaderFile', precompiled_header)
_ToolAppend(msbuild_settings, 'ClCompile',
'ForcedIncludeFiles', [precompiled_header])
+ else:
+ _ToolAppend(msbuild_settings, 'ClCompile', 'PrecompiledHeader', 'NotUsing')
+ # Turn off WinRT compilation
+ _ToolAppend(msbuild_settings, 'ClCompile', 'CompileAsWinRT', 'false')
+ # Turn on import libraries if appropriate
+ if spec.get('msvs_requires_importlibrary'):
+ _ToolAppend(msbuild_settings, '', 'IgnoreImportLibrary', 'false')
# Loadable modules don't generate import libraries;
# tell dependent projects to not expect one.
if spec['type'] == 'loadable_module':
@@ -3214,7 +3236,10 @@ def _GenerateMSBuildProject(project, options, version, generator_flags):
content += _GetMSBuildGlobalProperties(spec, project.guid, project_file_name)
content += import_default_section
content += _GetMSBuildConfigurationDetails(spec, project.build_file)
- content += _GetMSBuildLocalProperties(project.msbuild_toolset)
+ if spec.get('msvs_enable_winphone'):
+ content += _GetMSBuildLocalProperties('v120_wp81')
+ else:
+ content += _GetMSBuildLocalProperties(project.msbuild_toolset)
content += import_cpp_props_section
content += _GetMSBuildExtensions(props_files_of_rules)
content += _GetMSBuildPropertySheets(configurations)
diff --git a/pylib/gyp/msvs_emulation.py b/pylib/gyp/msvs_emulation.py
index fa97aaf3..56e5ffbd 100644
--- a/pylib/gyp/msvs_emulation.py
+++ b/pylib/gyp/msvs_emulation.py
@@ -478,7 +478,8 @@ class MsvsSettings(object):
libflags.extend(self._GetAdditionalLibraryDirectories(
'VCLibrarianTool', config, gyp_to_build_path))
lib('LinkTimeCodeGeneration', map={'true': '/LTCG'})
- lib('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:')
+ lib('TargetMachine', map={'1': 'X86', '17': 'X64', '3': 'ARM'},
+ prefix='/MACHINE:')
lib('AdditionalOptions')
return libflags
@@ -521,7 +522,8 @@ class MsvsSettings(object):
'VCLinkerTool', append=ldflags)
self._GetDefFileAsLdflags(ldflags, gyp_to_build_path)
ld('GenerateDebugInformation', map={'true': '/DEBUG'})
- ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:')
+ ld('TargetMachine', map={'1': 'X86', '17': 'X64', '3': 'ARM'},
+ prefix='/MACHINE:')
ldflags.extend(self._GetAdditionalLibraryDirectories(
'VCLinkerTool', config, gyp_to_build_path))
ld('DelayLoadDLLs', prefix='/DELAYLOAD:')
diff --git a/test/win/enable-winrt/dllmain.cc b/test/win/enable-winrt/dllmain.cc
new file mode 100644
index 00000000..dedd83c3
--- /dev/null
+++ b/test/win/enable-winrt/dllmain.cc
@@ -0,0 +1,30 @@
+// Copyright (c) 2013 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.
+
+#include <windows.h>
+#include <wrl.h>
+#include <wrl/wrappers/corewrappers.h>
+#include <windows.graphics.display.h>
+
+using namespace Microsoft::WRL;
+using namespace Microsoft::WRL::Wrappers;
+using namespace ABI::Windows::Foundation;
+using namespace ABI::Windows::Graphics::Display;
+
+bool TryToUseSomeWinRT() {
+ ComPtr<IDisplayPropertiesStatics> dp;
+ HStringReference s(RuntimeClass_Windows_Graphics_Display_DisplayProperties);
+ HRESULT hr = GetActivationFactory(s.Get(), dp.GetAddressOf());
+ if (SUCCEEDED(hr)) {
+ float dpi = 96.0f;
+ if (SUCCEEDED(dp->get_LogicalDpi(&dpi))) {
+ return true;
+ }
+ }
+ return false;
+}
+
+BOOL WINAPI DllMain(HINSTANCE hinstance, DWORD reason, LPVOID reserved) {
+ return TRUE;
+}
diff --git a/test/win/enable-winrt/enable-winrt.gyp b/test/win/enable-winrt/enable-winrt.gyp
new file mode 100644
index 00000000..69f70189
--- /dev/null
+++ b/test/win/enable-winrt/enable-winrt.gyp
@@ -0,0 +1,39 @@
+# Copyright (c) 2013 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': 'enable_winrt_dll',
+ 'type': 'shared_library',
+ 'msvs_enable_winrt': 1,
+ 'sources': [
+ 'dllmain.cc',
+ ],
+ },
+ {
+ 'target_name': 'enable_winrt_missing_dll',
+ 'type': 'shared_library',
+ 'sources': [
+ 'dllmain.cc',
+ ],
+ },
+ {
+ 'target_name': 'enable_winrt_winphone_dll',
+ 'type': 'shared_library',
+ 'msvs_enable_winrt': 1,
+ 'msvs_enable_winphone': 1,
+ 'sources': [
+ 'dllmain.cc',
+ ],
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'AdditionalDependencies': [
+ '%(AdditionalDependencies)',
+ ],
+ },
+ },
+ },
+ ]
+}
diff --git a/test/win/gyptest-link-enable-winrt.py b/test/win/gyptest-link-enable-winrt.py
new file mode 100644
index 00000000..0c99ca10
--- /dev/null
+++ b/test/win/gyptest-link-enable-winrt.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2013 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.
+
+"""
+Make sure msvs_enable_winrt works correctly.
+"""
+
+import TestGyp
+
+import os
+import sys
+import struct
+
+CHDIR = 'enable-winrt'
+
+if (sys.platform == 'win32' and
+ int(os.environ.get('GYP_MSVS_VERSION', 0)) >= 2013):
+ test = TestGyp.TestGyp(formats=['msvs'])
+
+ test.run_gyp('enable-winrt.gyp', chdir=CHDIR)
+
+ test.build('enable-winrt.gyp', 'enable_winrt_dll', chdir=CHDIR)
+
+ test.build('enable-winrt.gyp', 'enable_winrt_missing_dll', chdir=CHDIR,
+ status=1)
+
+ test.build('enable-winrt.gyp', 'enable_winrt_winphone_dll', chdir=CHDIR)
+
+ test.pass_test()