Skip to content

Commit c13c2f2

Browse files
committed
Minor fix for fixing the pckConfig dependency, travis fixes
1 parent 62c2b53 commit c13c2f2

File tree

12 files changed

+146
-27
lines changed

12 files changed

+146
-27
lines changed

.travis.yml

Lines changed: 96 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,102 @@
1-
language: haskell
1+
# This Travis job script has been generated by a script via
2+
#
3+
# make_travis_yml_2.hs 'LibClang.cabal'
4+
#
5+
# For more information, see https://github.com/hvr/multi-ghc-travis
6+
#
7+
language: c
8+
sudo: false
29

3-
before_install:
4-
- git submodule update --init --recursive
10+
git:
11+
submodules: false # whether to recursively clone submodules
12+
13+
cache:
14+
directories:
15+
- $HOME/.cabal/packages
16+
- $HOME/.cabal/store
517

6-
branches:
7-
only:
8-
- master
18+
before_cache:
19+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
20+
# remove files that are regenerated by 'cabal update'
21+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
22+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
23+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
24+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
25+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
26+
27+
matrix:
28+
include:
29+
- compiler: "ghc-7.8.4"
30+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
31+
addons: {apt: {packages: [libstdc++6,
32+
llvm-3.8,llvm-3.8-dev,llvm-3.8-runtime,libllvm3.8,
33+
libclang-3.8-dev,
34+
ghc-ppa-tools,cabal-install-head,ghc-7.8.4,alex-3.1.7,happy-1.19.5],
35+
sources: [hvr-ghc,llvm-toolchain-precise-3.8,ubuntu-toolchain-r-test]}}
36+
- compiler: "ghc-7.10.3"
37+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
38+
addons: {apt: {packages: [libstdc++6,
39+
llvm-3.8,llvm-3.8-dev,llvm-3.8-runtime,libllvm3.8,
40+
libclang-3.8-dev,
41+
ghc-ppa-tools,cabal-install-head,ghc-7.10.3,alex-3.1.7,happy-1.19.5],
42+
sources: [hvr-ghc,llvm-toolchain-precise-3.8,ubuntu-toolchain-r-test]}}
43+
- compiler: "ghc-8.0.2"
44+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
45+
addons: {apt: {packages: [libstdc++6,
46+
llvm-3.8,llvm-3.8-dev,llvm-3.8-runtime,libllvm3.8,
47+
libclang-3.8-dev,
48+
ghc-ppa-tools,cabal-install-head,ghc-8.0.2,alex-3.1.7,happy-1.19.5],
49+
sources: [hvr-ghc,llvm-toolchain-precise-3.8,ubuntu-toolchain-r-test]}}
50+
51+
before_install:
52+
- HC=${CC}
53+
- unset CC
54+
- export HAPPYVER=1.19.5
55+
- export ALEXVER=3.1.7
56+
- PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:/opt/happy/$HAPPYVER/bin:/opt/alex/$ALEXVER/bin:$PATH
57+
- PKGNAME='LibClang'
958

1059
install:
11-
- cabal update && cabal install Cabal cabal-install && cabal install --only-dependencies --enable-tests
60+
- cabal --version
61+
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
62+
- BENCH=${BENCH---enable-benchmarks}
63+
- TEST=${TEST---enable-tests}
64+
- travis_retry cabal update -v
65+
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
66+
- cabal install c2hs hsc2hs
67+
- rm -fv cabal.project.local
68+
- "echo 'packages: .' > cabal.project"
69+
- rm -f cabal.project.freeze
70+
- cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2
71+
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2
1272

