git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: add support for 'psc-package' tool (as the default)
3aa71c3Andy Arvanitis
pcc/Main.hs+1
@@ -78,6 +78,7 @@ compile :: PCCMakeOptions -> IO ()
78compile PCCMakeOptions{..} = do
78compile PCCMakeOptions{..} = do
79 input <- globWarningOnMisses (unless pccmJSONErrors . warnFileTypeNotFound) pccmInput
79 input <- globWarningOnMisses (unless pccmJSONErrors . warnFileTypeNotFound) pccmInput
80 when (null input && not pccmJSONErrors) $ do
80 when (null input && not pccmJSONErrors) $ do
81+ generatePackagefile
81 generateMakefile
82 generateMakefile
82 exitSuccess
83 exitSuccess
83 moduleFiles <- readInput input
84 moduleFiles <- readInput input
pcc/Makefile+9−11
@@ -15,7 +15,7 @@
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#
17PCC := {bin/pcc} # example: /usr/local/bin/pcc
17PCC := {bin/pcc} # example: /usr/local/bin/pcc
18−PURESCRIPT_PKGS := packages # example: bower_components
18+PURESCRIPT_PKGS := .psc-package
19PURESCRIPT_SRC := src
19PURESCRIPT_SRC := src
20OUTPUT := output
20OUTPUT := output
21BIN := main
21BIN := main
@@ -33,9 +33,6 @@ endif
33DEBUG := "-DDEBUG -g"
33DEBUG := "-DDEBUG -g"
34RELEASE := "-O3 -flto"
34RELEASE := "-O3 -flto"
35
35
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−
39INCLUDES := -I $(OUTPUT)
36INCLUDES := -I $(OUTPUT)
40BIN_DIR := $(OUTPUT)/bin
37BIN_DIR := $(OUTPUT)/bin
41
38
@@ -45,15 +42,16 @@ release: codegen
45debug: codegen
42debug: codegen
46 @$(MAKE) $(BIN) CXXFLAGS+=$(DEBUG)
43 @$(MAKE) $(BIN) CXXFLAGS+=$(DEBUG)
47
44
48−release-object: codegen
45+codegen: PURESCRIPT_PKG_SRCS=$(shell find $(PURESCRIPT_PKGS) -name '*.purs' | grep -v \/test\/ | grep -v \/example\/ | grep -v \/examples\/)
49− @$(MAKE) $(OBJ) CXXFLAGS+=$(RELEASE)
46+codegen: PURESCRIPT_SRCS=$(shell find $(PURESCRIPT_SRC) -name '*.purs')
50−
47+#
51−debug-object: codegen
52− @$(MAKE) $(OBJ) CXXFLAGS+=$(DEBUG)
53−
54−codegen:
48+codegen: .psc-package
55 @$(PCC) $(PCCFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
49 @$(PCC) $(PCCFLAGS) --output $(OUTPUT) $(PURESCRIPT_PKG_SRCS) $(PURESCRIPT_SRCS)
56
50
51+.psc-package:
52+ @echo "Getting packages using 'psc-package'..."
53+ @-psc-package update
54+
57SRCS := $(shell find $(OUTPUT) 2>/dev/null -name '*.cc')
55SRCS := $(shell find $(OUTPUT) 2>/dev/null -name '*.cc')
58
56
59OBJS = $(SRCS:.cc=.o)
57OBJS = $(SRCS:.cc=.o)
pcc/Makefile.hs+16−2
@@ -29,14 +29,28 @@ generateMakefile = do
29 let makefile = $(embedFile "pcc/Makefile")
29 let makefile = $(embedFile "pcc/Makefile")
30 exePath <- getExecutablePath
30 exePath <- getExecutablePath
31 putStrLn ""
31 putStrLn ""
32− putStrLn "Generating Makefile..."
32+ putStrLn $ "Generating Makefile... " ++ "pcc executable location " ++ exePath
33− putStrLn $ "pcc executable location: " ++ exePath
34 writeFile "Makefile" $ replace makefile pccPath exePath
33 writeFile "Makefile" $ replace makefile pccPath exePath
35 putStrLn "Done"
34 putStrLn "Done"
35+ putStrLn ""
36 putStrLn "Run 'make' or 'make release' to build an optimized release build."
36 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 ""
37 putStrLn "The resulting binary executable will be located in output/bin (by default)."
40 putStrLn "The resulting binary executable will be located in output/bin (by default)."
38 putStrLn ""
41 putStrLn ""
39
42
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+
40replace :: B.ByteString -> B.ByteString -> String -> String
54replace :: B.ByteString -> B.ByteString -> String -> String
41replace s orig repl = replace'
55replace s orig repl = replace'
42 where
56 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+}