Skip to content

Commit

Permalink
.phar build script
Browse files Browse the repository at this point in the history
  • Loading branch information
cweiske committed Dec 10, 2015
1 parent 2aaa13c commit 91615fe
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/composer.lock
/vendor
/README.html
/dist
/bin/phar-php-sqllint.php
39 changes: 37 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,30 @@ Usage
=====
::

$ ./bin/php-sqllint tests/files/create-missingcomma.sql
$ php-sqllint tests/files/create-missingcomma.sql
Checking SQL syntax of tests/files/create-missingcomma.sql
Line 3, col 5 at "pid": A comma or a closing bracket was expected.
Line 3, col 13 at "11": Unexpected beginning of statement.
Line 3, col 17 at "DEFAULT": Unrecognized statement type.

Emacs mode::

$ ./bin/php-sqllint -r emacs tests/files/create-noname.sql
$ php-sqllint -r emacs tests/files/create-noname.sql
tests/files/create-noname.sql:1.12:Error: The name of the entity was expected.
tests/files/create-noname.sql:1.13:Error: A closing bracket was expected.
tests/files/create-noname.sql:1.13:Error: At least one column definition was expected.


====
Bugs
====
Does ``php-sqllint`` not detect a syntax error, or doesn't support a certain
SQL statement?
Then please report a bug at `udan11/sql-parser`__.

__ https://github.com/udan11/sql-parser


============
Dependencies
============
Expand All @@ -38,6 +48,29 @@ __ https://github.com/udan11/sql-parser
__ https://www.phpmyadmin.net/


Dependency installation
=======================
::

$ composer install

Now you can use ``./bin/php-sqllint`` without building the phar yourself.


========
Building
========
You'll need `phing`__, the PHP build tool::

$ phing

__ https://www.phing.info/

The result are ``.phar`` files in ``dist/`` directory that you can execute::

$ ./dist/php-sqllint-0.0.1.phar tests/files/create-noname.sql
Checking SQL syntax of tests/files/create-noname.sql
Line 1, col 12 at "(": The name of the entity was expected.


=================
Expand All @@ -53,6 +86,8 @@ __ http://www.gnu.org/licenses/agpl.html

Homepage
========
Home page
http://cweiske.de/php-sqllint.htm
Source code
http://git.cweiske.de/php-sqllint.git

Expand Down
89 changes: 89 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<project name="php-sqllint" default="phar" basedir=".">

<property name="version" value="0.0.1" />
<property name="pharfile" value="${phing.dir}/dist/${phing.project.name}-${version}.phar" />
<property name="pharfilebz2" value="${phing.dir}/dist/${phing.project.name}-${version}.bz2.phar" />
<property name="libdir" value="${phing.dir}/lib"/>

<fileset id="fs.phar" dir="${phing.dir}">
<include name="bin/**"/>
<include name="lib/**"/>
<include name="src/**"/>

<include name="README.rst"/>

<include name="vendor/autoload.php"/>
<include name="vendor/composer/*.php"/>
<include name="vendor/pear/console_commandline/Console/**"/>
<include name="vendor/pear/pear_exception/PEAR/**"/>
<include name="vendor/udan11/sql-parser/src/**"/>
</fileset>


<typedef name="pearPackageFileSet" classname="phing.types.PearPackageFileSet" />

<target name="phar" depends="collectdeps"
description="Create zip file for release"
>
<!-- strip the shebang from bin script -->
<copy file="${phing.dir}/bin/php-sqllint" tofile="${phing.dir}/bin/phar-php-sqllint.php">
<filterchain>
<striplinecomments>
<comment value="#" />
</striplinecomments>
</filterchain>
</copy>

<mkdir dir="${phing.dir}/dist"/>
<delete file="${pharfile}"/>
<pharpackage basedir="${phing.dir}"
destfile="${pharfile}"
stub="${phing.dir}/src/stub-phar.php"
alias="php-sqllint.phar"
compression="none"
>
<fileset refid="fs.phar"/>
</pharpackage>

<pharpackage basedir="${phing.dir}"
destfile="${pharfilebz2}"
stub="${phing.dir}/src/stub-phar.php"
alias="php-sqllint.phar"
compression="bzip2"
>
<fileset refid="fs.phar"/>
</pharpackage>

<exec executable="chmod">
<arg value="+x"/>
<arg value="${pharfile}"/>
<arg value="${pharfilebz2}"/>
</exec>
</target>


<target name="collectdeps" description="Copy package dependencies to lib/">
<exec command="composer install"/>
<!--
<delete dir="${libdir}"/>
<mkdir dir="${libdir}"/>
<pearPackageFileset id="dep-Console_CommandLine" package="pear.php.net/Console_CommandLine"/>
<pearPackageFileset id="dep-PEAR" package="pear.php.net/PEAR">
<include name="PEAR/Exception.php"/>
</pearPackageFileset>
<copy todir="${libdir}">
<fileset refid="dep-Console_CommandLine"/>
<fileset refid="dep-PEAR"/>
</copy>
-->
</target>


<target name="docs" description="render documentation">
<rst file="README.rst"/>
</target>

</project>
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"require": {
"udan11/sql-parser": "^3.0"
"udan11/sql-parser": "^3.0",
"pear/console_commandline": "^1.2"
}
}
17 changes: 17 additions & 0 deletions src/stub-phar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env php
<?php
/**
* Phar stub file for php-sqllint. Handles startup of the .phar file.
*
* PHP version 5
*
* @category Tools
* @package PHP-SQLlint
* @author Christian Weiske <[email protected]>
* @copyright 2015 Christian Weiske
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
* @link http://cweiske.de/php-sqllint.htm
*/
require 'phar://' . __FILE__ . '/bin/phar-php-sqllint.php';
__HALT_COMPILER();
?>

0 comments on commit 91615fe

Please sign in to comment.