.phar build script v0.0.1
authorChristian Weiske <cweiske@cweiske.de>
Thu, 10 Dec 2015 22:12:33 +0000 (23:12 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 10 Dec 2015 22:12:39 +0000 (23:12 +0100)
.gitignore
README.rst
build.xml [new file with mode: 0644]
composer.json
src/stub-phar.php [new file with mode: 0644]

index 4d82a7be1bcb98436d10b64a176ac2496e978658..c1e6936f700767edd449f683babef7af18f059f3 100644 (file)
@@ -1,3 +1,5 @@
 /composer.lock
 /vendor
 /README.html
+/dist
+/bin/phar-php-sqllint.php
index 375ffd4526b7b4f6f08d5812678729d99c46fbd4..bca5a30c607df3c552f020b9569f31237fb987c8 100644 (file)
@@ -13,7 +13,7 @@ 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.
@@ -21,12 +21,22 @@ Usage
 
 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
 ============
@@ -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.
 
 
 =================
@@ -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
 
diff --git a/build.xml b/build.xml
new file mode 100644 (file)
index 0000000..d9ca6d5
--- /dev/null
+++ b/build.xml
@@ -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>
index 750ddf18ebb51d3cf93e76c45e332dd442e0e7b6..6dcd2922bb11a20c16153a7a9a9ea96a9be9935f 100644 (file)
@@ -1,5 +1,6 @@
 {
     "require": {
-        "udan11/sql-parser": "^3.0"
+        "udan11/sql-parser": "^3.0",
+        "pear/console_commandline": "^1.2"
     }
 }
diff --git a/src/stub-phar.php b/src/stub-phar.php
new file mode 100644 (file)
index 0000000..71f0586
--- /dev/null
@@ -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 <cweiske@cweiske.de>
+ * @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();
+?>