java-bridge 0.20130606.1 → 0.20130606.2
raw patch · 2 files changed
+36/−23 lines, 2 filessetup-changed
Files
- Setup.hs +33/−20
- java-bridge.cabal +3/−3
Setup.hs view
@@ -8,10 +8,11 @@ -fno-warn-name-shadowing #-} -import Prelude hiding (catch)+import Prelude import qualified Prelude as P -import Control.Exception+import qualified Control.Exception as Exc+import Control.Monad (when) import Data.List @@ -24,6 +25,7 @@ import Distribution.Verbosity import System.Environment+import System.Exit (ExitCode (..)) import System.Directory import System.FilePath @@ -41,11 +43,12 @@ args' <- case args of "configure" : _ -> do- args_ <- catch (configure args buildOS) $ \exc -> do+ notice normal ("OS and Arch are " ++ show buildOS ++ " " ++ show buildArch)+ args_ <- Exc.catch (configure verbose args buildOS) $ \exc -> do warn normal $ "Could not find a JDK. Continuing anyway.\n" ++ "The error is: "- ++ ((show :: SomeException -> String) exc)+ ++ ((show :: Exc.SomeException -> String) exc) return $ args ++ ["--extra-include-dirs=./include", "--ghc-option=-optc-DFFIJNI_LIBJVM=!404!"]@@ -181,7 +184,7 @@ "" -> "" -configure args OSX = do+configure verb args OSX = do -- In Mac OS X there is the tool /usr/libexec/java_home which tells -- us where JRE and JDK are installed. @@ -194,34 +197,43 @@ libjvmPath <- getEnvironment >>= return . lookup "FFIJNI_LIBJVM" >>= maybe (return $ javaHome ++ "/jre/lib/server/libjvm.dylib") return - notice normal $ "JAVA_HOME=" ++ javaHome- notice normal $ "FFIJNI_LIBJVM=" ++ libjvmPath+ notice verb $ "JAVA_HOME=" ++ javaHome+ notice verb $ "FFIJNI_LIBJVM=" ++ libjvmPath return $ args ++ ["--extra-include-dirs=" ++ javaHome ++ "/include", "--extra-include-dirs=" ++ javaHome ++ "/include/darwin", "--ghc-option=-optc-DFFIJNI_LIBJVM=" ++ libjvmPath] -configure args Linux = do+configure verb args Linux = do -- In Linux we find out where javac lives and resolve all -- symlinks until we find the JDK home. - javaHome <- findExecutable "javac"- >>= maybe (fail "Could not determine path to javac.") return- >>= resolve >>= return . takeDirectory . takeDirectory+ let lookupJavac = findExecutable "javac"+ >>= maybe (fail "Could not determine path to javac. Try setting JAVA_HOME.") return+ >>= resolve >>= return . takeDirectory . takeDirectory - rawSystemExit normal "javac" ["GetProperty.java"]+ javaHome <- getEnvironment >>= return . lookup "JAVA_HOME"+ >>= maybe lookupJavac return - javaArch <- rawSystemStdout normal "java" ["GetProperty", "os.arch"]+ when (verb >= deafening) $ do+ getDirectoryContentsRecursive javaHome >>= mapM_ (debug verb)++ rawSystemExitCode normal (javaHome ++ "/bin/javac") ["GetProperty.java"]+ >>= (\exit -> case exit of+ ExitSuccess -> return ()+ ExitFailure code -> fail $ "javac exited with ExitCode " ++ show code)++ javaArch <- rawSystemStdout normal (javaHome ++ "/bin/java") ["GetProperty", "os.arch"] >>= return . head . lines - notice normal $ "os.arch is " ++ javaArch+ notice verb $ "os.arch is " ++ javaArch libjvmPath <- getEnvironment >>= return . lookup "FFIJNI_LIBJVM" >>= maybe (return $ javaHome ++ "/jre/lib/" ++ javaArch ++ "/server/libjvm.so") return - notice normal $ "JAVA_HOME=" ++ javaHome- notice normal $ "FFIJNI_LIBJVM=" ++ libjvmPath+ notice verb $ "JAVA_HOME=" ++ javaHome+ notice verb $ "FFIJNI_LIBJVM=" ++ libjvmPath findFirstFile id [javaHome ++ "/include/jni.h"] >>= maybe (fail $ "jni.h was not found in " ++ javaHome ++ "/include")@@ -232,7 +244,7 @@ "--ghc-option=-optc-DFFIJNI_LIBJVM=" ++ libjvmPath] -configure args Windows = do+configure verb args Windows = do -- The strategy for finding a JDK in Windows is rather simplistic. -- Typically the JDK is installed in %ProgramFiles%/Java, so we look -- into that directory for directories starting with @jdk@. We choose@@ -247,8 +259,8 @@ >>= maybe (return $ javaHome ++ "\\jre\\bin\\server\\jvm.dll") return >>= return . replace '\\' '/' - notice normal $ "JAVA_HOME=" ++ javaHome- notice normal $ "FFIJNI_LIBJVM=" ++ libjvmPath+ notice verb $ "JAVA_HOME=" ++ javaHome+ notice verb $ "FFIJNI_LIBJVM=" ++ libjvmPath findFirstFile id [javaHome ++ "/include/jni.h"] >>= maybe (fail $ "jni.h was not found in " ++ javaHome ++ "/include")@@ -258,7 +270,8 @@ "--extra-include-dirs=" ++ javaHome ++ "/include/win32", "--ghc-option=-optc-DFFIJNI_LIBJVM=" ++ libjvmPath] -configure args _ = do+configure verb args os = do+ warn verb $ "Unknown platform: " ++ show os -- default, nothing return args
java-bridge.cabal view
@@ -1,5 +1,5 @@ name: java-bridge-version: 0.20130606.1+version: 0.20130606.2 license: MIT license-file: LICENSE@@ -155,8 +155,8 @@ Library- cc-options: -DFFIJNI_BRIDGE_VERSION="0.20130606.1"- cpp-options: -DFFIJNI_BRIDGE_VERSION="0.20130606.1"+ cc-options: -DFFIJNI_BRIDGE_VERSION="0.20130606.2"+ cpp-options: -DFFIJNI_BRIDGE_VERSION="0.20130606.2" build-depends: base >= 4.5 && < 5 , directory >= 1.1.0.2