Skip to content

Commit

Permalink
Add DUB build system support.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-stromberg committed Sep 10, 2013
1 parent 6b7f937 commit be7d6af
Show file tree
Hide file tree
Showing 26 changed files with 170 additions and 1,861 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
bin
.dub
4 changes: 4 additions & 0 deletions DerelictPQ/.gitignore
@@ -0,0 +1,4 @@
lib
bin
.dub
update.txt
16 changes: 16 additions & 0 deletions DerelictPQ/package.json
@@ -0,0 +1,16 @@
{
"name": "derelict-pq",
"description": "A dynamic binding to the PostgreSQL pq library.",
"homepage": "https://github.com/DerelictOrg/DerelictPQ",
"license": "Boost",
"authors": [
"Mike Parker"
],

"targetName": "DerelictPQ",
"targetPath": "lib",

"dependencies": {
"derelict-util": "~master"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
71 changes: 54 additions & 17 deletions README.md
Expand Up @@ -27,25 +27,59 @@ Building
--------

####Requirements:
Currently code builds with libpq 9.1.0 and higher, compiler dmd 2.062.
Currently code builds with libpq 9.1.0 and higher, compiler dmd 2.062 and higher.
Bindings for libpq can be static or dynamic, compilation described below.

Instead of explicitly installing dpq2, it is now recommended to use
[DUB](https://github.com/rejectedsoftware/dub) for building dpq2 based
applications. Once DUB is installed, you can create a new project by running
`dub init <name>` and enable the use of dpq2 by adding the following
dependency to the `package.json` file in your project's directory:

{
"name": "your-project-identifier",
"dependencies": {
"dpq2": "~master"
}
}

Invoking `dub` will then automatically download the latest dpq2 and compile
and run the project.

Similarly, you can run an example by invoking `dub` from any of the
example project directories.

If you want to install dpq2 explicitly, you can use:

```sh
git clone https://github.com/denizzzka/dpq2.git
cd dpq2
```
####Static bindings
$ rdmd compile.d static [release|debug]
####Static bindings - debug version
$ dub build

####Static bindings - release version
$ dub --build=release build

####Dynamic bindings - debug version
$ dub --config=dynamic build

####Dynamic bindings
$ rdmd compile.d dynamic [release|debug]
####Dynamic bindings - release version
$ dub --config=dynamic --build=release build

####Unittest version (see below)
$ rdmd compile.d unittest-static [release|debug]
$ rdmd compile.d unittest-dynamic [release|debug]
$ cd unittests
$ dub build
$ dub --build=release build
$ dub --config=dynamic build
$ dub --config=dynamic --build=release build

####Example compilation
$ rdmd compile.d example-static [release|debug]
$ rdmd compile.d example-dynamic [release|debug]
$ cd example
$ dub build
$ dub --build=release build
$ dub --config=dynamic build
$ dub --config=dynamic --build=release build

Example
-------
Expand Down Expand Up @@ -95,10 +129,10 @@ void main()
```
##Compile and run
Static bindings (requires libpq.a libcomm_err.a):
Static bindings (requires libpq.a libcom_err.a):
```sh
$ rdmd compile.d example-static
$ ./example
$ cd example
$ dub
1: 456.78
2: -1234.57
3: 0013-Oct-05 03:00:21.227803Z
Expand All @@ -111,8 +145,8 @@ second line
```
Dynamic bindings (requires libpq.so libssl.so libcrypto.so for linux, libpq.dll libeay32.dll ssleay32.dll for win):
```sh
$ rdmd compile.d example-dynamic
$ ./example
$ cd example
$ dub --config=dynamic
1: 456.78
2: -1234.57
3: 0013-Oct-05 03:00:21.227803Z
Expand Down Expand Up @@ -141,15 +175,18 @@ may contain connection string as described in [PostgreSQL documentation]
For default connection to DB type:

```sh
$ ./libdpq2
$ cd unittests
$ dub
```
Connection to usually available database "postgres":
```sh
$ ./libdpq2 --conninfo "dbname=postgres"
$ cd unittests
$ dub -- --conninfo "dbname=postgres"
```
Network connection:
```sh
$ ./libdpq2 --conninfo "host=123.45.67.89 dbname=testdb user=testuser password=123123"
$ cd unittests
$ dub -- --conninfo "host=123.45.67.89 dbname=testdb user=testuser password=123123"
```

TODO
Expand Down
71 changes: 0 additions & 71 deletions compile.d

This file was deleted.

0 comments on commit be7d6af

Please sign in to comment.