73+
# Here starts the actual work to be performed for the package under test;
74+
# any command which exits with a non-zero exit code causes the build to fail.
1375
script:
14-
- cabal configure --enable-tests && cabal build && cabal test
76+
- if [ -f configure.ac ]; then autoreconf -i; fi
77+
- rm -rf dist/
78+
- cabal sdist # test that a source-distribution can be generated
79+
- cd dist/
80+
- SRCTAR=(${PKGNAME}-*.tar.gz)
81+
- SRC_BASENAME="${SRCTAR/%.tar.gz}"
82+
- tar -xvf "./$SRC_BASENAME.tar.gz"
83+
- cd "$SRC_BASENAME/"
84+
## from here on, CWD is inside the extracted source-tarball
85+
- rm -fv cabal.project.local
86+
- "echo 'packages: .' > cabal.project"
87+
# this builds all libraries and executables (without tests/benchmarks)
88+
- rm -f cabal.project.freeze
89+
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks
90+
# this builds all libraries and executables (including tests/benchmarks)
91+
# - rm -rf ./dist-newstyle
92+
- cabal new-build -w ${HC} ${TEST} ${BENCH}
93+
94+
# there's no 'cabal new-test' yet, so let's emulate for now
95+
- TESTS=( $(awk 'tolower($0) ~ /^test-suite / { print $2 }' *.cabal) )
96+
- if [ "$TEST" != "--enable-tests" ]; then TESTS=(); fi
97+
- shopt -s globstar;
98+
RC=true; for T in ${TESTS[@]}; do echo "== $T ==";
99+
if dist-newstyle/build/**/$SRC_BASENAME/**/build/$T/$T; then echo "= $T OK =";
100+
else echo "= $T FAILED ="; RC=false; fi; done; $RC
101+
102+
# EOF

LibClang.cabal

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ Description:
1717
Please use <https://github.com/chetant/LibClang/issues> to report bugs
1818

