From fcde5ca4c491632b319e8b8f37a42936d5d63544 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 12 Jul 2018 16:11:03 +0000 Subject: [PATCH] Remove old samples. Change-Id: I07773e6d9095c17f6ad4ed223d456838ddf122b5 Reviewed-on: https://dart-review.googlesource.com/64700 Reviewed-by: Konstantin Shcheglov Commit-Queue: Devon Carew --- samples/build_dart/bin/test.dart | 30 ---- samples/build_dart/build.dart | 155 ------------------ samples/build_dart/pubspec.yaml | 6 - samples/build_dart/test.foo | 4 - samples/build_dart/test/build_dart_test.dart | 14 -- samples/build_dart_simple/build.dart | 34 ---- samples/build_dart_simple/test.dart | 30 ---- samples/build_dart_simple/test.foo | 1 - .../test/build_dart_simple_test.dart | 14 -- samples/samples.status | 5 - 10 files changed, 293 deletions(-) delete mode 100644 samples/build_dart/bin/test.dart delete mode 100644 samples/build_dart/build.dart delete mode 100644 samples/build_dart/pubspec.yaml delete mode 100644 samples/build_dart/test.foo delete mode 100644 samples/build_dart/test/build_dart_test.dart delete mode 100644 samples/build_dart_simple/build.dart delete mode 100644 samples/build_dart_simple/test.dart delete mode 100644 samples/build_dart_simple/test.foo delete mode 100644 samples/build_dart_simple/test/build_dart_simple_test.dart diff --git a/samples/build_dart/bin/test.dart b/samples/build_dart/bin/test.dart deleted file mode 100644 index bc7ce1b1c0f..00000000000 --- a/samples/build_dart/bin/test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library test_build_dart; - -import "dart:io"; - -/** - * In order to generate test.foobar, make an edit to test.foo. - */ -void main() { - printContents("test.foo"); - print(""); - printContents("test.foobar"); -} - -void printContents(String file) { - print("the contents of ${file} are:"); - - var f = new File(file); - - if (f.existsSync()) { - String contents = new File(file).readAsStringSync(); - - print("[${contents}]"); - } else { - print("[]"); - } -} diff --git a/samples/build_dart/build.dart b/samples/build_dart/build.dart deleted file mode 100644 index 7058e70ed29..00000000000 --- a/samples/build_dart/build.dart +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library build_dart; - -import "dart:io"; -import "package:args/args.dart"; - -bool cleanBuild; -bool fullBuild; -bool useMachineInterface; - -List changedFiles; -List removedFiles; - -/** - * If the file is named 'build.dart' and is placed in the root directory of a - * project or in a directory containing a pubspec.yaml file, then the Editor - * will automatically invoke that file whenever a file in that project changes. - * See the source code of [processArgs] for information about the legal command - * line options. - */ -void main(List arguments) { - processArgs(arguments); - - if (cleanBuild) { - handleCleanCommand(); - } else if (fullBuild) { - handleFullBuild(); - } else { - handleChangedFiles(changedFiles); - handleRemovedFiles(removedFiles); - } - - // Return a non-zero code to indicate a build failure. - //exit(1); -} - -/** - * Handle --changed, --removed, --clean, --full, and --help command-line args. - */ -void processArgs(List arguments) { - var parser = new ArgParser(); - parser.addOption("changed", - help: "the file has changed since the last build", allowMultiple: true); - parser.addOption("removed", - help: "the file was removed since the last build", allowMultiple: true); - parser.addFlag("clean", negatable: false, help: "remove any build artifacts"); - parser.addFlag("full", negatable: false, help: "perform a full build"); - parser.addFlag("machine", - negatable: false, help: "produce warnings in a machine parseable format"); - parser.addFlag("help", negatable: false, help: "display this help and exit"); - - var args = parser.parse(arguments); - - if (args["help"]) { - print(parser.getUsage()); - exit(0); - } - - changedFiles = args["changed"]; - removedFiles = args["removed"]; - - useMachineInterface = args["machine"]; - - cleanBuild = args["clean"]; - fullBuild = args["full"]; -} - -/** - * Delete all generated files. - */ -void handleCleanCommand() { - Directory current = Directory.current; - current.list(recursive: true).listen((FileSystemEntity entity) { - if (entity is File) _maybeClean(entity); - }); -} - -/** - * Recursively scan the current directory looking for .foo files to process. - */ -void handleFullBuild() { - var files = []; - - Directory.current.list(recursive: true).listen((entity) { - if (entity is File) { - files.add((entity as File).resolveSymbolicLinksSync()); - } - }, onDone: () => handleChangedFiles(files)); -} - -/** - * Process the given list of changed files. - */ -void handleChangedFiles(List files) { - files.forEach(_processFile); -} - -/** - * Process the given list of removed files. - */ -void handleRemovedFiles(List files) {} - -/** - * Convert a .foo file to a .foobar file. - */ -void _processFile(String arg) { - if (arg.endsWith(".foo")) { - print("processing: ${arg}"); - - File file = new File(arg); - - String contents = file.readAsStringSync(); - - File outFile = new File("${arg}bar"); - - IOSink out = outFile.openWrite(); - out.writeln("// processed from ${file.path}:"); - if (contents != null) { - out.write(contents); - } - out.close(); - - _findErrors(arg); - - print("wrote: ${outFile.path}"); - } -} - -void _findErrors(String arg) { - File file = new File(arg); - - List lines = file.readAsLinesSync(); - - for (int i = 0; i < lines.length; i++) { - if (lines[i].contains("woot") && !lines[i].startsWith("//")) { - if (useMachineInterface) { - // Ideally, we should emit the charStart and charEnd params as well. - print('[{"method":"error","params":{"file":"$arg","line":${i+1},' - '"message":"woot not supported"}}]'); - } - } - } -} - -/** - * If this file is a generated file (based on the extension), delete it. - */ -void _maybeClean(File file) { - if (file.path.endsWith(".foobar")) { - file.delete(); - } -} diff --git a/samples/build_dart/pubspec.yaml b/samples/build_dart/pubspec.yaml deleted file mode 100644 index 8af67a1a5d6..00000000000 --- a/samples/build_dart/pubspec.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: buildhook2 -description: A demo of the buildhook build.dart script. -dependencies: - args: ">=0.9.0 <0.10.0" -environment: - sdk: ">=0.8.10+6 <2.0.0" diff --git a/samples/build_dart/test.foo b/samples/build_dart/test.foo deleted file mode 100644 index 3c1e3c050a8..00000000000 --- a/samples/build_dart/test.foo +++ /dev/null @@ -1,4 +0,0 @@ -I'm from foo. -I'm from foo. -I'm from woot. -//I'm from woot. diff --git a/samples/build_dart/test/build_dart_test.dart b/samples/build_dart/test/build_dart_test.dart deleted file mode 100644 index e146d6b490d..00000000000 --- a/samples/build_dart/test/build_dart_test.dart +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library build_dart_test; - -import '../build.dart' as build_dart; -import '../bin/test.dart' as test2; - -/** - * This test exists to ensure that the build_dart sample compiles without - * errors. - */ -void main() {} diff --git a/samples/build_dart_simple/build.dart b/samples/build_dart_simple/build.dart deleted file mode 100644 index 0345f74a54b..00000000000 --- a/samples/build_dart_simple/build.dart +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library build_dart_simple; - -import "dart:io"; - -/** - * This minimal build script copies the contents of .foo files to .foobar files. - * In order to be invoked automatically by the Editor, this script must be named - * 'build.dart' and placed in the root of a project. - */ -void main(List arguments) { - for (String arg in arguments) { - if (arg.startsWith("--changed=")) { - String file = arg.substring("--changed=".length); - - if (file.endsWith(".foo")) { - _processFile(file); - } - } - } -} - -void _processFile(String file) { - String contents = new File(file).readAsStringSync(); - - if (contents != null) { - IOSink out = new File("${file}bar").openWrite(); - out.write("// processed from ${file}:\n${contents}"); - out.close(); - } -} diff --git a/samples/build_dart_simple/test.dart b/samples/build_dart_simple/test.dart deleted file mode 100644 index 6ed759b9322..00000000000 --- a/samples/build_dart_simple/test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library test_build_dart_simple; - -import "dart:io"; - -/** - * In order to generate test.foobar, make an edit to test.foo. - */ -void main() { - printContents("test.foo"); - print(""); - printContents("test.foobar"); -} - -void printContents(String file) { - print("the contents of ${file} are:"); - - var f = new File(file); - - if (f.existsSync()) { - String contents = new File(file).readAsStringSync(); - - print("[${contents}]"); - } else { - print("[]"); - } -} diff --git a/samples/build_dart_simple/test.foo b/samples/build_dart_simple/test.foo deleted file mode 100644 index c6d13c9d779..00000000000 --- a/samples/build_dart_simple/test.foo +++ /dev/null @@ -1 +0,0 @@ -I'm from foo. \ No newline at end of file diff --git a/samples/build_dart_simple/test/build_dart_simple_test.dart b/samples/build_dart_simple/test/build_dart_simple_test.dart deleted file mode 100644 index 8a8c4c30a7e..00000000000 --- a/samples/build_dart_simple/test/build_dart_simple_test.dart +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library build_dart_simple_test; - -import '../build.dart' as build_dart_simple; -import '../test.dart' as test1; - -/** - * This test exists to ensure that the build_dart_simple sample compiles - * without errors. - */ -void main() {} diff --git a/samples/samples.status b/samples/samples.status index 52da266b247..a875727808a 100644 --- a/samples/samples.status +++ b/samples/samples.status @@ -11,9 +11,6 @@ sample_extension/test/sample_extension_app_snapshot_test: SkipByDesign # This te [ $compiler == app_jit ] sample_extension/test/sample_extension_app_snapshot_test: RuntimeError -[ $compiler == dart2analyzer ] -build_dart: Skip - [ $compiler == precompiler ] sample_extension/test/*: Skip # These tests attempt to spawn another script using the precompiled runtime. @@ -36,8 +33,6 @@ sample_extension/test/sample_extension_test: RuntimeError # Skip tests that use dart:io [ $runtime == d8 || $browser ] -build_dart/*: Skip -build_dart_simple/*: Skip sample_extension/*: Skip [ $hot_reload || $hot_reload_rollback ]