forked from GitHub/gf-rgl
find the RGL folder by using gf --version
This commit is contained in:
14
Setup.bat
14
Setup.bat
@@ -37,20 +37,6 @@ if "%dest%"=="" (
|
|||||||
)
|
)
|
||||||
:BreakLibPath
|
: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%"=="" (
|
if "%dest%"=="" (
|
||||||
echo Unable to determine where to install the RGL. Please do one of the following:
|
echo Unable to determine where to install the RGL. Please do one of the following:
|
||||||
echo - Pass the --dest=... flag to this script
|
echo - Pass the --dest=... flag to this script
|
||||||
|
|||||||
15
Setup.hs
15
Setup.hs
@@ -8,7 +8,7 @@ import System.IO (hPutStrLn,stderr)
|
|||||||
import System.IO.Error (catchIOError)
|
import System.IO.Error (catchIOError)
|
||||||
import System.Exit (ExitCode(..),exitFailure)
|
import System.Exit (ExitCode(..),exitFailure)
|
||||||
import System.Environment (getArgs,lookupEnv)
|
import System.Environment (getArgs,lookupEnv)
|
||||||
import System.Process (rawSystem)
|
import System.Process (rawSystem,readProcess)
|
||||||
import System.FilePath ((</>),splitSearchPath) -- ,takeFileName,addExtension,dropExtension)
|
import System.FilePath ((</>),splitSearchPath) -- ,takeFileName,addExtension,dropExtension)
|
||||||
import System.Directory (createDirectoryIfMissing,copyFile,getDirectoryContents,removeDirectoryRecursive,findFile)
|
import System.Directory (createDirectoryIfMissing,copyFile,getDirectoryContents,removeDirectoryRecursive,findFile)
|
||||||
#if __GLASGOW_HASKELL__>=800
|
#if __GLASGOW_HASKELL__>=800
|
||||||
@@ -61,7 +61,7 @@ errLocation = unlines $
|
|||||||
[ "Unable to determine where to install the RGL. Please do one of the following:"
|
[ "Unable to determine where to install the RGL. Please do one of the following:"
|
||||||
, " - Pass the " ++ destination_flag ++ "... flag to this script"
|
, " - Pass the " ++ destination_flag ++ "... flag to this script"
|
||||||
, " - Set the GF_LIB_PATH environment variable"
|
, " - 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
|
-- | Copy single file between directories
|
||||||
@@ -116,10 +116,11 @@ data Info = Info
|
|||||||
mkInfo :: IO Info
|
mkInfo :: IO Info
|
||||||
mkInfo = do
|
mkInfo = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
|
let gf = maybe default_gf id (getFlag gf_flag args)
|
||||||
-- Look for install location in a few different places
|
-- Look for install location in a few different places
|
||||||
let mflag = getFlag destination_flag args
|
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)
|
menvar <- lookupEnv "GF_LIB_PATH" >>= return . fmap (head . splitSearchPath)
|
||||||
|
mbuilt <- catchIOError (readProcess gf ["--version"] "" >>= return . getPath) (\e -> return Nothing)
|
||||||
let
|
let
|
||||||
inst_dir =
|
inst_dir =
|
||||||
case catMaybes [mflag,menvar,mbuilt] of
|
case catMaybes [mflag,menvar,mbuilt] of
|
||||||
@@ -129,12 +130,18 @@ mkInfo = do
|
|||||||
return $ Info
|
return $ Info
|
||||||
{ infoBuildDir = "dist"
|
{ infoBuildDir = "dist"
|
||||||
, infoInstallDir = inst_dir
|
, infoInstallDir = inst_dir
|
||||||
, infoGFPath = maybe default_gf id (getFlag gf_flag args)
|
, infoGFPath = gf
|
||||||
, infoVerbose = verbose
|
, infoVerbose = verbose
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
default_gf = "gf"
|
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 -> FilePath
|
||||||
getRGLBuildDir info mode = infoBuildDir info </> getRGLBuildSubDir mode
|
getRGLBuildDir info mode = infoBuildDir info </> getRGLBuildSubDir mode
|
||||||
|
|
||||||
|
|||||||
6
Setup.sh
6
Setup.sh
@@ -38,15 +38,15 @@ done
|
|||||||
if [ -z "$dest" ]; then
|
if [ -z "$dest" ]; then
|
||||||
dest=$(echo "$GF_LIB_PATH" | sed 's/:.*$//')
|
dest=$(echo "$GF_LIB_PATH" | sed 's/:.*$//')
|
||||||
fi
|
fi
|
||||||
if [ -z "$dest" ] && [ -f "../gf-core/DATA_DIR" ]; then
|
if [ -z "$dest" ] && [ "$(gf --version | tail -1 | cut -c -14)" == "Shared folder:" ]; then
|
||||||
dest=$(cat ../gf-core/DATA_DIR)
|
dest=$(gf --version | tail -1 | cut -c 16-)/lib
|
||||||
if [ -n "$dest" ]; then dest="${dest}/lib"; fi
|
if [ -n "$dest" ]; then dest="${dest}/lib"; fi
|
||||||
fi
|
fi
|
||||||
if [ -z "$dest" ]; then
|
if [ -z "$dest" ]; then
|
||||||
echo "Unable to determine where to install the RGL. Please do one of the following:"
|
echo "Unable to determine where to install the RGL. Please do one of the following:"
|
||||||
echo " - Pass the --dest=... flag to this script"
|
echo " - Pass the --dest=... flag to this script"
|
||||||
echo " - Set the GF_LIB_PATH environment variable"
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user