diff --git a/WORKSPACE b/WORKSPACE index 0dbe6065..e22ec12e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -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" } ) @@ -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", ) @@ -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", diff --git a/src/ldfi/BUILD.bazel b/src/ldfi/BUILD.bazel index 52ed5e15..fa0a6a81 100644 --- a/src/ldfi/BUILD.bazel +++ b/src/ldfi/BUILD.bazel @@ -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" + } ) diff --git a/src/ldfi2/BUILD.bazel b/src/ldfi2/BUILD.bazel new file mode 100644 index 00000000..9322a539 --- /dev/null +++ b/src/ldfi2/BUILD.bazel @@ -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", + ], +) diff --git a/src/ldfi2/third_party/haskell-z3/BUILD.bazel b/src/ldfi2/third_party/haskell-z3/BUILD.bazel new file mode 100644 index 00000000..e69de29b diff --git a/src/ldfi2/third_party/haskell-z3/haskell-z3.BUILD b/src/ldfi2/third_party/haskell-z3/haskell-z3.BUILD new file mode 100644 index 00000000..c576558c --- /dev/null +++ b/src/ldfi2/third_party/haskell-z3/haskell-z3.BUILD @@ -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", + ], +)