Skip to content

Commit

Permalink
Move purescript-ast to a bazel rule
Browse files Browse the repository at this point in the history
We want to work around an issue with packages not at the top-level.

This follows the change we made for `purescript-cst` in
8f77f15f5d388b6a17c6a216ea1644caeda609af. I.e. addressing the problem of
Haskell packages in a sub-directory not really working with `stack ls
dependencies json` at the moment:
tweag/rules_haskell#1392 (comment).
  • Loading branch information
joneshf committed Nov 13, 2020
1 parent c703521 commit 475ab14
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 5 deletions.
35 changes: 34 additions & 1 deletion WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ http_archive(
],
)

http_archive(
name = "purescript_ast",
build_file = "//third_party/purescript-ast:purescript-ast.BUILD",
patch_args = [
"-p1",
],
patches = [
"//third_party/purescript-ast:purescript-ast-cabal-file.patch",
],
strip_prefix = "purescript-81909a9585b00bc99cc47c7959fbc5ae2e1ff285/lib/purescript-ast",
sha256 = "f2d685b754d93328fd2d175af0748f6f3bce7335c5d14157427876df38b566c3",
urls = [
"https://github.com/joneshf/purescript/archive/81909a9585b00bc99cc47c7959fbc5ae2e1ff285.zip",
],
)

http_archive(
name = "purescript_cst",
build_file = "//third_party/purescript-cst:purescript-cst.BUILD",
Expand Down Expand Up @@ -159,6 +175,23 @@ stack_snapshot(
"optparse-applicative",
"pathwalk",
"rio",
# `purescript-ast` dependencies
# These have to be here so the `//third_party/purescript:purescript-ast` package can pick them up.
# If we ever can get rid of the `//third_party/purescript:purescript-ast` package,
# we can remove these dependencies
"aeson",
"base",
"base-compat",
"bytestring",
"containers",
"deepseq",
"filepath",
"microlens-platform",
"mtl",
"protolude",
"scientific",
"text",
"vector",
# `purescript-cst` dependencies
# These have to be here so the `//third_party/purescript:purescript-cst` package can pick them up.
# If we ever can get rid of the `//third_party/purescript:purescript-cst` package,
Expand All @@ -167,7 +200,6 @@ stack_snapshot(
"base",
"containers",
"dlist",
"purescript-ast",
"scientific",
"semigroups",
"text",
Expand All @@ -177,6 +209,7 @@ stack_snapshot(
"@happy",
],
vendored_packages = {
"purescript-ast": "@purescript_ast//:purescript-ast",
"purescript-cst": "@purescript_cst//:purescript-cst",
},
)
4 changes: 0 additions & 4 deletions snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ packages:
- teardown-0.5.0.1@sha256:b7a6812637f79d81632bb7adebc5ad9a96fffacf3e5f655d5bf21728bd3786f9,2868
- typed-process-0.2.6.0@sha256:c901c13d491441830eb23132ad6968243a56b98161629d260a26c0b13c735fcd,2136
- unliftio-0.2.12@sha256:b089fbc2ff2628a963c2c4b12143f2020874e3e5144ffd6c62b25639a0ca1483,3325
- git: https://github.com/joneshf/purescript.git
commit: 81909a9585b00bc99cc47c7959fbc5ae2e1ff285
subdirs:
- lib/purescript-ast
resolver: lts-13.26
Empty file.
80 changes: 80 additions & 0 deletions third_party/purescript-ast/purescript-ast-cabal-file.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
diff --git a/purescript-ast.cabal b/purescript-ast.cabal
new file mode 100644
index 00000000..d886259e
--- /dev/null
+++ b/purescript-ast.cabal
@@ -0,0 +1,74 @@
+cabal-version: 1.12
+
+-- This file has been generated from package.yaml by hpack version 0.31.1.
+--
+-- see: https://github.com/sol/hpack
+--
+-- hash: 5e936f86b1ee77d33f4a9da5d917f41ca19c69b390366da8bdff54725ad5dc18
+
+name: purescript-ast
+version: 0.13.6
+synopsis: PureScript Programming Language Abstract Syntax Tree
+description: Defines the underlying syntax of the PureScript Programming Language.
+category: Language
+stability: experimental
+homepage: http://www.purescript.org/
+bug-reports: https://github.com/purescript/purescript/issues
+author: Phil Freeman <paf31@cantab.net>
+maintainer: Gary Burgess <gary.burgess@gmail.com>, Hardy Jones <jones3.hardy@gmail.com>, Harry Garrood <harry@garrood.me>, Christoph Hegemann <christoph.hegemann1337@gmail.com>, Liam Goodacre <goodacre.liam@gmail.com>, Nathan Faubion <nathan@n-son.com>
+
+copyright: (c) 2013-17 Phil Freeman, (c) 2014-19 Gary Burgess, (c) other contributors (see CONTRIBUTORS.md)
+license: BSD3
+license-file: LICENSE
+build-type: Simple
+extra-source-files:
+ README.md
+
+source-repository head
+ type: git
+ location: https://github.com/purescript/purescript
+
+library
+ exposed-modules:
+ Control.Monad.Supply
+ Control.Monad.Supply.Class
+ Language.PureScript.AST
+ Language.PureScript.AST.Binders
+ Language.PureScript.AST.Declarations
+ Language.PureScript.AST.Exported
+ Language.PureScript.AST.Literals
+ Language.PureScript.AST.Operators
+ Language.PureScript.AST.SourcePos
+ Language.PureScript.AST.Traversals
+ Language.PureScript.Comments
+ Language.PureScript.Constants.Prim
+ Language.PureScript.Crash
+ Language.PureScript.Environment
+ Language.PureScript.Kinds
+ Language.PureScript.Label
+ Language.PureScript.Names
+ Language.PureScript.PSString
+ Language.PureScript.Traversals
+ Language.PureScript.TypeClassDictionaries
+ Language.PureScript.Types
+ other-modules:
+ Paths_purescript_ast
+ hs-source-dirs:
+ src
+ default-extensions: ConstraintKinds DataKinds DeriveFunctor DeriveFoldable DeriveTraversable DeriveGeneric DerivingStrategies EmptyDataDecls FlexibleContexts KindSignatures LambdaCase MultiParamTypeClasses NoImplicitPrelude PatternGuards PatternSynonyms RankNTypes RecordWildCards OverloadedStrings ScopedTypeVariables TupleSections ViewPatterns
+ ghc-options: -Wall -O2
+ build-depends:
+ aeson >=1.0 && <1.5
+ , base >=4.11 && <4.13
+ , base-compat >=0.6.0
+ , bytestring
+ , containers
+ , deepseq
+ , filepath
+ , microlens-platform >=0.3.9.0 && <0.4
+ , mtl >=2.1.0 && <2.3.0
+ , protolude >=0.1.6 && <0.2.4
+ , scientific >=0.3.4.9 && <0.4
+ , text
+ , vector
+ default-language: Haskell2010
21 changes: 21 additions & 0 deletions third_party/purescript-ast/purescript-ast.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load(
"@rules_haskell//haskell:cabal.bzl",
"haskell_cabal_library",
)

load(
"@stackage//:packages.bzl",
"packages",
)

haskell_cabal_library(
name = "purescript-ast",
deps = packages["purescript-ast"].deps,
srcs = glob([
"**",
]),
version = packages["purescript-ast"].version,
visibility = [
"//visibility:public",
],
)

0 comments on commit 475ab14

Please sign in to comment.