diff --git a/.bazelrc b/.bazelrc index 58a34c7c8..8107e8550 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,5 +1,6 @@ # See https://docs.bazel.build/versions/master/user-manual.html#bazelrc. +build:ci --loading_phase_threads=8 #build:ci --all_incompatible_changes build:ci --sandbox_debug build:ci --verbose_failures diff --git a/.netlify/install.sh b/.netlify/install.sh index ccac4679e..a586132be 100755 --- a/.netlify/install.sh +++ b/.netlify/install.sh @@ -7,3 +7,22 @@ V=0.16.0 curl -LO https://github.com/bazelbuild/bazel/releases/download/$V/bazel-$V-installer-linux-x86_64.sh chmod +x bazel-$V-installer-linux-x86_64.sh ./bazel-$V-installer-linux-x86_64.sh --user + +# XXX: Hack to prevent the `haskell_nixpkgs_package_list` rule from crashing: +# This rule expects a `nix-build` executable which is used to generate a +# store-path containing an `all-haskell-packages.bzl` file which defines the +# `package` list. Since actually installing `nix-build` on the netlify image +# seems difficult, we provide a dummy shell script which does exactly that. +packages_list=$(mktemp -d) +cat < $packages_list/all-haskell-packages.bzl +packages = [] +EOF + +mkdir -p $HOME +cat < $HOME/bin/nix-build +#!/usr/bin/env bash + +echo $packages_list +EOF + +chmod +x $HOME/bin/nix-build diff --git a/WORKSPACE b/WORKSPACE index fdf69cec5..a236f6373 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -5,23 +5,28 @@ haskell_repositories() http_archive( name = "io_tweag_rules_nixpkgs", - strip_prefix = "rules_nixpkgs-0.2.3", - urls = ["https://github.com/tweag/rules_nixpkgs/archive/v0.2.3.tar.gz"], - sha256 = "2647bc9d5476fba95d9b4cc300be1ba9ad353e4e33bee01e041886aa4f4b554a", + strip_prefix = "rules_nixpkgs-0.3.1", + urls = ["https://github.com/tweag/rules_nixpkgs/archive/v0.3.1.tar.gz"], + sha256 = "1dc7ad9d4e0e7e690962317fa70bf5ab3bac5b4944e4f40eff3c2d6f5255eb20", ) load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_git_repository", "nixpkgs_package", ) +load("@io_tweag_rules_haskell//haskell:nix.bzl", + "haskell_nixpkgs_packages", + "haskell_nixpkgs_package", + "haskell_nixpkgs_packageset") -nixpkgs_package( +haskell_nixpkgs_package( name = "ghc", # rules_nixpkgs assumes we want to read from `` implicitly # if `repository` is not set, but our nix_file uses `./nixpkgs/`. # TODO(Profpatsch) - repository = "//nixpkgs:NOTUSED", + repositories = { "nixpkgs": "//nixpkgs:NOTUSED" }, nix_file = "//tests:ghc.nix", + attribute_path = "haskellPackages.ghc", build_file = "//haskell:ghc.BUILD", ) @@ -32,26 +37,6 @@ http_archive( urls = ["https://github.com/google/protobuf/archive/v3.5.0.zip"], ) -nixpkgs_package( - name = "protoc_gen_haskell", - # this is a trick to set to reference a nix file - # TODO(Profpatsch) document & fix upstream - repository = "//nixpkgs:default.nix", - attribute_path = "haskell.packages.ghc844.proto-lens-protoc" -) - -nixpkgs_package( - name = "doctest", - repository = "//nixpkgs:default.nix", - attribute_path = "haskell.packages.ghc844.doctest", -) - -nixpkgs_package( - name = "c2hs", - repository = "//nixpkgs:default.nix", - attribute_path = "haskell.packages.ghc844.c2hs", -) - register_toolchains( "//tests:ghc", "//tests:doctest-toolchain", @@ -60,7 +45,7 @@ register_toolchains( nixpkgs_package( name = "zlib", - repository = "//nixpkgs:default.nix", + repositories = { "nixpkgs": "//nixpkgs:default.nix" }, build_file_content = """ package(default_visibility = ["//visibility:public"]) @@ -78,7 +63,7 @@ filegroup ( nixpkgs_package( name = "zlib.dev", - repository = "//nixpkgs:default.nix", + repositories = { "nixpkgs": "//nixpkgs:default.nix" }, build_file_content = """ load("@io_tweag_rules_haskell//haskell:haskell.bzl", "haskell_cc_import") package(default_visibility = ["//visibility:public"]) @@ -101,7 +86,7 @@ haskell_cc_import( nixpkgs_package( name = "glib_locales", - repository = "//nixpkgs:default.nix", + repositories = { "nixpkgs": "//nixpkgs:default.nix" }, attribute_path = "glibcLocales", build_file_content = """ package(default_visibility = ["//visibility:public"]) @@ -113,6 +98,15 @@ filegroup( """ ) +haskell_nixpkgs_packageset( + name = "hackage-packages", + repositories = { "nixpkgs": "//nixpkgs:default.nix" }, + nix_file = "//tests:ghc.nix", + base_attribute_path = "haskellPackages", +) +load("@hackage-packages//:packages.bzl", "import_packages") +import_packages(name = "hackage") + # zlib as a Haskell library new_http_archive( diff --git a/docs/BUILD b/docs/BUILD index 157cd1a0b..ef82df9ce 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -29,6 +29,7 @@ skylark_doc( "//haskell:cc.bzl", "//haskell:repositories.bzl", "//haskell:ghc_bindist.bzl", + "//haskell:nix.bzl", ], format = "html", ) diff --git a/haskell/haddock.bzl b/haskell/haddock.bzl index 5171b9d5e..360cbef58 100644 --- a/haskell/haddock.bzl +++ b/haskell/haddock.bzl @@ -26,6 +26,11 @@ def _haskell_doc_aspect_impl(target, ctx): if HaskellBuildInfo not in target or HaskellLibraryInfo not in target: return [] + # Packages imported via `//haskell:import.bzl%haskell_import` already + # contain an `HaddockInfo` provider, so we just forward it + if HaddockInfo in target: + return [] + hs = haskell_context(ctx, ctx.rule.attr) package_id = target[HaskellLibraryInfo].package_id @@ -194,7 +199,7 @@ def _haskell_doc_rule_impl(ctx): command = """ mkdir -p "{doc_dir}" # Copy Haddocks of a dependency. - cp -r "{html_dir}" "{target_dir}" + cp -R -L "{html_dir}" "{target_dir}" """.format( doc_dir = doc_root_path, html_dir = html_dir.path, diff --git a/haskell/import.bzl b/haskell/import.bzl new file mode 100644 index 000000000..154f85ceb --- /dev/null +++ b/haskell/import.bzl @@ -0,0 +1,107 @@ +"""Importing prebuilt packages into bazel""" + +load(":private/context.bzl", "haskell_context") +load(":private/actions/package.bzl", "package") +load( + ":private/providers.bzl", + "HaddockInfo", + "HaskellBuildInfo", + "HaskellLibraryInfo", +) +load(":private/set.bzl", "set") +load(":private/path_utils.bzl", "copy_all", "link_forest", "ln") +load("@bazel_skylib//:lib.bzl", "paths") + +def _haskell_import_impl(ctx): + hs = haskell_context(ctx) + + package_cache = ctx.actions.declare_file( + paths.join("package.conf.d", "package.cache"), + ) + + local_package_confs = link_forest( + ctx = ctx, + srcs = ctx.attr.package_confs.files, + sibling = package_cache, + ) + + local_haddock_html = ctx.actions.declare_directory("haddock-html") + copy_all( + ctx = ctx, + srcs = ctx.attr.haddock_html.files, + dest = local_haddock_html, + ) + + ctx.actions.run( + outputs = [package_cache], + inputs = local_package_confs, + mnemonic = "HaskellCreatePackageCache", + executable = hs.tools.ghc_pkg, + arguments = [ + "recache", + "--package-db", + package_cache.dirname, + ], + ) + ln(ctx, package_cache, ctx.outputs.cache) + + dependencies_caches = set.singleton(package_cache) + for dep in ctx.attr.deps: + if HaskellBuildInfo in dep: + set.mutable_union(dependencies_caches, dep[HaskellBuildInfo].package_caches) + + deps_ids = [ + dep[HaskellLibraryInfo].package_id + for dep in ctx.attr.deps + if HaskellLibraryInfo in dep + ] + + libInfo = HaskellLibraryInfo( + package_id = ctx.attr.package_id, + version = ctx.attr.version, + import_dirs = [], + header_files = set.empty(), + boot_files = set.empty(), + source_files = set.empty(), + extra_source_files = set.empty(), + ghc_args = [], + ) + buildInfo = HaskellBuildInfo( + package_ids = set.from_list([ctx.attr.package_id] + deps_ids), + package_confs = set.from_list(local_package_confs), + package_caches = dependencies_caches, + static_libraries = [], + static_libraries_prof = [], + dynamic_libraries = set.empty(), + interface_dirs = set.empty(), + prebuilt_dependencies = set.empty(), + external_libraries = {}, + direct_prebuilt_deps = set.empty(), + ) + html_files = list(ctx.attr.haddock_html.files) + transitive_html = {ctx.attr.package_id: local_haddock_html} if html_files != [] else {} + interface_files = list(ctx.attr.haddock_interfaces.files) + transitive_haddocks = {ctx.attr.package_id: interface_files[0]} if interface_files != [] else {} + + haddockInfo = HaddockInfo( + package_id = ctx.attr.package_id, + transitive_html = transitive_html, + transitive_haddocks = transitive_haddocks, + ) + return [buildInfo, libInfo, haddockInfo] + +haskell_import = rule( + _haskell_import_impl, + attrs = dict( + package_id = attr.string(doc = "Workspace unique package identifier"), + deps = attr.label_list(doc = "Haskell dependencies for the package"), + version = attr.string(doc = "Package version."), + haddock_interfaces = attr.label(doc = "List of haddock interfaces"), + haddock_html = attr.label(doc = "List of haddock html dirs"), + package_confs = attr.label(doc = "List of ghc-pkg package.conf files"), + ), + outputs = { + "cache": "%{name}-cache", + }, + toolchains = ["@io_tweag_rules_haskell//haskell:toolchain"], +) diff --git a/haskell/nix.bzl b/haskell/nix.bzl new file mode 100644 index 000000000..30bdb6d6a --- /dev/null +++ b/haskell/nix.bzl @@ -0,0 +1,215 @@ +"""Loading of haskell packages from nixpkgs""" + +load( + "@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", + "nixpkgs_package", +) + +def haskell_nixpkgs_package( + name, + attribute_path, + nix_file_deps = [], + repositories = {}, + build_file_content = None, + build_file = None, + **kwargs): + """Load a single haskell package. + The package is expected to be in the form of the packages generated by + `genBazelBuild.nix` + """ + repositories = { + "bazel_haskell_wrapper": "@io_tweag_rules_haskell//haskell:nix/default.nix", + } + repositories + + nixpkgs_args = dict( + name = name, + attribute_path = attribute_path, + build_file_content = build_file_content, + nix_file_deps = nix_file_deps + ["@io_tweag_rules_haskell//haskell:nix/default.nix"], + repositories = repositories, + **kwargs + ) + + if build_file_content: + nixpkgs_args["build_file_content"] = build_file_content + elif build_file: + nixpkgs_args["build_file"] = build_file + else: + nixpkgs_args["build_file_content"] = """ +package(default_visibility = ["//visibility:public"]) +load("@io_tweag_rules_haskell//haskell:import.bzl", haskell_import_new = "haskell_import") + +load(":BUILD.bzl", "targets") +targets() +""" + + nixpkgs_package( + **nixpkgs_args + ) + +def _bundle_impl(repository_ctx): + build_file_content = """ +package(default_visibility = ["//visibility:public"]) + """ + for package in repository_ctx.attr.packages: + build_file_content += """ +alias( + name = "{package}", + actual = "@{base_repo}-{package}//:pkg", +) + """.format( + package = package, + base_repo = repository_ctx.attr.base_repository, + ) + repository_ctx.file("BUILD", build_file_content) + +_bundle = repository_rule( + attrs = { + "packages": attr.string_list(), + "base_repository": attr.string(), + }, + implementation = _bundle_impl, +) +""" +Generate an alias from `@base_repo//:package` to `@base_repo-package//:pkg` for +each one of the input package +""" + +def haskell_nixpkgs_packages(name, base_attribute_path, packages, **kwargs): + """Import a set of haskell packages from nixpkgs. + + This takes as input the same arguments as + [nixpkgs_package](https://github.com/tweag/rules_nixpkgs#nixpkgs_package), + expecting the `attribute_path` to resolve to a set of haskell packages + (such as `haskellPackages` or `haskell.packages.ghc822`) preprocessed by + the `genBazelBuild` function. It also takes as input a list of packages to + import (which can be generated by the `gen_packages_list` function). + """ + for package in packages: + haskell_nixpkgs_package( + name = name + "-" + package, + attribute_path = base_attribute_path + "." + package, + **kwargs + ) + _bundle( + name = name, + packages = packages, + base_repository = name, + ) + +def _gen_imports_impl(repository_ctx): + repository_ctx.file("BUILD", "") + extra_args_raw = "" + for foo, bar in repository_ctx.attr.extra_args.items(): + extra_args_raw += foo + " = " + bar + ", " + bzl_file_content = """ +load("{repo_name}", "packages") +load("@io_tweag_rules_haskell//haskell:nix.bzl", "haskell_nixpkgs_packages") + +def import_packages(name): + haskell_nixpkgs_packages( + name = name, + packages = packages, + {extra_args_raw} + ) + """.format( + repo_name = repository_ctx.attr.packages_list_file, + extra_args_raw = extra_args_raw, + ) + + repository_ctx.file("packages.bzl", bzl_file_content) + +_gen_imports_str = repository_rule( + implementation = _gen_imports_impl, + attrs = dict( + packages_list_file = attr.label(doc = "A list containing the list of packages to import"), + # We pass the extra arguments to `haskell_nixpkgs_packages` as strings + # since we can't forward arbitrary arguments in a rule and they will be + # converted to strings anyways. + extra_args = attr.string_dict(doc = "Extra arguments for `haskell_nixpkgs_packages`"), + ), +) +""" +Generate a repository containing a file `packages.bzl` which imports the given +packages list. +""" + +def _gen_imports(name, packages_list_file, extra_args): + """ + A wrapper around `_gen_imports_str` which allows passing an arbitrary set of + `extra_args` instead of a set of strings + """ + extra_args_str = {label: repr(value) for (label, value) in extra_args.items()} + _gen_imports_str( + name = name, + packages_list_file = packages_list_file, + extra_args = extra_args_str, + ) + +def haskell_nixpkgs_packageset(name, base_attribute_path, repositories = {}, **kwargs): + """Import all the available haskell packages. + The arguments are the same as the arguments of ``nixpkgs_package``, except + for the ``base_attribute_path`` which should point to an `haskellPackages` + set in the nix expression + + Example: + + In `haskellPackages.nix`: + + ```nix + with import {}; + + let wrapPackages = callPackage { }; in + { haskellPackages = wrapPackages haskell.packages.ghc822; } + ``` + + In your `WORKSPACE` + + ```bazel + # Define a nix repository to fetch the packages from + load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", + "nixpkgs_git_repository") + nixpkgs_git_repository( + name = "nixpkgs", + revision = "9a787af6bc75a19ac9f02077ade58ddc248e674a", + ) + + load("@io_tweag_rules_haskell//haskell:nix.bzl", + "haskell_nixpkgs_packageset", + + # Generate a list of all the available haskell packages + haskell_nixpkgs_packageset( + name = "hackage-packages", + repositories = {"@nixpkgs": "nixpkgs"}, + nix_file = "//haskellPackages.nix", + base_attribute_path = "haskellPackages", + ) + load("@hackage-packages//:packages.bzl", "import_packages") + import_packages(name = "hackage") + ``` + + Then in your `BUILD` files, you can access to the whole of hackage as + `@hackage//:{your-package-name}` + """ + + repositories = { + "bazel_haskell_wrapper": "@io_tweag_rules_haskell//haskell:nix/default.nix", + } + repositories + nixpkgs_package( + name = name + "-packages-list", + attribute_path = base_attribute_path + ".packageNames", + repositories = repositories, + build_file_content = """ +exports_files(["all-haskell-packages.bzl"]) + """, + **kwargs + ) + _gen_imports( + name = name, + packages_list_file = "@" + name + "-packages-list//:all-haskell-packages.bzl", + extra_args = dict( + repositories = repositories, + base_attribute_path = base_attribute_path, + **kwargs + ), + ) diff --git a/haskell/nix/default.nix b/haskell/nix/default.nix new file mode 100644 index 000000000..8d1502571 --- /dev/null +++ b/haskell/nix/default.nix @@ -0,0 +1,117 @@ +/** + Generate a bazel-friendly nix package containing + - The haskell package itself + - Its documentation + - A bazel file ready to be loaded from the `BUILD` file and containing the + right call to `haskell_import` +*/ +{ runCommand, lib, writeTextDir, symlinkJoin }: +let + /* Generate the BUILD file for the package */ + genBuildFile = + { package_name, package, ghc }: + runCommand "${package_name}-BUILD" { + ghc_pkg = "${ghc}/bin/ghc-pkg --simple-output -v0"; + GHC_PACKAGE_PATH = "${package}/lib/${ghc.name}/package.conf.d"; + inherit package_name; + } '' + query_field () { + $ghc_pkg field ${package_name} "$@" + } + + query_haddock () { + echo -n '[' + for FIELD in $(query_field "$@"); do + echo -n "\"$(echo "$FIELD" | cut -d/ -f5-)*\"," + echo -n "\"$(echo "$FIELD" | cut -d/ -f5-)/*\"," + done + echo -n ']' + } + + query_list () { + echo -n '[' + for FIELD in $(query_field "$@"); do + echo -n '"' + echo -n $(echo "$FIELD" | cut -d/ -f5-) + echo -n '",' + done + echo -n ']' + } + + get_deps () { + echo -n '[' + for DEP in $(query_field depends); do + DEPNAME=$(echo $DEP | sed 's/-[0-9].*//') + # Because of cabal's "internal libraries", we may have a package + # apparently depending on itself, so we have to filter out this + # corner-case (see + # https://github.com/tweag/rules_haskell/pull/442#discussion_r219859467) + if [[ -n $DEPNAME && $DEPNAME != $(query_field name) ]]; then + echo -n "\"@hackage-$DEPNAME\"," + fi + done + echo -n ']' + } + + mkdir -p $out + cat < $out/BUILD.bzl + load("@io_tweag_rules_haskell//haskell:import.bzl", haskell_import_new = "haskell_import") + deps_repos = $(get_deps) + + def targets(): + + haskell_import_new( + name = "pkg", + deps = [ dep + "//:pkg" for dep in deps_repos], + package_id = "$(query_field id)", + version = "$(query_field version)", + package_confs = "//:package_conf", + haddock_interfaces = "//:interfaces", + haddock_html = "//:html", + ) + native.filegroup( + name = "html", + srcs = native.glob($(query_haddock haddock-html), exclude_directories=1), + ) + native.filegroup( + name = "interfaces", + srcs = native.glob($(query_haddock haddock-interfaces), exclude_directories=0), + ) + native.filegroup( + name = "bin", + srcs = native.glob(["bin/*"]), + ) + native.filegroup( + name = "package_conf", + srcs = native.glob(["lib*/${ghc.name}/package.conf.d/$(query_field name)*.conf"]), + ) + EOF + ''; + genAllBuilds = pkgSet: + let newSet = + lib.mapAttrs (package_name: package: + let + # Some nix packages are actually `null` because the haskell package is + # bundled with ghc (so it doesn't have a custom derivation of its own). + # For these, we simply pass the ghc derivation instead of theirs. + real_package = if builtins.isNull package then pkgSet.ghc else package; + buildFile = genBuildFile { + inherit (pkgSet) ghc; + inherit package_name; + package = real_package; + }; + in + symlinkJoin { + name = package_name + "-bazel"; + paths = [ real_package (real_package.doc or null) buildFile ]; + } + ) + pkgSet; + in + newSet // { + packageNames = writeTextDir + "all-haskell-packages.bzl" + ("packages =" + builtins.toJSON (builtins.attrNames newSet)); + }; +in +genAllBuilds diff --git a/haskell/private/path_utils.bzl b/haskell/private/path_utils.bzl index 281dd179a..7126118ef 100644 --- a/haskell/private/path_utils.bzl +++ b/haskell/private/path_utils.bzl @@ -214,3 +214,34 @@ def ln(hs, target, link, extra_inputs = depset()): ), use_default_shell_env = True, ) + +def link_forest(ctx, srcs, basePath = ".", **kwargs): + """Write a symlink to each file in `srcs` into a destination directory + defined using the same arguments as `ctx.actions.declare_directory`""" + local_files = [] + for src in srcs: + dest = ctx.actions.declare_file( + paths.join(basePath, src.basename), + **kwargs + ) + local_files.append(dest) + ln(ctx, src, dest) + return local_files + +def copy_all(ctx, srcs, dest): + """Copy all the files in `srcs` into `dest`""" + if list(srcs) == []: + ctx.actions.run_shell( + command = "mkdir -p {dest}".format(dest = dest.path), + outputs = [dest], + ) + else: + args = ctx.actions.args() + args.add_all(srcs) + ctx.actions.run_shell( + inputs = depset(srcs), + outputs = [dest], + mnemonic = "Copy", + command = "mkdir -p {dest} && cp -L -R \"$@\" {dest}".format(dest = dest.path), + arguments = [args], + ) diff --git a/haskell/protobuf.bzl b/haskell/protobuf.bzl index 403159154..d1380f2ca 100644 --- a/haskell/protobuf.bzl +++ b/haskell/protobuf.bzl @@ -309,7 +309,7 @@ def haskell_proto_toolchain( haskell_proto_toolchain( name = "protobuf-toolchain", protoc = "@com_google_protobuf//:protoc", - plugin = "@protoc_gen_haskell//:bin/proto-lens-protoc", + plugin = "@hackage-proto-lens-protoc//:bin/proto-lens-protoc", prebuilt_deps = [ "base", "bytestring", diff --git a/tests/BUILD b/tests/BUILD index 73769fc51..b25382854 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -11,6 +11,7 @@ load( ) load("@bazel_tools//tools/build_rules:test_rules.bzl", "rule_test") load("//skylark:lint.bzl", "skylark_lint") +load("@io_tweag_rules_haskell//haskell:import.bzl", haskell_import_new = "haskell_import") ghc_version = "8.4.4" @@ -21,7 +22,7 @@ haskell_toolchain( # proto_library rules (from com_google_protobuf) can't themselves # be testonly. testonly = 0, - c2hs = "@c2hs//:bin", + c2hs = "@hackage-c2hs//:bin", compiler_flags = [ "-XStandaloneDeriving", # Flag used at compile time "-threaded", # Flag used at link time @@ -40,150 +41,34 @@ haskell_toolchain( "-UTESTS_TOOLCHAIN_REPL_FLAGS", # The repl test will need this flag, but set by the local `repl_ghci_args`. "-XOverloadedStrings", # The repl test will need OverloadedString ], - tools = "@ghc//:bin", + tools = "@hackage-ghc//:bin", version = ghc_version, ) haskell_doctest_toolchain( name = "doctest-toolchain", - doctest = "@doctest//:bin", + doctest = "@hackage-doctest//:bin", ) haskell_proto_toolchain( name = "protobuf-toolchain", testonly = 0, - plugin = "@protoc_gen_haskell//:bin/proto-lens-protoc", + plugin = "@hackage-proto-lens-protoc//:bin/proto-lens-protoc", protoc = "@com_google_protobuf//:protoc", deps = [ - "//tests:base", - "//tests:bytestring", - "//tests:containers", - "//tests:data-default-class", - "//tests:lens-family", - "//tests:lens-labels", - "//tests:proto-lens", - "//tests:text", + "@hackage//:base", + "@hackage//:bytestring", + "@hackage//:containers", + "@hackage//:data-default-class", + "@hackage//:lens-family", + "@hackage//:lens-family-core", + "@hackage//:lens-labels", + "@hackage//:mtl", + "@hackage//:proto-lens", + "@hackage//:text", ], ) -# Haskell packages -# `testonly = 0`, because they are also used to build -# the Haskell Protobuf Toolchain - -haskell_import( - name = "base", - testonly = 0, - package = "base", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "bytestring", - testonly = 0, - package = "bytestring", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "containers", - testonly = 0, - package = "containers", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "directory", - testonly = 0, - package = "directory", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "data-default-class", - testonly = 0, - package = "data-default-class", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "filepath", - testonly = 0, - package = "filepath", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "ghc-prim", - testonly = 0, - package = "ghc-prim", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "hspec", - testonly = 0, - package = "hspec", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "hspec-core", - testonly = 0, - package = "hspec-core", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "process", - testonly = 0, - package = "process", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "template-haskell", - testonly = 0, - package = "template-haskell", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "lens-family", - testonly = 0, - package = "lens-family", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "lens-labels", - testonly = 0, - package = "lens-labels", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "array", - testonly = 0, - package = "array", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "text", - testonly = 0, - package = "text", - visibility = ["//visibility:public"], -) - -haskell_import( - name = "proto-lens", - testonly = 0, - package = "proto-lens", - visibility = ["//visibility:public"], -) - -# All tests - rule_test( name = "test-binary-simple", size = "small", @@ -267,7 +152,9 @@ rule_test( name = "test-haddock", size = "small", generates = [ + "haddock/base-4.11.1.0", "haddock/index", + "haddock/template-haskell-2.13.0.0", "haddock/testsZShaddockZShaddock-lib-a", "haddock/testsZShaddockZShaddock-lib-b", "haddock/testsZShaddockZShaddock-lib-deep", @@ -459,9 +346,9 @@ haskell_binary( name = "run-tests", srcs = ["RunTests.hs"], deps = [ - ":base", - ":hspec", - ":hspec-core", - ":process", + "@hackage//:base", + "@hackage//:hspec", + "@hackage//:hspec-core", + "@hackage//:process", ], ) diff --git a/tests/BUILD.zlib b/tests/BUILD.zlib index e241d056e..49cf72037 100644 --- a/tests/BUILD.zlib +++ b/tests/BUILD.zlib @@ -35,8 +35,8 @@ haskell_library( ]), deps = [ ":zlib-import", - "@io_tweag_rules_haskell//tests:base", - "@io_tweag_rules_haskell//tests:bytestring", - "@io_tweag_rules_haskell//tests:ghc-prim", + "@hackage//:base", + "@hackage//:bytestring", + "@hackage//:ghc-prim", ], ) diff --git a/tests/binary-custom-main/BUILD b/tests/binary-custom-main/BUILD index 2cf9e8ad5..6301de235 100644 --- a/tests/binary-custom-main/BUILD +++ b/tests/binary-custom-main/BUILD @@ -9,5 +9,5 @@ haskell_binary( name = "binary-custom-main", srcs = ["foo.hs"], visibility = ["//visibility:public"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) diff --git a/tests/binary-mostly-static/BUILD b/tests/binary-mostly-static/BUILD index 9104fa92d..3ed069d3e 100644 --- a/tests/binary-mostly-static/BUILD +++ b/tests/binary-mostly-static/BUILD @@ -9,6 +9,6 @@ haskell_binary( name = "binary-mostly-static", srcs = ["Main.hs"], visibility = ["//visibility:public"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], linkstatic = True, ) diff --git a/tests/binary-simple/BUILD b/tests/binary-simple/BUILD index 520f75973..d52c46145 100644 --- a/tests/binary-simple/BUILD +++ b/tests/binary-simple/BUILD @@ -9,5 +9,5 @@ haskell_binary( name = "binary-simple", srcs = ["Main.hs"], visibility = ["//visibility:public"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) diff --git a/tests/binary-with-compiler-flags/BUILD b/tests/binary-with-compiler-flags/BUILD index f218992ea..c45c4e2e9 100644 --- a/tests/binary-with-compiler-flags/BUILD +++ b/tests/binary-with-compiler-flags/BUILD @@ -11,5 +11,5 @@ haskell_test( # A flag that requires -threaded, which we should get from the toolchain's # compiler_flags: compiler_flags = ["-with-rtsopts=-qg"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) diff --git a/tests/binary-with-data/BUILD b/tests/binary-with-data/BUILD index 095c42d5e..e561d7e7f 100644 --- a/tests/binary-with-data/BUILD +++ b/tests/binary-with-data/BUILD @@ -11,7 +11,7 @@ haskell_binary( # Regular file input: data = ["bin1-input"], visibility = ["//visibility:public"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_binary( @@ -21,7 +21,7 @@ haskell_binary( data = [":bin1"], visibility = ["//visibility:public"], deps = [ - "//tests:base", - "//tests:process", + "@hackage//:base", + "@hackage//:process", ], ) diff --git a/tests/binary-with-lib/BUILD b/tests/binary-with-lib/BUILD index be5d6b019..5fe5c8414 100644 --- a/tests/binary-with-lib/BUILD +++ b/tests/binary-with-lib/BUILD @@ -18,6 +18,6 @@ haskell_binary( visibility = ["//visibility:public"], deps = [ ":lib", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/binary-with-link-flags/BUILD b/tests/binary-with-link-flags/BUILD index ff4d136b9..c86b6a916 100644 --- a/tests/binary-with-link-flags/BUILD +++ b/tests/binary-with-link-flags/BUILD @@ -13,5 +13,5 @@ haskell_binary( srcs = ["Main.hs"], compiler_flags = ["-threaded"], visibility = ["//visibility:public"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) diff --git a/tests/binary-with-main/BUILD b/tests/binary-with-main/BUILD index a014c6301..f71451574 100644 --- a/tests/binary-with-main/BUILD +++ b/tests/binary-with-main/BUILD @@ -10,5 +10,5 @@ haskell_binary( srcs = ["MainIsHere.hs"], main_function = "MainIsHere.this", visibility = ["//visibility:public"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) diff --git a/tests/binary-with-prebuilt/BUILD b/tests/binary-with-prebuilt/BUILD index 620c3e9c1..4bbfc0475 100644 --- a/tests/binary-with-prebuilt/BUILD +++ b/tests/binary-with-prebuilt/BUILD @@ -3,6 +3,7 @@ package(default_testonly = 1) load( "@io_tweag_rules_haskell//haskell:haskell.bzl", "haskell_binary", + "haskell_doctest", ) haskell_binary( @@ -10,7 +11,9 @@ haskell_binary( srcs = ["Main.hs"], visibility = ["//visibility:public"], deps = [ - "//tests:base", - "//tests:template-haskell", + "@hackage//:base", + "@hackage//:streaming", + "@hackage//:template-haskell", + "@hackage//:void", ], ) diff --git a/tests/binary-with-sysdeps/BUILD b/tests/binary-with-sysdeps/BUILD index 7f15f5ad1..1dd7f6f00 100644 --- a/tests/binary-with-sysdeps/BUILD +++ b/tests/binary-with-sysdeps/BUILD @@ -17,6 +17,6 @@ haskell_binary( visibility = ["//visibility:public"], deps = [ ":zlib", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/c-compiles-still/BUILD b/tests/c-compiles-still/BUILD index fc8458da4..a50dd75ff 100644 --- a/tests/c-compiles-still/BUILD +++ b/tests/c-compiles-still/BUILD @@ -9,7 +9,7 @@ haskell_library( name = "foo", srcs = ["Foo.hs"], deps = [ - "//tests:base", "//tests/data:ourclibrary", + "@hackage//:base", ], ) diff --git a/tests/c-compiles/BUILD b/tests/c-compiles/BUILD index 9345797b6..f14e5d2c8 100644 --- a/tests/c-compiles/BUILD +++ b/tests/c-compiles/BUILD @@ -10,7 +10,7 @@ haskell_library( name = "hs-lib", srcs = ["Lib.hs"], deps = [ - "//tests:base", + "@hackage//:base", "//tests/data:ourclibrary", ], ) @@ -20,7 +20,7 @@ haskell_binary( srcs = ["Main.hs"], visibility = ["//visibility:public"], deps = [ - "//tests:base", ":hs-lib", + "@hackage//:base", ], ) diff --git a/tests/c2hs/BUILD b/tests/c2hs/BUILD index bed419458..c338002a7 100644 --- a/tests/c2hs/BUILD +++ b/tests/c2hs/BUILD @@ -35,5 +35,5 @@ haskell_library( ":foo", "@c2hs_repo//:baz", ], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) diff --git a/tests/cc_haskell_import/BUILD b/tests/cc_haskell_import/BUILD index efe085025..c9c813142 100644 --- a/tests/cc_haskell_import/BUILD +++ b/tests/cc_haskell_import/BUILD @@ -11,7 +11,7 @@ haskell_library( name = "hs-lib-a", srcs = ["LibA.hs"], deps = [ - "//tests:base", + "@hackage//:base", "//tests/data:ourclibrary", ], ) @@ -21,7 +21,7 @@ haskell_library( srcs = ["LibB.hs"], deps = [ ":hs-lib-a", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/cpp_macro_conflict/BUILD b/tests/cpp_macro_conflict/BUILD index aa5a4b835..4276439e0 100644 --- a/tests/cpp_macro_conflict/BUILD +++ b/tests/cpp_macro_conflict/BUILD @@ -10,7 +10,7 @@ load( haskell_library( name = "bytestring", srcs = ["BS.hs"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) # This depends on two packages "bytestring" @@ -18,7 +18,7 @@ haskell_library( haskell_binary( name = "macro_conflict", srcs = ["Main.hs"], - deps = ["//tests:base", "//tests:bytestring", ":bytestring"], + deps = ["@hackage//:base", "@hackage//:bytestring", ":bytestring"], compiler_flags = ["-XCPP", "-Werror"] + select({ # clang on darwin fails because of unused command line argument, it fails because of -Werror "@bazel_tools//src/conditions:darwin": [ diff --git a/tests/encoding/BUILD b/tests/encoding/BUILD index 32e845a9a..a681d0012 100644 --- a/tests/encoding/BUILD +++ b/tests/encoding/BUILD @@ -15,7 +15,7 @@ haskell_binary( "unicode.txt", ], deps = [ - "//tests:base", - "//tests:template-haskell", + "@hackage//:base", + "@hackage//:template-haskell", ], ) diff --git a/tests/extra-source-files/BUILD b/tests/extra-source-files/BUILD index eee8da967..ddbdae54c 100644 --- a/tests/extra-source-files/BUILD +++ b/tests/extra-source-files/BUILD @@ -19,8 +19,8 @@ haskell_library( "ld-options.txt", ], deps = [ - "//tests:base", - "//tests:template-haskell", + "@hackage//:base", + "@hackage//:template-haskell", ], ) @@ -38,7 +38,7 @@ haskell_binary( "ld-options.txt", ], deps = [ - "//tests:base", - "//tests:template-haskell", + "@hackage//:base", + "@hackage//:template-haskell", ], ) diff --git a/tests/failures/transitive-deps/BUILD b/tests/failures/transitive-deps/BUILD index 9f91a75fe..dc478945d 100644 --- a/tests/failures/transitive-deps/BUILD +++ b/tests/failures/transitive-deps/BUILD @@ -8,7 +8,7 @@ load( haskell_library( name = "lib-a", srcs = ["LibA.hs"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_library( @@ -17,7 +17,7 @@ haskell_library( visibility = ["//visibility:private"], deps = [ ":lib-a", - "//tests:base", + "@hackage//:base", ], ) @@ -40,7 +40,7 @@ haskell_library( srcs = ["LibC.hs"], deps = [ ":lib-b", - "//tests:base", + "@hackage//:base", ], ) @@ -51,7 +51,7 @@ haskell_library( tags = ["manual"], deps = [ ":lib-b", - "//tests:base", + "@hackage//:base", ], ) @@ -61,6 +61,6 @@ haskell_library( deps = [ ":lib-a", ":lib-b", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/generated-modules/BUILD b/tests/generated-modules/BUILD index d44eb24b7..f47dc0746 100644 --- a/tests/generated-modules/BUILD +++ b/tests/generated-modules/BUILD @@ -19,7 +19,7 @@ haskell_library( name = "GenModule", srcs = [":generate-genmodule"], src_strip_prefix = "src", - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) genrule( @@ -33,7 +33,7 @@ haskell_library( name = "BinModule", srcs = [":generate-binmodule"], src_strip_prefix = "src", - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) genrule( @@ -51,6 +51,6 @@ haskell_test( deps = [ ":BinModule", ":GenModule", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/ghc.nix b/tests/ghc.nix index 9e34b3ca8..45c5759ba 100644 --- a/tests/ghc.nix +++ b/tests/ghc.nix @@ -1,4 +1,10 @@ -{ pkgs ? import ../nixpkgs {} }: +{ pkgs ? import ../nixpkgs {} +# Whether we want to wrap the packages using . +# When this is called from inside bazel, we need to wrap the haskell package +# set using . Otherwise we don't need (and don't want) +# to. +, wrapPackages ? (builtins.tryEval ).success +}: with pkgs; @@ -7,21 +13,29 @@ let haskellPackages = pkgs.haskell.packages.ghc844.override { libc = import ./haddock/libC.nix self pkgs; }; }; + genBazelBuild = + if wrapPackages + then callPackage {} + else (x: x); -in haskellPackages.ghcWithPackages (p: with p; [ +in + { + ghc = haskellPackages.ghcWithPackages (p: with p; [ - # haskell_proto_library inputs - bytestring - containers - data-default-class - lens-family - lens-labels - proto-lens - text + # haskell_proto_library inputs + bytestring + containers + data-default-class + lens-family + lens-labels + proto-lens + text # test inputs libc # for test runner hspec -]) + ]); + haskellPackages = genBazelBuild haskellPackages; +} diff --git a/tests/haddock/BUILD b/tests/haddock/BUILD index 7e0205d6a..24dc38af4 100644 --- a/tests/haddock/BUILD +++ b/tests/haddock/BUILD @@ -19,7 +19,7 @@ haskell_cc_import( haskell_library( name = "haddock-lib-deep", srcs = ["Deep.hsc"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_library( @@ -32,8 +32,8 @@ haskell_library( compiler_flags = ["-I."], deps = [ ":haddock-lib-deep", - "//tests:base", - "//tests:template-haskell", + "@hackage//:base", + "@hackage//:template-haskell", ], ) @@ -53,10 +53,10 @@ haskell_library( ], deps = [ ":haddock-lib-a", - ":haddock-lib-c", ":zlib", - "//tests:base", - "//tests:template-haskell", + "@hackage//:base", + "@hackage//:libc", + "@hackage//:template-haskell", ], ) diff --git a/tests/haskell_doctest/BUILD b/tests/haskell_doctest/BUILD index 9973b8fa9..2b55cf4e0 100644 --- a/tests/haskell_doctest/BUILD +++ b/tests/haskell_doctest/BUILD @@ -12,7 +12,7 @@ haskell_library( srcs = ["Foo.hs"], deps = [ "//tests/data:ourclibrary", - "//tests:base", + "@hackage//:base", "@zlib.dev//:zlib", ], ) @@ -26,7 +26,7 @@ haskell_library( ], deps = [ ":lib-a", - "//tests:base", + "@hackage//:base", ], ) @@ -56,7 +56,7 @@ haskell_binary( srcs = ["Main.hs"], deps = [ ":lib-a", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/haskell_import/BUILD b/tests/haskell_import/BUILD index a0b623abd..6595b96b0 100644 --- a/tests/haskell_import/BUILD +++ b/tests/haskell_import/BUILD @@ -7,21 +7,12 @@ load( "haskell_test", ) -haskell_import( - name = "bytestring", -) - -haskell_import( - name = "text_pkg", - package = "text", -) - haskell_library( name = "Lib", srcs = ["Lib.hs"], deps = [ - ":bytestring", - "//tests:base", + "@hackage//:base", + "@hackage//:bytestring", ], ) @@ -30,7 +21,7 @@ haskell_test( srcs = ["Bin.hs"], deps = [ ":Lib", - ":text_pkg", - "//tests:base", + "@hackage//:base", + "@hackage//:text", ], ) diff --git a/tests/haskell_lint/BUILD b/tests/haskell_lint/BUILD index 0bb2afe60..04f027f2f 100644 --- a/tests/haskell_lint/BUILD +++ b/tests/haskell_lint/BUILD @@ -12,7 +12,7 @@ haskell_library( name = "lib-a", srcs = ["Foo.hs"], visibility = ["//visibility:public"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_library( @@ -21,7 +21,7 @@ haskell_library( visibility = ["//visibility:public"], deps = [ ":lib-a", - "//tests:base", + "@hackage//:base", ], ) @@ -37,7 +37,7 @@ haskell_binary( visibility = ["//visibility:public"], deps = [ ":lib-a", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/haskell_proto_library/BUILD b/tests/haskell_proto_library/BUILD index 03d708fff..e46492cc4 100644 --- a/tests/haskell_proto_library/BUILD +++ b/tests/haskell_proto_library/BUILD @@ -44,7 +44,7 @@ haskell_library( deps = [ ":address_haskell_proto", ":person_haskell_proto", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/haskell_test/BUILD b/tests/haskell_test/BUILD index 5a0997ca9..d4e64ed22 100644 --- a/tests/haskell_test/BUILD +++ b/tests/haskell_test/BUILD @@ -9,7 +9,7 @@ load( haskell_library( name = "mylib", srcs = ["Lib.hs"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_test( @@ -24,6 +24,6 @@ haskell_test( deps = [ "//tests/data:ourclibrary", ":mylib", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/hidden-modules/BUILD b/tests/hidden-modules/BUILD index 8af88eb1f..f4e4fbca6 100644 --- a/tests/hidden-modules/BUILD +++ b/tests/hidden-modules/BUILD @@ -13,14 +13,14 @@ haskell_library( srcs = glob(["lib-a/*.hs"]), hidden_modules = ["Foo"], src_strip_prefix = "lib-a", - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_library( name = "lib-b", srcs = glob(["lib-b/*.hs"]), src_strip_prefix = "lib-b", - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_library( @@ -30,6 +30,6 @@ haskell_library( deps = [ ":lib-a", ":lib-b", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/hs-boot/BUILD b/tests/hs-boot/BUILD index 3391d738f..afb6b7571 100644 --- a/tests/hs-boot/BUILD +++ b/tests/hs-boot/BUILD @@ -29,7 +29,7 @@ haskell_library( ], src_strip_prefix = "srcs", visibility = ["//visibility:public"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_binary( @@ -43,6 +43,6 @@ haskell_binary( visibility = ["//visibility:public"], deps = [ ":hs-boot-lib", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/hsc/BUILD b/tests/hsc/BUILD index e32550a33..d8c54cfd6 100644 --- a/tests/hsc/BUILD +++ b/tests/hsc/BUILD @@ -13,7 +13,7 @@ haskell_library( "Bar/Baz.hsc", "Foo.hsc", ], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_binary( @@ -25,6 +25,6 @@ haskell_binary( visibility = ["//visibility:public"], deps = [ ":hsc-lib", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/java_classpath/BUILD b/tests/java_classpath/BUILD index bad0dc7d9..f811206d6 100644 --- a/tests/java_classpath/BUILD +++ b/tests/java_classpath/BUILD @@ -10,8 +10,8 @@ haskell_binary( srcs = ["Main.hs"], visibility = ["//visibility:public"], deps = [ - "//tests:base", - "//tests:template-haskell", + "@hackage//:base", + "@hackage//:template-haskell", "@org_apache_spark_spark_core_2_10//jar", ], ) diff --git a/tests/lhs/BUILD b/tests/lhs/BUILD index 46a281440..a0a99956e 100644 --- a/tests/lhs/BUILD +++ b/tests/lhs/BUILD @@ -9,7 +9,7 @@ load( haskell_library( name = "lhs-lib", srcs = ["Lib.lhs"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_binary( @@ -18,6 +18,6 @@ haskell_binary( visibility = ["//visibility:public"], deps = [ ":lhs-lib", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/library-deps/BUILD b/tests/library-deps/BUILD index e6f451c1a..f3e768494 100644 --- a/tests/library-deps/BUILD +++ b/tests/library-deps/BUILD @@ -11,8 +11,8 @@ haskell_library( srcs = ["TestLib.hs"], visibility = ["//visibility:public"], deps = [ - "//tests:base", "//tests/library-deps/sublib", + "@hackage//:base", ], ) @@ -22,7 +22,7 @@ haskell_test( srcs = ["Bin.hs"], visibility = ["//visibility:public"], deps = [ - "//tests:base", "//tests/library-deps/sublib", + "@hackage//:base", ], ) diff --git a/tests/library-deps/sublib/BUILD b/tests/library-deps/sublib/BUILD index 30b6d2d98..d42f21e00 100644 --- a/tests/library-deps/sublib/BUILD +++ b/tests/library-deps/sublib/BUILD @@ -11,7 +11,7 @@ haskell_library( visibility = ["//visibility:public"], deps = [ ":sublib-c", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/library-exports/BUILD b/tests/library-exports/BUILD index 9f4ffb0c6..e883d4ae9 100644 --- a/tests/library-exports/BUILD +++ b/tests/library-exports/BUILD @@ -9,18 +9,24 @@ load( haskell_library( name = "sublib", srcs = ["TestSubLib.hs"], - exports = {"//tests:containers": "Data.Map as SubLib.Map"}, - deps = ["//tests:base", "//tests:containers"], + exports = {"@hackage//:containers": "Data.Map as SubLib.Map"}, + deps = [ + "@hackage//:base", + "@hackage//:containers", + ], ) haskell_library( name = "lib", srcs = ["TestLib.hs"], - deps = ["//tests:base", ":sublib"], exports = { ":sublib": "TestSubLib", - "//tests:containers": "Data.Map as Lib.Map", + "@hackage//:containers": "Data.Map as Lib.Map", }, + deps = [ + ":sublib", + "@hackage//:base", + ], ) haskell_test( @@ -28,5 +34,8 @@ haskell_test( size = "small", srcs = ["Bin.hs"], visibility = ["//visibility:public"], - deps = [":lib", "//tests:base"], + deps = [ + ":lib", + "@hackage//:base", + ], ) diff --git a/tests/library-with-includes/BUILD b/tests/library-with-includes/BUILD index 7128d889f..4d2572820 100644 --- a/tests/library-with-includes/BUILD +++ b/tests/library-with-includes/BUILD @@ -25,6 +25,6 @@ haskell_library( srcs = ["Lib.hs"], deps = [ ":clib", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/library-with-sysdeps/BUILD b/tests/library-with-sysdeps/BUILD index 3417f8532..1c189c239 100644 --- a/tests/library-with-sysdeps/BUILD +++ b/tests/library-with-sysdeps/BUILD @@ -18,7 +18,7 @@ haskell_library( visibility = ["//visibility:public"], deps = [ ":zlib", - "//tests:base", + "@hackage//:base", ], ) @@ -27,6 +27,6 @@ haskell_binary( srcs = ["Main.hs"], deps = [ ":library-with-sysdeps", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/library-with-sysincludes/BUILD b/tests/library-with-sysincludes/BUILD index 368b6cd73..3b76cb4cc 100644 --- a/tests/library-with-sysincludes/BUILD +++ b/tests/library-with-sysincludes/BUILD @@ -38,7 +38,7 @@ haskell_library( deps = [ ":zlib", ":zlib-with-genrule-header", - "//tests:base", + "@hackage//:base", ], ) @@ -51,8 +51,8 @@ haskell_library( visibility = ["//visibility:public"], deps = [ ":intermediate-library", - "//tests:base", - "//tests:template-haskell", + "@hackage//:base", + "@hackage//:template-haskell", ], ) @@ -63,7 +63,7 @@ haskell_library( srcs = ["IntLib.hsc"], deps = [ ":zlib-with-genrule-header", - "//tests:base", + "@hackage//:base", "@zlib.dev//:zlib", ], ) @@ -77,7 +77,7 @@ haskell_library( visibility = ["//visibility:public"], deps = [ ":intermediate-library-other", - "//tests:base", - "//tests:template-haskell", + "@hackage//:base", + "@hackage//:template-haskell", ], ) diff --git a/tests/package-id-clash-binary/BUILD b/tests/package-id-clash-binary/BUILD index 411219445..ffc57c364 100644 --- a/tests/package-id-clash-binary/BUILD +++ b/tests/package-id-clash-binary/BUILD @@ -1,17 +1,17 @@ load( "@io_tweag_rules_haskell//haskell:haskell.bzl", - "haskell_import", "haskell_binary", + "haskell_import", ) haskell_import(name = "base") haskell_binary( name = "bin", + srcs = ["Main.hs"], deps = [ ":base", "//tests/package-id-clash-binary/a:foo", "//tests/package-id-clash-binary/b:foo", ], - srcs = ["Main.hs"], ) diff --git a/tests/package-id-clash-binary/a/BUILD b/tests/package-id-clash-binary/a/BUILD index 08babe144..005212784 100644 --- a/tests/package-id-clash-binary/a/BUILD +++ b/tests/package-id-clash-binary/a/BUILD @@ -9,6 +9,6 @@ haskell_import(name = "base") haskell_library( name = "foo", srcs = ["Foo.hs"], - deps = [":base"], visibility = ["//visibility:public"], + deps = [":base"], ) diff --git a/tests/package-id-clash-binary/b/BUILD b/tests/package-id-clash-binary/b/BUILD index d0108cb1a..9dc891171 100644 --- a/tests/package-id-clash-binary/b/BUILD +++ b/tests/package-id-clash-binary/b/BUILD @@ -9,6 +9,6 @@ haskell_import(name = "base") haskell_library( name = "foo", srcs = ["Baz.hs"], - deps = [":base"], visibility = ["//visibility:public"], + deps = [":base"], ) diff --git a/tests/package-id-clash/BUILD b/tests/package-id-clash/BUILD index 56c235eaf..4a18c9469 100644 --- a/tests/package-id-clash/BUILD +++ b/tests/package-id-clash/BUILD @@ -9,7 +9,7 @@ haskell_library( name = "sublib", srcs = ["Foo.hs"], visibility = ["//visibility:public"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_library( @@ -18,7 +18,7 @@ haskell_library( visibility = ["//visibility:public"], deps = [ ":sublib", - "//tests:base", "//tests/package-id-clash/sublib", + "@hackage//:base", ], ) diff --git a/tests/package-id-clash/sublib/BUILD b/tests/package-id-clash/sublib/BUILD index 9c30064bb..f3550706f 100644 --- a/tests/package-id-clash/sublib/BUILD +++ b/tests/package-id-clash/sublib/BUILD @@ -8,6 +8,6 @@ load( haskell_library( name = "sublib", srcs = ["Bar.hs"], - deps = ["//tests:base"], visibility = ["//visibility:public"], + deps = ["@hackage//:base"], ) diff --git a/tests/package-name/BUILD b/tests/package-name/BUILD index 6f9264232..5908dcbd1 100644 --- a/tests/package-name/BUILD +++ b/tests/package-name/BUILD @@ -13,7 +13,7 @@ haskell_library( name = "lib-a_Z", srcs = ["Lib.hs"], version = "1.2.3.4", - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_test( @@ -23,6 +23,6 @@ haskell_test( version = "0.0.0", # This flags triggers the `MIN_VERSION` macro generation deps = [ ":lib-a_Z", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/repl-flags/BUILD b/tests/repl-flags/BUILD index 795c7f106..526fcf6d3 100644 --- a/tests/repl-flags/BUILD +++ b/tests/repl-flags/BUILD @@ -17,8 +17,8 @@ haskell_binary( compiler_flags = ["-XOverloadedStrings"], visibility = ["//visibility:public"], deps = [ - "//tests:base", - "//tests:bytestring", + "@hackage//:base", + "@hackage//:bytestring", ], ) @@ -39,7 +39,7 @@ haskell_binary( repl_ghci_args = ["-DTESTS_TOOLCHAIN_REPL_FLAGS"], visibility = ["//visibility:public"], deps = [ - "//tests:base", - "//tests:bytestring", + "@hackage//:base", + "@hackage//:bytestring", ], ) diff --git a/tests/repl-name-conflicts/BUILD b/tests/repl-name-conflicts/BUILD index f710710d7..d1cafc3b5 100644 --- a/tests/repl-name-conflicts/BUILD +++ b/tests/repl-name-conflicts/BUILD @@ -9,7 +9,7 @@ haskell_library( name = "lib", srcs = ["PreludeShadowing.hs"], deps = [ - "//tests:base", - "//tests:bytestring", + "@hackage//:base", + "@hackage//:bytestring", ], ) diff --git a/tests/repl-targets/BUILD b/tests/repl-targets/BUILD index e9c921a3e..96f21bf8b 100644 --- a/tests/repl-targets/BUILD +++ b/tests/repl-targets/BUILD @@ -44,8 +44,8 @@ haskell_library( deps = [ "//tests/data:ourclibrary", ":zlib", - "//tests:array", - "//tests:base", + "@hackage//:array", + "@hackage//:base", ], ) @@ -58,8 +58,8 @@ haskell_library( deps = [ "//tests/data:ourclibrary", ":zlib", - "//tests:array", - "//tests:base", + "@hackage//:array", + "@hackage//:base", ], tags = ["manual"], ) @@ -67,7 +67,7 @@ haskell_library( haskell_library( name = "QuuxLib", srcs = ["QuuxLib.hs"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) haskell_binary( @@ -76,6 +76,6 @@ haskell_binary( visibility = ["//visibility:public"], deps = [ ":QuuxLib", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tests/textual-hdrs/BUILD b/tests/textual-hdrs/BUILD index 4e9a79a1f..ad9465702 100644 --- a/tests/textual-hdrs/BUILD +++ b/tests/textual-hdrs/BUILD @@ -13,5 +13,5 @@ haskell_binary( ], compiler_flags = ["-Itests/textual-hdrs/include"], visibility = ["//visibility:public"], - deps = ["//tests:base"], + deps = ["@hackage//:base"], ) diff --git a/tests/two-libs/BUILD b/tests/two-libs/BUILD index 021958d73..47ce7a0d8 100644 --- a/tests/two-libs/BUILD +++ b/tests/two-libs/BUILD @@ -13,7 +13,7 @@ haskell_library( name = "one", srcs = ["One.hs"], deps = [ - "//tests:base", + "@hackage//:base", ], ) @@ -22,7 +22,7 @@ haskell_library( srcs = ["Two.hs"], deps = [ ":one", - "//tests:base", + "@hackage//:base", ], ) @@ -31,6 +31,6 @@ haskell_binary( srcs = ["Main.hs"], deps = [ ":two", - "//tests:base", + "@hackage//:base", ], ) diff --git a/tools/runfiles/BUILD b/tools/runfiles/BUILD index 5871ffcdb..4c7bd9349 100644 --- a/tools/runfiles/BUILD +++ b/tools/runfiles/BUILD @@ -10,9 +10,9 @@ haskell_library( srcs = ["src/Bazel/Runfiles.hs"], visibility = ["//visibility:public"], deps = [ - "//tests:base", - "//tests:directory", - "//tests:filepath", + "@hackage//:base", + "@hackage//:directory", + "@hackage//:filepath", ], ) @@ -23,8 +23,8 @@ haskell_binary( data = ["bin-data.txt"], deps = [ ":runfiles", - "//tests:base", - "//tests:filepath", + "@hackage//:base", + "@hackage//:filepath", ], ) @@ -37,8 +37,8 @@ haskell_test( ], deps = [ ":runfiles", - "//tests:base", - "//tests:filepath", - "//tests:process", + "@hackage//:base", + "@hackage//:filepath", + "@hackage//:process", ], )