Commits

Kirill Simonov committed 29c1ac3

Refactored the Makefiles.

Extracted variables to `Makefile.common`.
Added targets `demo-htraf` and `demo-ssi` to run the respective demos.
Updated demo makefiles to use variables from `Makefile.common`
and have a single target `serve`.

  • Participants
  • Parent commits 3769596

Comments (0)

Files changed (5)

 # This makefile provides various build, installation and testing tasks.
 
 .PHONY: default build install develop doc dist windist pypi \
-	test cleanup train train-ctl train-sqlite train-pgsql purge-test
+	test cleanup train train-ctl train-sqlite train-pgsql purge-test \
+	demo-htraf demo-ssi
 
 
-# Load configuration variables from `Makefile.env`.  There is a sample
-# file `Makefile.env.sample`; copy it to `Makefile.env` and edit it
-# to match your configuration.
--include Makefile.env
+# Load configuration variables from `Makefile.common`.  Do not edit
+# `Makefile` or `Makefile.common` directly, you could override any
+# parameters in `Makefile.env`.  There is a sample file `Makefile.env.sample`;
+# copy it to `Makefile.env` and edit it to match your configuration.
+include Makefile.common
 
 
 #
 	@echo "  serve-sqlite: to start an HTTP server on the SQLite test database"
 	@echo "  serve-pgsql: to start an HTTP server on the PostgreSQL test database"
 	@echo
+	@echo "  *** Demos and Examples ***"
+	@echo "  demo-htraf: to run the HTRAF demo"
+	@echo "  demo-ssi: to run the SSI demo"
+	@echo
 
 
 #
 # Shell and server tasks.
 #
 
-# The connection URI for regression databases.
-SQLITE_REGRESS_DB?=sqlite:///build/regress/regress-sqlite/htsql_regress.sqlite
-PGSQL_ADDRESS?=${PGSQL_HOST}$(if ${PGSQL_PORT},:${PGSQL_PORT})
-PGSQL_REGRESS_DB?=pgsql://htsql_regress:secret@${PGSQL_ADDRESS}/htsql_regress
-
-# The HTTP server address.
-HTSQL_HOST?=localhost
-HTSQL_PORT?=8080
-
 # Start an HTSQL shell on the SQLite regression database.
 shell-sqlite:
 	htsql-ctl shell ${SQLITE_REGRESS_DB}
 	htsql-ctl serve ${PGSQL_REGRESS_DB} ${HTSQL_HOST} ${HTSQL_PORT}
 
 
+#
+# Demos and examples.
+#
+
+# Start the HTRAF demo.
+demo-htraf:
+	cd demo/htraf; ${MAKE}
+
+# Start the SSI demo.
+demo-ssi:
+	cd demo/ssi; ${MAKE}
+
+
+# Common variables used by all makefiles.
+
+
+# Load configuration variables from `Makefile.env`.  There is a sample
+# file `Makefile.env.sample`; copy it to `Makefile.env` and edit it
+# to match your configuration.
+-include Makefile.env
+
+# The connection URI for regression databases.
+SQLITE_REGRESS_DB?=sqlite:///build/regress/regress-sqlite/htsql_regress.sqlite
+PGSQL_ADDRESS?=${PGSQL_HOST}$(if ${PGSQL_PORT},:${PGSQL_PORT})
+PGSQL_REGRESS_DB?=pgsql://htsql_regress:secret@${PGSQL_ADDRESS}/htsql_regress
+
+# The HTTP server address.
+HTSQL_HOST?=localhost
+HTSQL_PORT?=8080
+
+

demo/htraf/Makefile

-.PHONY: setup serve
+.PHONY: serve
 
-# The connection URI for regression databases.
-SQLITE_REGRESS_DB?=sqlite:///build/regress/regress-sqlite/htsql_regress.sqlite
-PGSQL_ADDRESS?=${PGSQL_HOST}$(if ${PGSQL_PORT},:${PGSQL_PORT})
-PGSQL_REGRESS_DB?=pgsql://htsql_regress:secret@${PGSQL_ADDRESS}/htsql_regress
+include ../../Makefile.common
 
-# The HTTP server address.
-HTTP_HOST?=localhost
-HTTP_PORT?=8080
+serve:
+	python serve.py ${PGSQL_REGRESS_DB} ${HTSQL_HOST} ${HTSQL_PORT}
 
-setup-pgsql:
-	cd ../../ && htsql-ctl regress -i test/regress.yaml cleanup-pgsql setup-pgsql 
-
-serve-pgsql: setup-pgsql
-	python serve.py "${PGSQL_REGRESS_DB}" ${HTTP_HOST} ${HTTP_PORT}

demo/ssi/Makefile

 .PHONY: serve
 
-include ../../Makefile
+include ../../Makefile.common
 
 serve:
 	python serve.py ${PGSQL_REGRESS_DB} ${HTSQL_HOST} ${HTSQL_PORT}

demo/ssi/serve.py

         port = int(port)
         htsql = HTSQL(db)
         app = cls(htsql)
-        print >>sys.stderr, "Starting an HTTL server on %s:%s over %s" \
+        print >>sys.stderr, "Starting an HTTP server on %s:%s over %s" \
                             % (host, port, db)
         httpd = wsgiref.simple_server.make_server(host, port, app)
         httpd.serve_forever()