Skip to content

Commit 136e892

Browse files
authored
Validate that generated dart code is rebuilt (#1717)
* basically works * WIP: basic build works * WIP: back to original * Fix up grinder and builder so they work well together * Fix package warnings, move builder * Restore clearing temp directories * Make checks actually work by taking into account written-in-place files (even with --output) * make it work on windows * make builder work on windows * Add inline debugging information * More debugging * Eliminate remnants of cache creation * Make logging a little nicer * Review comments * clean up path usage for windows * quiver dep update for .64 * pin everything to .63 until pub fixed * Bypass conflicting outputs warning * Remove accidental build output directory
1 parent 6241b55 commit 136e892

File tree

8 files changed

+212
-63
lines changed

8 files changed

+212
-63
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: dart
22
sudo: false
33
dart:
4-
- "dev/raw/latest"
4+
- "dev/raw/2.0.0-dev.63.0"
55
env:
66
- DARTDOC_BOT=main
77
# TODO(devoncarew): add angulardart support

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# BSD-style license that can be found in the LICENSE file.
44

55
install:
6-
- ps: wget https://storage.googleapis.com/dart-archive/channels/dev/raw/latest/sdk/dartsdk-windows-x64-release.zip -OutFile dart-sdk.zip
6+
- ps: wget https://storage.googleapis.com/dart-archive/channels/dev/raw/2.0.0-dev.63.0/sdk/dartsdk-windows-x64-release.zip -OutFile dart-sdk.zip
77
- cmd: echo "Unzipping dart-sdk..."
88
- cmd: 7z x dart-sdk.zip -o"C:\tools" -y > nul
99
- set PATH=%PATH%;C:\tools\dart-sdk\bin

build.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
builders:
2+
resource_builder:
3+
# TODO(jcollins-g): switch to "tool/builder.dart" for next build release
4+
import: "../../../tool/builder.dart"
5+
builder_factories: ["resourceBuilder"]
6+
build_extensions: {'$lib$': ['src/html/resources.g.dart']}
7+
build_to: "source"
8+
auto_apply: none
9+
10+
targets:
11+
builder:
12+
sources: ["tool/builder.dart"]
13+
14+
$default:
15+
sources:
16+
exclude: ["tool/builder.dart"]
17+
builders: {"dartdoc|resource_builder": {enabled: true}}

lib/src/html/resources.g.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// WARNING: This file is auto-generated. Do not taunt.
22

3-
library dartdoc.html.resources;
4-
53
const List<String> resource_names = const [
64
'package:dartdoc/resources/URI.js',
75
'package:dartdoc/resources/css/bootstrap.css',

pubspec.lock

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,55 @@ packages:
2929
url: "https://pub.dartlang.org"
3030
source: hosted
3131
version: "1.0.3"
32+
build:
33+
dependency: "direct dev"
34+
description:
35+
name: build
36+
url: "https://pub.dartlang.org"
37+
source: hosted
38+
version: "0.12.6"
39+
build_config:
40+
dependency: transitive
41+
description:
42+
name: build_config
43+
url: "https://pub.dartlang.org"
44+
source: hosted
45+
version: "0.3.0"
46+
build_resolvers:
47+
dependency: transitive
48+
description:
49+
name: build_resolvers
50+
url: "https://pub.dartlang.org"
51+
source: hosted
52+
version: "0.2.0+2"
53+
build_runner:
54+
dependency: "direct dev"
55+
description:
56+
name: build_runner
57+
url: "https://pub.dartlang.org"
58+
source: hosted
59+
version: "0.8.10"
60+
build_runner_core:
61+
dependency: transitive
62+
description:
63+
name: build_runner_core
64+
url: "https://pub.dartlang.org"
65+
source: hosted
66+
version: "0.1.0"
67+
built_collection:
68+
dependency: transitive
69+
description:
70+
name: built_collection
71+
url: "https://pub.dartlang.org"
72+
source: hosted
73+
version: "3.1.1"
74+
built_value:
75+
dependency: transitive
76+
description:
77+
name: built_value
78+
url: "https://pub.dartlang.org"
79+
source: hosted
80+
version: "5.5.1"
3281
charcode:
3382
dependency: transitive
3483
description:
@@ -43,6 +92,13 @@ packages:
4392
url: "https://pub.dartlang.org"
4493
source: hosted
4594
version: "0.1.2+1"
95+
code_builder:
96+
dependency: transitive
97+
description:
98+
name: code_builder
99+
url: "https://pub.dartlang.org"
100+
source: hosted
101+
version: "3.1.0"
46102
collection:
47103
dependency: "direct main"
48104
description:
@@ -71,13 +127,27 @@ packages:
71127
url: "https://pub.dartlang.org"
72128
source: hosted
73129
version: "0.14.1"
130+
dart_style:
131+
dependency: transitive
132+
description:
133+
name: dart_style
134+
url: "https://pub.dartlang.org"
135+
source: hosted
136+
version: "1.0.14"
74137
dhttpd:
75138
dependency: "direct dev"
76139
description:
77140
name: dhttpd
78141
url: "https://pub.dartlang.org"
79142
source: hosted
80143
version: "2.0.0"
144+
fixnum:
145+
dependency: transitive
146+
description:
147+
name: fixnum
148+
url: "https://pub.dartlang.org"
149+
source: hosted
150+
version: "0.10.7"
81151
front_end:
82152
dependency: "direct main"
83153
description:
@@ -86,12 +156,19 @@ packages:
86156
source: hosted
87157
version: "0.1.1"
88158
glob:
89-
dependency: transitive
159+
dependency: "direct dev"
90160
description:
91161
name: glob
92162
url: "https://pub.dartlang.org"
93163
source: hosted
94164
version: "1.1.5"
165+
graphs:
166+
dependency: transitive
167+
description:
168+
name: graphs
169+
url: "https://pub.dartlang.org"
170+
source: hosted
171+
version: "0.1.2"
95172
grinder:
96173
dependency: "direct dev"
97174
description:
@@ -141,6 +218,13 @@ packages:
141218
url: "https://pub.dartlang.org"
142219
source: hosted
143220
version: "0.6.1"
221+
json_annotation:
222+
dependency: transitive
223+
description:
224+
name: json_annotation
225+
url: "https://pub.dartlang.org"
226+
source: hosted
227+
version: "0.2.8"
144228
kernel:
145229
dependency: transitive
146230
description:
@@ -246,13 +330,20 @@ packages:
246330
url: "https://pub.dartlang.org"
247331
source: hosted
248332
version: "1.3.7"
333+
pubspec_parse:
334+
dependency: transitive
335+
description:
336+
name: pubspec_parse
337+
url: "https://pub.dartlang.org"
338+
source: hosted
339+
version: "0.1.1"
249340
quiver:
250341
dependency: "direct main"
251342
description:
252343
name: quiver
253344
url: "https://pub.dartlang.org"
254345
source: hosted
255-
version: "0.27.0"
346+
version: "0.29.0+1"
256347
quiver_hashcode:
257348
dependency: transitive
258349
description:
@@ -330,6 +421,13 @@ packages:
330421
url: "https://pub.dartlang.org"
331422
source: hosted
332423
version: "1.6.4"
424+
stream_transform:
425+
dependency: transitive
426+
description:
427+
name: stream_transform
428+
url: "https://pub.dartlang.org"
429+
source: hosted
430+
version: "0.0.14"
333431
string_scanner:
334432
dependency: transitive
335433
description:
@@ -394,4 +492,4 @@ packages:
394492
source: hosted
395493
version: "2.1.13"
396494
sdks:
397-
dart: ">=2.0.0-dev.59.0 <=2.0.0-dev.62.0"
495+
dart: ">=2.0.0-dev.59.0 <=2.0.0-dev.63.0"

pubspec.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ homepage: https://github.com/dart-lang/dartdoc
77
environment:
88
sdk: '>=2.0.0-dev.59.0 <3.0.0'
99
dependencies:
10-
analyzer: 0.32.1
10+
analyzer: ^0.32.1
1111
args: '>=1.4.1 <2.0.0'
1212
collection: ^1.2.0
1313
front_end: ^0.1.1
@@ -21,13 +21,16 @@ dependencies:
2121
package_config: '>=0.1.5 <2.0.0'
2222
path: ^1.3.0
2323
pub_semver: ^1.3.7
24-
quiver: ^0.27.0
24+
quiver: ^0.29.0
2525
resource: ^2.1.2
2626
stack_trace: ^1.4.2
2727
tuple: ^1.0.1
2828
yaml: ^2.1.0
2929
dev_dependencies:
30+
build: ^0.12.6
31+
build_runner: ^0.8.10
3032
dhttpd: ^2.0.0
33+
glob: ^1.1.5
3134
grinder: ^0.8.2
3235
io: ^0.3.0
3336
http: ^0.11.0

tool/builder.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
import 'package:build/build.dart';
8+
import 'package:glob/glob.dart';
9+
import 'package:path/path.dart' as pathLib;
10+
11+
String _resourcesFile(Iterable<String> packagePaths) => '''
12+
// WARNING: This file is auto-generated. Do not taunt.
13+
14+
const List<String> resource_names = const [
15+
${packagePaths.map((p) => " '$p'").join(',\n')}
16+
];
17+
''';
18+
19+
class ResourceBuilder implements Builder {
20+
final BuilderOptions builderOptions;
21+
ResourceBuilder(this.builderOptions);
22+
23+
static final _allResources = new Glob('lib/resources/**');
24+
@override
25+
Future build(BuildStep buildStep) async {
26+
var packagePaths = <String>[];
27+
await for (AssetId asset in buildStep.findAssets(_allResources)) {
28+
packagePaths.add(asset.uri.toString());
29+
}
30+
packagePaths.sort();
31+
await buildStep.writeAsString(
32+
new AssetId(buildStep.inputId.package,
33+
pathLib.url.join('lib', 'src', 'html', 'resources.g.dart')),
34+
_resourcesFile(packagePaths));
35+
}
36+
37+
@override
38+
final Map<String, List<String>> buildExtensions = const {
39+
r'$lib$': const ['src/html/resources.g.dart']
40+
};
41+
}
42+
43+
Builder resourceBuilder(BuilderOptions options) => new ResourceBuilder(options);

0 commit comments

Comments
 (0)