1919
Category: Language
20+
Tested-With: GHC == 7.8.4
21+
, GHC == 7.10.3
22+
, GHC == 8.0.2
2023
Build-type: Custom
2124
Extra-Source-Files: cbits/utils.h, cbits/visitors.h, cbits/wrappers.h,
22-
test/*.hs, test/*.c, test/runTest.sh
25+
test/*.hs, test/*.c, test/runTest.sh, test/Makefile
2326
Source-Repository head
2427
type: git
2528
location: git://github.com/chetant/LibClang.git
@@ -68,5 +71,5 @@ Library
6871
Clang.Internal.FFI,
6972
Clang.Internal.FFIConstants
7073
default-language: Haskell2010
71-
pkgconfig-depends: ncurses, llvm == 3.8.0
72-
extra-libraries: clang-3.8.0
74+
pkgconfig-depends: ncurses
75+
extra-libraries: clang-3.8

Setup.hs

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
{-# LANGUAGE CPP #-}
12
import Distribution.Simple
3+
import Distribution.PackageDescription
4+
import Data.Version
25
import Data.List
3-
import Data.Char (isSpace)
6+
import Data.Char(isSpace)
7+
import Data.Maybe
48
import System.Directory(getCurrentDirectory, removeFile)
59
import System.IO(IOMode(..), openFile, hPutStr, hFlush, hClose)
610
import System.IO.Error(catchIOError)
711
import System.Process(readProcess)
812
import System.Environment(lookupEnv, getEnv, setEnv)
913
import System.FilePath.Posix((</>))
14+
import Control.Applicative((<$>))
1015
import Control.Exception(bracket)
1116

1217
rtrim :: String -> String
@@ -15,45 +20,59 @@ rtrim = f . f
1520

1621
getLLVMDetails llvmConfigPath = do
1722
version <- rtrim <$> readProcess llvmConfigPath ["--version"] []
18-
cxxFlags <- rtrim <$> readProcess llvmConfigPath ["--cxxflags"] []
1923
libPath <- rtrim <$> readProcess llvmConfigPath ["--libdir"] []
2024
includePath <- rtrim <$> readProcess llvmConfigPath ["--includedir"] []
21-
let cFlags = unwords $ filter (not . isPrefixOf "-std") $ words cxxFlags
22-
return (version,cFlags,libPath,includePath)
25+
return (version,libPath,includePath)
2326

2427
setupLLVMPkgConfig tmpPCPath outf = do
2528
let tryElse act failAct = catchIOError act (const failAct)
26-
(version,cFlags,libPath,includePath) <- getLLVMDetails "llvm-config" `tryElse`
27-
getLLVMDetails "llvm-config-3.8" `tryElse`
28-
(getEnv "LLVM_CONFIG" >>= getLLVMDetails) `tryElse`
29-
(error "ERROR: cannot find llvm-config, please setup environment variable LLVM_CONFIG with location of llvm-config and try again")
29+
(version,libPath,includePath) <- getLLVMDetails "llvm-config-3.8" `tryElse`
30+
getLLVMDetails "llvm-config" `tryElse`
31+
(getEnv "LLVM_CONFIG" >>= getLLVMDetails) `tryElse`
32+
(error "ERROR: cannot find llvm-config, please setup environment variable LLVM_CONFIG with location of llvm-config and try again")
3033
let pc = unlines $ ["Name: LLVM"
3134
,"Description: Low-level Virtual Machine compiler framework"
3235
,"Version: " ++ version
3336
,"URL: http://www.llvm.org/"
3437
,"Requires:"
3538
,"Conflicts:"
3639
,"Libs: -L" ++ libPath ++ " -lLLVM-" ++ version
37-
,"Cflags: -I" ++ includePath ++ " " ++ cFlags]
40+
,"Cflags: -I" ++ includePath]
3841
pkgConfigPath = "PKG_CONFIG_PATH"
39-
-- putStrLn pc
4042
hPutStr outf pc
4143
hFlush outf
4244
mpc <- lookupEnv pkgConfigPath
43-
setEnv pkgConfigPath $ case mpc of
44-
Just pc -> pc ++ ":" ++ tmpPCPath
45-
Nothing -> tmpPCPath
45+
let pkgConfigPathVal = case mpc of
46+
Just pc -> pc ++ ":" ++ tmpPCPath
47+
Nothing -> tmpPCPath
48+
-- putStrLn $ pkgConfigPath ++ "=" ++ pkgConfigPathVal
49+
setEnv pkgConfigPath pkgConfigPathVal
4650

4751
withTmpPC runM = do
4852
cwd <- getCurrentDirectory
4953
let llvmPCFname = cwd </> "llvm.pc"
5054
bracket
5155
(openFile llvmPCFname WriteMode)
52-
-- (\outf -> hClose outf >> removeFile llvmPCFname)
53-
hClose
56+
(\outf -> hClose outf >> removeFile llvmPCFname)
5457
(runM cwd)
5558

59+
pcHook = simpleUserHooks { confHook = confHookM }
60+
where confHookM (gpd, hbi) cf = do
61+
let cdt = fromJust $ condLibrary gpd
62+
lib = condTreeData cdt
63+
lbi = libBuildInfo lib
64+
vRange = withinVersion $ makeVersion [3,8]
65+
lbi' = lbi { pkgconfigDepends = pkgconfigDepends lbi ++
66+
[Dependency (PackageName "llvm") vRange] }
67+
lib' = lib { libBuildInfo = lbi' }
68+
gpd' = gpd { condLibrary = Just (cdt { condTreeData = lib' }) }
69+
(confHook simpleUserHooks) (gpd', hbi) cf
70+
71+
#if __GLASGOW_HASKELL__ < 710
72+
makeVersion xs = Version xs []
73+
#endif
74+
5675
main =
5776
withTmpPC $ \cwd outf -> do
5877
setupLLVMPkgConfig cwd outf
59-
defaultMain
78+
defaultMainWithHooks pcHook

src/Clang/Comment.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module Clang.Comment
2929
, FFI.InlineCommandRenderStyle (..)
3030
) where
3131

32+
import Control.Applicative
3233
import Control.Monad
3334
import Control.Monad.IO.Class
3435
import Data.Maybe

src/Clang/Completion.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module Clang.Completion
4141
, getBriefComment
4242
) where
4343

44+
import Control.Applicative
4445
import Control.Monad
4546
import Control.Monad.IO.Class
4647
import Data.Typeable

src/Clang/Cursor.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module Clang.Cursor
8585
, getCompletionString
8686
) where
8787

88+
import Control.Applicative
8889
import Control.Monad.IO.Class
8990
import GHC.Word
9091

src/Clang/File.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module Clang.File
2121
, FFI.UniqueId
2222
) where
2323

24+
import Control.Applicative
2425
import Control.Monad.IO.Class
2526
import Data.Time.Clock.POSIX (POSIXTime, posixSecondsToUTCTime)
2627
import Data.Time.Clock (UTCTime)

src/Clang/Index.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module Clang.Index
2121
, FFI.threadBackgroundPriorityForAll
2222
) where
2323

24+
import Control.Applicative
2425
import Control.Monad.IO.Class
2526

2627
import Clang.Internal.BitFlags

src/Clang/Internal/Comment.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Clang.Internal.Comment
99
, getFFIComment
1010
) where
1111

12+
import Control.Applicative
1213
import Control.Monad
1314
import Control.Monad.IO.Class
1415
import Data.Typeable

src/Clang/Internal/FFI.chs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ module Clang.Internal.FFI
341341
, remap_getFilenames
342342
) where
343343

344+
import Control.Applicative
344345
import Control.Monad (forM_)
345346
import Control.Monad.Trans
346347
import qualified Data.ByteString as B

0 commit comments

Comments
 (0)