Skip to content

Commit

Permalink
add some more comments to the makefile
Browse files Browse the repository at this point in the history
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
JakeWheat committed Oct 29, 2011
1 parent 997f585 commit a783a2f
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 86 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
34 changes: 28 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand All @@ -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
@:

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
4 changes: 0 additions & 4 deletions bigplan
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions src-extra/chaos/build.lhs
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 4 additions & 15 deletions src-extra/devel-util/MakeAntiNodes.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -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
>
Expand All @@ -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]
Expand Down
2 changes: 0 additions & 2 deletions src-extra/devel-util/MakeAntiNodesRunner.lhs
Original file line number Diff line number Diff line change
@@ -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 ()
Expand Down
3 changes: 0 additions & 3 deletions src-extra/h7c/h7c.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion src-extra/tests/Database/HsSqlPpp/Tests/Parsing/Selects.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
> ]
>

Expand Down
2 changes: 0 additions & 2 deletions src-extra/tests/Tests.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 2 additions & 6 deletions src-extra/tosort/util/DevelTool.lhs
Original file line number Diff line number Diff line change
@@ -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

Expand Down
7 changes: 2 additions & 5 deletions src-extra/tosort/util/MakeWebsite.lhs
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 3 additions & 5 deletions src/Database/HsSqlPpp/Internals/AstAnti.hs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
23 changes: 2 additions & 21 deletions src/Database/HsSqlPpp/Internals/AstInternal.ag
Original file line number Diff line number Diff line change
Expand Up @@ -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

-}

Expand Down
13 changes: 9 additions & 4 deletions todo
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
checklist for 0.4.0
haddock
website review

= next release, 0.5.0

see bigplan for some details
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions website_source/adding_syntax.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 12 additions & 3 deletions website_source/devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions website_source/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
============
Expand Down

0 comments on commit a783a2f

Please sign in to comment.