Skip to content

Instantly share code, notes, and snippets.

@amutake
Created August 20, 2015 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amutake/a58acf4121724bf3b10a to your computer and use it in GitHub Desktop.
Save amutake/a58acf4121724bf3b10a to your computer and use it in GitHub Desktop.
#!/usr/bin/env runghc
import Distribution.Simple.InstallDirs -- Cabal package
( platformTemplateEnv
, fromPathTemplate, toPathTemplate
, substPathTemplate
)
import Distribution.System (buildPlatform) -- Cabal package
import System.Process -- process package
( shell
, readCreateProcess
)
main :: IO ()
main = do
compiler <- filter (/= '\n') . ("ghc-" ++) <$>
readCreateProcess (shell "ghc --numeric-version") ""
let platform = buildPlatform
let env = platformTemplateEnv platform
putStrLn $ fromPathTemplate $ substPathTemplate env $ toPathTemplate $ "$arch-$os-" ++ compiler
$ ./abi.hs
x86_64-osx-ghc-7.10.2
@amutake
Copy link
Author

amutake commented Aug 20, 2015

System.Info.compilerVersion が patch level をとってくれないのどうなの

@amutake
Copy link
Author

amutake commented Aug 20, 2015

cabal-install の Main から Distribution.Client.Install.install -> ... -> Distribution.Simple.Program.Db.lookupProgramVersion まで追っていったけど諦めた

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment