From adeef73a97cf191301a7b563883a075caed733b7 Mon Sep 17 00:00:00 2001 From: Damien Martin-Guillerez Date: Tue, 24 Mar 2015 09:05:08 +0000 Subject: Move all examples into Bazel workspace Those examples will be used for Bazel integration tests and their sources should be available directly to the Bazel workspace itself. -- MOS_MIGRATED_REVID=89380736 --- base_workspace/examples/cpp/BUILD | 25 -- base_workspace/examples/cpp/README.md | 4 - base_workspace/examples/cpp/hello-fail.cc | 22 -- base_workspace/examples/cpp/hello-lib.cc | 21 -- base_workspace/examples/cpp/hello-lib.h | 23 -- base_workspace/examples/cpp/hello-world.cc | 26 --- base_workspace/examples/gen/BUILD | 14 -- base_workspace/examples/go/BUILD | 14 -- base_workspace/examples/go/README.md | 121 ---------- base_workspace/examples/go/fib.go | 11 - base_workspace/examples/go/lib1/BUILD | 24 -- base_workspace/examples/go/lib1/fail_test.go | 9 - base_workspace/examples/go/lib1/lib1.go | 9 - base_workspace/examples/go/lib1/lib1_test.go | 14 -- base_workspace/examples/java-native/README.md | 4 - .../src/main/java/com/example/myproject/BUILD | 24 -- .../main/java/com/example/myproject/Greeter.java | 49 ---- .../examples/java-native/src/main/resources/BUILD | 6 - .../java-native/src/main/resources/greeting.txt | 1 - .../src/test/java/com/example/myproject/BUILD | 33 --- .../src/test/java/com/example/myproject/Fail.java | 14 -- .../com/example/myproject/TestCustomGreeting.java | 32 --- .../test/java/com/example/myproject/TestHello.java | 35 --- base_workspace/examples/java-skylark/README.md | 7 - .../src/main/java/com/example/myproject/BUILD | 21 -- .../main/java/com/example/myproject/Greeter.java | 45 ---- .../examples/java-skylark/src/main/resources/BUILD | 6 - .../java-skylark/src/main/resources/greeting.txt | 1 - .../src/test/java/com/example/myproject/BUILD | 16 -- .../src/test/java/com/example/myproject/Fail.java | 7 - .../test/java/com/example/myproject/TestHello.java | 35 --- base_workspace/examples/objc/BUILD | 106 --------- .../examples/objc/PrenotCalculator/AppDelegate.h | 21 -- .../examples/objc/PrenotCalculator/AppDelegate.m | 59 ----- .../objc/PrenotCalculator/CalculatedValues.h | 28 --- .../objc/PrenotCalculator/CalculatedValues.m | 48 ---- .../PrenotCalculator/CalculatorViewController.h | 35 --- .../PrenotCalculator/CalculatorViewController.m | 127 ---------- .../PrenotCalculator/CalculatorViewController.xib | 257 --------------------- .../examples/objc/PrenotCalculator/CoreData.h | 23 -- .../examples/objc/PrenotCalculator/CoreData.m | 41 ---- .../DataModel.xcdatamodeld/.xccurrentversion | 23 -- .../DataModel-1.0.xcdatamodel/contents | 24 -- .../DataModel-1.1.xcdatamodel/contents | 25 -- .../examples/objc/PrenotCalculator/Equation.h | 34 --- .../examples/objc/PrenotCalculator/Equation.m | 108 --------- .../examples/objc/PrenotCalculator/Expression.h | 21 -- .../examples/objc/PrenotCalculator/Expression.m | 34 --- .../examples/objc/PrenotCalculator/Literal.h | 21 -- .../examples/objc/PrenotCalculator/Literal.m | 44 ---- .../PrenotCalculator/PrenotCalculator-Info.plist | 60 ----- .../objc/PrenotCalculator/Resources/test.txt | 1 - .../objc/PrenotCalculator/ValuesViewController.h | 19 -- .../objc/PrenotCalculator/ValuesViewController.m | 64 ----- .../examples/objc/PrenotCalculator/main.m | 27 --- base_workspace/examples/objc/README.md | 17 -- base_workspace/examples/objc/expression_prebuilt.a | Bin 9460 -> 0 bytes base_workspace/examples/proto/BUILD | 8 - base_workspace/examples/proto/test.proto | 10 - base_workspace/examples/py/BUILD | 14 -- base_workspace/examples/py/bin.py | 3 - base_workspace/examples/py/lib.py | 5 - 62 files changed, 1980 deletions(-) delete mode 100644 base_workspace/examples/cpp/BUILD delete mode 100644 base_workspace/examples/cpp/README.md delete mode 100644 base_workspace/examples/cpp/hello-fail.cc delete mode 100644 base_workspace/examples/cpp/hello-lib.cc delete mode 100644 base_workspace/examples/cpp/hello-lib.h delete mode 100644 base_workspace/examples/cpp/hello-world.cc delete mode 100644 base_workspace/examples/gen/BUILD delete mode 100644 base_workspace/examples/go/BUILD delete mode 100644 base_workspace/examples/go/README.md delete mode 100644 base_workspace/examples/go/fib.go delete mode 100644 base_workspace/examples/go/lib1/BUILD delete mode 100644 base_workspace/examples/go/lib1/fail_test.go delete mode 100644 base_workspace/examples/go/lib1/lib1.go delete mode 100644 base_workspace/examples/go/lib1/lib1_test.go delete mode 100644 base_workspace/examples/java-native/README.md delete mode 100644 base_workspace/examples/java-native/src/main/java/com/example/myproject/BUILD delete mode 100644 base_workspace/examples/java-native/src/main/java/com/example/myproject/Greeter.java delete mode 100644 base_workspace/examples/java-native/src/main/resources/BUILD delete mode 100644 base_workspace/examples/java-native/src/main/resources/greeting.txt delete mode 100644 base_workspace/examples/java-native/src/test/java/com/example/myproject/BUILD delete mode 100644 base_workspace/examples/java-native/src/test/java/com/example/myproject/Fail.java delete mode 100644 base_workspace/examples/java-native/src/test/java/com/example/myproject/TestCustomGreeting.java delete mode 100644 base_workspace/examples/java-native/src/test/java/com/example/myproject/TestHello.java delete mode 100644 base_workspace/examples/java-skylark/README.md delete mode 100644 base_workspace/examples/java-skylark/src/main/java/com/example/myproject/BUILD delete mode 100644 base_workspace/examples/java-skylark/src/main/java/com/example/myproject/Greeter.java delete mode 100644 base_workspace/examples/java-skylark/src/main/resources/BUILD delete mode 100644 base_workspace/examples/java-skylark/src/main/resources/greeting.txt delete mode 100644 base_workspace/examples/java-skylark/src/test/java/com/example/myproject/BUILD delete mode 100644 base_workspace/examples/java-skylark/src/test/java/com/example/myproject/Fail.java delete mode 100644 base_workspace/examples/java-skylark/src/test/java/com/example/myproject/TestHello.java delete mode 100644 base_workspace/examples/objc/BUILD delete mode 100644 base_workspace/examples/objc/PrenotCalculator/AppDelegate.h delete mode 100644 base_workspace/examples/objc/PrenotCalculator/AppDelegate.m delete mode 100644 base_workspace/examples/objc/PrenotCalculator/CalculatedValues.h delete mode 100644 base_workspace/examples/objc/PrenotCalculator/CalculatedValues.m delete mode 100644 base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.h delete mode 100644 base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.m delete mode 100644 base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.xib delete mode 100644 base_workspace/examples/objc/PrenotCalculator/CoreData.h delete mode 100644 base_workspace/examples/objc/PrenotCalculator/CoreData.m delete mode 100644 base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/.xccurrentversion delete mode 100644 base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.0.xcdatamodel/contents delete mode 100644 base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.1.xcdatamodel/contents delete mode 100644 base_workspace/examples/objc/PrenotCalculator/Equation.h delete mode 100644 base_workspace/examples/objc/PrenotCalculator/Equation.m delete mode 100644 base_workspace/examples/objc/PrenotCalculator/Expression.h delete mode 100644 base_workspace/examples/objc/PrenotCalculator/Expression.m delete mode 100644 base_workspace/examples/objc/PrenotCalculator/Literal.h delete mode 100644 base_workspace/examples/objc/PrenotCalculator/Literal.m delete mode 100644 base_workspace/examples/objc/PrenotCalculator/PrenotCalculator-Info.plist delete mode 100644 base_workspace/examples/objc/PrenotCalculator/Resources/test.txt delete mode 100644 base_workspace/examples/objc/PrenotCalculator/ValuesViewController.h delete mode 100644 base_workspace/examples/objc/PrenotCalculator/ValuesViewController.m delete mode 100644 base_workspace/examples/objc/PrenotCalculator/main.m delete mode 100644 base_workspace/examples/objc/README.md delete mode 100644 base_workspace/examples/objc/expression_prebuilt.a delete mode 100644 base_workspace/examples/proto/BUILD delete mode 100644 base_workspace/examples/proto/test.proto delete mode 100644 base_workspace/examples/py/BUILD delete mode 100644 base_workspace/examples/py/bin.py delete mode 100644 base_workspace/examples/py/lib.py (limited to 'base_workspace') diff --git a/base_workspace/examples/cpp/BUILD b/base_workspace/examples/cpp/BUILD deleted file mode 100644 index 195bbb3d25..0000000000 --- a/base_workspace/examples/cpp/BUILD +++ /dev/null @@ -1,25 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "hello-lib", - srcs = ["hello-lib.cc"], - hdrs = ["hello-lib.h"], -) - -cc_binary( - name = "hello-world", - srcs = ["hello-world.cc"], - deps = [":hello-lib"], -) - -cc_test( - name = "hello-success_test", - srcs = ["hello-world.cc"], - deps = [":hello-lib"], -) - -cc_test( - name = "hello-fail_test", - srcs = ["hello-fail.cc"], - deps = [":hello-lib"], -) diff --git a/base_workspace/examples/cpp/README.md b/base_workspace/examples/cpp/README.md deleted file mode 100644 index fba714321c..0000000000 --- a/base_workspace/examples/cpp/README.md +++ /dev/null @@ -1,4 +0,0 @@ -C++ Examples -============ - -These examples demonstrate building C++ binaries, libraries, and tests. diff --git a/base_workspace/examples/cpp/hello-fail.cc b/base_workspace/examples/cpp/hello-fail.cc deleted file mode 100644 index 5b561cb0ce..0000000000 --- a/base_workspace/examples/cpp/hello-fail.cc +++ /dev/null @@ -1,22 +0,0 @@ -#include "examples/cpp/hello-lib.h" - -#include - -using hello::HelloLib; -using std::string; - -/** - * This is a fake test that prints "Hello barf" and then exits with exit code 1. - * If run as a test (cc_test), the non-0 exit code indicates to Bazel that the - * "test" has failed. - */ -int main(int argc, char** argv) { - HelloLib lib; - string thing = "barf"; - if (argc > 1) { - thing = argv[1]; - } - - lib.greet(thing); - return 1; -} diff --git a/base_workspace/examples/cpp/hello-lib.cc b/base_workspace/examples/cpp/hello-lib.cc deleted file mode 100644 index 8e40921cee..0000000000 --- a/base_workspace/examples/cpp/hello-lib.cc +++ /dev/null @@ -1,21 +0,0 @@ -#include "examples/cpp/hello-lib.h" - -#include - -using std::cout; -using std::endl; -using std::string; - -namespace hello { - -HelloLib::HelloLib() : HelloLib("Hello") { -} - -HelloLib::HelloLib(const string& greeting) : greeting_(new string(greeting)) { -} - -void HelloLib::greet(const string& thing) { - cout << *greeting_ << " " << thing << endl; -} - -} // namespace hello diff --git a/base_workspace/examples/cpp/hello-lib.h b/base_workspace/examples/cpp/hello-lib.h deleted file mode 100644 index 555d177936..0000000000 --- a/base_workspace/examples/cpp/hello-lib.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef EXAMPLES_CPP_HELLO_LIB_H_ -#define EXAMPLES_CPP_HELLO_LIB_H_ - -#include -#include - -namespace hello { - -class HelloLib { - public: - HelloLib(); - - explicit HelloLib(const std::string &greeting); - - void greet(const std::string &thing); - - private: - std::unique_ptr greeting_; -}; - -} // namespace hello - -#endif // EXAMPLES_CPP_HELLO_LIB_H_ diff --git a/base_workspace/examples/cpp/hello-world.cc b/base_workspace/examples/cpp/hello-world.cc deleted file mode 100644 index be435c3256..0000000000 --- a/base_workspace/examples/cpp/hello-world.cc +++ /dev/null @@ -1,26 +0,0 @@ -#include "examples/cpp/hello-lib.h" - -#include - -using hello::HelloLib; -using std::string; - -/** - * This prints "Hello world". If it is run with arguments, it will use the first - * argument instead of "world". Build and run //examples/cpp:hello-world to see - * this program in action. - * - * This file does double-duty as a "test." It is a cc_binary, so it can also be - * compiled as a cc_test and Bazel will decide on whether it passed or failed - * based on exit code (which is always 0 here, so the test "passes"). See - * hello-fail.cc for an example of making a test fail. - */ -int main(int argc, char** argv) { - HelloLib lib("Hello"); - string thing = "world"; - if (argc > 1) { - thing = argv[1]; - } - lib.greet(thing); - return 0; -} diff --git a/base_workspace/examples/gen/BUILD b/base_workspace/examples/gen/BUILD deleted file mode 100644 index 988fa8b7de..0000000000 --- a/base_workspace/examples/gen/BUILD +++ /dev/null @@ -1,14 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -genquery( - name = "genquery", - expression = "deps(//tools/defaults:jdk)", - scope = ["//tools/defaults:jdk"], -) - -genrule( - name = "genrule", - srcs = [":genquery"], - outs = ["genrule.txt"], - cmd = "cat $(SRCS) > $@", -) diff --git a/base_workspace/examples/go/BUILD b/base_workspace/examples/go/BUILD deleted file mode 100644 index dd0846110c..0000000000 --- a/base_workspace/examples/go/BUILD +++ /dev/null @@ -1,14 +0,0 @@ -# See README.md for instructions on how to use these rules. - -package(default_visibility = ["//visibility:public"]) - -load("/tools/build_rules/go_rules", "go_library", "go_binary") - -go_binary( - name = "fib", - srcs = glob( - ["*.go"], - exclude = ["*_test.go"], - ), - deps = ["//examples/go/lib1"], -) diff --git a/base_workspace/examples/go/README.md b/base_workspace/examples/go/README.md deleted file mode 100644 index 69bcc4c664..0000000000 --- a/base_workspace/examples/go/README.md +++ /dev/null @@ -1,121 +0,0 @@ - -Go rules --------- - -The files here demonstrate how to use the rules for Go supplied under -`//tools/build_rules:go_rules.bzl`. The rules should be considered -experimental. They support: - - * libraries - * binaries - * tests - -They currently do not support: - - * coverage - * race detector - * multiple target configurations - * //+build tags - * C/C++ interoperation (cgo, swig etc.) - - -Testing -------- - -Setup a symlink to the Go installation you wish to use, - - ln -s /usr/lib/golang/ tools/go/go_root - -or - - ln -s $(go env GOROOT) tools/go/go_root - -To build something, run - - bazel build examples/go/... - -To run a test, run - - bazel test --test_arg=--test.v examples/go/lib1:lib1_test - - -Writing BUILD rules -------------------- - -In the bazel model of compiling Go, each directory can hold multiple -packages, rather than just one in the standard "go" tool. Suppose you -have - - dir/f.go: - - package p - func F() {} - -then in the BUILD file could say - - go_library( - name = "q", - srcs = ["f.go"]) - -and you import it with its Bazel name, - - import "dir/p/q" - -this add the declared package name as namespace, i.e., it is -equivalent to - - import p "dir/p/q" - -so you use it as follows - - import "dir/p/q" - main() { - p.F() - } - - -Writing tests -------------- - -For tests, you should create a separate target, - - go_test( - name = "q_test", - srcs = [ "f_test.go" ], - deps = [ ":q" ]) - -if the test code is in the same package as the library under test -(e.g., because you are testing private parts of the library), you should -use the `library` attribute, - - go_test( - name = "q_test", - srcs = [ "f_test.go" ], - library = ":q" ) - -This causes the test and the library under test to be compiled -together. - - -FAQ ---- - -# Why does this not follow the external Go conventions? - -These rules were inspired on Google's internal Go rules, which work -like this. For Bazel, these make more sense, because directories in -Bazel do not correspond to single targets. - - -# Do I have to specify dependencies twice? - -Yes, once in the BUILD file, once in the source file. Bazel does not -examine file contents, so it cannot infer the dependencies. It is -possible to generate the BUILD file from the Go sources through a -separate program, though. - - -Disclaimer ----------- - -These rules are not supported by Google's Go team. diff --git a/base_workspace/examples/go/fib.go b/base_workspace/examples/go/fib.go deleted file mode 100644 index 43d8a499ba..0000000000 --- a/base_workspace/examples/go/fib.go +++ /dev/null @@ -1,11 +0,0 @@ -package main - -import ( - "fmt" - - "examples/go/lib1/lib1" -) - -func main() { - fmt.Println("Fib(5):", lib1.Fib(5)) -} diff --git a/base_workspace/examples/go/lib1/BUILD b/base_workspace/examples/go/lib1/BUILD deleted file mode 100644 index fb400772ef..0000000000 --- a/base_workspace/examples/go/lib1/BUILD +++ /dev/null @@ -1,24 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load("/tools/build_rules/go_rules", "go_library", "go_binary", "go_test") - -go_library( - name = "lib1", - srcs = glob( - ["*.go"], - exclude = ["*_test.go"], - ), -) - -go_test( - name = "lib1_test", - srcs = [ - "lib1_test.go", - ], - library = ":lib1", -) - -go_test( - name = "fail_test", - srcs = ["fail_test.go"], -) diff --git a/base_workspace/examples/go/lib1/fail_test.go b/base_workspace/examples/go/lib1/fail_test.go deleted file mode 100644 index 5ef41a3b4d..0000000000 --- a/base_workspace/examples/go/lib1/fail_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package fail - -import ( - "testing" -) - -func TestFail(t *testing.T) { - t.Fatal("I am failing.") -} diff --git a/base_workspace/examples/go/lib1/lib1.go b/base_workspace/examples/go/lib1/lib1.go deleted file mode 100644 index f42494770d..0000000000 --- a/base_workspace/examples/go/lib1/lib1.go +++ /dev/null @@ -1,9 +0,0 @@ -package lib1 - -func Fib(n int) int { - if n < 2 { - return 1 - } - - return Fib(n-1) + Fib(n-2) -} diff --git a/base_workspace/examples/go/lib1/lib1_test.go b/base_workspace/examples/go/lib1/lib1_test.go deleted file mode 100644 index 8eb88a0aca..0000000000 --- a/base_workspace/examples/go/lib1/lib1_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package lib1 - -import ( - "testing" -) - -func TestFib(t *testing.T) { - got := Fib(5) - want := 8 - - if got != want { - t.Fatalf("got %d want %d", got, want) - } -} diff --git a/base_workspace/examples/java-native/README.md b/base_workspace/examples/java-native/README.md deleted file mode 100644 index fb37462bf3..0000000000 --- a/base_workspace/examples/java-native/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Java Examples -============= - -This directory contains examples for Java language rules. diff --git a/base_workspace/examples/java-native/src/main/java/com/example/myproject/BUILD b/base_workspace/examples/java-native/src/main/java/com/example/myproject/BUILD deleted file mode 100644 index 717625343b..0000000000 --- a/base_workspace/examples/java-native/src/main/java/com/example/myproject/BUILD +++ /dev/null @@ -1,24 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -java_binary( - name = "hello-world", - main_class = "com.example.myproject.Greeter", - runtime_deps = [":hello-lib"], -) - -java_library( - name = "hello-lib", - srcs = glob(["*.java"]), -) - -java_binary( - name = "hello-resources", - main_class = "com.example.myproject.Greeter", - runtime_deps = [":custom-greeting"], -) - -java_library( - name = "custom-greeting", - srcs = ["Greeter.java"], - resources = ["//examples/java-native/src/main/resources:greeting"], -) diff --git a/base_workspace/examples/java-native/src/main/java/com/example/myproject/Greeter.java b/base_workspace/examples/java-native/src/main/java/com/example/myproject/Greeter.java deleted file mode 100644 index 4123f2e202..0000000000 --- a/base_workspace/examples/java-native/src/main/java/com/example/myproject/Greeter.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.example.myproject; - -import java.io.InputStream; -import java.io.PrintStream; -import java.util.Scanner; - -/** - * Prints a greeting which can be customized by building with resources and/or passing in command- - * line arguments. - * - *

