git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: add PSC_PACKAGE variable to Makefile
commit69cb2e45a47276b77728139409b08105727b5c8f authorAndy Arvanitis <andyarvanitis@gmail.com> dateFri 18 Nov 2016, 11:02 (10 years ago) parent68078bf
2 files changed+15−17
pcc/Makefile+6−5 pcc/Makefile.hs+9−12
pcc/Makefile+6−5
@@ -14,7 +14,8 @@
1414#
1515# You can also edit the generated version of this file directly.
1616#
17−PCC := {bin/pcc} # example: /usr/local/bin/pcc
17+PCC := {{path}}/pcc
18+PSC_PACKAGE := psc-package
1819PURESCRIPT_PKGS := .psc-package
1920PURESCRIPT_SRC := src
2021OUTPUT := output
@@ -51,12 +52,12 @@ debug-object: codegen
5152codegen: PURESCRIPT_PKG_SRCS=$(shell find $(PURESCRIPT_PKGS) -name '*.purs' | grep -v \/test\/ | grep -v \/example\/ | grep -v \/examples\/)
5253codegen: PURESCRIPT_SRCS=$(shell find $(PURESCRIPT_SRC) -name '*.purs')
5354#
54−codegen: .psc-package
55+codegen: $(PURESCRIPT_PKGS)
5556 @$(PCC) $(PCCFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
5657
57−.psc-package:
58− @echo "Getting packages using 'psc-package'..."
59− @-psc-package update
58+$(PURESCRIPT_PKGS):
59+ @echo "Getting packages using" $(PSC_PACKAGE) "..."
60+ @$(PSC_PACKAGE) update
6061
6162SRCS := $(shell find $(OUTPUT) 2>/dev/null -name '*.cc')
6263
pcc/Makefile.hs+9−12
@@ -19,7 +19,9 @@ import Control.Monad (when)
1919import Data.FileEmbed (embedFile)
2020import System.Environment (getExecutablePath)
2121import System.Directory (doesFileExist)
22+import System.FilePath (takeDirectory)
2223
24+import qualified Data.Text as T
2325import qualified Data.ByteString.Char8 as B
2426
2527generateMakefile :: IO ()
@@ -30,7 +32,11 @@ generateMakefile = do
3032 exePath <- getExecutablePath
3133 putStrLn ""
3234 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)
3440 putStrLn "Done"
3541 putStrLn ""
3642 putStrLn "Run 'make' or 'make release' to build an optimized release build."
@@ -51,14 +57,5 @@ generatePackagefile = do
5157 putStrLn "Done"
5258 putStrLn "Use the 'psc-package' utility to install or update packages."
5359
54−replace :: B.ByteString -> B.ByteString -> String -> String
55−replace s orig repl = replace'
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}"
60+pathPlaceholder :: T.Text
61+pathPlaceholder = "{{path}}"