diff options
author | scottmg@chromium.org <scottmg@chromium.org> | 2014-09-23 17:04:00 +0000 |
---|---|---|
committer | scottmg@chromium.org <scottmg@chromium.org> | 2014-09-23 17:04:00 +0000 |
commit | 397b1c684b0b07a38f485f091cc4394a3d733334 (patch) | |
tree | 2005b618ed9c8a0b93b6f3e327129d019df41198 | |
parent | c5aaab5e438ba6ca40ec2137a46998b2a35915cb (diff) | |
download | gyp-397b1c684b0b07a38f485f091cc4394a3d733334.tar.gz |
I need this change to create Windows 8.1/Windows Phone 8.1 projects that compile modules that can be consumed by Windows Store Applications (WinRT).
This change is required as a prerequisite to adding proper Windows Store (8.1 only) support to Google's ANGLE codebase.
Patch from coopp@microsoft.com.
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/521693002
git-svn-id: http://gyp.googlecode.com/svn/trunk@1981 78cadc50-ecff-11dd-a971-7dbc132099af
-rw-r--r-- | pylib/gyp/generator/msvs.py | 43 | ||||
-rw-r--r-- | test/win/enable-winrt/dllmain.cc | 30 | ||||
-rw-r--r-- | test/win/enable-winrt/enable-winrt.gyp | 42 | ||||
-rw-r--r-- | test/win/gyptest-link-enable-winrt.py | 31 | ||||
-rw-r--r-- | test/win/gyptest-link-target-machine.py | 3 | ||||
-rw-r--r-- | test/win/linker-flags/target-machine.gyp | 10 |
6 files changed, 149 insertions, 10 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/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..466fff90 --- /dev/null +++ b/test/win/enable-winrt/enable-winrt.gyp @@ -0,0 +1,42 @@ +# 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..2dc4860f --- /dev/null +++ b/test/win/gyptest-link-enable-winrt.py @@ -0,0 +1,31 @@ +#!/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 struct +import sys + + +CHDIR = 'enable-winrt' + +if sys.platform == 'win32': + 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() diff --git a/test/win/gyptest-link-target-machine.py b/test/win/gyptest-link-target-machine.py index 5a15f3f4..477937df 100644 --- a/test/win/gyptest-link-target-machine.py +++ b/test/win/gyptest-link-target-machine.py @@ -18,11 +18,12 @@ if sys.platform == 'win32': CHDIR = 'linker-flags' test.run_gyp('target-machine.gyp', chdir=CHDIR) # The .cc file is compiled as x86 (the default), so the link/libs that are - # x64 need to fail. + # x64 or ARM need to fail. test.build('target-machine.gyp', 'test_target_link_x86', chdir=CHDIR) test.build( 'target-machine.gyp', 'test_target_link_x64', chdir=CHDIR, status=1) test.build('target-machine.gyp', 'test_target_lib_x86', chdir=CHDIR) test.build('target-machine.gyp', 'test_target_lib_x64', chdir=CHDIR, status=1) + test.build('target-machine.gyp', 'test_target_lib_arm', chdir=CHDIR, status=1) test.pass_test() diff --git a/test/win/linker-flags/target-machine.gyp b/test/win/linker-flags/target-machine.gyp index 30271926..73719994 100644 --- a/test/win/linker-flags/target-machine.gyp +++ b/test/win/linker-flags/target-machine.gyp @@ -44,5 +44,15 @@ }, 'sources': ['hello.cc'], }, + { + 'target_name': 'test_target_lib_arm', + 'type': 'static_library', + 'msvs_settings': { + 'VCLibrarianTool': { + 'TargetMachine': '3', + }, + }, + 'sources': ['hello.cc'], + }, ] } |