about summary refs log tree commit diff
path: root/third_party/bazel/rules_haskell/tests/haskell_proto_library
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-07-04T10·18+0100
committerVincent Ambo <tazjin@google.com>2019-07-04T10·18+0100
commitf723b8b878a3c4a4687b9e337a875500bebb39b1 (patch)
treee85204cf042c355e90cff61c111e7d8cd15df311 /third_party/bazel/rules_haskell/tests/haskell_proto_library
parent2eb1dc26e42ffbdc168f05ef744bd4b4f3e4c36f (diff)
feat(third_party/bazel): Check in rules_haskell from Tweag r/17
Diffstat (limited to 'third_party/bazel/rules_haskell/tests/haskell_proto_library')
-rw-r--r--third_party/bazel/rules_haskell/tests/haskell_proto_library/BUILD.bazel78
-rw-r--r--third_party/bazel/rules_haskell/tests/haskell_proto_library/Bar.hs8
-rw-r--r--third_party/bazel/rules_haskell/tests/haskell_proto_library/address.proto11
-rw-r--r--third_party/bazel/rules_haskell/tests/haskell_proto_library/person.proto16
-rw-r--r--third_party/bazel/rules_haskell/tests/haskell_proto_library/stripped_address.proto10
-rw-r--r--third_party/bazel/rules_haskell/tests/haskell_proto_library/stripped_zip_code.proto7
-rw-r--r--third_party/bazel/rules_haskell/tests/haskell_proto_library/zip_code.proto7
7 files changed, 137 insertions, 0 deletions
diff --git a/third_party/bazel/rules_haskell/tests/haskell_proto_library/BUILD.bazel b/third_party/bazel/rules_haskell/tests/haskell_proto_library/BUILD.bazel
new file mode 100644
index 000000000000..f5f8762b3aff
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/haskell_proto_library/BUILD.bazel
@@ -0,0 +1,78 @@
+load(
+    "@io_tweag_rules_haskell//haskell:haskell.bzl",
+    "haskell_doc",
+    "haskell_library",
+    "haskell_proto_library",
+)
+
+package(default_testonly = 1)
+
+proto_library(
+    name = "zip_code_proto",
+    srcs = ["zip_code.proto"],
+)
+
+proto_library(
+    name = "address_proto",
+    srcs = ["address.proto"],
+    deps = [":zip_code_proto"],
+)
+
+proto_library(
+    name = "person_proto",
+    srcs = ["person.proto"],
+    deps = [
+        ":address_proto",
+        "@com_google_protobuf//:timestamp_proto",
+    ],
+)
+
+proto_library(
+    name = "stripped_zip_code_proto",
+    srcs = ["stripped_zip_code.proto"],
+    strip_import_prefix = "/tests/haskell_proto_library/",
+)
+
+proto_library(
+    name = "stripped_address_proto",
+    srcs = ["stripped_address.proto"],
+    strip_import_prefix = "/tests/haskell_proto_library/",
+    deps = [":stripped_zip_code_proto"],
+)
+
+haskell_proto_library(
+    name = "address_haskell_proto",
+    tags = ["requires_hackage"],
+    deps = [":address_proto"],
+)
+
+haskell_proto_library(
+    name = "stripped_address_haskell_proto",
+    tags = ["requires_hackage"],
+    deps = [":stripped_address_proto"],
+)
+
+haskell_proto_library(
+    name = "person_haskell_proto",
+    tags = ["requires_hackage"],
+    deps = [":person_proto"],
+)
+
+haskell_library(
+    name = "hs-lib",
+    srcs = ["Bar.hs"],
+    tags = ["requires_hackage"],
+    visibility = ["//visibility:public"],
+    deps = [
+        ":address_haskell_proto",
+        ":person_haskell_proto",
+        ":stripped_address_haskell_proto",
+        "//tests/hackage:base",
+    ],
+)
+
+haskell_doc(
+    name = "docs",
+    tags = ["requires_hackage"],
+    deps = [":hs-lib"],
+)
diff --git a/third_party/bazel/rules_haskell/tests/haskell_proto_library/Bar.hs b/third_party/bazel/rules_haskell/tests/haskell_proto_library/Bar.hs
new file mode 100644
index 000000000000..fa95bf088c91
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/haskell_proto_library/Bar.hs
@@ -0,0 +1,8 @@
+module Bar (bar) where
+
+import Proto.StrippedAddress
+import Proto.Tests.HaskellProtoLibrary.Person
+import Proto.Tests.HaskellProtoLibrary.Person_Fields
+
+bar :: Int
+bar = 5
diff --git a/third_party/bazel/rules_haskell/tests/haskell_proto_library/address.proto b/third_party/bazel/rules_haskell/tests/haskell_proto_library/address.proto
new file mode 100644
index 000000000000..d81642d8bcd4
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/haskell_proto_library/address.proto
@@ -0,0 +1,11 @@
+syntax = "proto3";
+
+package demo; // Required to generate valid code.
+
+// Always import protos with a full path relative to the WORKSPACE file.
+import "tests/haskell_proto_library/zip_code.proto";
+
+message Address {
+  string city = 1;
+  ZipCode zip_code = 2;
+}
diff --git a/third_party/bazel/rules_haskell/tests/haskell_proto_library/person.proto b/third_party/bazel/rules_haskell/tests/haskell_proto_library/person.proto
new file mode 100644
index 000000000000..95bf3524f819
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/haskell_proto_library/person.proto
@@ -0,0 +1,16 @@
+syntax = "proto3";
+
+package demo; // Required to generate valid code.
+
+// Always import protos with a full path relative to the WORKSPACE file.
+import "tests/haskell_proto_library/address.proto";
+
+import "google/protobuf/timestamp.proto";
+
+message Person {
+  string name = 1;
+  int32 id = 2;
+  string email = 3;
+  Address address = 4;
+  google.protobuf.Timestamp timestamp = 5;
+}
diff --git a/third_party/bazel/rules_haskell/tests/haskell_proto_library/stripped_address.proto b/third_party/bazel/rules_haskell/tests/haskell_proto_library/stripped_address.proto
new file mode 100644
index 000000000000..5b5ce47be83a
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/haskell_proto_library/stripped_address.proto
@@ -0,0 +1,10 @@
+syntax = "proto3";
+
+package demo; // Required to generate valid code.
+
+import "stripped_zip_code.proto";
+
+message StrippedAddress {
+  string city = 1;
+  StrippedZipCode zip_code = 2;
+}
diff --git a/third_party/bazel/rules_haskell/tests/haskell_proto_library/stripped_zip_code.proto b/third_party/bazel/rules_haskell/tests/haskell_proto_library/stripped_zip_code.proto
new file mode 100644
index 000000000000..690d7c9d99cc
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/haskell_proto_library/stripped_zip_code.proto
@@ -0,0 +1,7 @@
+syntax = "proto3";
+
+package demo; // Required to generate valid code.
+
+message StrippedZipCode {
+  string code = 1;
+}
diff --git a/third_party/bazel/rules_haskell/tests/haskell_proto_library/zip_code.proto b/third_party/bazel/rules_haskell/tests/haskell_proto_library/zip_code.proto
new file mode 100644
index 000000000000..e72578cf2178
--- /dev/null
+++ b/third_party/bazel/rules_haskell/tests/haskell_proto_library/zip_code.proto
@@ -0,0 +1,7 @@
+syntax = "proto3";
+
+package demo; // Required to generate valid code.
+
+message ZipCode {
+  string code = 1;
+}