Skip to content

Commit

Permalink
Replace //haskell/private/unix by rules_sh
Browse files Browse the repository at this point in the history
  • Loading branch information
aherrmann committed Nov 14, 2019
1 parent e79ed1a commit ec6afb8
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 432 deletions.
16 changes: 8 additions & 8 deletions haskell/cabal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ def _cabal_tool_flag(tool):
def _binary_paths(binaries):
return [binary.dirname for binary in binaries.to_list()]

def _prepare_cabal_inputs(hs, cc, unix, dep_info, cc_info, component, package_id, tool_inputs, tool_input_manifests, cabal, setup, srcs, flags, cabal_wrapper, package_database):
def _prepare_cabal_inputs(hs, cc, posix, dep_info, cc_info, component, package_id, tool_inputs, tool_input_manifests, cabal, setup, srcs, flags, cabal_wrapper, package_database):
"""Compute Cabal wrapper, arguments, inputs."""
with_profiling = is_profiling_enabled(hs)

(ghci_extra_libs, env) = get_ghci_extra_libs(hs, cc_info)
env.update(**hs.env)
env["PATH"] = join_path_list(hs, _binary_paths(tool_inputs) + unix.paths)
env["PATH"] = join_path_list(hs, _binary_paths(tool_inputs) + posix.paths)
if hs.toolchain.is_darwin:
env["SDKROOT"] = "macosx" # See haskell/private/actions/link.bzl

