diff --git a/Setup.bat b/Setup.bat index e0cc00ab..01c5c2c5 100644 --- a/Setup.bat +++ b/Setup.bat @@ -37,20 +37,6 @@ if "%dest%"=="" ( ) :BreakLibPath -set DATA_DIR=..\gf-core\DATA_DIR -if "%dest%"=="" ( - REM Look in already compiled GF folder - if exist %DATA_DIR% ( - for /f "delims=" %%x in (%DATA_DIR%) do ( - if not "%%x"=="" ( - set dest=%%x\lib - goto BreakDataDir - ) - ) - ) -) -:BreakDataDir - if "%dest%"=="" ( echo Unable to determine where to install the RGL. Please do one of the following: echo - Pass the --dest=... flag to this script diff --git a/Setup.hs b/Setup.hs index 76c21b35..4a9ad07a 100644 --- a/Setup.hs +++ b/Setup.hs @@ -8,7 +8,7 @@ import System.IO (hPutStrLn,stderr) import System.IO.Error (catchIOError) import System.Exit (ExitCode(..),exitFailure) import System.Environment (getArgs,lookupEnv) -import System.Process (rawSystem) +import System.Process (rawSystem,readProcess) import System.FilePath ((),splitSearchPath) -- ,takeFileName,addExtension,dropExtension) import System.Directory (createDirectoryIfMissing,copyFile,getDirectoryContents,removeDirectoryRecursive,findFile) #if __GLASGOW_HASKELL__>=800 @@ -61,7 +61,7 @@ errLocation = unlines $ [ "Unable to determine where to install the RGL. Please do one of the following:" , " - Pass the " ++ destination_flag ++ "... flag to this script" , " - Set the GF_LIB_PATH environment variable" - , " - Compile & install GF from the gf-core repository (must be in same directory as gf-rgl)" + , " - Compile & install GF from the gf-core repository" ] -- | Copy single file between directories @@ -116,10 +116,11 @@ data Info = Info mkInfo :: IO Info mkInfo = do args <- getArgs + let gf = maybe default_gf id (getFlag gf_flag args) -- Look for install location in a few different places let mflag = getFlag destination_flag args - mbuilt <- catchIOError (readFile "../gf-core/DATA_DIR" >>= \d -> return (Just (d "lib"))) (\e -> return Nothing) menvar <- lookupEnv "GF_LIB_PATH" >>= return . fmap (head . splitSearchPath) + mbuilt <- catchIOError (readProcess gf ["--version"] "" >>= return . getPath) (\e -> return Nothing) let inst_dir = case catMaybes [mflag,menvar,mbuilt] of @@ -129,12 +130,18 @@ mkInfo = do return $ Info { infoBuildDir = "dist" , infoInstallDir = inst_dir - , infoGFPath = maybe default_gf id (getFlag gf_flag args) + , infoGFPath = gf , infoVerbose = verbose } where default_gf = "gf" + getPath s = + let l = last (lines s) + in if take 14 l == "Shared folder:" + then Just (drop 14 l "lib") + else Nothing + getRGLBuildDir :: Info -> Mode -> FilePath getRGLBuildDir info mode = infoBuildDir info getRGLBuildSubDir mode diff --git a/Setup.sh b/Setup.sh index 6a6a7c39..7d024523 100755 --- a/Setup.sh +++ b/Setup.sh @@ -38,15 +38,15 @@ done if [ -z "$dest" ]; then dest=$(echo "$GF_LIB_PATH" | sed 's/:.*$//') fi -if [ -z "$dest" ] && [ -f "../gf-core/DATA_DIR" ]; then - dest=$(cat ../gf-core/DATA_DIR) +if [ -z "$dest" ] && [ "$(gf --version | tail -1 | cut -c -14)" == "Shared folder:" ]; then + dest=$(gf --version | tail -1 | cut -c 16-)/lib if [ -n "$dest" ]; then dest="${dest}/lib"; fi fi if [ -z "$dest" ]; then echo "Unable to determine where to install the RGL. Please do one of the following:" echo " - Pass the --dest=... flag to this script" echo " - Set the GF_LIB_PATH environment variable" - echo " - Compile & install GF from the gf-core repository (must be in same directory as gf-rgl)" + echo " - Compile & install GF from the gf-core repository" exit 1 fi