Skip to content

Commit 38fd075

Browse files
authored
Add a Bazel build (#12)
* Add a Bazel build
1 parent 97a8f4c commit 38fd075

File tree

18 files changed

+410
-9
lines changed

18 files changed

+410
-9
lines changed

Diff for: .gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
project/boot
23
target
34
.ensime
@@ -25,4 +26,9 @@ testData/
2526
.phantom-temp
2627

2728
# PGP keys
28-
secring.asc
29+
secring.asc
30+
31+
# bazel
32+
result
33+
bazel-*
34+
!*.nix

Diff for: .travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
- script:
1212
- nix-shell --pure --command 'sbt test'
1313

14+
- script:
15+
- ./tools/bazel build ...
16+
1417
- script:
1518
- nix-shell --pure --command 'sbt coverage +test coverageReport'
1619
after_success:

Diff for: 3rdparty/BUILD

Whitespace-only changes.

Diff for: 3rdparty/jvm/org/scala_lang/BUILD

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
load("@io_bazel_rules_scala//scala:scala_import.bzl", "scala_import")
2+
java_library(
3+
name = "scala_compiler",
4+
exports = [
5+
"//3rdparty/jvm/org/scala_lang/modules:scala_parser_combinators_2_11",
6+
"//3rdparty/jvm/org/scala_lang/modules:scala_xml_2_11",
7+
"//external:jar/io_higherkindness_droste_org/scala_lang/scala_compiler",
8+
":scala_library",
9+
":scala_reflect"
10+
],
11+
visibility = [
12+
"//3rdparty/jvm:__subpackages__"
13+
]
14+
)
15+
16+
17+
18+
java_library(
19+
name = "scala_library",
20+
exports = [
21+
"//external:jar/io_higherkindness_droste_org/scala_lang/scala_library"
22+
],
23+
visibility = [
24+
"//3rdparty/jvm:__subpackages__"
25+
]
26+
)
27+
28+
29+
30+
java_library(
31+
name = "scala_reflect",
32+
exports = [
33+
"//external:jar/io_higherkindness_droste_org/scala_lang/scala_reflect",
34+
":scala_library"
35+
],
36+
visibility = [
37+
"//3rdparty/jvm:__subpackages__"
38+
]
39+
)
40+
41+

Diff for: 3rdparty/jvm/org/scala_lang/modules/BUILD

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
load("@io_bazel_rules_scala//scala:scala_import.bzl", "scala_import")
2+
java_library(
3+
name = "scala_parser_combinators_2_11",
4+
exports = [
5+
"//3rdparty/jvm/org/scala_lang:scala_library",
6+
"//external:jar/io_higherkindness_droste_org/scala_lang/modules/scala_parser_combinators_2_11"
7+
],
8+
visibility = [
9+
"//3rdparty/jvm:__subpackages__"
10+
]
11+
)
12+
13+
14+
15+
java_library(
16+
name = "scala_xml_2_11",
17+
exports = [
18+
"//3rdparty/jvm/org/scala_lang:scala_library",
19+
"//external:jar/io_higherkindness_droste_org/scala_lang/modules/scala_xml_2_11"
20+
],
21+
visibility = [
22+
"//3rdparty/jvm:__subpackages__"
23+
]
24+
)
25+
26+

Diff for: 3rdparty/jvm/org/spire_math/BUILD

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
load("@io_bazel_rules_scala//scala:scala_import.bzl", "scala_import")
2+
scala_import(
3+
name = "kind_projector",
4+
exports = [
5+
"//3rdparty/jvm/org/scala_lang:scala_compiler",
6+
"//3rdparty/jvm/org/scala_lang:scala_library"
7+
],
8+
jars = [
9+
"//external:jar/io_higherkindness_droste_org/spire_math/kind_projector_2_11"
10+
],
11+
visibility = [
12+
"//visibility:public"
13+
]
14+
)
15+
16+

Diff for: 3rdparty/jvm/org/typelevel/BUILD

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
load("@io_bazel_rules_scala//scala:scala_import.bzl", "scala_import")
2+
scala_import(
3+
name = "cats_core",
4+
exports = [
5+
"//3rdparty/jvm/org/scala_lang:scala_library",
6+
":cats_kernel",
7+
":cats_macros_2_11",
8+
":machinist_2_11"
9+
],
10+
jars = [
11+
"//external:jar/io_higherkindness_droste_org/typelevel/cats_core_2_11"
12+
],
13+
visibility = [
14+
"//visibility:public"
15+
]
16+
)
17+
18+
19+
20+
scala_import(
21+
name = "cats_free",
22+
exports = [
23+
"//3rdparty/jvm/org/scala_lang:scala_library",
24+
":cats_core",
25+
":cats_macros_2_11",
26+
":machinist_2_11"
27+
],
28+
jars = [
29+
"//external:jar/io_higherkindness_droste_org/typelevel/cats_free_2_11"
30+
],
31+
visibility = [
32+
"//visibility:public"
33+
]
34+
)
35+
36+
37+
38+
scala_import(
39+
name = "cats_kernel",
40+
exports = [
41+
"//3rdparty/jvm/org/scala_lang:scala_library"
42+
],
43+
jars = [
44+
"//external:jar/io_higherkindness_droste_org/typelevel/cats_kernel_2_11"
45+
],
46+
visibility = [
47+
"//visibility:public"
48+
]
49+
)
50+
51+
52+
53+
java_library(
54+
name = "cats_macros_2_11",
55+
exports = [
56+
"//3rdparty/jvm/org/scala_lang:scala_library",
57+
"//external:jar/io_higherkindness_droste_org/typelevel/cats_macros_2_11",
58+
":machinist_2_11"
59+
],
60+
visibility = [
61+
"//3rdparty/jvm:__subpackages__"
62+
]
63+
)
64+
65+
66+
67+
java_library(
68+
name = "machinist_2_11",
69+
exports = [
70+
"//3rdparty/jvm/org/scala_lang:scala_library",
71+
"//3rdparty/jvm/org/scala_lang:scala_reflect",
72+
"//external:jar/io_higherkindness_droste_org/typelevel/machinist_2_11"
73+
],
74+
visibility = [
75+
"//3rdparty/jvm:__subpackages__"
76+
]
77+
)
78+
79+

Diff for: 3rdparty/workspace.bzl

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Do not edit. bazel-deps autogenerates this file from bazel_deps.yaml.
2+
3+
def declare_maven(hash):
4+
native.maven_jar(
5+
name = hash["name"],
6+
artifact = hash["artifact"],
7+
sha1 = hash["sha1"],
8+
repository = hash["repository"]
9+
)
10+
native.bind(
11+
name = hash["bind"],
12+
actual = hash["actual"]
13+
)
14+
15+
def list_dependencies():
16+
return [
17+
{"artifact": "org.scala-lang.modules:scala-parser-combinators_2.11:1.0.4", "lang": "java", "sha1": "7369d653bcfa95d321994660477a4d7e81d7f490", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_scala_lang_modules_scala_parser_combinators_2_11", "actual": "@io_higherkindness_droste_org_scala_lang_modules_scala_parser_combinators_2_11//jar", "bind": "jar/io_higherkindness_droste_org/scala_lang/modules/scala_parser_combinators_2_11"},
18+
{"artifact": "org.scala-lang.modules:scala-xml_2.11:1.0.5", "lang": "java", "sha1": "77ac9be4033768cf03cc04fbd1fc5e5711de2459", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_scala_lang_modules_scala_xml_2_11", "actual": "@io_higherkindness_droste_org_scala_lang_modules_scala_xml_2_11//jar", "bind": "jar/io_higherkindness_droste_org/scala_lang/modules/scala_xml_2_11"},
19+
{"artifact": "org.scala-lang:scala-compiler:2.11.12", "lang": "java", "sha1": "a1b5e58fd80cb1edc1413e904a346bfdb3a88333", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_scala_lang_scala_compiler", "actual": "@io_higherkindness_droste_org_scala_lang_scala_compiler//jar", "bind": "jar/io_higherkindness_droste_org/scala_lang/scala_compiler"},
20+
# duplicates in org.scala-lang:scala-library promoted to 2.11.12
21+
# - org.scala-lang.modules:scala-parser-combinators_2.11:1.0.4 wanted version 2.11.6
22+
# - org.scala-lang.modules:scala-xml_2.11:1.0.5 wanted version 2.11.7
23+
# - org.scala-lang:scala-compiler:2.11.12 wanted version 2.11.12
24+
# - org.scala-lang:scala-reflect:2.11.12 wanted version 2.11.12
25+
# - org.spire-math:kind-projector_2.11:0.9.7 wanted version 2.11.12
26+
# - org.typelevel:cats-core_2.11:1.1.0 wanted version 2.11.12
27+
# - org.typelevel:cats-free_2.11:1.1.0 wanted version 2.11.12
28+
# - org.typelevel:cats-kernel_2.11:1.1.0 wanted version 2.11.12
29+
# - org.typelevel:cats-macros_2.11:1.1.0 wanted version 2.11.12
30+
# - org.typelevel:machinist_2.11:0.6.2 wanted version 2.11.8
31+
{"artifact": "org.scala-lang:scala-library:2.11.12", "lang": "java", "sha1": "bf5534e6fec3d665bd6419c952a929a8bdd4b591", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_scala_lang_scala_library", "actual": "@io_higherkindness_droste_org_scala_lang_scala_library//jar", "bind": "jar/io_higherkindness_droste_org/scala_lang/scala_library"},
32+
# duplicates in org.scala-lang:scala-reflect promoted to 2.11.12
33+
# - org.scala-lang:scala-compiler:2.11.12 wanted version 2.11.12
34+
# - org.typelevel:machinist_2.11:0.6.2 wanted version 2.11.8
35+
{"artifact": "org.scala-lang:scala-reflect:2.11.12", "lang": "java", "sha1": "2bb23c13c527566d9828107ca4108be2a2c06f01", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_scala_lang_scala_reflect", "actual": "@io_higherkindness_droste_org_scala_lang_scala_reflect//jar", "bind": "jar/io_higherkindness_droste_org/scala_lang/scala_reflect"},
36+
{"artifact": "org.spire-math:kind-projector_2.11:0.9.7", "lang": "scala", "sha1": "9dd7e57630f5a3765e7a65c08a02f83cecc59ff7", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_spire_math_kind_projector_2_11", "actual": "@io_higherkindness_droste_org_spire_math_kind_projector_2_11//jar:file", "bind": "jar/io_higherkindness_droste_org/spire_math/kind_projector_2_11"},
37+
{"artifact": "org.typelevel:cats-core_2.11:1.1.0", "lang": "scala", "sha1": "854ab2123eccb2edc7bf00a484cf7826626ce71d", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_typelevel_cats_core_2_11", "actual": "@io_higherkindness_droste_org_typelevel_cats_core_2_11//jar:file", "bind": "jar/io_higherkindness_droste_org/typelevel/cats_core_2_11"},
38+
{"artifact": "org.typelevel:cats-free_2.11:1.1.0", "lang": "scala", "sha1": "a43effe7b5c1d9a1d1dd105865e4afe987e6e402", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_typelevel_cats_free_2_11", "actual": "@io_higherkindness_droste_org_typelevel_cats_free_2_11//jar:file", "bind": "jar/io_higherkindness_droste_org/typelevel/cats_free_2_11"},
39+
{"artifact": "org.typelevel:cats-kernel_2.11:1.1.0", "lang": "scala", "sha1": "45051dfb4703364929d603ac06afcda4a421d8da", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_typelevel_cats_kernel_2_11", "actual": "@io_higherkindness_droste_org_typelevel_cats_kernel_2_11//jar:file", "bind": "jar/io_higherkindness_droste_org/typelevel/cats_kernel_2_11"},
40+
{"artifact": "org.typelevel:cats-macros_2.11:1.1.0", "lang": "java", "sha1": "59a4fa3d642046b3997cfcc2db43f4df736545f2", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_typelevel_cats_macros_2_11", "actual": "@io_higherkindness_droste_org_typelevel_cats_macros_2_11//jar", "bind": "jar/io_higherkindness_droste_org/typelevel/cats_macros_2_11"},
41+
{"artifact": "org.typelevel:machinist_2.11:0.6.2", "lang": "java", "sha1": "029c6a46d66b6616f8795a70753e6753975f42fc", "repository": "http://central.maven.org/maven2/", "name": "io_higherkindness_droste_org_typelevel_machinist_2_11", "actual": "@io_higherkindness_droste_org_typelevel_machinist_2_11//jar", "bind": "jar/io_higherkindness_droste_org/typelevel/machinist_2_11"},
42+
]
43+
44+
def maven_dependencies(callback = declare_maven):
45+
for hash in list_dependencies():
46+
callback(hash)

Diff for: BUILD

Whitespace-only changes.

Diff for: WORKSPACE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
workspace(name = "io_higherkindness_droste")
2+
3+
rules_scala_version="63eab9f4d80612e918ba954211f377cc83d27a07" # update this as needed
4+
5+
http_archive(
6+
name = "io_bazel_rules_scala",
7+
url = "https://github.com/bazelbuild/rules_scala/archive/%s.zip"%rules_scala_version,
8+
type = "zip",
9+
strip_prefix= "rules_scala-%s" % rules_scala_version
10+
)
11+
12+
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
13+
scala_repositories()
14+
15+
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
16+
scala_register_toolchains()
17+
18+
load("//3rdparty:workspace.bzl", "maven_dependencies")
19+
maven_dependencies()
20+
21+
load(":workspace.bzl", "droste_bind_dependencies")
22+
droste_bind_dependencies()

Diff for: bazel_deps.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
options:
2+
buildHeader: [ "load(\"@io_bazel_rules_scala//scala:scala_import.bzl\", \"scala_import\")" ]
3+
languages: [ "java", "scala:2.11.11" ]
4+
namePrefix: "io_higherkindness_droste_"
5+
resolverType: "coursier"
6+
versionConflictPolicy: highest
7+
8+
dependencies:
9+
org.spire-math:
10+
kind-projector:
11+
lang: scala
12+
version: "0.9.7"
13+
14+
org.typelevel:
15+
cats:
16+
lang: scala
17+
modules: [ "core", "free", "kernel" ]
18+
version: "1.1.0"

Diff for: default.nix

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
with pkgs;
3+
4+
stdenv.mkDerivation rec {
5+
name = "env";
6+
7+
src = builtins.filterSource (path: type: false) ./.;
8+
9+
bazel = (import (fetchFromGitHub {
10+
owner = "andyscott";
11+
repo = "bazel-nix";
12+
rev = "d03cebdba5aefdccad70608ec348fdd1ca0c1ed1";
13+
sha256 = "08znczxmm4ijlw3lfcz8xw3f1368nn56i5ka453gygslj6qfg1g3";
14+
})) {
15+
version = "0.14.1";
16+
};
17+
18+
buildInputs = [
19+
sbt nodejs bazel
20+
];
21+
22+
installPhase = ''
23+
mkdir -p $out
24+
ln -s $bazel/bin/bazel $out/bazel
25+
'';
26+
}
27+

Diff for: modules/core/BUILD

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library")
2+
3+
scala_library(
4+
name = "core",
5+
srcs = glob(["**/*.scala"]),
6+
plugins = [
7+
"//external:io_higherkindness_droste_spire_math_kind_projector_jar",
8+
],
9+
scalacopts = [
10+
"-encoding", "UTF-8",
11+
"-feature",
12+
"-language:existentials",
13+
"-language:experimental.macros",
14+
"-language:higherKinds",
15+
"-language:implicitConversions",
16+
"-Ypartial-unification",
17+
],
18+
deps = [
19+
"//external:io_higherkindness_droste_typelevel_cats_core",
20+
"//external:io_higherkindness_droste_typelevel_cats_free",
21+
"//modules/meta",
22+
],
23+
exports = [
24+
"//modules/meta",
25+
],
26+
visibility = [
27+
"//visibility:public"
28+
],
29+
)

Diff for: modules/meta/BUILD

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_macro_library")
2+
3+
scala_macro_library(
4+
name = "meta",
5+
srcs = glob(["**/*.scala"]),
6+
deps = [],
7+
visibility = [
8+
"//visibility:public"
9+
],
10+
)

Diff for: scripts/update_bazel_deps.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
echo -ne "\033[0;32m"
4+
echo 'Updating jvm dependencies. This will take a few minutes.'
5+
echo -ne "\033[0m"
6+
7+
# update this to move to later versions of this repo:
8+
# https://github.com/johnynek/bazel-deps
9+
GITSHA="18928d33855defd5a72078938231ea1ef022c924"
10+
11+
set -e
12+
13+
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
14+
cd $SCRIPTS_DIR
15+
16+
REPO_ROOT=$(git rev-parse --show-toplevel)
17+
18+
BAZEL_DEPS_PATH="$HOME/.bazel-deps-cache/$(basename $REPO_ROOT)"
19+
BAZEL_DEPS_REPO_PATH="$BAZEL_DEPS_PATH/bazel-deps"
20+
BAZEL_DEPS_WORKSPACE="$BAZEL_DEPS_REPO_PATH/WORKSPACE"
21+
22+
if [ ! -f "$BAZEL_DEPS_WORKSPACE" ]; then
23+
mkdir -p $BAZEL_DEPS_PATH
24+
cd $BAZEL_DEPS_PATH
25+
git clone https://github.com/johnynek/bazel-deps.git
26+
fi
27+
28+
cd $BAZEL_DEPS_REPO_PATH
29+
git reset --hard $GITSHA || (git fetch && git reset --hard $GITSHA)
30+
bazel run //:parse -- generate -r $REPO_ROOT -s 3rdparty/workspace.bzl -d bazel_deps.yaml
31+
# now reformat the dependencies to keep them sorted
32+
bazel run //:parse -- format-deps -d $REPO_ROOT/bazel_deps.yaml -o

Diff for: shell.nix

-8
This file was deleted.

0 commit comments

Comments
 (0)