git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: add PSC_PACKAGE variable to Makefile
69cb2e4Andy Arvanitis
pcc/Makefile+6−5
@@ -14,7 +14,8 @@
14#
14#
15# You can also edit the generated version of this file directly.
15# You can also edit the generated version of this file directly.
16#
16#
17−PCC := {bin/pcc} # example: /usr/local/bin/pcc
17+PCC := {{path}}/pcc
18+PSC_PACKAGE := psc-package
18PURESCRIPT_PKGS := .psc-package
19PURESCRIPT_PKGS := .psc-package
19PURESCRIPT_SRC := src
20PURESCRIPT_SRC := src
20OUTPUT := output
21OUTPUT := output
@@ -51,12 +52,12 @@ debug-object: codegen
51codegen: PURESCRIPT_PKG_SRCS=$(shell find $(PURESCRIPT_PKGS) -name '*.purs' | grep -v \/test\/ | grep -v \/example\/ | grep -v \/examples\/)
52codegen: PURESCRIPT_PKG_SRCS=$(shell find $(PURESCRIPT_PKGS) -name '*.purs' | grep -v \/test\/ | grep -v \/example\/ | grep -v \/examples\/)
52codegen: PURESCRIPT_SRCS=$(shell find $(PURESCRIPT_SRC) -name '*.purs')
53codegen: PURESCRIPT_SRCS=$(shell find $(PURESCRIPT_SRC) -name '*.purs')
53#
54#
54−codegen: .psc-package
55+codegen: $(PURESCRIPT_PKGS)
55 @$(PCC) $(PCCFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
56 @$(PCC) $(PCCFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
56
57
57−.psc-package:
58+$(PURESCRIPT_PKGS):
58− @echo "Getting packages using 'psc-package'..."
59+ @echo "Getting packages using" $(PSC_PACKAGE) "..."
59− @-psc-package update
60+ @$(PSC_PACKAGE) update
60
61
61SRCS := $(shell find $(OUTPUT) 2>/dev/null -name '*.cc')
62SRCS := $(shell find $(OUTPUT) 2>/dev/null -name '*.cc')
62
63
pcc/Makefile.hs+9−12
@@ -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)
22
23
24+import qualified Data.Text as T
23import qualified Data.ByteString.Char8 as B
25import qualified Data.ByteString.Char8 as B
24
26
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 $
36+ T.replace
37+ pathPlaceholder
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."
53
59
54−replace :: B.ByteString -> B.ByteString -> String -> String
60+pathPlaceholder :: T.Text
55−replace s orig repl = replace'
61+pathPlaceholder = "{{path}}"
56− where
57− replace'
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)
62−
63−pccPath :: B.ByteString
64−pccPath = "{bin/pcc}"