Permalink
Browse files

Build separate libraries for VSGI implementations

Organize sources in multiple folders to simplify the build and reduce
dependencies.

 - isolate the use of 'fcgi.h' for 'vsgi-fastcgi'
 - isolate the use of 'gio-unix-2.0' for 'vsgi-cgi'
 - provide a pkg-config file for each implementation

Each VSGI implementation is built as a 'TypeModule' and define the
'plugin_init' symbol to load its 'Server' implementation. This will be
used along with the loader described in #130.

Rename 'Soup' for 'HTTP' to avoid a *dirty* namespace conflict.

Extract the test implementation of VSGI under the name of 'VSGI.Mock'.
  • Loading branch information...
arteymix committed Jan 10, 2016
1 parent ecd5d36 commit 4bcfbde867f23bac204a0f545c8b2da632a262c4
Showing with 376 additions and 202 deletions.
  1. +1 −1 README.md
  2. +1 −2 data/vsgi.pc.in
  3. +3 −3 docs/application.rst
  4. +0 −8 docs/extras/index.rst
  5. +7 −23 docs/getting-started.rst
  6. +2 −0 docs/recipes/index.rst
  7. +1 −1 docs/recipes/persistence.rst
  8. +2 −2 docs/recipes/scripting.rst
  9. +1 −1 docs/vsgi/connection.rst
  10. +1 −1 docs/vsgi/index.rst
  11. +4 −4 docs/vsgi/server/{soup.rst → http.rst}
  12. +1 −1 docs/vsgi/server/index.rst
  13. +1 −1 examples/api-interaction/app.vala
  14. +0 −1 examples/api-interaction/wscript
  15. +1 −1 examples/app/app.vala
  16. +0 −1 examples/app/wscript
  17. +0 −1 examples/cgi/wscript
  18. +0 −1 examples/fastcgi/wscript
  19. +1 −1 examples/genie/app.gs
  20. +0 −1 examples/genie/wscript
  21. +1 −1 examples/json/app.vala
  22. +0 −1 examples/json/wscript
  23. +1 −1 examples/lua/app.vala
  24. +12 −0 examples/lua/wscript
  25. +0 −10 examples/lua/wscript_build
  26. +0 −3 examples/lua/wscript_configure
  27. +1 −1 examples/markdown/app.vala
  28. +1 −1 examples/markdown/wscript
  29. +1 −1 examples/memcached/app.vala
  30. +1 −1 examples/memcached/wscript
  31. +1 −2 examples/scgi/wscript
  32. 0 src/{ → valum}/valum-negociate.vala
  33. 0 src/{ → valum}/valum-route.vala
  34. 0 src/{ → valum}/valum-router.vala
  35. 0 src/{ → valum}/valum-server-sent-events.vala
  36. 0 src/{ → valum}/valum-status.vala
  37. 0 src/{ → valum}/valum-subdomain.vala
  38. 0 src/{ → valum}/valum.vala
  39. +15 −0 src/valum/wscript
  40. +11 −0 src/vsgi-cgi/vsgi-cgi.pc.in
  41. +1 −1 src/{ → vsgi-cgi}/vsgi-cgi.vala
  42. +24 −0 src/vsgi-cgi/wscript
  43. 0 {vapi → src/vsgi-fastcgi}/fcgi.deps
  44. 0 {vapi → src/vsgi-fastcgi}/fcgi.vapi
  45. +11 −0 src/vsgi-fastcgi/vsgi-fastcgi.pc.in
  46. +9 −3 src/{ → vsgi-fastcgi}/vsgi-fastcgi.vala
  47. +27 −0 src/vsgi-fastcgi/wscript
  48. +10 −0 src/vsgi-http/vsgi-http.pc.in
  49. +27 −20 src/{vsgi-soup.vala → vsgi-http/vsgi-http.vala}
  50. +24 −0 src/vsgi-http/wscript
  51. +11 −0 src/vsgi-mock/vsgi-mock.pc.in
  52. +3 −3 tests/vsgi-test.vala → src/vsgi-mock/vsgi-mock.vala
  53. +23 −0 src/vsgi-mock/wscript
  54. +10 −0 src/vsgi-scgi/vsgi-scgi.pc.in
  55. +7 −0 src/{ → vsgi-scgi}/vsgi-scgi.vala
  56. +23 −0 src/vsgi-scgi/wscript
  57. 0 src/{ → vsgi}/vsgi-chunked-encoder.vala
  58. 0 src/{ → vsgi}/vsgi-converted-request.vala
  59. 0 src/{ → vsgi}/vsgi-converted-response.vala
  60. 0 src/{ → vsgi}/vsgi-cookies.vala
  61. 0 src/{ → vsgi}/vsgi-filtered-request.vala
  62. 0 src/{ → vsgi}/vsgi-filtered-response.vala
  63. 0 src/{ → vsgi}/vsgi-request.vala
  64. 0 src/{ → vsgi}/vsgi-response.vala
  65. 0 src/{ → vsgi}/vsgi-server.vala
  66. 0 src/{ → vsgi}/vsgi.vala
  67. +46 −0 src/vsgi/wscript
  68. +20 −0 src/wscript
  69. +5 −5 tests/cgi-test.vala
  70. +1 −1 tests/cookies-test.vala
  71. +4 −4 tests/fastcgi-test.vala
  72. +3 −3 tests/{soup-test.vala → http-test.vala}
  73. +1 −1 tests/negociate-test.vala
  74. +1 −1 tests/route-test.vala
  75. +1 −1 tests/router-test.vala
  76. +1 −1 tests/scgi-test.vala
  77. +1 −1 tests/server-sent-events-test.vala
  78. +1 −1 tests/subdomain-test.vala
  79. +1 −2 tests/wscript
  80. +0 −3 vapi/wscript_build
  81. +8 −74 wscript
