This repository has been archived by the owner on Jul 19, 2021. It is now read-only.
forked from stackb/rules_proto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdk.bzl
141 lines (117 loc) · 3.31 KB
/
sdk.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# NOTE: this is a slightly modified version of
# https://github.com/dart-lang/rules_dart/blob/master/dart/build_rules/internal/sdk.bzl
# to experiment with different versions. A better solution would be a PR on the
# rules_dart repository to make it customizable.
# Copyright 2016 The Bazel Authors. 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.
"""A repository rule to download the Dart SDK."""
SDK_BUILD_FILE = """
package(default_visibility = [ "//visibility:public" ])
filegroup(
name = "dart_vm",
srcs = ["bin/dart"],
)
filegroup(
name = "analyzer",
srcs = ["bin/dartanalyzer"],
)
filegroup(
name = "dart2js",
srcs = ["bin/dart2js"],
)
filegroup(
name = "dart2js_support",
srcs = glob([
"bin/dart",
"bin/snapshots/dart2js.dart.snapshot",
"lib/**",
]),
)
filegroup(
name = "dev_compiler",
srcs = ["bin/dartdevc"],
)
filegroup(
name = "ddc_support",
srcs = glob(["lib/dev_compiler/legacy/*.*"]),
)
filegroup(
name = "pub",
srcs = ["bin/pub"],
)
filegroup(
name = "pub_support",
srcs = glob([
"version",
"bin/dart",
"bin/snapshots/pub.dart.snapshot",
]),
)
filegroup(
name = "sdk_summary",
srcs = ["lib/_internal/strong.sum"],
)
filegroup(
name = "sdk_summary_dill",
srcs = ["lib/_internal/vm_platform_strong.dill"],
)
filegroup(
name = "kernel_worker_snapshot",
srcs = ["bin/snapshots/kernel_worker.dart.snapshot"],
)
filegroup(
name = "lib_files_no_summaries",
srcs = glob([
"lib/**/*.dart",
"lib/dart_client.platform",
"lib/dart_shared.platform",
"version",
]),
)
filegroup(
name = "lib_files",
srcs = glob([
":lib_files_no_summaries",
":sdk_summaries",
]),
)
"""
_hosted_prefix = "https://storage.googleapis.com/dart-archive/channels/dev/release"
_linux_file = "dartsdk-linux-x64-release.zip"
_mac_file = "dartsdk-macos-x64-release.zip"
# From https://www.dartlang.org/tools/sdk/archive
_version = "2.2.0"
_linux_sha = "89777ceba8227d4dad6081c44bc70d301a259f3c2fdb4c1391961e376ec3af68"
_mac_sha = "9438afb49b69ac655882036c214e343232fdcd5af24607e6058e2def33261197"
def _sdk_repository_impl(repository_ctx):
"""Downloads the appropriate SDK for the current OS."""
os_name = repository_ctx.os.name
file_name = False
if "linux" in os_name:
file_name = _linux_file
sha = _linux_sha
elif "mac os" in os_name:
file_name = _mac_file
sha = _mac_sha
if not file_name:
fail("Cannot find SDK for OS: %s" % os_name)
repository_ctx.download_and_extract(
url = "%s/%s/sdk/%s" % (_hosted_prefix, _version, file_name),
sha256 = sha,
stripPrefix = "dart-sdk/",
)
repository_ctx.file("BUILD", SDK_BUILD_FILE)
dart_sdk_repository = repository_rule(
implementation = _sdk_repository_impl,
)