git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: add support for 'psc-package' tool (as the default)
commit3aa71c35917d4378a85a231add8e457712d5c43d authorAndy Arvanitis <andyarvanitis@gmail.com> dateMon 14 Nov 2016, 20:55 (10 years ago) parent6d14b76
4 files changed+35−13
pcc/Main.hs+1 pcc/Makefile+9−11 pcc/Makefile.hs+16−2 pcc/psc-package.json+9
pcc/Main.hs+1
@@ -78,6 +78,7 @@ compile :: PCCMakeOptions -> IO ()
7878compile PCCMakeOptions{..} = do
7979 input <- globWarningOnMisses (unless pccmJSONErrors . warnFileTypeNotFound) pccmInput
8080 when (null input && not pccmJSONErrors) $ do
81+ generatePackagefile
8182 generateMakefile
8283 exitSuccess
8384 moduleFiles <- readInput input
pcc/Makefile+9−11
@@ -15,7 +15,7 @@
1515# You can also edit the generated version of this file directly.
1616#
1717PCC := {bin/pcc} # example: /usr/local/bin/pcc
18−PURESCRIPT_PKGS := packages # example: bower_components
18+PURESCRIPT_PKGS := .psc-package
1919PURESCRIPT_SRC := src
2020OUTPUT := output
2121BIN := main
@@ -33,9 +33,6 @@ endif
3333DEBUG := "-DDEBUG -g"
3434RELEASE := "-O3 -flto"
3535
36−PURESCRIPT_PKG_SRCS := $(shell find $(PURESCRIPT_PKGS) -name '*.purs' | grep -v \/test\/ | grep -v \/example\/ | grep -v \/examples\/)
37−PURESCRIPT_SRCS := $(shell find $(PURESCRIPT_SRC) -name '*.purs')
38−
3936INCLUDES := -I $(OUTPUT)
4037BIN_DIR := $(OUTPUT)/bin
4138
@@ -45,15 +42,16 @@ release: codegen
4542debug: codegen
4643 @$(MAKE) $(BIN) CXXFLAGS+=$(DEBUG)
4744
48−release-object: codegen
49− @$(MAKE) $(OBJ) CXXFLAGS+=$(RELEASE)
50−
51−debug-object: codegen
52− @$(MAKE) $(OBJ) CXXFLAGS+=$(DEBUG)
53−
54−codegen:
45+codegen: PURESCRIPT_PKG_SRCS=$(shell find $(PURESCRIPT_PKGS) -name '*.purs' | grep -v \/test\/ | grep -v \/example\/ | grep -v \/examples\/)
46+codegen: PURESCRIPT_SRCS=$(shell find $(PURESCRIPT_SRC) -name '*.purs')
47+#
48+codegen: .psc-package
5549 @$(PCC) $(PCCFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
5650
51+.psc-package:
52+ @echo "Getting packages using 'psc-package'..."
53+ @-psc-package update
54+
5755SRCS := $(shell find $(OUTPUT) 2>/dev/null -name '*.cc')
5856
5957OBJS = $(SRCS:.cc=.o)
pcc/Makefile.hs+16−2
@@ -29,14 +29,28 @@ generateMakefile = do
2929 let makefile = $(embedFile "pcc/Makefile")
3030 exePath <- getExecutablePath
3131 putStrLn ""
32− putStrLn "Generating Makefile..."
33− putStrLn $ "pcc executable location: " ++ exePath
32+ putStrLn $ "Generating Makefile... " ++ "pcc executable location " ++ exePath
3433 writeFile "Makefile" $ replace makefile pccPath exePath
3534 putStrLn "Done"
35+ putStrLn ""
3636 putStrLn "Run 'make' or 'make release' to build an optimized release build."
37+ putStrLn "Run 'make debug' to build an executable with assertions enabled and"
38+ putStrLn "suitable for source-level debugging."
39+ putStrLn ""
3740 putStrLn "The resulting binary executable will be located in output/bin (by default)."
3841 putStrLn ""
3942
43+generatePackagefile :: IO ()
44+generatePackagefile = do
45+ pkgfileExists <- doesFileExist "psc-package.json"
46+ when (not pkgfileExists) $ do
47+ let pkgfile = $(embedFile "pcc/psc-package.json")
48+ putStrLn ""
49+ putStrLn "Generating psc-package.json..."
50+ writeFile "psc-package.json" $ B.unpack pkgfile
51+ putStrLn "Done"
52+ putStrLn "Use the 'psc-package' utility to install or update packages."
53+
4054replace :: B.ByteString -> B.ByteString -> String -> String
4155replace s orig repl = replace'
4256 where
pcc/psc-package.jsonnew file+9
@@ -0,0 +1,9 @@
1+{
2+ "name": "Main",
3+ "set": "psc-0.10.2",
4+ "source": "https://github.com/pure11/package-sets.git",
5+ "depends": [
6+ "console",
7+ "prelude"
8+ ]
9+}