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

Clean up uses of locateRunfiles #15446

Merged
merged 15 commits into from
Nov 10, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use locateResource to get ghc-pkg executable
  • Loading branch information
akrmn committed Nov 4, 2022
commit 6bcf0eb08faf4026ba6ea479391a3ddf83f6dfb7
21 changes: 14 additions & 7 deletions compiler/damlc/lib/DA/Cli/Damlc/Packaging.hs
Original file line number Diff line number Diff line change
@@ -451,9 +451,9 @@ copyFiles from srcs to = do
recachePkgDb :: FilePath -> IO ()
recachePkgDb dbPath = do
T.writeFileUtf8 (dbPath </> "settings") $ T.pack $ show settings
ghcPkgPath <- getGhcPkgPath
ghcPkgExe <- getGhcPkgExe
callProcess
(ghcPkgPath </> exe "ghc-pkg")
ghcPkgExe
[ "recache"
-- ghc-pkg insists on using a global package db and will try
-- to find one automatically if we don’t specify it here.
@@ -529,11 +529,18 @@ writeSrc (fp, content) = do
writeFileUTF8 path content

-- | Locate ghc-pkg
getGhcPkgPath :: IO FilePath
getGhcPkgPath =
if isWindows
then locateRunfiles "rules_haskell_ghc_windows_amd64/bin"
else locateRunfiles "ghc_nix/lib/ghc-9.0.2/bin"
getGhcPkgExe :: IO FilePath
getGhcPkgExe = locateResource Resource
{ runfilesPath = if isWindows
then "rules_haskell_ghc_windows_amd64" </> "bin" </> exe "ghc-pkg"
else "ghc_nix" </> "lib" </> "ghc-9.0.2" </> "bin" </> exe "ghc-pkg"
-- see @compiler/damlc/util.bzl@
, resourcesPath = exe "ghc-pkg"
-- In a packaged application, the executable is stored directly underneath
-- the resources directory because //compiler/damlc:ghc-pkg-dist produces
-- a tarball which has the executable directly under the top directory.
-- See @bazel_tools/packaging/packaging.bzl@.
}

-- | Fail with an exit failure and errror message when Nothing is returned.
mbErr :: String -> Maybe a -> IO a