diff options
Diffstat (limited to 'gn/infra/recipe_modules')
12 files changed, 219 insertions, 10 deletions
diff --git a/gn/infra/recipe_modules/macos_sdk/__init__.py b/gn/infra/recipe_modules/macos_sdk/__init__.py index f749bfd5af6..56b6a9450ed 100644 --- a/gn/infra/recipe_modules/macos_sdk/__init__.py +++ b/gn/infra/recipe_modules/macos_sdk/__init__.py @@ -34,11 +34,11 @@ PROPERTIES = { ), default={ 'sdk_version': - '10b61', + '12B5025f', 'tool_package': 'infra/tools/mac_toolchain/${platform}', 'tool_version': - 'git_revision:434f5462a77e7103f9d610fa5cabc426bb21502e', + 'git_revision:e9b1fe29fe21a1cd36428c43ea2aba244bd31280', }, ) } diff --git a/gn/infra/recipe_modules/macos_sdk/api.py b/gn/infra/recipe_modules/macos_sdk/api.py index 23d0066aca3..cde4a8bff2d 100644 --- a/gn/infra/recipe_modules/macos_sdk/api.py +++ b/gn/infra/recipe_modules/macos_sdk/api.py @@ -17,10 +17,16 @@ class MacOSSDKApi(recipe_api.RecipeApi): def __init__(self, sdk_properties, *args, **kwargs): super(MacOSSDKApi, self).__init__(*args, **kwargs) + self._sdk_dir = None self._sdk_version = sdk_properties['sdk_version'].lower() self._tool_package = sdk_properties['tool_package'] self._tool_version = sdk_properties['tool_version'] + @property + def sdk_dir(self): + assert self._sdk_dir + return self._sdk_dir + @contextmanager def __call__(self): """Sets up the XCode SDK environment. @@ -61,9 +67,9 @@ class MacOSSDKApi(recipe_api.RecipeApi): try: with self.m.context(infra_steps=True): - sdk_dir = self._ensure_sdk() + self._sdk_dir = self._ensure_sdk() self.m.step('select XCode', - ['sudo', 'xcode-select', '--switch', sdk_dir]) + ['sudo', 'xcode-select', '--switch', self._sdk_dir]) yield finally: with self.m.context(infra_steps=True): diff --git a/gn/infra/recipe_modules/macos_sdk/examples/full.expected/mac.json b/gn/infra/recipe_modules/macos_sdk/examples/full.expected/mac.json index e2acecdfa75..1fb8aba6432 100644 --- a/gn/infra/recipe_modules/macos_sdk/examples/full.expected/mac.json +++ b/gn/infra/recipe_modules/macos_sdk/examples/full.expected/mac.json @@ -6,7 +6,7 @@ "-root", "[CACHE]/macos_sdk", "-ensure-file", - "infra/tools/mac_toolchain/${platform} git_revision:434f5462a77e7103f9d610fa5cabc426bb21502e", + "infra/tools/mac_toolchain/${platform} git_revision:e9b1fe29fe21a1cd36428c43ea2aba244bd31280", "-json-output", "/path/to/tmp/json" ], @@ -17,7 +17,7 @@ "@@@STEP_LOG_LINE@json.output@ \"result\": {@@@", "@@@STEP_LOG_LINE@json.output@ \"\": [@@@", "@@@STEP_LOG_LINE@json.output@ {@@@", - "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"resolved-instance_id-of-git_revision:434\", @@@", + "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"resolved-instance_id-of-git_revision:e9b\", @@@", "@@@STEP_LOG_LINE@json.output@ \"package\": \"infra/tools/mac_toolchain/resolved-platform\"@@@", "@@@STEP_LOG_LINE@json.output@ }@@@", "@@@STEP_LOG_LINE@json.output@ ]@@@", @@ -33,7 +33,7 @@ "-kind", "mac", "-xcode-version", - "10b61", + "12b5025f", "-output-dir", "[CACHE]/macos_sdk/XCode.app" ], diff --git a/gn/infra/recipe_modules/macos_sdk/examples/full.py b/gn/infra/recipe_modules/macos_sdk/examples/full.py index 5546ad5058e..a3348ab9402 100644 --- a/gn/infra/recipe_modules/macos_sdk/examples/full.py +++ b/gn/infra/recipe_modules/macos_sdk/examples/full.py @@ -12,6 +12,7 @@ DEPS = [ def RunSteps(api): with api.macos_sdk(): + sdk_dir = api.macos_sdk.sdk_dir if api.platform.is_mac else None api.step('gn', ['gn', 'gen', 'out/Release']) api.step('ninja', ['ninja', '-C', 'out/Release']) diff --git a/gn/infra/recipe_modules/target/__init__.py b/gn/infra/recipe_modules/target/__init__.py new file mode 100644 index 00000000000..1239fd28642 --- /dev/null +++ b/gn/infra/recipe_modules/target/__init__.py @@ -0,0 +1,7 @@ +# Copyright 2018 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. + +DEPS = [ + 'recipe_engine/platform', +] diff --git a/gn/infra/recipe_modules/target/api.py b/gn/infra/recipe_modules/target/api.py new file mode 100644 index 00000000000..850c104e9ba --- /dev/null +++ b/gn/infra/recipe_modules/target/api.py @@ -0,0 +1,98 @@ +# Copyright 2018 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. + +from recipe_engine import recipe_api + + +PLATFORM_TO_TRIPLE = { + 'fuchsia-amd64': 'x86_64-fuchsia', + 'fuchsia-arm64': 'aarch64-fuchsia', + 'linux-amd64': 'x86_64-linux-gnu', + 'linux-arm64': 'aarch64-linux-gnu', + 'mac-amd64': 'x86_64-apple-darwin', + 'mac-arm64': 'arm64-apple-darwin', +} +PLATFORMS = PLATFORM_TO_TRIPLE.keys() + + +class Target(object): + + def __init__(self, api, os, arch): + self.m = api + self._os = os + self._arch = arch + + @property + def is_win(self): + """Returns True iff the target platform is Windows.""" + return self.os == 'windows' + + @property + def is_mac(self): + """Returns True iff the target platform is macOS.""" + return self.os == 'mac' + + @property + def is_linux(self): + """Returns True iff the target platform is Linux.""" + return self.os == 'linux' + + @property + def is_host(self): + """Returns True iff the target platform is host.""" + return self == self.m.host + + @property + def os(self): + """Returns the target os name which will be in: + * windows + * mac + * linux + """ + return self._os + + @property + def arch(self): + """Returns the current CPU architecture.""" + return self._arch + + @property + def platform(self): + """Returns the target platform in the <os>-<arch> format.""" + return '%s-%s' % (self.os, self.arch) + + @property + def triple(self): + """Returns the target triple.""" + return PLATFORM_TO_TRIPLE[self.platform] + + def __str__(self): + return self.platform + + def __eq__(self, other): + if isinstance(other, Target): + return self._os == other._os and self._arch == other._arch + return False + + def __ne__(self, other): + return not self.__eq__(other) + + +class TargetApi(recipe_api.RecipeApi): + + def __call__(self, platform): + return Target(self, *platform.split('-', 2)) + + @property + def host(self): + return Target(self, self.m.platform.name.replace('win', 'windows'), { + 'intel': { + 32: '386', + 64: 'amd64', + }, + 'arm': { + 32: 'armv6', + 64: 'arm64', + }, + }[self.m.platform.arch][self.m.platform.bits]) diff --git a/gn/infra/recipe_modules/target/examples/full.expected/linux.json b/gn/infra/recipe_modules/target/examples/full.expected/linux.json new file mode 100644 index 00000000000..947f5d2aee9 --- /dev/null +++ b/gn/infra/recipe_modules/target/examples/full.expected/linux.json @@ -0,0 +1,22 @@ +[ + { + "cmd": [], + "name": "platform things", + "~followup_annotations": [ + "@@@STEP_LOG_LINE@name@fuchsia@@@", + "@@@STEP_LOG_END@name@@@", + "@@@STEP_LOG_LINE@arch@arm64@@@", + "@@@STEP_LOG_END@arch@@@", + "@@@STEP_LOG_LINE@platform@fuchsia-arm64@@@", + "@@@STEP_LOG_END@platform@@@", + "@@@STEP_LOG_LINE@triple@aarch64-fuchsia@@@", + "@@@STEP_LOG_END@triple@@@", + "@@@STEP_LOG_LINE@string@fuchsia-arm64@@@", + "@@@STEP_LOG_END@string@@@" + ] + }, + { + "jsonResult": null, + "name": "$result" + } +]
\ No newline at end of file diff --git a/gn/infra/recipe_modules/target/examples/full.expected/mac.json b/gn/infra/recipe_modules/target/examples/full.expected/mac.json new file mode 100644 index 00000000000..947f5d2aee9 --- /dev/null +++ b/gn/infra/recipe_modules/target/examples/full.expected/mac.json @@ -0,0 +1,22 @@ +[ + { + "cmd": [], + "name": "platform things", + "~followup_annotations": [ + "@@@STEP_LOG_LINE@name@fuchsia@@@", + "@@@STEP_LOG_END@name@@@", + "@@@STEP_LOG_LINE@arch@arm64@@@", + "@@@STEP_LOG_END@arch@@@", + "@@@STEP_LOG_LINE@platform@fuchsia-arm64@@@", + "@@@STEP_LOG_END@platform@@@", + "@@@STEP_LOG_LINE@triple@aarch64-fuchsia@@@", + "@@@STEP_LOG_END@triple@@@", + "@@@STEP_LOG_LINE@string@fuchsia-arm64@@@", + "@@@STEP_LOG_END@string@@@" + ] + }, + { + "jsonResult": null, + "name": "$result" + } +]
\ No newline at end of file diff --git a/gn/infra/recipe_modules/target/examples/full.expected/win.json b/gn/infra/recipe_modules/target/examples/full.expected/win.json new file mode 100644 index 00000000000..947f5d2aee9 --- /dev/null +++ b/gn/infra/recipe_modules/target/examples/full.expected/win.json @@ -0,0 +1,22 @@ +[ + { + "cmd": [], + "name": "platform things", + "~followup_annotations": [ + "@@@STEP_LOG_LINE@name@fuchsia@@@", + "@@@STEP_LOG_END@name@@@", + "@@@STEP_LOG_LINE@arch@arm64@@@", + "@@@STEP_LOG_END@arch@@@", + "@@@STEP_LOG_LINE@platform@fuchsia-arm64@@@", + "@@@STEP_LOG_END@platform@@@", + "@@@STEP_LOG_LINE@triple@aarch64-fuchsia@@@", + "@@@STEP_LOG_END@triple@@@", + "@@@STEP_LOG_LINE@string@fuchsia-arm64@@@", + "@@@STEP_LOG_END@string@@@" + ] + }, + { + "jsonResult": null, + "name": "$result" + } +]
\ No newline at end of file diff --git a/gn/infra/recipe_modules/target/examples/full.py b/gn/infra/recipe_modules/target/examples/full.py new file mode 100644 index 00000000000..c47c86a3f6b --- /dev/null +++ b/gn/infra/recipe_modules/target/examples/full.py @@ -0,0 +1,31 @@ +# Copyright 2018 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. + +DEPS = [ + 'target', + 'recipe_engine/platform', + 'recipe_engine/properties', + 'recipe_engine/step', +] + + +def RunSteps(api): + target = api.target('fuchsia-arm64') + assert not target.is_win + assert not target.is_linux + assert not target.is_mac + assert api.target.host.is_host + assert target != api.target.host + assert target != 'foo' + step_result = api.step('platform things', cmd=None) + step_result.presentation.logs['name'] = [target.os] + step_result.presentation.logs['arch'] = [target.arch] + step_result.presentation.logs['platform'] = [target.platform] + step_result.presentation.logs['triple'] = [target.triple] + step_result.presentation.logs['string'] = [str(target)] + + +def GenTests(api): + for platform in ('linux', 'mac', 'win'): + yield api.test(platform) + api.platform.name(platform) diff --git a/gn/infra/recipe_modules/windows_sdk/__init__.py b/gn/infra/recipe_modules/windows_sdk/__init__.py index 3c790ded06b..83323a8e13e 100644 --- a/gn/infra/recipe_modules/windows_sdk/__init__.py +++ b/gn/infra/recipe_modules/windows_sdk/__init__.py @@ -25,7 +25,7 @@ PROPERTIES = { sdk_version=Single(str)), default={ 'sdk_package': 'chrome_internal/third_party/sdk/windows', - 'sdk_version': 'uploaded:2018-06-13' + 'sdk_version': 'uploaded:2019-09-06' }, ) } diff --git a/gn/infra/recipe_modules/windows_sdk/examples/full.expected/win.json b/gn/infra/recipe_modules/windows_sdk/examples/full.expected/win.json index def8e7a2b6d..f8b2b7172d8 100644 --- a/gn/infra/recipe_modules/windows_sdk/examples/full.expected/win.json +++ b/gn/infra/recipe_modules/windows_sdk/examples/full.expected/win.json @@ -6,7 +6,7 @@ "-root", "[CACHE]\\windows_sdk", "-ensure-file", - "chrome_internal/third_party/sdk/windows uploaded:2018-06-13", + "chrome_internal/third_party/sdk/windows uploaded:2019-09-06", "-json-output", "/path/to/tmp/json" ], @@ -17,7 +17,7 @@ "@@@STEP_LOG_LINE@json.output@ \"result\": {@@@", "@@@STEP_LOG_LINE@json.output@ \"\": [@@@", "@@@STEP_LOG_LINE@json.output@ {@@@", - "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"resolved-instance_id-of-uploaded:2018-06\", @@@", + "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"resolved-instance_id-of-uploaded:2019-09\", @@@", "@@@STEP_LOG_LINE@json.output@ \"package\": \"chrome_internal/third_party/sdk/windows\"@@@", "@@@STEP_LOG_LINE@json.output@ }@@@", "@@@STEP_LOG_LINE@json.output@ ]@@@", |