Skip to content

Commit

Permalink
Use a consistant include dir for cwd (#2978)
Browse files Browse the repository at this point in the history
* Use a consistant include dir for cwd

See haskell/ghcide#114 for the actual
fix.
This PR just bumps ghcide and adds a regression test. I’ll change the
revision before merging, I just want to test CI for now.

fixes #2929

* Switch to proper ghcide revision

* writeIfacesAndHie no longer exists

* Add changelog entry

* Maybe I should try to compile code before committing but I don’t want to

* Fix ghcide exe
  • Loading branch information
cocreature authored and mergify[bot] committed Sep 23, 2019
1 parent aad98b4 commit 2ab06da
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 4 deletions.
1 change: 1 addition & 0 deletions 3rdparty/haskell/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ exports_files([
"network-package.bzl",
"c2hs-package.bzl",
"old-time-package.bzl",
"Paths_ghcide.hs",
])
14 changes: 14 additions & 0 deletions 3rdparty/haskell/BUILD.ghcide
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,25 @@ haskell_binary(
hazel_library("shake"),
hazel_library("text"),
":lib-ghc",
"ghcide-paths",
],
version = "0.1.0",
src_strip_prefix = "exe",
visibility = ["//visibility:public"],
)

# For now, we hack this together manually. This will change
# with stack_snapshot anyway.
haskell_library(
name = "ghcide-paths",
srcs = ["@com_github_digital_asset_daml//3rdparty/haskell:Paths_ghcide.hs"],
compiler_flags = common_flags,
deps = [
hazel_library("base")
],
visibility = ["//visibility:public"],
)

# Used in getModificationTimeRule in Development.IDE.Core.FileStore
cc_library(
name = "getmodtime",
Expand Down
6 changes: 6 additions & 0 deletions 3rdparty/haskell/Paths_ghcide.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Paths_ghcide (version) where

import Data.Version

version :: Version
version = Version [0,1,0] []
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ hazel_custom_package_github(
strip_prefix = "wai-app-static",
)

GHCIDE_REV = "a162e81aa306c8efe2be3ce0d591f46abd5f88e4"
GHCIDE_REV = "dcd7cb499e33273e1d5835ea1e69907e8224e483"

# We need a custom build file to depend on ghc-lib and ghc-lib-parser
hazel_custom_package_github(
Expand Down
3 changes: 2 additions & 1 deletion compiler/damlc/daml-compiler/src/DA/Daml/Compiler/Dar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module DA.Daml.Compiler.Dar
, getSrcRoot
, getDamlFiles
, getDamlRootFiles
, writeIfacesAndHie
) where

import qualified "zip" Codec.Archive.Zip as Zip
Expand All @@ -32,7 +33,7 @@ import qualified Data.Set as S
import qualified Data.Text as T
import Development.IDE.Core.API
import Development.IDE.Core.RuleTypes.Daml
import Development.IDE.Core.Rules.Daml hiding (writeIfacesAndHie)
import Development.IDE.Core.Rules.Daml
import Development.IDE.Core.Shake
import Development.IDE.GHC.Compat
import Development.IDE.GHC.Util
Expand Down
4 changes: 2 additions & 2 deletions compiler/damlc/lib/DA/Cli/Damlc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import Development.IDE.Core.Shake
import Development.IDE.Core.Rules
import Development.IDE.Core.Rules.Daml (getDalf, getDlintIdeas)
import Development.IDE.Core.RuleTypes.Daml (DalfPackage(..), GetParsedModule(..))
import Development.IDE.GHC.Util (fakeDynFlags, moduleImportPaths, hscEnv)
import Development.IDE.GHC.Util (fakeDynFlags, moduleImportPath, hscEnv)
import Development.IDE.Types.Diagnostics
import Development.IDE.Types.Location
import Development.IDE.Types.Options (clientSupportsProgress)
Expand Down Expand Up @@ -908,7 +908,7 @@ execDocTest opts files =
pmS <- catMaybes <$> uses GetParsedModule files'
-- This is horrible but we do not have a way to change the import paths in a running
-- IdeState at the moment.
pure $ nubOrd $ mapMaybe moduleImportPaths pmS
pure $ nubOrd $ mapMaybe moduleImportPath pmS
opts <- mkOptions opts { optImportPath = importPaths <> optImportPath opts, optHaddock = Haddock True }
withDamlIdeState opts logger diagnosticsLogger $ \ideState ->
docTest ideState files'
Expand Down
27 changes: 27 additions & 0 deletions daml-assistant/integration-tests/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,33 @@ packagingTests tmpDir = testGroup "packaging"
assertBool "B.hi missing" (any (\f -> takeFileName f == "B.hi") darFiles)
assertBool "B.hie missing" (any (\f -> takeFileName f == "B.hie") darFiles)

, testCase "Imports from differen directories" $ withTempDir $ \projDir -> do
-- Regression test for #2929
createDirectory (projDir </> "A")
writeFileUTF8 (projDir </> "A.daml") $ unlines
[ "daml 1.2"
, "module A where"
, "import A.B ()"
, "import A.C ()"
]
writeFileUTF8 (projDir </> "A/B.daml") $ unlines
[ "daml 1.2"
, "module A.B where"
, "import A.C ()"
]
writeFileUTF8 (projDir </> "A/C.daml") $ unlines
[ "daml 1.2"
, "module A.C where"
]
writeFileUTF8 (projDir </> "daml.yaml") $ unlines
[ "sdk-version: " <> sdkVersion
, "name: proj"
, "version: 0.1.0"
, "source: ."
, "dependencies: [daml-prim, daml-stdlib]"
]
withCurrentDirectory projDir $ callCommandQuiet "daml build"

, testCase "Project without exposed modules" $ withTempDir $ \projDir -> do
writeFileUTF8 (projDir </> "A.daml") $ unlines
[ "daml 1.2"
Expand Down
3 changes: 3 additions & 0 deletions unreleased.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ HEAD — ongoing
Fix a bug where ``.dar`` files produced by ``daml build`` were missing
all ``.daml`` files except for the one that ``source`` pointed to.
+ [DAML Integration Toolkit] 30 more test cases have been added to the transaction service test suite.
- [DAML Compiler]
Fix a bug where importing the same module from different directories
resulted in an error in ``daml build``.

0 comments on commit 2ab06da

Please sign in to comment.