| # Copyright 2016 Google Inc. All Rights Reserved. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| import logging |
| import os |
| import sys |
| |
| import config.starboard |
| |
| from starboard.tools.paths import STARBOARD_ROOT |
| |
| import sdk_configuration |
| |
| def _QuotePath(path): |
| return '"' + path + '"' |
| |
| class PlatformConfig(config.starboard.PlatformConfigStarboard): |
| """Starboard Microsoft Windows platform configuration.""" |
| |
| def __init__(self, platform): |
| super(PlatformConfig, self).__init__(platform) |
| self.sdk = sdk_configuration.SdkConfiguration() |
| |
| def GetVariables(self, configuration): |
| sdk = self.sdk |
| variables = super(PlatformConfig, self).GetVariables(configuration) |
| variables.update({ |
| 'visual_studio_install_path': sdk.vs_install_dir_with_version, |
| 'windows_sdk_path': sdk.windows_sdk_path, |
| 'windows_sdk_version': sdk.required_sdk_version, |
| }) |
| return variables |
| |
| def GetEnvironmentVariables(self): |
| sdk = self.sdk |
| cl = _QuotePath(os.path.join(sdk.vs_host_tools_path, 'cl.exe')) |
| lib = _QuotePath(os.path.join(sdk.vs_host_tools_path, 'lib.exe')) |
| link = _QuotePath(os.path.join(sdk.vs_host_tools_path, 'link.exe')) |
| rc = _QuotePath(os.path.join(sdk.windows_sdk_host_tools, 'rc.exe')) |
| env_variables = { |
| 'AR': lib, |
| 'AR_HOST': lib, |
| 'CC': cl, |
| 'CXX': cl, |
| 'LD': link, |
| 'RC': rc, |
| 'VS_INSTALL_DIR': sdk.vs_install_dir, |
| 'CC_HOST': cl, |
| 'CXX_HOST': cl, |
| 'LD_HOST': link, |
| 'ARFLAGS_HOST': 'rcs', |
| 'ARTHINFLAGS_HOST': 'rcsT', |
| } |
| return env_variables |
| |
| def GetBuildFormat(self): |
| """Returns the desired build format.""" |
| # The comma means that ninja, msvs_makefile, will be chained and use the |
| # same input information so that .gyp files will only have to be parsed |
| # once. |
| return 'ninja,msvs_makefile' |
| |
| def GetGeneratorVariables(self, configuration): |
| """Returns a dict of generator variables for the given configuration.""" |
| _ = configuration |
| generator_variables = { |
| 'msvs_version': 2017, |
| 'msvs_platform': 'x64', |
| 'msvs_template_prefix': 'win/', |
| 'msvs_deploy_dir': '', |
| 'qtcreator_session_name_prefix': 'cobalt', |
| } |
| return generator_variables |
| |
| def GetToolchain(self): |
| sys.path.append( |
| os.path.join(STARBOARD_ROOT, 'shared', 'msvc', 'uwp')) |
| from toolchain import MSVCUWPToolchain # pylint: disable=g-import-not-at-top,g-bad-import-order |
| return MSVCUWPToolchain() |