-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
390be30
commit f252aa6
Showing
7 changed files
with
165 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
.stack-work | ||
dist | ||
build | ||
.history | ||
.cabal-sandbox | ||
cabal.sandbox.config | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import Distribution.PackageDescription | ||
import Distribution.Simple | ||
import Distribution.Simple.LocalBuildInfo | ||
import Distribution.Simple.UserHooks | ||
import Distribution.Simple.Setup | ||
|
||
import System.Info | ||
import System.Directory | ||
import System.Environment | ||
import System.Process | ||
import System.FilePath | ||
|
||
import Data.Maybe | ||
|
||
main = defaultMainWithHooks simpleUserHooks { confHook = odenConfHook | ||
, postConf = odenPostConf } | ||
|
||
addLibDirsToBuildInfo :: BuildInfo -> IO BuildInfo | ||
addLibDirsToBuildInfo buildInfo = do | ||
wd <- getCurrentDirectory | ||
let libDir = wd </> "build" </> "lib" | ||
return $ buildInfo { | ||
extraLibDirs = libDir : extraLibDirs buildInfo | ||
} | ||
|
||
addLibDirsToOdenExe :: [Executable] -> IO [Executable] | ||
addLibDirsToOdenExe exes = mapM addIfOden exes | ||
where | ||
addIfOden exe | ||
| exeName exe == "oden-exe" = do | ||
withLibDirs <- addLibDirsToBuildInfo (buildInfo exe) | ||
return $ exe { buildInfo = withLibDirs } | ||
| otherwise = return exe | ||
|
||
addLibDirsToTests :: [TestSuite] -> IO [TestSuite] | ||
addLibDirsToTests suites = mapM addLibDirs suites | ||
where | ||
addLibDirs suite = do | ||
withLibDirs <- addLibDirsToBuildInfo (testBuildInfo suite) | ||
return $ suite { testBuildInfo = withLibDirs } | ||
|
||
odenConfHook :: (GenericPackageDescription, HookedBuildInfo) | ||
-> ConfigFlags | ||
-> IO LocalBuildInfo | ||
odenConfHook (description, buildInfo) flags = do | ||
localBuildInfo <- confHook simpleUserHooks (description, buildInfo) flags | ||
let packageDescription = localPkgDescr localBuildInfo | ||
lib = fromJust $ library packageDescription | ||
|
||
libWithLibDirs <- addLibDirsToBuildInfo (libBuildInfo lib) | ||
executablesWithLibDirs <- addLibDirsToOdenExe (executables packageDescription) | ||
testSuitesWithLibDirs <- addLibDirsToTests (testSuites packageDescription) | ||
|
||
return $ localBuildInfo { | ||
localPkgDescr = packageDescription { | ||
library = Just $ lib { | ||
libBuildInfo = libWithLibDirs | ||
}, | ||
executables = executablesWithLibDirs, | ||
testSuites = testSuitesWithLibDirs | ||
} | ||
} | ||
|
||
ext :: String | ||
ext = case os of | ||
"darwin" -> ".dylib" | ||
"windows" -> ".dll" | ||
_ -> ".so" | ||
|
||
odenPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO () | ||
odenPostConf _ _ _ _ = do | ||
wd <- getCurrentDirectory | ||
setEnv "GOPATH" (wd </> "go") | ||
|
||
let dynamicPath = wd </> "build" </> "lib" </> ("libimporter" ++ ext) | ||
buildDynamic = shell ("go build -buildmode=c-shared -o " ++ dynamicPath ++ " oden/cmd/importer") | ||
|
||
putStrLn $ "Compiling Go dynamic library to " ++ dynamicPath | ||
readCreateProcess buildDynamic "" >>= putStr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
here="$(dirname "$(readlink -f "$0")")" | ||
|
||
LD_LIBRARY_PATH="$here"/../lib:"$LD_LIBRARY_PATH" | ||
export LD_LIBRARY_PATH | ||
exec "$0"-exe "$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,11 @@ license: MIT | |
license-file: LICENSE.md | ||
author: Oskar Wickström | ||
maintainer: [email protected] | ||
build-type: Simple | ||
build-type: Custom | ||
extra-source-files: | ||
README.md, | ||
go/src/oden/importer/main.go, | ||
go/src/oden/cmd/importer/importer.go, | ||
go/src/oden/importer/objects.go, | ||
go/src/oden/importer/types.go | ||
cabal-version: >=1.10 | ||
|
||
|
@@ -81,12 +82,16 @@ library | |
Oden.Type.Signature | ||
default-language: Haskell2010 | ||
hs-source-dirs: src | ||
ghc-options: -fPIC -Wall dist/go-lib/importer.a -fno-warn-orphans | ||
extra-libraries: importer | ||
ghc-options: -Wall -fno-warn-orphans | ||
|
||
executable cli | ||
exposed-modules: | ||
executable oden-exe | ||
other-modules: | ||
Paths_oden, | ||
Oden.CLI, | ||
Oden.CLI.Build, | ||
Oden.CLI.Lint, | ||
Oden.CLI.PrintPackage, | ||
Oden.CLI.Run | ||
build-depends: | ||
base == 4.*, | ||
|
@@ -104,7 +109,8 @@ executable cli | |
default-language: Haskell2010 | ||
main-is: Main.hs | ||
hs-source-dirs: cli | ||
ghc-options: -fPIC -Wall dist/go-lib/importer.a -fno-warn-orphans | ||
extra-libraries: importer | ||
ghc-options: -Wall -fno-warn-orphans | ||
|
||
test-suite spec | ||
type: exitcode-stdio-1.0 | ||
|
@@ -124,4 +130,6 @@ test-suite spec | |
containers >= 0.4 && <0.6, | ||
wl-pprint >= 1.2, | ||
oden | ||
ghc-options: -Wall -fno-warn-orphans -fno-warn-missing-signatures | ||
extra-libraries: importer | ||
ghc-options: | ||
-Wall -fno-warn-orphans -fno-warn-missing-signatures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md | ||
|
||
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2) | ||
resolver: lts-4.2 | ||
|
||
# Local packages, usually specified by relative directory name | ||
packages: | ||
- '.' | ||
|
||
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3) | ||
extra-deps: [] | ||
|
||
# Override default flag values for local packages and extra-deps | ||
flags: {} | ||
|
||
# Extra package databases containing global packages | ||
extra-package-dbs: [] | ||
|
||
# Control whether we use the GHC we find on the path | ||
# system-ghc: true | ||
|
||
# Require a specific version of stack, using version ranges | ||
# require-stack-version: -any # Default | ||
# require-stack-version: >= 0.1.10.0 | ||
|
||
# Override the architecture used by stack, especially useful on Windows | ||
# arch: i386 | ||
# arch: x86_64 | ||
|
||
# Extra directories used by stack for building | ||
# extra-include-dirs: [/path/to/dir] | ||
# extra-lib-dirs: [/path/to/dir] | ||
ghc-options: | ||
"spec": -Wall -L build/lib |