Skip to content

Commit

Permalink
bazel(ldfi2): make building work
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Feb 24, 2021
1 parent 80e9745 commit 7400c55
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 15 deletions.
47 changes: 44 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ nixpkgs_git_repository(
)

nixpkgs_cc_configure(
repository = "@nixpkgs//:default.nix"
name = "nixpkgs_config_cc",
repository = "@nixpkgs//:default.nix",
)

nixpkgs_package(
name = "z3.dev",
repositories = { "nixpkgs": "@nixpkgs//:default.nix" }
)

nixpkgs_package(
name = "z3",
name = "z3.lib",
repositories = { "nixpkgs": "@nixpkgs//:default.nix" }
)

Expand Down Expand Up @@ -69,7 +75,7 @@ rules_haskell_dependencies()
load("@rules_haskell//haskell:nixpkgs.bzl", "haskell_register_ghc_nixpkgs")

haskell_register_ghc_nixpkgs(
attribute_path = "nixpkgs.ghc",
attribute_path = "haskell.compiler.ghc8103",
repositories = {"nixpkgs": "@nixpkgs"},
version = "8.10.3",
)
Expand All @@ -78,6 +84,41 @@ load("@rules_haskell//haskell:toolchain.bzl", "rules_haskell_toolchains")

rules_haskell_toolchains(version = "8.10.3")

http_archive(
name = "haskell_z3",
build_file = "//src/ldfi2/third_party/haskell-z3:haskell-z3.BUILD",
strip_prefix = "haskell-z3-e8af470c0e6045d063f2361719dfac488e5476bd",
sha256 = "5ce97d4315855d2ec4abdd0f7c2404225d3abfbd80a6c2a9e1ff8de62c8a5cc2",
urls = [
"https://github.com/IagoAbal/haskell-z3/archive/e8af470c0e6045d063f2361719dfac488e5476bd.tar.gz",
],
)

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

stack_snapshot(
name = "stackage",
packages = [
"base",
"containers",
"filepath",
"mtl",
"template-haskell",
"QuickCheck",
"sqlite-simple",
"text",

# z3-haskell dependencies
"transformers",

],
snapshot = "lts-17.2",
extra_deps = {"z3": ["@z3.dev//:include", "@z3.lib//:lib"]},
vendored_packages = {
"z3": "@haskell_z3//:z3",
}
)

# Golang
http_archive(
name = "io_bazel_rules_go",
Expand Down
24 changes: 12 additions & 12 deletions src/ldfi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ load("@pip//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_test")

py_test(
name = "ldfi_test",
main = "tests/test_ldfi.py",
srcs = ["tests/test_ldfi.py"],
imports = [".."],
deps = [
requirement("z3-solver"),
"//src/ldfi/src:ldfi_lib",
],
data = ["@z3//:bin"],
name = "ldfi_test",
main = "tests/test_ldfi.py",
srcs = ["tests/test_ldfi.py"],
imports = [".."],
deps = [
requirement("z3-solver"),
"//src/ldfi/src:ldfi_lib",
],
data = ["@z3.dev//:bin"],

env = {
"Z3_LIBRARY_PATH": "/nix/store/zdaninww6cyh3h9aj7w0kymz8c13b1q4-z3-4.8.9-lib/lib"
}
env = {
"Z3_LIBRARY_PATH": "/nix/store/zdaninww6cyh3h9aj7w0kymz8c13b1q4-z3-4.8.9-lib/lib"
}
)
24 changes: 24 additions & 0 deletions src/ldfi2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package(default_visibility = ["//visibility:public"])

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

haskell_library(
name = "ldfi-lib",
src_strip_prefix = "src",
srcs = glob(['src/**/*.hs']),
deps = [
"@stackage//:base",
"@stackage//:containers",
"@stackage//:filepath",
"@stackage//:QuickCheck",
"@stackage//:sqlite-simple",
"@stackage//:template-haskell",
"@stackage//:text",
"@stackage//:z3",
],
)
Empty file.
29 changes: 29 additions & 0 deletions src/ldfi2/third_party/haskell-z3/haskell-z3.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
load(
"@rules_haskell//haskell:cabal.bzl",
"haskell_cabal_library",
)

load(
"@stackage//:packages.bzl",
"packages",
)

cc_library(
name = "libz3",
srcs = ["@z3.lib//:lib"],
hdrs = ["@z3.dev//:include"],
strip_include_prefix = "/include",
linkstatic = 1,
)

haskell_cabal_library(
name = "z3",
deps = packages["z3"].deps + [":libz3"],
srcs = glob([
"**",
]),
version = "408.2",
visibility = [
"//visibility:public",
],
)

0 comments on commit 7400c55

Please sign in to comment.