@@ -19,7 +19,9 @@ import Control.Monad (when)
19import Data.FileEmbed (embedFile)
19import Data.FileEmbed (embedFile)
20import System.Environment (getExecutablePath)
20import System.Environment (getExecutablePath)
21import System.Directory (doesFileExist)
21import System.Directory (doesFileExist)
22+import System.FilePath (takeDirectory)
24+import qualified Data.Text as T
23import qualified Data.ByteString.Char8 as B
25import qualified Data.ByteString.Char8 as B
25generateMakefile :: IO ()
27generateMakefile :: IO ()
@@ -30,7 +32,11 @@ generateMakefile = do
30 exePath <- getExecutablePath
32 exePath <- getExecutablePath
31 putStrLn ""
33 putStrLn ""
32 putStrLn $ "Generating Makefile... " ++ "pcc executable location " ++ exePath
34 putStrLn $ "Generating Makefile... " ++ "pcc executable location " ++ exePath
33− writeFile "Makefile" $ replace makefile pccPath exePath
35+ writeFile "Makefile" . T.unpack $
38+ (T.pack $ takeDirectory exePath)
39+ (T.pack $ B.unpack makefile)
34 putStrLn "Done"
40 putStrLn "Done"
35 putStrLn ""
41 putStrLn ""
36 putStrLn "Run 'make' or 'make release' to build an optimized release build."
42 putStrLn "Run 'make' or 'make release' to build an optimized release build."
@@ -51,14 +57,5 @@ generatePackagefile = do
51 putStrLn "Done"
57 putStrLn "Done"
52 putStrLn "Use the 'psc-package' utility to install or update packages."
58 putStrLn "Use the 'psc-package' utility to install or update packages."
54−replace :: B.ByteString -> B.ByteString -> String -> String
60+pathPlaceholder :: T.Text
55−replace s orig repl = replace'
61+pathPlaceholder = "{{path}}"
58− | (p1, p2) <- B.breakSubstring orig s,
59− not (B.null p2) = B.unpack p1 ++ repl ++ trim (B.unpack p2)
60− | otherwise = B.unpack s
61− trim = drop (B.length orig)
63−pccPath :: B.ByteString