Expand Down Expand Up @@ -157,7 +157,7 @@ def _haskell_cabal_library_impl(ctx):
cc_info = cc_common.merge_cc_infos(
cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep],
)
unix = ctx.toolchains["@rules_haskell//haskell/private/unix:toolchain_type"]
posix = ctx.toolchains["@rules_sh//sh/posix:toolchain_type"]
package_id = "{}-{}".format(
ctx.attr.package_name if ctx.attr.package_name else hs.label.name,
ctx.attr.version,
Expand Down Expand Up @@ -200,7 +200,7 @@ def _haskell_cabal_library_impl(ctx):
c = _prepare_cabal_inputs(
hs,
cc,
unix,
posix,
dep_info,
cc_info,
component = "lib:{}".format(
Expand Down Expand Up @@ -320,7 +320,7 @@ haskell_cabal_library = rule(
},
toolchains = [
"@rules_haskell//haskell:toolchain",
"@rules_haskell//haskell/private/unix:toolchain_type",
"@rules_sh//sh/posix:toolchain_type",
],
fragments = ["cpp"],
)
Expand Down Expand Up @@ -360,7 +360,7 @@ def _haskell_cabal_binary_impl(ctx):
cc_info = cc_common.merge_cc_infos(
cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep],
)
unix = ctx.toolchains["@rules_haskell//haskell/private/unix:toolchain_type"]
posix = ctx.toolchains["@rules_sh//sh/posix:toolchain_type"]

cabal = _find_cabal(hs, ctx.files.srcs)
setup = _find_setup(hs, cabal, ctx.files.srcs)
Expand All @@ -383,7 +383,7 @@ def _haskell_cabal_binary_impl(ctx):
c = _prepare_cabal_inputs(
hs,
cc,
unix,
posix,
dep_info,
cc_info,
component = "exe:{}".format(hs.label.name),
Expand Down Expand Up @@ -460,7 +460,7 @@ haskell_cabal_binary = rule(
},
toolchains = [
"@rules_haskell//haskell:toolchain",
"@rules_haskell//haskell/private/unix:toolchain_type",
"@rules_sh//sh/posix:toolchain_type",
],
fragments = ["cpp"],
)
Expand Down
11 changes: 4 additions & 7 deletions haskell/ghc_bindist.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
"""Workspace rules (GHC binary distributions)"""

load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch")
load(
"@rules_haskell//haskell/private/unix:unix_configure.bzl",
"unix_configure",
)
load("@rules_sh//sh:posix.bzl", "sh_posix_configure")

_GHC_DEFAULT_VERSION = "8.6.5"

Expand Down Expand Up @@ -452,9 +449,9 @@ def haskell_register_ghc_bindists(
haddock_flags = haddock_flags,
repl_ghci_args = repl_ghci_args,
)
local_unix_repo_name = "rules_haskell_unix_local"
if local_unix_repo_name not in native.existing_rules():
unix_configure(name = local_unix_repo_name)
local_sh_posix_repo_name = "rules_haskell_sh_posix_local"
if local_sh_posix_repo_name not in native.existing_rules():
sh_posix_configure(name = local_sh_posix_repo_name)

def _find_python(repository_ctx):
python = repository_ctx.which("python3")
Expand Down
24 changes: 11 additions & 13 deletions haskell/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
load(
"@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl",
"nixpkgs_package",
)
load(
"@rules_haskell//haskell/private/unix:unix_nixpkgs.bzl",
"unix_nixpkgs",
"nixpkgs_sh_posix_configure",
)

def _ghc_nixpkgs_haskell_toolchain_impl(repository_ctx):
Expand Down Expand Up @@ -171,7 +168,7 @@ def haskell_register_ghc_nixpkgs(
repl_ghci_args = None,
locale_archive = None,
attribute_path = "haskellPackages.ghc",
unix_attributes = None,
sh_posix_attributes = None,
nix_file = None,
nix_file_deps = [],
nixopts = None,
Expand All @@ -192,7 +189,8 @@ def haskell_register_ghc_nixpkgs(
Args:
compiler_flags_select: temporary workaround to pass conditional arguments.
See https://github.com/bazelbuild/bazel/issues/9199 for details.
unix_attributes: List of attribute paths to extract standard Unix shell tools from.
sh_posix_attributes: List of attribute paths to extract standard Unix shell tools from.
Passed to nixpkgs_sh_posix_configure.
Example:
Expand All @@ -214,7 +212,7 @@ def haskell_register_ghc_nixpkgs(
"""
nixpkgs_ghc_repo_name = "rules_haskell_ghc_nixpkgs"
nixpkgs_unix_repo_name = "rules_haskell_unix_nixpkgs"
nixpkgs_sh_posix_repo_name = "rules_haskell_sh_posix_nixpkgs"
haskell_toolchain_repo_name = "rules_haskell_ghc_nixpkgs_haskell_toolchain"
toolchain_repo_name = "rules_haskell_ghc_nixpkgs_toolchain"

Expand Down Expand Up @@ -250,17 +248,17 @@ def haskell_register_ghc_nixpkgs(
native.register_toolchains("@{}//:toolchain".format(toolchain_repo_name))

# Unix tools toolchain required for Cabal packages
unix_nixpkgs_kwargs = dict(
sh_posix_nixpkgs_kwargs = dict(
nix_file_deps = nix_file_deps,
nixopts = nixopts,
repositories = repositories,
repository = repository,
)
if unix_attributes != None:
unix_nixpkgs_kwargs["packages"] = unix_attributes
unix_nixpkgs(
name = nixpkgs_unix_repo_name,
**unix_nixpkgs_kwargs
if sh_posix_attributes != None:
sh_posix_nixpkgs_kwargs["packages"] = sh_posix_attributes
nixpkgs_sh_posix_configure(
name = nixpkgs_sh_posix_repo_name,
**sh_posix_nixpkgs_kwargs
)

def _find_children(repository_ctx, target_dir):
Expand Down
4 changes: 0 additions & 4 deletions haskell/private/unix/BUILD.bazel

This file was deleted.

165 changes: 0 additions & 165 deletions haskell/private/unix/unix_commands.bzl

This file was deleted.

65 changes: 0 additions & 65 deletions haskell/private/unix/unix_configure.bzl

This file was deleted.

Loading

0 comments on commit ec6afb8

Please sign in to comment.