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

Cleanup: remove deprecated options and targets #2050

Merged
merged 12 commits into from
Nov 27, 2023
35 changes: 35 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,41 @@ env:
cache-version: 0

jobs:
lint:
name: Format & Lint
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-lint
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
run: |
# Avoid failures of the form `deadline exceeded after 14999958197ns DEADLINE_EXCEEDED`.
# See https://github.com/tweag/rules_haskell/issues/1498 and https://github.com/tweag/rules_haskell/pull/1692.
[[ ${{ runner.os }} == Linux ]] && sudo sysctl -w net.ipv4.tcp_keepalive_time=60
if [ -z "$BUILDBUDDY_API_KEY" ]; then
cache_setting='--noremote_upload_local_results'
else
cache_setting="--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY"
fi
cat >.bazelrc.local <<EOF
common --config=ci
build $cache_setting
EOF
cat >~/.netrc <<EOF
machine api.github.com
password ${{ secrets.GITHUB_TOKEN }}
EOF
- run: |
bazelisk test buildifier:buildifier_test

test-nixpkgs:
name: Build & Test - Nixpkgs
needs:
- lint
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.module }}-${{ matrix.bzlmod }}-${{ matrix.ghc }}-nixpkgs
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
Expand Down Expand Up @@ -115,6 +148,8 @@ jobs:

test-bindist:
name: Build & Test - bindist
needs:
- lint
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.module }}-${{ matrix.bzlmod }}-${{ matrix.ghc }}-bindist
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/).

## Unreleased

### Removed

* remove `compiler_flags` option which was deprecated since 0.14 from macros and rules
* remove `<name>-repl` aliases for repl targets introduced in 0.7
* remove deprecated nixpkgs platform aliases introduced in 0.13

## [0.17] 2023-10-19

[0.17]: https://github.com/tweag/rules_haskell/compare/v0.16...v0.17
Expand Down
10 changes: 10 additions & 0 deletions buildifier/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ buildifier_exclude_patterns = [
"./vendor/**",
]

_lint_warnings = [
"load",
"unused-variable",
]

# Run this to fix the errors in BUILD files.
buildifier(
name = "buildifier",
exclude_patterns = buildifier_exclude_patterns,
lint_mode = "fix",
lint_warnings = _lint_warnings,
verbose = True,
)

Expand All @@ -33,9 +40,12 @@ buildifier_test(
"@examples//:all_files",
"@tutorial//:all_files",
],
lint_mode = "warn",
lint_warnings = _lint_warnings,
mode = "diff",
tags = [
"dont_test_on_windows",
"manual",
],
)

Expand Down
22 changes: 20 additions & 2 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_haskell//docs/pandoc:pandoc.bzl", "set_site_end_location")
Expand Down Expand Up @@ -34,6 +35,17 @@ libraries = [
"c2hs",
]

# moved here so that //haskell is not dependent upon rules_nixpkgs_*
bzl_library(
name = "haskell_nix",
srcs = ["//haskell:nixpkgs.bzl"],
deps = [
"//haskell",
"@rules_nixpkgs_core//:nixpkgs",
"@rules_nixpkgs_posix//:posix",
],
)

