Permalink
Browse files

add some more comments to the makefile

move the util to generate the exe rules to src-extra/devel-util
fix old references to building things to use the makefile style
add test for the :: cast bug #2 on github, the example there now
  parses fine
  • Loading branch information...
1 parent 997f585 commit a783a2f4a48655b7cb7cec00b7dfc4e35e9d82b5 @JakeWheat committed Oct 29, 2011
View
@@ -15,10 +15,9 @@
/src-extra/examples/TypeCheck
/src-extra/examples/TypeCheckDB
/src-extra/h7c/dist/
-/src-extra/tests/dist/
/src-extra/tosort/util/DevelTool
/src-extra/tests/Tests
/src-extra/devel-util/MakeDefaultTemplate1Catalog
-/src-extra/util/GenerateExeRules
+/src-extra/devel-util/GenerateExeRules
/src-extra/h7c/h7c
/.depend.bak
View
@@ -41,7 +41,13 @@ HC_PACKAGES = -package haskell-src-exts -package uniplate -package mtl \
HC_OPTS = $(HC_BASIC_OPTS) $(HC_INCLUDE_DIRS) $(HC_PACKAGES)
-
+# this is the list of exe files which are all compiled to check
+# nothing has been broken. It doesn't include some of the makefile
+# utilities below
+# the set of .o files for each exe, and the build rule are generated
+# by a utility (use make exe_depend) since ghc -M doesn't provide
+# the list of .o files which an .lhs for an exe needs to build
+# (ghc -M is used for all the dependencies other than the exes)
EXE_FILES = src-extra/tests/Tests \
src-extra/devel-util/MakeAntiNodesRunner \
src-extra/devel-util/MakeDefaultTemplate1Catalog \
@@ -58,7 +64,7 @@ EXE_FILES = src-extra/tests/Tests \
# src-extra/chaos/build.lhs
-# used for dependency generation
+# used for dependency generation with ghc -M
# first all the modules which are public in the cabal package
# this is all the hs files directly in the src/Database/HsSqlPpp/ folder
# then it lists the lhs for all the exe files
@@ -67,29 +73,43 @@ SRCS_ROOTS = $(shell find src/Database/HsSqlPpp/ -maxdepth 1 -iname '*hs') \
AG_FILES = $(shell find src -iname '*ag')
+# include the autogenerated rules for the exes
-include exe_rules.mk
+
+#special targets
+
+# run the tests
tests : src-extra/tests/Tests
src-extra/tests/Tests --hide-successes
+# make the website
website : src-extra/tosort/util/DevelTool
src-extra/tosort/util/DevelTool makewebsite +RTS -N
+# make the haddock and put in the correct place in the generated
+# website
website_haddock :
cabal configure
cabal haddock
mv dist/doc/html/hssqlppp hssqlppp/haddock
+# task to build the chaos sql, which takes the source sql
+# transforms it and produces something which postgres understands
CHAOS_SQL_SRC = $(shell find src-extra/chaos/sql/ -iname '*.sql')
chaos.sql : $(CHAOS_SQL_SRC) src-extra/h7c/h7c
src-extra/h7c/h7c > chaos.sql
+# targets mainly used to check everything builds ok
all : $(EXE_FILES)
more_all : all website website_haddock tests
+
+# generic rules
+
%.hi : %.o
@:
@@ -99,10 +119,11 @@ more_all : all website website_haddock tests
%.o : %.hs
$(HC) $(HC_OPTS) -c $<
+# dependency and rules for exe autogeneration:
-exe_depend : src-extra/util/GenerateExeRules.lhs Makefile
- ghc -isrc-extra/util src-extra/util/GenerateExeRules.lhs
- src-extra/util/GenerateExeRules
+exe_depend : src-extra/devel-util/GenerateExeRules.lhs Makefile
+ ghc -isrc-extra/devel-util src-extra/devel-util/GenerateExeRules.lhs
+ src-extra/devel-util/GenerateExeRules
depend :
ghc -M $(HC_OPTS) $(SRCS_ROOTS) -dep-makefile .depend
@@ -123,7 +144,6 @@ src/Database/HsSqlPpp/Internals/AstInternal.hs : $(AG_FILES)
# don't want to automatically keep this up to date, only regenerate it
# manually
-.PHONY : regenDefaultTemplate1Catalog
regenDefaultTemplate1Catalog : src-extra/devel-util/MakeDefaultTemplate1Catalog
src-extra/devel-util/MakeDefaultTemplate1Catalog > \
src/Database/HsSqlPpp/Internals/Catalog/DefaultTemplate1Catalog.lhs_new
@@ -137,5 +157,7 @@ clean :
find . -iname '*.hi' -delete
-rm chaos.sql
-rm $(EXE_FILES)
+ -rm -Rf hssqlppp
+# include the ghc -M dependencies
-include .depend
View
@@ -20,10 +20,6 @@ typechecking (enough to produce the types of most things - not looking
at adding the missing error checks for a bunch of things yet) and the
quasiquotes used in the extensions all working.
-write the make file properly, so there is one way to do every build,
-can get rid of all the lines for calling ghc in each of the exes, and
-all the different scripts and docs spread out everywhere.
-
get to the stage of being able to compile and roughly typecheck the
chaos sql again
@@ -1,6 +1,4 @@
-cd /home/jake/wd/hssqlppp/trunk/src-extra/chaos && ghc -iextensions:../extensions build.hs
-
Problems with this:
the extensions use the internals of the hssqlppp library
solution:
File renamed without changes.
@@ -15,14 +15,8 @@ for preprocessors examples for typesafe database access.
The code is quite fragile and depends on the exact style (or lack of)
of coding used in AstInternal.ag.
-Run this from ghci:
-
-change to the folder with the cabal file in
-run ghci
-enter:
-:set -isrc-extra/util:src-extra/devel-util
-:l "src-extra/devel-util/MakeAntiNodes.lhs"
-writeAntiNodes
+run using make:
+make src/Database/HsSqlPpp/Internals/AstAnti.hs
> module MakeAntiNodes (writeAntiNodes) where
>
@@ -45,13 +39,8 @@ writeAntiNodes
> preamble :: String
> preamble =
> "{-\n\
-> \This file is autogenerated, to generate: load this file (MakeAntiNodes.lhs)\n\
-> \into ghci and run:\n\
-> \n\
-> \writeAntiNodes\n\
-> \n\\n\
-> \The path might need tweaking.\n\
-> \n\
+> \This file is autogenerated, to build run\n\
+> \make src/Database/HsSqlPpp/Internals/AstAnti.hs\n\
> \-}\n"
>
> nodesToAntificate :: [String]
@@ -1,6 +1,4 @@
-ghc -i/home/jake/wd/hssqlppp/trunk/src-extra/util/:/home/jake/wd/hssqlppp/trunk/src-extra/devel-util /home/jake/wd/hssqlppp/trunk/src-extra/devel-util/MakeAntiNodesRunner.lhs
-
> import MakeAntiNodes
> main :: IO ()
View
@@ -163,6 +163,3 @@ parse configuration file:
To use this, want to compile the source in extension-source-dirs to
dll then dlopen the dll to get the function mentioned in extensions
or/ some other approach to load the code at compile time?
-
-
-cd /home/jake/wd/hssqlppp/trunk/ && ghc -Wall -XTupleSections -XScopedTypeVariables -XDeriveDataTypeable -isrc:src-extra/util:src-extra/tests/:src-extra/extensions:src-extra/h7c:src-extra/chaos/extensions src-extra/h7c/h7c
@@ -48,7 +48,14 @@
> (sl (selIL ["a"]))
> [Tref ea (i "t") (NoAlias ea)]
> Nothing [] Nothing [] (Just (NumberLit ea "10")) Nothing]-}
-
+> ,s "select t.a::int from table as t;"
+> [QueryStatement ea
+> (Select ea Dupes
+> (SelectList ea
+> [SelExp ea (Cast ea (QIdentifier ea [Nmc "t",Nmc "a"])
+> (SimpleTypeName ea "int"))])
+> [Tref ea (Name ea [Nmc "table"]) (TableAlias ea (Nmc "t"))]
+> Nothing [] Nothing [] Nothing Nothing)]
> ]
>
@@ -26,5 +26,3 @@ type inference tests
> main :: IO ()
> main = defaultMain allTests
-
-cd /home/jake/wd/hssqlppp/trunk/ && make && ghc -Wall -XTupleSections -XScopedTypeVariables -XDeriveDataTypeable -isrc:src-extra/util:src-extra/tests/ src-extra/tests/Tests.lhs
@@ -1,11 +1,7 @@
-Make the website,
-To compile, use something like:
-
-time ghc -threaded -XDeriveDataTypeable -DPOSTGRES -cpp -pgmPcpphs -optP--cpp -idevel:src:examples/chaos:examples/extensions/:examples/util/:tests/ --make devel/DevelTool
-
-cd /home/jake/wd/hssqlppp/trunk && ghc -XTupleSections -XScopedTypeVariables -XDeriveDataTypeable -isrc:src-extra/examples:src-extra/tests:src-extra/util:src-extra/tosort/util src-extra/tosort/util/DevelTool.lhs -rtsopts -threaded
+Used to build the website. To compile and run use
+make website
> import System.Environment
@@ -1,10 +1,7 @@
-Make the website,
-To compile and run, use something like:
+Used to build the website. To compile and run use
-ghc --make -threaded -XScopedTypeVariables -XDeriveDataTypeable -XTupleSections -DPOSTGRES -cpp -pgmPcpphs -optP--cpp -iutil:src/lib:src/qq:src/postgresql:examples/chaos:examples/extensions/:examples/util/:tests/ --make util/DevelTool.lhs -rtsopts
-
-time util/DevelTool makewebsite +RTS -N
+make website
> module MakeWebsite (makeWebsite, sourceLinks) where
@@ -1,9 +1,7 @@
{-
-This file is autogenerated, to generate: load this file (MakeAntiNodes.lhs)
-into ghci and run:
-nwriteAntiNodes
-n\nThe path might need tweaking.
-n-}
+This file is autogenerated, to build run
+make src/Database/HsSqlPpp/Internals/AstAnti.hs
+-}
{-# LANGUAGE DeriveDataTypeable #-}
module Database.HsSqlPpp.Internals.AstAnti
(convertStatements, convertScalarExpr, attributeDef, queryExpr,
@@ -16,28 +16,9 @@ These ast nodes are both used as the result of successful parsing, and
as the input to the type checker (and the output from the type
checker), and the pretty printer.
-= compiling
+see here for how to compile:
-use
-
-uuagc -dcfwsp --cycle --genlinepragmas AstInternal.ag
-
-to generate a new AstInternal.hs from this file (cycle will check for
-cycles - it's bad if you get any of these, and genlinepragmas mean
-that you'll be able to view the original source ag positions when
-there are errors or warnings compiling the generated hs file, which
-you want much more often than not).
-
-Depending on the alignment of the planets, you might need to use
-
-uuagc -dcfwsp AstInternal.ag
-
-At the moment, genlinepragmas seems to break when you use where with
-uuagc > 0.9.19.
-
-(install uuagc with
-cabal install uuagc
-)
+http://jakewheat.github.com/hssqlppp/devel.txt.html
-}
View
13 todo
@@ -1,7 +1,3 @@
-checklist for 0.4.0
-haddock
-website review
-
= next release, 0.5.0
see bigplan for some details
@@ -18,6 +14,15 @@ start thinking about how to support both postgresql and sql server better
syntactically possible because of the design of the ast types,
but don't represent valid concrete syntax
+idea for :: cast
+
+-> parse typenames as scalarexpressions by embeddeding them in
+ numberlits (hacky but should be unambiguous)
+then transform to cast after parsing. This can then use the proper
+precedence in buildExpressionParser to parse ::. Also produce parse
+errors if after parsing, you try to cast to something which isn't a
+typename
+
= 'arcs'
== names
@@ -60,9 +60,8 @@ Now check the test fails.
~~~~
-$ cd src-extra/tests
-$ ghc -XTupleSections -XScopedTypeVariables -XDeriveDataTypeable -i../../src:../util Tests.lhs
-$ ./Tests -t "numeric"
+$ make src-extra/tests/Tests
+$ src-extra/tests/Tests -t "numeric"
parserTests:
parse expressions:
simple operators:
View
@@ -23,13 +23,22 @@ Rebuild the generated files for the syntax
==========================================
If you edit the ag files, you need to rebuild the AstInternal.hs and
-the AstAnti.hs. Use the makefile:
+the AstAnti.hs. First make sure you have uuagc installed:
+
+~~~~~
+cabal install uuagc
+~~~~~
+
+Then use the makefile:
~~~~~
make src/Database/HsSqlPpp/Internals/AstAnti.hs
~~~~~
-The makefile hasn't been heavily tested yet.
+The makefile hasn't been heavily tested yet. If you have any problems
+with unrecognised modules, the complete list of packages referenced is
+in the Makefile (it may be missing build tools, such as cpphs, this
+hasn't been checked yet).
To just rebuild the library in the usual way after editing the ag
files use:
@@ -40,7 +49,7 @@ cabal build
~~~~~
There is one further generated file, DefaultTemplate1Catalog.lhs. You
-don't usually need to regenerate this:
+don't usually need to regenerate this, but this is how you do it:
~~~~~
make regenDefaultTemplate1Catalog
View
@@ -48,8 +48,8 @@ The pretty printer should support everything the parser supports
understand).
Catalog information is limited, supports the type checking. Some
-information is collected on: scalar types, domains, composite types,
-casts, tables, views and functions currently.
+information is collected on scalar types, domains, composite types,
+casts, tables, views and functions.
Installation
============

0 comments on commit a783a2f

Please sign in to comment.