From 475ab1465dbc8232b2a2078837edea74d448d93b Mon Sep 17 00:00:00 2001 From: joneshf Date: Fri, 13 Nov 2020 02:55:54 -0800 Subject: [PATCH] Move `purescript-ast` to a `bazel` rule 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: https://github.com/tweag/rules_haskell/issues/1392#issuecomment-657472777. --- WORKSPACE.bazel | 35 +++++++- snapshot.yaml | 4 - third_party/purescript-ast/BUILD.bazel | 0 .../purescript-ast-cabal-file.patch | 80 +++++++++++++++++++ .../purescript-ast/purescript-ast.BUILD | 21 +++++ 5 files changed, 135 insertions(+), 5 deletions(-) create mode 100644 third_party/purescript-ast/BUILD.bazel create mode 100644 third_party/purescript-ast/purescript-ast-cabal-file.patch create mode 100644 third_party/purescript-ast/purescript-ast.BUILD diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 8bcafc8..a22e031 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -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", @@ -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, @@ -167,7 +200,6 @@ stack_snapshot( "base", "containers", "dlist", - "purescript-ast", "scientific", "semigroups", "text", @@ -177,6 +209,7 @@ stack_snapshot( "@happy", ], vendored_packages = { + "purescript-ast": "@purescript_ast//:purescript-ast", "purescript-cst": "@purescript_cst//:purescript-cst", }, ) diff --git a/snapshot.yaml b/snapshot.yaml index 5ab360b..ced6b65 100644 --- a/snapshot.yaml +++ b/snapshot.yaml @@ -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 diff --git a/third_party/purescript-ast/BUILD.bazel b/third_party/purescript-ast/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/third_party/purescript-ast/purescript-ast-cabal-file.patch b/third_party/purescript-ast/purescript-ast-cabal-file.patch new file mode 100644 index 0000000..d9bacbe --- /dev/null +++ b/third_party/purescript-ast/purescript-ast-cabal-file.patch @@ -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 ++maintainer: Gary Burgess , Hardy Jones , Harry Garrood , Christoph Hegemann , Liam Goodacre , Nathan Faubion ++ ++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 diff --git a/third_party/purescript-ast/purescript-ast.BUILD b/third_party/purescript-ast/purescript-ast.BUILD new file mode 100644 index 0000000..e211f4e --- /dev/null +++ b/third_party/purescript-ast/purescript-ast.BUILD @@ -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", + ], +)