[
(
# Extract API documentation metadata to generate navigation and index.
Expand All @@ -47,7 +59,10 @@ libraries = [
provider_template = ":templates/metadata/provider.vm",
rule_template = ":templates/metadata/rule.vm",
tags = ["dont_test_on_windows"],
deps = ["//haskell"],
deps = [
":haskell_nix",
"//haskell",
],
),
# Generate markdown API documentation.
stardoc(
Expand All @@ -60,7 +75,10 @@ libraries = [
provider_template = ":templates/markdown/provider.vm",
rule_template = ":templates/markdown/rule.vm",
tags = ["dont_test_on_windows"],
deps = ["//haskell"],
deps = [
":haskell_nix",
"//haskell",
],
),
# Convert markdown to html.
genrule(
Expand Down
4 changes: 2 additions & 2 deletions docs/haskell.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ a single ``BUILD.bazel`` as follows::
haskell_binary(
name = "demorgan",
srcs = ["Main.hs"],
compiler_flags = ["-threaded"],
ghcopts = ["-threaded"],
deps = [":base", ":booleans"],
)

Expand Down Expand Up @@ -317,7 +317,7 @@ And at the ``main/BUILD.bazel`` file::
haskell_binary(
name = "demorgan",
srcs = ["Main.hs"],
compiler_flags = ["-threaded"],
ghcopts = ["-threaded"],
deps = [":base", "//lib:booleans"],
)

Expand Down
1 change: 0 additions & 1 deletion examples/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ local_repository(
path = "arm",
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@rules_haskell//haskell:repositories.bzl", "rules_haskell_dependencies")

rules_haskell_dependencies()
Expand Down
2 changes: 1 addition & 1 deletion extensions/rules_haskell_dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@rules_haskell//tools:os_info.bzl", "os_info")
load("@rules_haskell_ghc_version//:ghc_version.bzl", "GHC_VERSION")

def repositories(*, bzlmod):
def repositories(*, bzlmod): # @unused
rules_haskell_dependencies_bzlmod()

# Some helpers for platform-dependent configuration
Expand Down
2 changes: 0 additions & 2 deletions haskell/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ bzl_library(
"@bazel_skylib//lib:shell",
"@bazel_skylib//lib:versions",
"@bazel_skylib//rules:expand_template",
"@rules_nixpkgs_core//:nixpkgs",
"@rules_nixpkgs_posix//:posix",
"@rules_sh//sh:posix",
],
)
Expand Down
4 changes: 2 additions & 2 deletions haskell/asterius/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ asterius_toolchain = rule(
# select the asterius platform.
# We also set the asterius_targets_browser back to it's default value
# as it in not needed anymore.
def _asterius_transition_impl(settings, attr):
def _asterius_transition_impl(_settings, _attr):
return {
"//command_line_option:platforms": "@rules_haskell//haskell/asterius:asterius_platform",
"@rules_haskell_asterius_build_setting//:asterius_targets_browser": False,
Expand All @@ -64,7 +64,7 @@ _asterius_transition = transition(

# ahc_dist targets used by asterius_webpack rules must be configured for the browser.
# We use the following transition for this purpose.
def _set_ahc_dist_browser_target_impl(settings, attr):
def _set_ahc_dist_browser_target_impl(_settings, _attr):
return {"@rules_haskell_asterius_build_setting//:asterius_targets_browser": True}

_set_ahc_dist_browser_target = transition(
Expand Down
4 changes: 1 addition & 3 deletions haskell/asterius/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ load(
"//haskell:private/workspace_utils.bzl",
"define_rule",
"execute_or_fail_loudly",
"find_python",
"resolve_labels",
)
load("//haskell:private/validate_attrs.bzl", "check_deprecated_attribute_usage")
load(
"//haskell:private/pkgdb_to_bzl.bzl",
"pkgdb_to_bzl",
Expand Down Expand Up @@ -279,7 +277,7 @@ def rules_haskell_asterius_toolchains(
version = AHC_DEFAULT_VERSION,
ghcopts = [],
cabalopts = [],
repl_ghci_args = [],
repl_ghci_args = [], # @unused
locale = None,
register = True):
"""
Expand Down
29 changes: 11 additions & 18 deletions haskell/cabal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ load(
"relative_rpath_prefix",
"truly_relativize",
)
load(":private/set.bzl", "set")
load("@bazel_skylib//lib:sets.bzl", "sets")
load(":private/validate_attrs.bzl", "typecheck_stackage_extradeps")
load(":haddock.bzl", "generate_unified_haddock_info")
Expand Down Expand Up @@ -93,7 +92,7 @@ def _chop_version(name):
"""Remove any version component from the given package name."""
return name.rpartition("-")[0]

def _find_cabal(hs, srcs):
def _find_cabal(srcs):
"""Check that a .cabal file exists. Choose the root one."""
cabal = None
for f in srcs:
Expand Down Expand Up @@ -207,7 +206,7 @@ def _prepare_cabal_inputs(
verbose,
transitive_haddocks,
generate_paths_module,
is_library = False,
is_library = False, # @unused
dynamic_file = None):
"""Compute Cabal wrapper, arguments, inputs."""
with_profiling = is_profiling_enabled(hs)
Expand Down Expand Up @@ -458,12 +457,9 @@ def _haskell_cabal_library_impl(ctx):

user_cabalopts = _expand_make_variables("cabalopts", ctx, ctx.attr.cabalopts)
if ctx.attr.compiler_flags:
print("WARNING: compiler_flags attribute is deprecated. Use cabalopts instead.")
user_cabalopts.extend([
"--ghc-option=" + opt
for opt in _expand_make_variables("compiler_flags", ctx, ctx.attr.compiler_flags)
])
cabal = _find_cabal(hs, ctx.files.srcs)
fail("ERROR: `compiler_flags` attribute was removed. Use `cabalopts` with `--ghc-option` instead.")

cabal = _find_cabal(ctx.files.srcs)
setup = _find_setup(hs, cabal, ctx.files.srcs)
package_database = hs.actions.declare_file(
"_install/{}.conf.d/package.cache".format(package_id),
Expand Down Expand Up @@ -696,7 +692,7 @@ haskell_cabal_library = rule(
""",
),
"compiler_flags": attr.string_list(
doc = """DEPRECATED. Use `cabalopts` with `--ghc-option` instead.
doc = """REMOVED. Use `cabalopts` with `--ghc-option` instead.

Flags to pass to Haskell compiler, in addition to those defined the cabal file. Subject to Make variable substitution.""",
),
Expand Down Expand Up @@ -808,12 +804,9 @@ def _haskell_cabal_binary_impl(ctx):
exe_name = ctx.attr.exe_name if ctx.attr.exe_name else hs.label.name
user_cabalopts = _expand_make_variables("cabalopts", ctx, ctx.attr.cabalopts)
if ctx.attr.compiler_flags:
print("WARNING: compiler_flags attribute is deprecated. Use cabalopts instead.")
user_cabalopts.extend([
"--ghc-option=" + opt
for opt in _expand_make_variables("compiler_flags", ctx, ctx.attr.compiler_flags)
])
cabal = _find_cabal(hs, ctx.files.srcs)
fail("ERROR: `compiler_flags` attribute was removed. Use `cabalopts` with `--ghc-option` instead.")

cabal = _find_cabal(ctx.files.srcs)
setup = _find_setup(hs, cabal, ctx.files.srcs)
package_database = hs.actions.declare_file(
"_install/{}.conf.d/package.cache".format(hs.label.name),
Expand Down Expand Up @@ -1400,7 +1393,7 @@ def _pin_packages(repository_ctx, resolved):
hashes_url = "https://raw.githubusercontent.com/commercialhaskell/all-cabal-hashes/" + hashes_commit

resolved = dict(**resolved)
for (name, spec) in resolved.items():
for (_name, spec) in resolved.items():
# Determine package sha256
if spec["location"]["type"] == "hackage":
# stack does not expose sha256, see https://github.com/commercialhaskell/stack/issues/5274
Expand Down Expand Up @@ -2438,7 +2431,7 @@ def stack_snapshot(
tools = [],
components = {},
components_dependencies = {},
stack_update = None,
stack_update = None, # @unused
verbose = False,
netrc = "",
toolchain_libraries = None,
Expand Down
Loading