Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazelify compiler's global package database #859

Merged
merged 10 commits into from
May 17, 2019
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
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Use this configuration when targeting Windows. Eventually this will
# no longer be required:
# https://bazel.build/roadmaps/platforms.html#replace---cpu-and---host_cpu-flags.
build:windows --crosstool_top=@io_tweag_rules_haskell_ghc_windows_amd64//:toolchain -s --verbose_failures --sandbox_debug
build:windows --crosstool_top=@io_tweag_rules_haskell_ghc_windows_amd64//:cc_toolchain -s --verbose_failures --sandbox_debug

build:ci --loading_phase_threads=1
build:ci --jobs=2
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
name: Setup test environment
command: |
apt-get update
apt-get install -y wget gnupg golang make libgmp3-dev libtinfo-dev pkg-config zip g++ zlib1g-dev unzip python bash-completion locales
apt-get install -y wget gnupg golang make libgmp3-dev libtinfo-dev pkg-config zip g++ zlib1g-dev unzip python python3 bash-completion locales
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
wget "https://github.com/bazelbuild/bazel/releases/download/0.24.0/bazel_0.24.0-linux-x86_64.deb"
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ of `rules_haskell`.
sed -i 's/^haskell_import/haskell_toolchain_library/' **/BUILD{,.bazel}
sed -i 's/"haskell_import"/"haskell_toolchain_library"/' **/BUILD{,.bazel}
```
* The `haskell_toolchain` macro now no longer adds a `toolchain`
definition. You must now define yourself a `haskell_toolchain` and
a `toolchain` separately. This should be a mostly transparent
change, because nearly no one uses these functions directly. They
are normally only used transitively via
`haskell_register_toolchains` and related functions.
* It is now possible to statically link Haskell libraries in CC
binaries.

See [#843](https://github.com/tweag/rules_haskell/pull/843).

Expand Down
1 change: 0 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ load(
haskell_nixpkgs_package(
name = "ghc",
attribute_path = "haskellPackages.ghc",
build_file = "//haskell:ghc.BUILD",
nix_file = "//tests:ghc.nix",
nix_file_deps = ["//nixpkgs:default.nix"],
# rules_nixpkgs assumes we want to read from `<nixpkgs>` implicitly
Expand Down
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ jobs:
pool:
vmImage: 'vs2017-win2016'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
architecture: 'x64'
- bash: |
set -e
curl -LO https://github.com/bazelbuild/bazel/releases/download/0.24.0/bazel-0.24.0-windows-x86_64.exe
Expand Down
10 changes: 0 additions & 10 deletions examples/BUILD.bazel

This file was deleted.

4 changes: 3 additions & 1 deletion examples/primitive/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ haskell_toolchain_library(name = "base")

haskell_toolchain_library(name = "ghc-prim")

haskell_toolchain_library(name = "rts")

cc_library(
name = "memops",
srcs = ["cbits/primitive-memops.c"],
hdrs = ["cbits/primitive-memops.h"],
deps = ["@ghc//:threaded-rts"],
deps = [":rts"],
)

haskell_library(
Expand Down
13 changes: 6 additions & 7 deletions examples/rts/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@ load(

haskell_toolchain_library(name = "base")

haskell_toolchain_library(name = "rts")

haskell_library(
name = "add-one-hs",
srcs = ["One.hs"],
deps = [":base"],
)

cc_haskell_import(
name = "add-one-so",
dep = ":add-one-hs",
)

cc_test(
name = "add-one",
srcs = [
"main.c",
":add-one-so",
],
visibility = ["//visibility:public"],
deps = ["@ghc//:threaded-rts"],
deps = [
":add-one-hs",
":rts",
],
)
4 changes: 0 additions & 4 deletions examples/vector/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ haskell_toolchain_library(name = "deepseq")

haskell_toolchain_library(name = "ghc-prim")

haskell_toolchain_library(name = "primitive")

haskell_toolchain_library(name = "semigroups")

haskell_library(
name = "vector",
testonly = 1,
Expand Down
7 changes: 7 additions & 0 deletions haskell/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports_files(
"private/haddock_wrapper.sh.tpl",
"private/coverage_wrapper.sh.tpl",
"private/osx_cc_wrapper.sh.tpl",
"private/pkgdb_to_bzl.py",
],
)

Expand All @@ -14,6 +15,12 @@ exports_files(
visibility = ["//tests/unit-tests:__pkg__"],
)

py_binary(
name = "pkgdb_to_bzl",
srcs = ["private/pkgdb_to_bzl.py"],
visibility = ["//visibility:public"],
)

py_binary(
name = "ls_modules",
srcs = ["private/ls_modules.py"],
Expand Down
3 changes: 2 additions & 1 deletion haskell/doctest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ load(
"@io_tweag_rules_haskell//haskell:providers.bzl",
"HaskellInfo",
"HaskellLibraryInfo",
"HaskellPrebuiltPackageInfo",
)

def _doctest_toolchain_impl(ctx):
Expand Down Expand Up @@ -80,7 +81,7 @@ def _haskell_doctest_single(target, ctx):
File: the doctest log.
"""

if HaskellInfo not in target:
if HaskellInfo not in target or HaskellPrebuiltPackageInfo in target:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we filter by whether the target is in an external workspace? This would also filter Hazel targets.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will be removed in a future PR (that actually and finally removes HaskellPrebuiltPackageInfo). In this PR I'm just doing the simplest thing.

return []

hs = haskell_context(ctx, ctx.attr)
Expand Down
88 changes: 0 additions & 88 deletions haskell/ghc.BUILD

This file was deleted.

52 changes: 52 additions & 0 deletions haskell/ghc.BUILD.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
load(
"@io_tweag_rules_haskell//haskell:cc_toolchain_config.bzl",
"cc_toolchain_config",
)
load(
"@io_tweag_rules_haskell//haskell:haskell.bzl",
"haskell_import",
"haskell_toolchain",
)

package(default_visibility = ["//visibility:public"])

%{toolchain}

filegroup(
name = "bin",
srcs = glob(["bin/*"]),
)

# Expose embedded MinGW toolchain when on Windows.

filegroup(
name = "mingw",
srcs = glob(["mingw/**"]),
)

cc_toolchain_suite(
name = "cc_toolchain",
toolchains = {
"x64_windows": ":cc-compiler-mingw64",
"x64_windows|ghc-mingw-gcc": ":cc-compiler-mingw64",
},
)

# Keep in sync with @bazel_tools//cpp:cc-compiler-x64_windows definition.
cc_toolchain(
name = "cc-compiler-mingw64",
all_files = ":mingw",
ar_files = ":mingw",
as_files = ":mingw",
compiler_files = ":mingw",
cpu = "x64_windows",
dwp_files = ":mingw",
linker_files = ":mingw",
objcopy_files = ":mingw",
strip_files = ":mingw",
supports_param_files = 0,
toolchain_config = ":ghc_windows_mingw64_config",
toolchain_identifier = "ghc_windows_mingw64",
)

cc_toolchain_config(name = "ghc_windows_mingw64_config")
Loading