@@ -10,7 +10,7 @@ Valum is a web micro-framework entirely written in the
```vala
using Valum;
using VSGI.Soup;
using VSGI.HTTP;
var app = new Router ();
@@ -7,7 +7,6 @@ Name: VSGI
Description: Interface and implementations for various web server technologies
URL: https://github.com/valum-framework/valum
Version: @VERSION@
Requires: glib-2.0 gio-2.0 gthread-2.0 libsoup-2.4
Requires: glib-2.0 gio-2.0 libsoup-2.4
Libs: -L${libdir} -lvsgi
Libs.private: -L${libdir} -lfcgi
Cflags: -I${includedir}/vsgi
@@ -14,7 +14,7 @@ a ``using`` statement as they all respect a common interface.
.. code:: vala
using Valum;
using VSGI.Soup; // or VSGI.FastCGI
using VSGI.HTTP; // or VSGI.FastCGI
Many implementations are provided and documented in :doc:`vsgi/server/index`.
@@ -55,8 +55,8 @@ Serving the application
-----------------------
This part is pretty straightforward: you create a server that will serve your
application at port ``3003`` and since ``using VSGI.Soup`` was specified,
``Server`` refers to :doc:`vsgi/server/soup`.
application at port ``3003`` and since ``using VSGI.HTTP`` was specified,
``Server`` refers to :doc:`vsgi/server/http`.
.. code:: vala

This file was deleted.

Oops, something went wrong.
@@ -27,7 +27,7 @@ the latest changes in the framework.
.. code:: vala
using Valum;
using VSGI.Soup;
using VSGI.HTTP;
var app = new Router ();
@@ -48,22 +48,6 @@ pretty much what you think is the best for your needs.
build/
src/
app.vala
vapi/
ctpl.vala
fcgi.vala
VAPI bindings
-------------
`CTPL`_ and `FastCGI`_ are not providing Vala bindings, so you need to copy
them in your project ``vapi`` folder. They are included in Valum's
`vapi folder`_ and you can also find more VAPIs in `nemequ/vala-extra-vapis`_
GitHub repository.
.. _CTPL: http://ctpl.tuxfamily.org
.. _FastCGI: http://www.fastcgi.com/drupal/
.. _vapi folder: https://github.com/antono/valum/tree/master/vapi
.. _nemequ/vala-extra-vapis: https://github.com/nemequ/vala-extra-vapis
Building manually
-----------------
@@ -74,13 +58,13 @@ locations, so this wont be necessary.
.. code-block:: bash
valac --pkg valum --vapidir=vapi
valac --pkg=valum --pkg=vsgi-http --vapidir=vapi
-X -I/usr/local/include/valum -X -lvalum # compiler options
src/app.vala
-o build/app
# if installed in default location /usr
valac --pkg valum --vapidir=vapi src/app.vala -o build/app
valac --pkg=valum --pkg=vsgi-http --vapidir=vapi src/app.vala -o build/app
Building with waf
-----------------
@@ -101,15 +85,15 @@ at the root of your project.
def configure(cfg):
cfg.load('compiler_c vala')
cfg.check_cfg(package='valum', uselib_store='VALUM', args='--libs --cflags')
cfg.check_cfg(package='vsgi-http', uselib_store='VSGI_HTTP', args='--libs --cflags')
def build(bld):
bld.load('vala')
bld.program(
packages = ['valum'],
packages = ['valum', 'vsgi-http'],
target = 'app',
source = 'src/app.vala',
use = 'VALUM'
vapi_dirs = ['vapi'])
use = 'VALUM VSGI_HTTP')
You should now be able to build by issuing the following commands:
@@ -124,7 +108,7 @@ Running the example
VSGI produces process-based applications that are either self-hosted or able to
communicate with a HTTP server according to a standardized protocol.
The :doc:`vsgi/server/soup` implementation is self-hosting, so you just have to
The :doc:`vsgi/http/soup` implementation is self-hosting, so you just have to
run it and point your browser at http://127.0.0.1:3003 to see the result.
.. code-block:: bash
@@ -6,6 +6,8 @@ their potential integration with Valum.
.. toctree::
configuration
json
persistence
static-resource
scripting
@@ -30,7 +30,7 @@ maintained in nemequ/vala-extra-vapis GitHub repository.
.. code:: vala
using Valum;
using VSGI.Soup;
using VSGI.HTTP;
var app = new Router ();
var memcached = new Memcached.Context ();
@@ -20,7 +20,7 @@ Lua
.. code:: vala
using Valum;
using VSGI.Soup;
using VSGI.HTTP;
using Lua;
var app = new Router ();
@@ -41,7 +41,7 @@ Lua
writer.put_string (lua.do_file ("scripts/hello.lua"));
});
new Soup (app).run ();
new Server ("org.valum.example.Lua", app).run ();
The sample Lua script contains:
@@ -22,7 +22,7 @@ require the status to be part of the response headers.
.. code::
using VSGI.Soup;
using VSGI.HTTP;
new Server ("org.vsgi.App", (req, res) => {
var message = req.connection.output_stream;
@@ -30,7 +30,7 @@ a :doc:`request` and a :doc:`response`.
.. code:: vala
using VSGI.Soup;
using VSGI.HTTP;
new Server ("org.vsgi.App", (req, res) => {
// process the request and produce the response...
@@ -1,5 +1,5 @@
libsoup-2.4 built-in server
============================
HTTP
====
libsoup-2.4 provides a `built-in HTTP server`_ that you can use to test your
application or spawn workers in production.
@@ -9,9 +9,9 @@ application or spawn workers in production.
.. code:: vala
using Valum;
using VSGI.Soup;
using VSGI.HTTP;
new Server ("org.vsgi.Soup", () => {
new Server ("org.vsgi.HTTP", () => {
res.status = Soup.Status.OK;
res.body.write_all ("Hello world!".data, null);
}).run ({"app", "--port", "3003"});
@@ -8,7 +8,7 @@ host environment.
.. toctree::
:caption: Table of Contents
soup
http
cgi
fastcgi
scgi
@@ -16,7 +16,7 @@
*/
using Valum;
using VSGI.Soup;
using VSGI.HTTP;
var app = new Router ();
@@ -9,5 +9,4 @@ def build(bld):
target = 'app',
source = 'app.vala',
use = 'valum JSON CTPL',
vapi_dirs = '../../vapi',
install_path = None)
@@ -17,7 +17,7 @@
using Valum;
using Valum.ServerSentEvents;
using VSGI.Soup;
using VSGI.HTTP;
var app = new Router ();
@@ -12,5 +12,4 @@ def build(bld):
target = 'app',
source = ['app.vala', 'view.vala', 'app.gresource.xml'],
use = 'valum CTPL GEE',
vapi_dirs = '../../vapi',
install_path = None)
@@ -8,5 +8,4 @@ def build(bld):
target = 'cgi-bin/app.cgi',
use = 'valum',
source = ['app.vala'],
vapi_dirs = '../../vapi',
install_path = None)
@@ -8,6 +8,5 @@ def build(bld):
target = 'fastcgi',
use = 'valum',
source = ['app.vala'],
vapi_dirs = '../../vapi',
install_path = None)
@@ -4,7 +4,7 @@ init
app.get ("", home)
new VSGI.Soup.Server ("org.valum.example.Genie", app.handle).run ({"app", "--all"})
new VSGI.HTTP.Server ("org.valum.example.Genie", app.handle).run ({"app", "--all"})
def home (req : VSGI.Request, res : VSGI.Response) raises IOError
res.body.write_all ("Hello world!".data, null)
@@ -8,5 +8,4 @@ def build(bld):
target = 'app',
source = 'app.gs',
use = 'valum',
vapi_dirs = '../../vapi',
install_path = None)
@@ -16,7 +16,7 @@
*/
using Valum;
using VSGI.Soup;
using VSGI.HTTP;
var app = new Router ();
@@ -9,5 +9,4 @@ def build(bld):
target = 'app',
use = 'valum JSON',
source = 'app.vala',
vapi_dirs = '../../vapi',
install_path = None)
@@ -17,7 +17,7 @@
using Lua;
using Valum;
using VSGI.Soup;
using VSGI.HTTP;
var app = new Router ();
var vm = new LuaVM ();
@@ -0,0 +1,12 @@
#!/usr/bin/env python
def configure(cfg):
cfg.check_cfg(package='luajit', uselib_store='LUA', args='--cflags --libs')
def build(bld):
bld.program(
packages = 'lua',
target = 'app',
source = 'app.vala',
use = 'valum LUA',
install_path = None)

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -1,6 +1,6 @@
using Markdown;
using Valum;
using VSGI.Soup;
using VSGI.HTTP;
var app = new Router ();
@@ -9,5 +9,5 @@ def build(bld):
target = 'app',
source = 'app.vala',
use = 'valum MARKDOWN',
vapi_dirs = ['vapi', '../../vapi'],
vapi_dirs = 'vapi',
install_path = None)
@@ -16,7 +16,7 @@
*/
using Valum;
using VSGI.Soup;
using VSGI.HTTP;
var app = new Router ();
var memcached = new Memcached.Context.from_configuration ("--SERVER=localhost".data);
@@ -9,5 +9,5 @@ def build(bld):
target = 'app',
source = 'app.vala',
use = 'valum MEMCACHED',
vapi_dirs = ['vapi', '../../vapi'],
vapi_dirs = 'vapi',
install_path = None)
@@ -7,6 +7,5 @@ def build(bld):
bld.program(
target = 'app',
use = 'valum',
source = ['app.vala'],
vapi_dirs = '../../vapi',
source = 'app.vala',
install_path = None)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,15 @@
#!/usr/bin/env python
def configure(cfg):
pass
def build(bld):
from waflib import Context
bld.shlib(
target = 'valum',
gir = 'Valum-{}'.format(Context.g_module.API_VERSION),
source = bld.path.ant_glob('*.vala'),
use = 'vsgi',
header_path = '${INCLUDEDIR}/valum',
install_path = '${LIBDIR}')
@@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: VSGI.CGI
Description: CGI implementation for VSGI
URL: https://github.com/valum-framework/valum
Version: @VERSION@
Libs: -L${libdir} -lvsgi-cgi
Cflags: -I${includedir}/vsgi
@@ -142,7 +142,7 @@ namespace VSGI.CGI {
protected override uint8[]? build_head () {
var head = new StringBuilder ();
head.append_printf ("Status: %u %s\r\n", status, global::Soup.Status.get_phrase (status));
head.append_printf ("Status: %u %s\r\n", status, Status.get_phrase (status));
this.headers.foreach ((k, v) => {
head.append_printf ("%s: %s\r\n", k, v);
Oops, something went wrong.

0 comments on commit 4bcfbde

Please sign in to comment.