Building and running this file will print "Hello world". Build and run the - * //examples/java-native/src/main/java/com/example/myproject:hello-world target to demonstrate - * this.

- * - *

If this is built with a greeting.txt resource included, it will replace "Hello" with the - * contents of greeting.txt. The - * //examples/java-native/src/main/java/com/example/myproject:hello-resources target demonstrates - * this.

- * - *

If arguments are passed to the binary on the command line, the first argument will replace - * "world" in the output. See //examples/java-native/src/test/java/com/example/myproject:hello's - * argument test.

- */ -public class Greeter { - static PrintStream out = System.out; - - public static String convertStreamToString(InputStream is) throws Exception { - try (Scanner s = new Scanner(is)) { - s.useDelimiter("\n"); - return s.hasNext() ? s.next() : ""; - } - } - - public void hello(String obj) throws Exception { - String greeting = "Hello"; - InputStream stream = Greeter.class.getResourceAsStream( - "/examples/java-native/src/main/resources/greeting.txt"); - if (stream != null) { - greeting = convertStreamToString(stream); - } - out.println(greeting + " " + obj); - } - - public static void main(String... args) throws Exception { - Greeter g = new Greeter(); - String obj = args.length > 0 ? args[0] : "world"; - g.hello(obj); - } -} diff --git a/base_workspace/examples/java-native/src/main/resources/BUILD b/base_workspace/examples/java-native/src/main/resources/BUILD deleted file mode 100644 index 8347a3555a..0000000000 --- a/base_workspace/examples/java-native/src/main/resources/BUILD +++ /dev/null @@ -1,6 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -filegroup( - name = "greeting", - srcs = ["greeting.txt"], -) diff --git a/base_workspace/examples/java-native/src/main/resources/greeting.txt b/base_workspace/examples/java-native/src/main/resources/greeting.txt deleted file mode 100644 index 09170083fc..0000000000 --- a/base_workspace/examples/java-native/src/main/resources/greeting.txt +++ /dev/null @@ -1 +0,0 @@ -Bye diff --git a/base_workspace/examples/java-native/src/test/java/com/example/myproject/BUILD b/base_workspace/examples/java-native/src/test/java/com/example/myproject/BUILD deleted file mode 100644 index 838107650c..0000000000 --- a/base_workspace/examples/java-native/src/test/java/com/example/myproject/BUILD +++ /dev/null @@ -1,33 +0,0 @@ -java_test( - name = "hello", - srcs = ["TestHello.java"], - deps = [ - "//examples/java-native/src/main/java/com/example/myproject:hello-lib", - "//third_party:junit4", - ], -) - -java_test( - name = "custom", - srcs = ["TestCustomGreeting.java"], - deps = [ - "//examples/java-native/src/main/java/com/example/myproject:custom-greeting", - "//third_party:junit4", - ], -) - -java_test( - name = "fail", - srcs = ["Fail.java"], - deps = ["//third_party:junit4"], -) - -# This attempts to run TestCustomGreeting.java without any resources, so fails. -java_test( - name = "resource-fail", - srcs = glob(["Test*.java"]), - deps = [ - "//examples/java-native/src/main/java/com/example/myproject:hello-lib", - "//third_party:junit4", - ], -) diff --git a/base_workspace/examples/java-native/src/test/java/com/example/myproject/Fail.java b/base_workspace/examples/java-native/src/test/java/com/example/myproject/Fail.java deleted file mode 100644 index 7b947c6e96..0000000000 --- a/base_workspace/examples/java-native/src/test/java/com/example/myproject/Fail.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example.myproject; - -import org.junit.Assert; -import org.junit.Test; - -/** - * A test that always fails. - */ -public class Fail { - @Test - public void testFail() { - Assert.fail("This is an expected test failure."); - } -} diff --git a/base_workspace/examples/java-native/src/test/java/com/example/myproject/TestCustomGreeting.java b/base_workspace/examples/java-native/src/test/java/com/example/myproject/TestCustomGreeting.java deleted file mode 100644 index f14b7d234a..0000000000 --- a/base_workspace/examples/java-native/src/test/java/com/example/myproject/TestCustomGreeting.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.example.myproject; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.nio.charset.StandardCharsets; - -/** - * Tests using a resource file to replace "Hello" in the output. - */ -public class TestCustomGreeting { - - @Test - public void testNoArgument() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - Greeter.out = new PrintStream(out); - Greeter.main(); - assertEquals("Bye world\n", new String(out.toByteArray(), StandardCharsets.UTF_8)); - } - - @Test - public void testWithArgument() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - Greeter.out = new PrintStream(out); - Greeter.main("toto"); - assertEquals("Bye toto\n", new String(out.toByteArray(), StandardCharsets.UTF_8)); - } - -} diff --git a/base_workspace/examples/java-native/src/test/java/com/example/myproject/TestHello.java b/base_workspace/examples/java-native/src/test/java/com/example/myproject/TestHello.java deleted file mode 100644 index d50e6e503f..0000000000 --- a/base_workspace/examples/java-native/src/test/java/com/example/myproject/TestHello.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.example.myproject; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.nio.charset.StandardCharsets; - -/** - * Tests different numbers of arguments to main(). - * - *

