mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
2d85b47cb2
This reverts commit 597675ee37af16c8cd62c830b7964bfffec4ad9e.
47 lines
1.7 KiB
Haskell
47 lines
1.7 KiB
Haskell
import Distribution.Simple
|
|
import Distribution.PackageDescription
|
|
import Distribution.Simple.Setup
|
|
import Distribution.Simple.Utils
|
|
import Distribution.Simple.LocalBuildInfo
|
|
import Data.Maybe
|
|
import System.Directory
|
|
import Distribution.System
|
|
import System.FilePath.Posix
|
|
|
|
main = defaultMainWithHooks simpleUserHooks {
|
|
preConf = makeScannerLib,
|
|
confHook = \a f -> confHook simpleUserHooks a f >>= updateExtraLibDirs,
|
|
postClean = cleanScannerLib
|
|
}
|
|
|
|
makeScannerLib :: Args -> ConfigFlags -> IO HookedBuildInfo
|
|
makeScannerLib _ flags = do
|
|
let verbosity = fromFlag $ configVerbosity flags
|
|
rawSystemExit verbosity "env" ["mkdir", "-p", "lib"]
|
|
let flag = if buildOS == OSX then "-std=c++11" else "-std=c++0x"
|
|
rawSystemExit verbosity "env" ["g++", flag, "-Ivendor/tree-sitter-ruby/src/", "-fPIC", "vendor/tree-sitter-ruby/src/scanner.cc", "-c", "-o", "lib/scanner.o"]
|
|
rawSystemExit verbosity "env" ["ar", "rcvs", "lib/libscanner.a", "lib/scanner.o"]
|
|
pure emptyHookedBuildInfo
|
|
|
|
updateExtraLibDirs :: LocalBuildInfo -> IO LocalBuildInfo
|
|
updateExtraLibDirs localBuildInfo = do
|
|
let packageDescription = localPkgDescr localBuildInfo
|
|
lib = fromJust $ library packageDescription
|
|
libBuild = libBuildInfo lib
|
|
dir <- getCurrentDirectory
|
|
pure localBuildInfo {
|
|
localPkgDescr = packageDescription {
|
|
library = Just $ lib {
|
|
libBuildInfo = libBuild {
|
|
extraLibDirs = (dir </> "lib") : extraLibDirs libBuild
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
cleanScannerLib :: Args -> CleanFlags -> PackageDescription -> () -> IO ()
|
|
cleanScannerLib _ flags _ _ = do
|
|
let verbosity = fromFlag $ cleanVerbosity flags
|
|
dir <- getCurrentDirectory
|
|
rawSystemExit verbosity "env" ["rm", "-rf", dir </> "lib"]
|