Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:

jobs:
run-tests-with-ubuntu:
name: Run Tests with ubuntu runner
name: with bazel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -28,6 +28,7 @@ jobs:
restore-keys: |
repo-cache-${{ runner.os }}-nixpkgs-${{ env.cache-version }}-
- run: |
nix-shell --pure --run "bazel run $BAZEL_ARGS //:gazelle"
nix-shell --pure --run "bazel test --test_output=all //... $BAZEL_ARGS"
- uses: actions/cache/save@v3
if: github.ref == 'refs/heads/master'
Expand All @@ -36,9 +37,48 @@ jobs:
~/repo-cache
~/disk-cache
key: repo-cache-${{ runner.os }}-nixpkgs-${{ env.cache-version }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: gazelle check
run: |
if ! git diff --exit-code
then
echo Repository files have changed
echo You might need to run: nix-shell --run "\"bazel run //:gazelle\""
echo and commit the resulting changes.
exit 1
fi

run-tests-with-stack:
name: with stack
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
- name: Configure
run: |
mkdir -p ~/repo-cache ~/disk-cache
echo build --host_platform=@io_tweag_rules_nixpkgs//nixpkgs/platforms:host > .bazelrc.local
- name: Get Stack snapshot install directory
id: stack-snapshot
# NOTE: `stack path` must run at least once prior to caching to ensure the directory
# exists and is populated.
run: |
stack --nix path --snapshot-install-root
echo "dir=$(stack --nix path --snapshot-install-root)" > "${GITHUB_OUTPUT}"
- uses: actions/cache@v4
with:
path: ${{ steps.stack-snapshot.outputs.dir }}
key: ${{ runner.os }}-stack-${{ hashFiles('**/*.cabal') }}
restore-keys: ${{ runner.os }}-stack-
- name: Build
run: |
stack --nix build
- name: Test
if: ${{ runner.os == 'Linux' }}
run: |
stack --nix test

run-tests-with-darwin:
name: Run Tests with darwin runner
name: with bazel in darwin
runs-on: macos-11

steps:
Expand Down
123 changes: 109 additions & 14 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,36 +1,80 @@
exports_files(["nixpkgs.nix"])

# gazelle:exclude {benchmarks,examples,jvm-streaming,jvm-batching}
# gazelle:resolve gazelle_cabal jvm @openjdk//:lib

load(
"@rules_haskell//haskell:defs.bzl",
"ghc_plugin",
"haskell_binary",
"haskell_library",
"haskell_test",
)

cc_library(
name = "bctable",
hdrs = ["cbits/bctable.h"],
srcs = ["cbits/bctable.c"],
hdrs = ["cbits/bctable.h"],
strip_include_prefix = "cbits",
)

ghc_plugin(
name = "inline-java-plugin",
args = ["$(JAVABASE)/bin/javac"],
module = "Language.Java.Inline.Plugin",
toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"],
tools = ["@bazel_tools//tools/jdk:current_java_runtime"],
visibility = ["//visibility:public"],
deps = [":inline-java"],
)

load(
"@bazel_gazelle//:def.bzl",
"DEFAULT_LANGUAGES",
"gazelle",
"gazelle_binary",
)

gazelle(
name = "gazelle",
gazelle = ":gazelle_binary",
)

gazelle_binary(
name = "gazelle_binary",
languages = DEFAULT_LANGUAGES + ["@io_tweag_gazelle_cabal//gazelle_cabal"],
)

# rule generated from inline-java.cabal by gazelle_cabal
haskell_library(
name = "inline-java",
# cbits/bctable.h is included here so it can be found by Plugin.hs
# at the same location when building with bazel as with stack.
srcs = glob(['src/**/*.hs',
'src/**/*.hsc',
'cbits/bctable.h',
]),
srcs = [
"cbits/bctable.h", # keep
"src/GhcPlugins/Extras.hs",
"src/Language/Java/Inline.hs",
"src/Language/Java/Inline/Internal.hs",
"src/Language/Java/Inline/Internal/Magic.hsc",
"src/Language/Java/Inline/Internal/QQMarker.hs",
"src/Language/Java/Inline/Internal/QQMarker/Names.hs",
"src/Language/Java/Inline/Internal/QQMarker/Safe.hs",
"src/Language/Java/Inline/Plugin.hs",
"src/Language/Java/Inline/Safe.hs",
"src/Language/Java/Inline/Unsafe.hs",
],
ghcopts = ["-DVERSION_inline_java=\"0.10.0\""],
hidden_modules = ["GhcPlugins.Extras"],
version = "0.10.0",
visibility = ["//visibility:public"],
deps = [
":bctable", # keep
"//jni",
"//jvm",
":bctable",
"@stackage//:Cabal",
"@stackage//:base",
"@stackage//:bytestring",
"@stackage//:directory",
"@stackage//:filemanip",
"@stackage//:filepath",
"@stackage//:ghc",
"@stackage//:language-java",
Expand All @@ -43,12 +87,63 @@ haskell_library(
],
)

ghc_plugin(
name = "inline-java-plugin",
args = ["$(JAVABASE)/bin/javac"],
module = "Language.Java.Inline.Plugin",
toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"],
tools = ["@bazel_tools//tools/jdk:current_java_runtime"],
# rule generated from inline-java.cabal by gazelle_cabal
haskell_test(
name = "spec",
srcs = [
"tests/Language/Java/Inline/SafeSpec.hs",
"tests/Language/Java/InlineSpec.hs",
"tests/Main.hs",
"tests/SafeSpec.hs",
"tests/Spec.hs",
],
extra_srcs = ["@openjdk//:rpath"], # keep
ghcopts = [
"-optl-Wl,@$(location @openjdk//:rpath)", # keep
"-DVERSION_inline_java=\"0.10.0\"",
"-threaded",
"-DHSPEC_DISCOVER_HSPEC_DISCOVER_PATH=$(location @stackage-exe//hspec-discover)",
],
main_file = "tests/Main.hs",
plugins = [":inline-java-plugin"],
tools = ["@stackage-exe//hspec-discover"],
version = "0.10.0",
visibility = ["//visibility:public"],
deps = [":inline-java"],
deps = [
"//:inline-java", # keep
"//jni",
"//jvm",
"@stackage//:QuickCheck",
"@stackage//:base",
"@stackage//:hspec",
"@stackage//:linear-base",
"@stackage//:quickcheck-unicode",
"@stackage//:text",
"@stackage//:vector",
],
)

# rule generated from inline-java.cabal by gazelle_cabal
haskell_binary(
name = "micro-benchmarks",
srcs = ["benchmarks/micro/Main.hs"],
extra_srcs = ["@openjdk//:rpath"], # keep
ghcopts = [
"-optl-Wl,@$(location @openjdk//:rpath)", # keep
"-DVERSION_inline_java=\"0.10.0\"",
"-threaded",
],
main_file = "benchmarks/micro/Main.hs",
plugins = [":inline-java-plugin"],
version = "0.10.0",
visibility = ["//visibility:public"],
deps = [
"//:inline-java", # keep
"//jni",
"//jvm",
"@stackage//:base",
"@stackage//:criterion",
"@stackage//:deepseq",
"@stackage//:singletons",
],
)
2 changes: 2 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
81 changes: 75 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ stack_snapshot(
"filepath",
"ghc",
"hspec",
"hspec-discover",
"inline-c",
"language-java",
"monad-logger",
Expand Down Expand Up @@ -98,6 +99,10 @@ stack_snapshot(
"ghc-boot-th",
"pretty",
"transformers",
# gazelle_cabal dependencies
"json", # keep
"path", # keep
"path-io", # keep
],
extra_deps = { "zlib" : ["@zlib.dev//:zlib"] },
components_dependencies = {
Expand All @@ -109,6 +114,10 @@ stack_snapshot(
"lib",
"lib:attoparsec-internal",
],
"hspec-discover": [
"lib",
"exe",
],
},
local_snapshot = "//:snapshot-9.0.2.yaml",
# stack = "@stack_ignore_global_hints//:bin/stack" if ghc_version == "9.0.1" else None,
Expand Down Expand Up @@ -144,12 +153,6 @@ haskell_register_ghc_nixpkgs(
],
)

nixpkgs_package(
name = "sed",
attribute_path = "gnused",
repository = "@nixpkgs",
)

nixpkgs_package(
name = "hspec-discover",
attribute_path = "haskellPackages.hspec-discover",
Expand Down Expand Up @@ -250,3 +253,69 @@ maven_install(
"https://repo1.maven.org/maven2",
],
)

# gazelle setup

http_archive(
name = "rules_nixpkgs_go",
sha256 = "30271f7bd380e4e20e4d7132c324946c4fdbc31ebe0bbb6638a0f61a37e74397",
strip_prefix = "rules_nixpkgs-0.13.0/toolchains/go",
urls = ["https://github.com/tweag/rules_nixpkgs/releases/download/v0.13.0/rules_nixpkgs-0.13.0.tar.gz"],
)

http_archive(
name = "io_bazel_rules_go",
sha256 = "f2dcd210c7095febe54b804bb1cd3a58fe8435a909db2ec04e31542631cf715c",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
],
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

############################################################
# Define your own dependencies here using go_repository.
# Else, dependencies declared by rules_go/gazelle will be used.
# The first declaration of an external repository "wins".
############################################################

load("@rules_nixpkgs_go//:go.bzl", "nixpkgs_go_configure")

nixpkgs_go_configure(
repository = "@nixpkgs",
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

gazelle_dependencies()


http_archive(
name = "io_tweag_gazelle_cabal",
strip_prefix = "gazelle_cabal-ca8f68e250bea33815fb373320f9610582c42083",
sha256 = "bd2ee67943007723b3425bf2fcbdb6b41b269c7bc03f01e40683d4b5f3984b3b",
url = "https://github.com/tweag/gazelle_cabal/archive/ca8f68e.zip",
)

load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot")
load("@io_tweag_gazelle_cabal//:defs.bzl", "gazelle_cabal_dependencies")
gazelle_cabal_dependencies()

go_repository(
name = "org_golang_x_xerrors",
importpath = "golang.org/x/xerrors",
sum = "h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=",
version = "v0.0.0-20200804184101-5ec99f83aff1",
)
25 changes: 0 additions & 25 deletions benchmarks/micro/BUILD.bazel

This file was deleted.

Loading
Loading