With an empty args array, {@link Greeter} should print "Hello world". If there are one or more - * args, {@link Greeter} should print "Hello <arg[0]>".

- */ -public class TestHello { - - @Test - public void testNoArgument() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - Greeter.out = new PrintStream(out); - Greeter.main(); - assertEquals("Hello world\n", new String(out.toByteArray(), StandardCharsets.UTF_8)); - } - - @Test - public void testWithArgument() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - Greeter.out = new PrintStream(out); - Greeter.main("toto"); - assertEquals("Hello toto\n", new String(out.toByteArray(), StandardCharsets.UTF_8)); - } - -} diff --git a/base_workspace/examples/java-skylark/README.md b/base_workspace/examples/java-skylark/README.md deleted file mode 100644 index 970a859f54..0000000000 --- a/base_workspace/examples/java-skylark/README.md +++ /dev/null @@ -1,7 +0,0 @@ -Skylark Java Examples -===================== - -Use the native Java rules (see the examples in -_base_workspace/examples/java-native_) for building Java, not these. These -files are examples of how Skylark rules can be used (see -_tools/build_rules/java_rules_skylark.bzl_ for the rule definitions). diff --git a/base_workspace/examples/java-skylark/src/main/java/com/example/myproject/BUILD b/base_workspace/examples/java-skylark/src/main/java/com/example/myproject/BUILD deleted file mode 100644 index 10ca2d440d..0000000000 --- a/base_workspace/examples/java-skylark/src/main/java/com/example/myproject/BUILD +++ /dev/null @@ -1,21 +0,0 @@ -load("/tools/build_rules/java_rules_skylark", "java_library", "java_binary", "java_test") - -package(default_visibility = ["//visibility:public"]) - -java_binary( - name = "hello-world", - srcs = ["Greeter.java"], - main_class = "com.example.myproject.Greeter", -) - -java_binary( - name = "hello-data", - main_class = "com.example.myproject.Greeter", - deps = [":hello-lib"], -) - -java_library( - name = "hello-lib", - srcs = ["Greeter.java"], - data = ["//examples/java-skylark/src/main/resources:greeting"], -) diff --git a/base_workspace/examples/java-skylark/src/main/java/com/example/myproject/Greeter.java b/base_workspace/examples/java-skylark/src/main/java/com/example/myproject/Greeter.java deleted file mode 100644 index b4d8516dc9..0000000000 --- a/base_workspace/examples/java-skylark/src/main/java/com/example/myproject/Greeter.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.example.myproject; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.PrintStream; -import java.util.Scanner; - -/** - * Prints a greeting which can be customized by building with data and/or passing in command- - * line arguments. - */ -public class Greeter { - static PrintStream out = System.out; - - public static String getRunfiles() { - String path = System.getenv("JAVA_RUNFILES"); - if (path == null) { - path = System.getenv("TEST_SRCDIR"); - } - return path; - } - - public static String convertStreamToString(InputStream is) throws Exception { - Scanner s = new Scanner(is).useDelimiter("\n"); - return s.hasNext() ? s.next() : ""; - } - - public void hello(String obj) throws Exception { - String greeting = "Hello"; - try { - String greetFile = getRunfiles() + "/examples/java-skylark/src/main/resources/greeting.txt"; - greeting = convertStreamToString(new FileInputStream(greetFile)); - } catch (FileNotFoundException e) { - // use default. - } - out.println(greeting + " " + obj); - } - - public static void main(String... args) throws Exception { - Greeter g = new Greeter(); - String obj = args.length > 0 ? args[0] : "world"; - g.hello(obj); - } -}; diff --git a/base_workspace/examples/java-skylark/src/main/resources/BUILD b/base_workspace/examples/java-skylark/src/main/resources/BUILD deleted file mode 100644 index 8347a3555a..0000000000 --- a/base_workspace/examples/java-skylark/src/main/resources/BUILD +++ /dev/null @@ -1,6 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -filegroup( - name = "greeting", - srcs = ["greeting.txt"], -) diff --git a/base_workspace/examples/java-skylark/src/main/resources/greeting.txt b/base_workspace/examples/java-skylark/src/main/resources/greeting.txt deleted file mode 100644 index 17654db5a1..0000000000 --- a/base_workspace/examples/java-skylark/src/main/resources/greeting.txt +++ /dev/null @@ -1 +0,0 @@ -Heyo diff --git a/base_workspace/examples/java-skylark/src/test/java/com/example/myproject/BUILD b/base_workspace/examples/java-skylark/src/test/java/com/example/myproject/BUILD deleted file mode 100644 index 36c4cc3a67..0000000000 --- a/base_workspace/examples/java-skylark/src/test/java/com/example/myproject/BUILD +++ /dev/null @@ -1,16 +0,0 @@ -load("/tools/build_rules/java_rules_skylark", "java_test") - -java_test( - name = "pass", - srcs = ["TestHello.java"], - deps = [ - "//examples/java-skylark/src/main/java/com/example/myproject:hello-lib", - "//third_party:junit4-skylark", - ], -) - -java_test( - name = "fail", - srcs = ["Fail.java"], - main_class = "com.example.myproject.Fail", -) diff --git a/base_workspace/examples/java-skylark/src/test/java/com/example/myproject/Fail.java b/base_workspace/examples/java-skylark/src/test/java/com/example/myproject/Fail.java deleted file mode 100644 index 079e1e9f04..0000000000 --- a/base_workspace/examples/java-skylark/src/test/java/com/example/myproject/Fail.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.example.myproject; - -class Fail { - public static void main(String []args) { - System.exit(1); - } -} diff --git a/base_workspace/examples/java-skylark/src/test/java/com/example/myproject/TestHello.java b/base_workspace/examples/java-skylark/src/test/java/com/example/myproject/TestHello.java deleted file mode 100644 index d50e6e503f..0000000000 --- a/base_workspace/examples/java-skylark/src/test/java/com/example/myproject/TestHello.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.example.myproject; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.nio.charset.StandardCharsets; - -/** - * Tests different numbers of arguments to main(). - * - *

With an empty args array, {@link Greeter} should print "Hello world". If there are one or more - * args, {@link Greeter} should print "Hello <arg[0]>".

- */ -public class TestHello { - - @Test - public void testNoArgument() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - Greeter.out = new PrintStream(out); - Greeter.main(); - assertEquals("Hello world\n", new String(out.toByteArray(), StandardCharsets.UTF_8)); - } - - @Test - public void testWithArgument() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - Greeter.out = new PrintStream(out); - Greeter.main("toto"); - assertEquals("Hello toto\n", new String(out.toByteArray(), StandardCharsets.UTF_8)); - } - -} diff --git a/base_workspace/examples/objc/BUILD b/base_workspace/examples/objc/BUILD deleted file mode 100644 index 0499d61258..0000000000 --- a/base_workspace/examples/objc/BUILD +++ /dev/null @@ -1,106 +0,0 @@ -# Copyright 2015 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. - -objc_binary( - name = "PrenotCalculator", - srcs = [ - "PrenotCalculator/main.m", - ], - infoplist = "PrenotCalculator/PrenotCalculator-Info.plist", - visibility = ["//visibility:public"], - deps = [ - ":PrenotCalculatorClasses", - ], -) - -objc_library( - name = "PrenotCalculatorClasses", - srcs = [ - "PrenotCalculator/AppDelegate.m", - "PrenotCalculator/CalculatedValues.m", - "PrenotCalculator/CalculatorViewController.m", - "PrenotCalculator/CoreData.m", - "PrenotCalculator/Equation.m", - "PrenotCalculator/Literal.m", - "PrenotCalculator/ValuesViewController.m", - ], - hdrs = glob( - ["**/*.h"], - exclude = ["PrenotCalculator/Expression.h"], - ), - bundles = [":PrenotCalculatorResources"], - sdk_frameworks = ["CoreData"], - xibs = ["PrenotCalculator/CalculatorViewController.xib"], - deps = [ - ":CoreDataResources", - ":ExpressionPrebuilt", - ], -) - -# A prebuilt library that contains multiple architectures. -# Currently compiled for: i386, x86_64, armv7. -objc_import( - name = "ExpressionPrebuilt", - hdrs = ["PrenotCalculator/Expression.h"], - archives = [ - "expression_prebuilt.a", - ], -) - -# Don't use this directly, instead use it to construct ExpressionPrebuilt and -# depend on that instead. Instructions: -# Build using the following command repeatedly with the desired CPU values: -# bazel build --ios_cpu= examples/objc/PrenotCalculator:ExpressionClasses -# and combining the resulting .a's (copied after each bazel build) using lipo: -# /usr/bin/lipo -create expression_i386.a expression_armv7.a -output expression_prebuilt.a -objc_library( - name = "ExpressionClasses", - srcs = [ - "PrenotCalculator/Expression.m", - ], - hdrs = ["PrenotCalculator/Expression.h"], -) - -objc_bundle_library( - name = "PrenotCalculatorResources", - resources = glob(["PrenotCalculator/Resources/**"]), -) - -objc_library( - name = "CoreDataResources", - datamodels = glob(["PrenotCalculator/DataModel.xcdatamodeld/**"]), -) - -# If instruments is supported this genrule should *not timeout* and it should -# produce a screenshot of the PrenotCalculator.ipa in ~ few seconds. -genrule( - name = "PrenotCalculatorInstruments", - srcs = [":PrenotCalculator.ipa"], - outs = ["hello_instruments.png"], - cmd = - # This command expects the PrenotCalculator.ipa as input then unzips - # it into a temporary directory, creates a .js script on the fly - # that captures a screenshot, and finally invokes /usr/bin/instruments - # with the former as arguments. - "unzip -q $(location :PrenotCalculator.ipa) -d $${TMPDIR} ; " + - "echo 'UIATarget.localTarget().delay(5); UIATarget.localTarget().captureScreenWithName(\"hello_instruments\");' > $${TMPDIR}/hello_instruments.js && " + - "/usr/bin/instruments " + - "-t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate " + - "-w 'iPhone 5 (8.1 Simulator)' " + - "$${TMPDIR}/Payload/PrenotCalculator.app " + - "-e UIASCRIPT $${TMPDIR}/hello_instruments.js " + - "-e UIARESULTSPATH $${TMPDIR} -v && " + - "cp $${TMPDIR}'/Run 1/hello_instruments.png' $(@)", - tags = ["requires-darwin"], -) diff --git a/base_workspace/examples/objc/PrenotCalculator/AppDelegate.h b/base_workspace/examples/objc/PrenotCalculator/AppDelegate.h deleted file mode 100644 index 75b1f1da38..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/AppDelegate.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 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 - -@interface AppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/AppDelegate.m b/base_workspace/examples/objc/PrenotCalculator/AppDelegate.m deleted file mode 100644 index f6ecc4d6c3..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/AppDelegate.m +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2015 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 "AppDelegate.h" - -#import "CalculatorViewController.h" -#import "ValuesViewController.h" - -@implementation AppDelegate - -- (BOOL)application:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [self validateBundleLibrary]; - - UITabBarController *bar = [[UITabBarController alloc] init]; - [bar setViewControllers: - @[[[CalculatorViewController alloc] init], [[ValuesViewController alloc] init]]]; - bar.selectedIndex = 0; - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - self.window.rootViewController = bar; - [self.window makeKeyAndVisible]; - return YES; -} - -- (void)applicationWillResignActive:(UIApplication *)application {} - -- (void)applicationDidEnterBackground:(UIApplication *)application {} - -- (void)applicationWillEnterForeground:(UIApplication *)application {} - -- (void)applicationDidBecomeActive:(UIApplication *)application {} - -- (void)applicationWillTerminate:(UIApplication *)application {} - -- (void)validateBundleLibrary { - NSString *bundlePath = [[[NSBundle mainBundle] bundlePath] - stringByAppendingPathComponent:@"PrenotCalculatorResources.bundle"]; - NSBundle *bundle = [NSBundle bundleWithPath:bundlePath]; - NSString *testPath = [bundle pathForResource:@"test" ofType:@"txt"]; - NSString *testContents = [NSString stringWithContentsOfFile:testPath - encoding:NSUTF8StringEncoding - error:NULL]; - NSAssert([testContents hasSuffix:@"It worked!\n"], - @"Unable to find file given mainBundle: %@", - [[NSBundle mainBundle] description]); -} - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/CalculatedValues.h b/base_workspace/examples/objc/PrenotCalculator/CalculatedValues.h deleted file mode 100644 index 026fadf6ca..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/CalculatedValues.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 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 - -#import "Equation.h" -#import "Expression.h" - -@interface CalculatedValues : NSObject - -+ (CalculatedValues *)sharedInstance; - -- (NSArray *)values; - -- (void)addEquation:(Equation *)equation; - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/CalculatedValues.m b/base_workspace/examples/objc/PrenotCalculator/CalculatedValues.m deleted file mode 100644 index 2e401cb1c1..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/CalculatedValues.m +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2015 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 "CalculatedValues.h" - -#import "Equation.h" - -@implementation CalculatedValues { - NSMutableArray *_values; -} - -+ (CalculatedValues *)sharedInstance { - static CalculatedValues *values = nil; - if (!values) { - values = [[[self class] alloc] init]; - } - return values; -} - -- (id)init { - self = [super init]; - if (self) { - _values = [NSMutableArray array]; - } - return self; -} - -- (NSArray *)values { - return [_values copy]; -} - -- (void)addEquation:(Equation *)equation { - [_values addObject: - [NSString stringWithFormat:@"%@ = %0.2lf", equation, [equation calculate]]]; -} - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.h b/base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.h deleted file mode 100644 index 60dbc83bb8..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 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 - -@interface CalculatorViewController : UIViewController - -- (IBAction)enterDigit:(id)sender; - -- (IBAction)finish:(id)sender; - -- (IBAction)operate:(id)sender; - -@property (weak, nonatomic) IBOutlet UIButton *divideButton; -@property (weak, nonatomic) IBOutlet UIButton *multiplyButton; -@property (weak, nonatomic) IBOutlet UIButton *plusButton; -@property (weak, nonatomic) IBOutlet UIButton *minusButton; -@property (strong, nonatomic) IBOutletCollection(UIButton) - NSArray *nonZeroDigitButtons; -@property (weak, nonatomic) IBOutlet UILabel *resultLabel; -@property (weak, nonatomic) IBOutlet UIButton *finishButton; -@property (weak, nonatomic) IBOutlet UIButton *zeroButton; - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.m b/base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.m deleted file mode 100644 index 5d26fefcc0..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.m +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2015 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 "CalculatorViewController.h" - -#import "CalculatedValues.h" -#import "CoreData.h" -#import "Equation.h" -#import "Expression.h" -#import "Literal.h" - -@interface CalculatorViewController () -- (void)updateEnabledViews; -- (void)updateButtonColor:(UIButton *)button; -@end - -@implementation CalculatorViewController { - NSMutableArray *_locationStack; - NSMutableString *_currentNumber; -} - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - self.title = @"Calculator"; - CoreData *coreData = [[CoreData alloc] init]; - [coreData verify]; - } - return self; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - _locationStack = [NSMutableArray array]; - _currentNumber = [NSMutableString stringWithString:@""]; - [self updateEnabledViews]; -} - -- (IBAction)enterDigit:(id)sender { - UIButton *button = (UIButton *)sender; - [_currentNumber appendString:button.titleLabel.text]; - self.resultLabel.text = _currentNumber; - [self updateEnabledViews]; -} - -- (IBAction)finish:(id)sender { - if (![_locationStack count]) { - _currentNumber = [NSMutableString stringWithString:@""]; - self.resultLabel.text = @"hello"; - } - if (![_locationStack count]) { - _currentNumber = [NSMutableString stringWithString:@""]; - } else if ([_currentNumber length]) { - Equation *last = [_locationStack lastObject]; - [last addExpressionAsChild:[[Literal alloc] initWithDouble: - atof([_currentNumber cStringUsingEncoding:NSUTF8StringEncoding])]]; - _currentNumber = [NSMutableString stringWithString:@""]; - self.resultLabel.text = [NSString stringWithFormat:@"%@", last]; - } else { - Equation *popped = [_locationStack lastObject]; - [_locationStack removeLastObject]; - [[CalculatedValues sharedInstance] addEquation:popped]; - self.resultLabel.text = - [NSString stringWithFormat:@"%lf", [popped calculate]]; - } - [self updateEnabledViews]; -} - -- (IBAction)operate:(id)sender { - Operation operation; - if ([_currentNumber length]) { - // finish the current number first automatically: - [self finish:nil]; - } - if (sender == self.multiplyButton) { - operation = kMultiply; - } else if (sender == self.plusButton) { - operation = kAdd; - } else if (sender == self.divideButton) { - operation = kDivide; - } else if (sender == self.minusButton) { - operation = kSubtract; - } else { - // Shouldn't happen - operation = kAdd; - } - Equation *newEquation = [[Equation alloc] initWithOperation:operation]; - if ([_locationStack count]) { - [[_locationStack lastObject] addExpressionAsChild:newEquation]; - } - [_locationStack addObject:newEquation]; - self.resultLabel.text = [NSString stringWithFormat:@"%@", _locationStack[0]]; - [self updateEnabledViews]; -} - -#pragma mark - Private - - -- (void)updateEnabledViews { - self.finishButton.enabled = [_locationStack count] || [_currentNumber length]; - [self updateButtonColor:self.finishButton]; - self.zeroButton.enabled = self.finishButton.enabled; - [self updateButtonColor:self.zeroButton]; - BOOL enableNonZeroDigits = ![_currentNumber isEqualToString:@"0"]; - for (UIButton *digit in self.nonZeroDigitButtons) { - digit.enabled = enableNonZeroDigits; - [self updateButtonColor:digit]; - } -} - -- (void)updateButtonColor:(UIButton *)button { - button.backgroundColor = button.enabled ? - [UIColor whiteColor] : [UIColor grayColor]; -} - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.xib b/base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.xib deleted file mode 100644 index 7ed3f42c60..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/CalculatorViewController.xib +++ /dev/null @@ -1,257 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/base_workspace/examples/objc/PrenotCalculator/CoreData.h b/base_workspace/examples/objc/PrenotCalculator/CoreData.h deleted file mode 100644 index 2b55bb1404..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/CoreData.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 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 - -// A simple class to confirm CoreData versioning works properly. -@interface CoreData : NSObject - -// Check that the datamodel was loaded properly. -- (void)verify; - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/CoreData.m b/base_workspace/examples/objc/PrenotCalculator/CoreData.m deleted file mode 100644 index 43a1e89122..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/CoreData.m +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2015 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 "CoreData.h" - -@implementation CoreData -- (id)init { - self = [super init]; - if (self) { - - } - return self; -} - -- (void)verify { - NSURL *modelURL = [self modelURL]; - NSAssert(modelURL, - @"Unable to find modelURL given mainBundle: %@", - [[NSBundle mainBundle] description]); -} - -#pragma mark Private Methods. - -- (NSURL *)modelURL { - NSBundle *bundle = [NSBundle bundleForClass:[CoreData class]]; - NSURL *modelURL = [bundle URLForResource:@"DataModel" withExtension:@"momd"]; - return modelURL; -} - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/.xccurrentversion b/base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/.xccurrentversion deleted file mode 100644 index aae30cd305..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/.xccurrentversion +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - _XCCurrentVersionName - DataModel-1.1.xcdatamodel - - diff --git a/base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.0.xcdatamodel/contents b/base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.0.xcdatamodel/contents deleted file mode 100644 index 1cd3e57dae..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.0.xcdatamodel/contents +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.1.xcdatamodel/contents b/base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.1.xcdatamodel/contents deleted file mode 100644 index 80b28dd35a..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.1.xcdatamodel/contents +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/base_workspace/examples/objc/PrenotCalculator/Equation.h b/base_workspace/examples/objc/PrenotCalculator/Equation.h deleted file mode 100644 index c04fc705e4..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/Equation.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 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 - -#import "Expression.h" - -typedef enum { - kAdd, - kSubtract, - kMultiply, - kDivide -} Operation; - -@interface Equation : Expression - -@property (nonatomic, assign) Operation operation; - -- (id)initWithOperation:(Operation)operation; -- (NSArray *)children; -- (void)addExpressionAsChild:(Expression *)child; - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/Equation.m b/base_workspace/examples/objc/PrenotCalculator/Equation.m deleted file mode 100644 index 4894e82b93..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/Equation.m +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2015 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 "Equation.h" - -@implementation Equation { - NSMutableArray *_children; -} - -@synthesize operation = _operation; - -- (id)init { - [self doesNotRecognizeSelector:_cmd]; - return nil; -} - -- (id)initWithOperation:(Operation)operation { - self = [super init]; - if (self) { - _children = [NSMutableArray array]; - _operation = operation; - } - return self; -} - -- (NSArray *)children { - return [_children copy]; -} - -- (void)addExpressionAsChild:(Expression *)child { - [_children addObject:child]; -} - -- (double)calculate { - if ([_children count] == 1) { - return (_operation == kSubtract) - ? -[_children[0] calculate] : [_children[0] calculate]; - } else if ([_children count] == 0) { - return (_operation == kSubtract || _operation == kAdd) ? 0 : 1; - } - double value = [_children[0] calculate]; - for (Equation *child in [_children subarrayWithRange: - NSMakeRange(1, [_children count] - 1)]) { - double childValue = [child calculate]; - switch (_operation) { - case kAdd: - value += childValue; - break; - case kSubtract: - value -= childValue; - break; - case kMultiply: - value *= childValue; - break; - case kDivide: - value /= childValue; - break; - } - } - return value; -} - -- (NSString *)description { - NSMutableString *result = [[NSMutableString alloc] init]; - [result appendString:@"("]; - switch (_operation) { - case kAdd: - [result appendString:@"+"]; - break; - case kSubtract: - [result appendString:@"-"]; - break; - case kMultiply: - [result appendString:@"*"]; - break; - case kDivide: - [result appendString:@"/"]; - break; - } - for (Equation *child in _children) { - [result appendString:@" "]; - [result appendString:[child description]]; - } - [result appendString:@")"]; - return [result copy]; -} - -- (BOOL)isEqual:(id)object { - if (![object isKindOfClass:[self class]]) { - return NO; - } - Equation *other = object; - return other->_operation == _operation && - [other->_children isEqual:_children]; -} - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/Expression.h b/base_workspace/examples/objc/PrenotCalculator/Expression.h deleted file mode 100644 index f5b2dcf63e..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/Expression.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 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 - -@interface Expression : NSObject - -- (double)calculate; - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/Expression.m b/base_workspace/examples/objc/PrenotCalculator/Expression.m deleted file mode 100644 index 68e954170c..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/Expression.m +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 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 "Expression.h" - -@implementation Expression - -- (double)calculate { - [self doesNotRecognizeSelector:_cmd]; - return NAN; -} - -- (BOOL)isEqual:(id)object { - [self doesNotRecognizeSelector:_cmd]; - return NO; -} - -- (NSString *)description { - [self doesNotRecognizeSelector:_cmd]; - return nil; -} - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/Literal.h b/base_workspace/examples/objc/PrenotCalculator/Literal.h deleted file mode 100644 index 62ee13c466..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/Literal.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 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 "Expression.h" - -@interface Literal : Expression - -- (id)initWithDouble:(double)value; - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/Literal.m b/base_workspace/examples/objc/PrenotCalculator/Literal.m deleted file mode 100644 index c103f46510..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/Literal.m +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2015 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 "Literal.h" - -@implementation Literal { - double _value; -} - -- (id)initWithDouble:(double)value { - self = [super init]; - if (self) { - _value = value; - } - return self; -} - -- (double)calculate { - return _value; -} - -- (NSString *)description { - return [NSString stringWithFormat:@"%0.2lf", _value]; -} - -- (BOOL)isEqual:(id)object { - if (![object isKindOfClass:[self class]]) { - return NO; - } - return _value == ((Literal *)object)->_value; -} - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/PrenotCalculator-Info.plist b/base_workspace/examples/objc/PrenotCalculator/PrenotCalculator-Info.plist deleted file mode 100644 index 178f34c4c0..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/PrenotCalculator-Info.plist +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - CFBundleDevelopmentRegion - en - CFBundleDisplayName - PrenotCalculator - CFBundleExecutable - PrenotCalculator - CFBundleIdentifier - Google.PrenotCalculator - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - PrenotCalculator - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - LSRequiresIPhoneOS - - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/base_workspace/examples/objc/PrenotCalculator/Resources/test.txt b/base_workspace/examples/objc/PrenotCalculator/Resources/test.txt deleted file mode 100644 index 3dc3aa5164..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/Resources/test.txt +++ /dev/null @@ -1 +0,0 @@ -It worked! diff --git a/base_workspace/examples/objc/PrenotCalculator/ValuesViewController.h b/base_workspace/examples/objc/PrenotCalculator/ValuesViewController.h deleted file mode 100644 index 27055b905f..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/ValuesViewController.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 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 - -@interface ValuesViewController : UITableViewController - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/ValuesViewController.m b/base_workspace/examples/objc/PrenotCalculator/ValuesViewController.m deleted file mode 100644 index 333ea11b1f..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/ValuesViewController.m +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 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 "ValuesViewController.h" - -#import "CalculatedValues.h" - -@interface ValuesViewController () - -@end - -@implementation ValuesViewController - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - self.title = @"Values"; - } - return self; -} - -#pragma mark - Table view data source - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; -} - -- (NSInteger)tableView:(UITableView *)tableView - numberOfRowsInSection:(NSInteger)section { - return [[[CalculatedValues sharedInstance] values] count]; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView - cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *CellIdentifier = @"Cell"; - UITableViewCell *cell = - [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - if (!cell) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault - reuseIdentifier:CellIdentifier]; - } - - cell.textLabel.text = - [CalculatedValues sharedInstance].values[[indexPath indexAtPosition:1]]; - - return cell; -} - -- (void)viewDidAppear:(BOOL)animated { - [self.tableView reloadData]; -} - -@end diff --git a/base_workspace/examples/objc/PrenotCalculator/main.m b/base_workspace/examples/objc/PrenotCalculator/main.m deleted file mode 100644 index f521bd84bb..0000000000 --- a/base_workspace/examples/objc/PrenotCalculator/main.m +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 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 - -int main(int argc, char * argv[]) { - @autoreleasepool { - NSString *delegateClassName = - #ifndef KIF_TESTS - @"AppDelegate"; - #else - @"AppDelegateForKIF"; - #endif - return UIApplicationMain(argc, argv, nil, delegateClassName); - } -} diff --git a/base_workspace/examples/objc/README.md b/base_workspace/examples/objc/README.md deleted file mode 100644 index 045264fed6..0000000000 --- a/base_workspace/examples/objc/README.md +++ /dev/null @@ -1,17 +0,0 @@ -Objective C Examples -====== - -The example in this directory show typical use of Objective C libraries, -binaries and imports. Because they build iOS an application they can only be run -on Mac OSX. - -Build the top-level application with -`bazel build examples/objc:PrenotCalculator`, which when finished prints the -path to the generated .ipa. which you can then install to your test device. The -same build will also print the path to an Xcode project directory which you can -open to continue working with the application in Xcode. - -Running `bazel build examples/objc:PrenotCalculatorInstruments` will build and -run the application to obtain a screenshot, the path to which it then prints. - - diff --git a/base_workspace/examples/objc/expression_prebuilt.a b/base_workspace/examples/objc/expression_prebuilt.a deleted file mode 100644 index 8bb74bbb3b..0000000000 Binary files a/base_workspace/examples/objc/expression_prebuilt.a and /dev/null differ diff --git a/base_workspace/examples/proto/BUILD b/base_workspace/examples/proto/BUILD deleted file mode 100644 index 2228fc4398..0000000000 --- a/base_workspace/examples/proto/BUILD +++ /dev/null @@ -1,8 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load("/tools/build_rules/genproto", "genproto") - -genproto( - name = "test_proto", - src = "test.proto", -) diff --git a/base_workspace/examples/proto/test.proto b/base_workspace/examples/proto/test.proto deleted file mode 100644 index 16a6dc335a..0000000000 --- a/base_workspace/examples/proto/test.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto2"; - -package test; - -option java_package = "com.google.test"; - -message KeyVal { - optional string key = 1; - optional string val = 2; -} diff --git a/base_workspace/examples/py/BUILD b/base_workspace/examples/py/BUILD deleted file mode 100644 index 6eecd4a4f3..0000000000 --- a/base_workspace/examples/py/BUILD +++ /dev/null @@ -1,14 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load("/tools/build_rules/py_rules", "py_library", "py_binary") - -py_library( - name = "lib", - srcs = ["lib.py"], -) - -py_binary( - name = "bin", - srcs = ["bin.py"], - deps = [":lib"], -) diff --git a/base_workspace/examples/py/bin.py b/base_workspace/examples/py/bin.py deleted file mode 100644 index 53e917e491..0000000000 --- a/base_workspace/examples/py/bin.py +++ /dev/null @@ -1,3 +0,0 @@ -from examples.py import lib - -print "Fib(5)=%d" % lib.Fib(5) diff --git a/base_workspace/examples/py/lib.py b/base_workspace/examples/py/lib.py deleted file mode 100644 index a27d4ce47c..0000000000 --- a/base_workspace/examples/py/lib.py +++ /dev/null @@ -1,5 +0,0 @@ -def Fib(n): - if n == 0 or n == 1: - return 1 - else: - return Fib(n-1) + Fib(n-2) -- cgit v1.2.3