Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/windows build #2

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions CREDITS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
geos
Sandro Santilli <strk@kbt.io> - GEOS
J Smith <dark.panda@gmail.com> <jay@php.net> - PHP packaging
Sandro Santilli strk@kbt.io - GEOS
J Smith dark.panda@gmail.com jay@php.net - PHP packaging
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this format change ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of < > The RC resource compiler crashes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like an upstream bug. The current one does not crash, right ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the current version compiles without errors

86 changes: 68 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,102 @@
PHP module for GEOS
===================
# PHP module for GEOS

[![build status]
(https://drone.osgeo.org/api/badges/geos/php-geos/status.svg?branch=master)]
(https://drone.osgeo.org/geos/php-geos?branch=master)
[![build status](https://dronie.osgeo.org/api/badges/geos/php-geos/status.svg?branch=master)](https://github.com/libgeos/php-geos/tree/master)

The code in this directory provides a PHP module to make use
of functionalities of the [GEOS library] (http://geos.osgeo.org).
of functionalities of the [GEOS library](http://geos.osgeo.org).

The bindings are linked to the C-API, for betters stability.

# Building
## Building (UNIX)

## Requirements
### Requirements

You need:

- PHP development files
( often found in packages named something like 'php5-dev' )
- PHP development files
( often found in packages named something like 'php5-dev' )

- GEOS development files
( often found in packages named something like 'libgeos-dev' )
- GEOS development files
( often found in packages named something like 'libgeos-dev' )

## Procedure
### Procedure

git clone https://git.osgeo.org/gitea/geos/php-geos.git
git clone https://github.com/libgeos/php-geos.git
eisberg marked this conversation as resolved.
Show resolved Hide resolved
cd php-geos
./autogen.sh
./configure
make # generates modules/geos.so

# Testing
## Building (Windows)

### Requirements

- PHP source files: download [zip](http://windows.php.net/download/) or clone from [github](https://github.com/php/php-src)
- PHP SDK ( https://github.com/Microsoft/php-sdk-binary-tools )
- Visual C++:
* Visual C++ 14.0 (Visual Studio 2015) for PHP 7.0 or PHP 7.1.
* Visual C++ 15.0 (Visual Studio 2017) for PHP 7.2, PHP 7.3 or PHP 7.4.
* Visual C++ 16.0 (Visual Studio 2019) for master.
- GEOS Windows binaries (binary dll, includes and lib):
* As part of [OSGeo4W](http://osgeo4w.osgeo.org/) as part of the geos package.
* As part of [MS4W](https://ms4w.com/)

### Configure

Official instructions for compiling PHP extensions: https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2

1. Install OSGeo4w in `C:\OSGeo4W64` and PHP-SDK in `C:/php-sdk.`
2. Invoke the starter script, for example for Visual Studio 2015 64-bit build, invoke phpsdk-vc15-x64.bat
3. Run the phpsdk_buildtree batch script which will create the desired directory structure:

phpsdk_buildtree phpdev

The phpsdk_buildtree script will create the path according to the currently VC++ version used and switch into the newly created directory
4. Extract the PHP source code to `C:\php-sdk\phpdev\vX##\x##`, where:

vX## is the compiler version you are using (eq vc15 or vs16)
x## is your architecture (x86 or x64)
For example: `C:\php-sdk\phpdev\vc15\x64\php-7.4.11-src`
In the same directory where you extracted the PHP source there is a deps directory.
For example: `C:\php-sdk\phpdev\vc15\x64\deps`

5. Copy GEOS binaries from `C:\OSGeo4W64` (`bin`, `include` and `lib` subdir) to `C:\php-sdk\phpdev\vc15\x64\deps\`
6. Copy (clone) code from this repository to `C:\php-sdk\phpdev\vc15\x64\php-7.4.11-src\ext\geos`


### Compile

Run next commands to compile ([see official php instruction](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2)):

c:\php-sdk\phpsdk-vc15-x64.bat
cd C:\php-sdk\phpdev\vc15\x64\php-7.4.11-src
buildconf
configure --disable-all --enable-cli --with-geos
nmake



## Testing

Automated testing is executed on 'make check'.

You'll need phpunit installed for this to work. To install:

pear install --force --alldeps phpunit/phpunit

# Installing
## Installing

### Unix

As root (or owner with write access to the directory
returned by php-config --extension-dir), run:

make install

# Using
### Window
Copy php_geos.dll to extension directory and enable it in php.ini

## Using

... TODO ...
(reference some automatically built doc?)

59 changes: 59 additions & 0 deletions config.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// vim:ft=javascript

ARG_WITH("geos", "geos support", "yes");

if (PHP_GEOS != "no") {
if (CHECK_LIB("geos_c.lib", "geos", PHP_GEOS) &&
CHECK_HEADER_ADD_INCLUDE("geos_c.h", "CFLAGS_GEOS", PHP_GEOS)) {

CHECK_LIB("geos_c.lib", "initGEOS_r", PHP_GEOS) && !PHP_GEOS && WARNING("Unable to build the GEOS: a newer libgeos is required");

CHECK_LIB("geos_c.lib", "GEOSClipByRect_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_CLIP_BY_RECT', 1, 'Whether we have GEOSClipByRect_r');
CHECK_LIB("geos_c.lib", "GEOSCoveredBy_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_COVERED_BY', 1, 'Whether we have GEOSCoveredBy_r');
CHECK_LIB("geos_c.lib", "GEOSCovers_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_COVERS', 1, 'Whether we have GEOSCovers_r');
CHECK_LIB("geos_c.lib", "GEOSDelaunayTriangulation_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_DELAUNAY_TRIANGULATION', 1, 'Whether we have GEOSDelaunayTriangulation_r');
CHECK_LIB("geos_c.lib", "GEOSGeomGetEndPoint_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_GEOM_GET_END_POINT', 1, 'Whether we have GEOSGeomGetEndPoint_r');
CHECK_LIB("geos_c.lib", "GEOSGeomGetNumPoints_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_GEOM_GET_NUM_POINTS', 1, 'Whether we have GEOSGeomGetNumPoints_r');
CHECK_LIB("geos_c.lib", "GEOSGeomGetPointN_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_GEOM_GET_POINT_N', 1, 'Whether we have GEOSGeomGetPointN_r');
CHECK_LIB("geos_c.lib", "GEOSGeomGetStartPoint_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_GEOM_GET_START_POINT', 1, 'Whether we have GEOSGeomGetStartPoint_r');
CHECK_LIB("geos_c.lib", "GEOSGeomGetX_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_GEOM_GET_X', 1, 'Whether we have GEOSGeomGetX_r');
CHECK_LIB("geos_c.lib", "GEOSGeomGetY_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_GEOM_GET_Y', 1, 'Whether we have GEOSGeomGetY_r');
CHECK_LIB("geos_c.lib", "GEOSGeom_extractUniquePoints_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_GEOM_EXTRACT_UNIQUE_POINTS', 1, 'Whether we have GEOSGeom_extractUniquePoints_r');
CHECK_LIB("geos_c.lib", "GEOSGeom_getCoordinateDimension_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_GEOM_GET_COORDINATE_DIMENSION', 1, 'Whether we have GEOSGeom_getCoordinateDimension_r');
CHECK_LIB("geos_c.lib", "GEOSNode_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_NODE', 1, 'Whether we have GEOSNode_r');
CHECK_LIB("geos_c.lib", "GEOSOffsetCurve_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_OFFSET_CURVE', 1, 'Whether we have GEOSOffsetCurve_r');
CHECK_LIB("geos_c.lib", "GEOSPolygonize_full_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_POLYGONIZE_FULL', 1, 'Whether we have GEOSPolygonize_full_r');
CHECK_LIB("geos_c.lib", "GEOSRelateBoundaryNodeRule_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_RELATE_BOUNDARY_NODE_RULE', 1, 'Whether we have GEOSRelateBoundaryNodeRule_r');
CHECK_LIB("geos_c.lib", "GEOSRelatePatternMatch_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_RELATE_PATTERN_MATCH', 1, 'Whether we have GEOSRelatePatternMatch_r');
CHECK_LIB("geos_c.lib", "GEOSSharedPaths_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_SHARED_PATHS', 1, 'Whether we have GEOSSharedPaths_r');
CHECK_LIB("geos_c.lib", "GEOSSnap_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_SNAP', 1, 'Whether we have GEOSSnap_r');
CHECK_LIB("geos_c.lib", "GEOSUnaryUnion_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_UNARY_UNION', 1, 'Whether we have GEOSUnaryUnion_r');
CHECK_LIB("geos_c.lib", "GEOSVoronoiDiagram_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_VORONOI_DIAGRAM', 1, 'Whether we have GEOSVoronoiDiagram_r');
CHECK_LIB("geos_c.lib", "GEOSisClosed_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_IS_CLOSED', 1, 'Whether we have GEOSisClosed_r');
CHECK_LIB("geos_c.lib", "GEOSisValidDetail_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_IS_VALID_DETAIL', 1, 'Whether we have GEOSisValidDetail_r');
CHECK_LIB("geos_c.lib", "GEOSGeom_setPrecision_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_GEOM_SET_PRECISION', 1, 'Whether we have GEOSGeom_setPrecision_r');
CHECK_LIB("geos_c.lib", "GEOSGeom_getPrecision_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_GEOM_GET_PRECISION', 1, 'Whether we have GEOSGeom_getPrecision_r');

CHECK_LIB("geos_c.lib", "GEOSWKTWriter_setTrim_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_WKT_WRITER_SET_TRIM', 1, 'Whether we have GEOSWKTWriter_setTrim_r');
CHECK_LIB("geos_c.lib", "GEOSWKTWriter_setRoundingPrecision_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_WKT_WRITER_SET_ROUNDING_PRECISION', 1, 'Whether we have GEOSWKTWriter_setRoundingPrecision_r');
CHECK_LIB("geos_c.lib", "GEOSWKTWriter_setOutputDimension_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_WKT_WRITER_SET_OUTPUT_DIMENSION', 1, 'Whether we have GEOSWKTWriter_setOutputDimension_r');
CHECK_LIB("geos_c.lib", "GEOSWKTWriter_getOutputDimension_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_WKT_WRITER_GET_OUTPUT_DIMENSION', 1, 'Whether we have GEOSWKTWriter_getOutputDimension_r');
CHECK_LIB("geos_c.lib", "GEOSWKTWriter_setOld3D_r", PHP_GEOS) && AC_DEFINE('HAVE_GEOS_WKT_WRITER_SET_OLD_3D', 1, 'Whether we have GEOSWKTWriter_setOld3D_r');

// https://juliahub.com/docs/LibGEOS/we91k/0.6.5/autodocs/
// setPrecision: GEOS_PREC_NO_TOPO -- do not attempt at preserving the topology -- geos.c l. 3379
// setPrecision: GEOS_PREC_KEEP_COLLAPSED -- retain collapsed elements -- geos.c l. 3384
// We can't run TRY_COMPILE tests on Windows ?? force HAVE_GEOS_PREC_NO_TOPO & HAVE_GEOS_PREC_KEEP_COLLAPSED
// AC_TRY_COMPILE(geos_c.h, GEOS_PREC_NO_TOPO, AC_DEFINE(HAVE_GEOS_PREC_NO_TOPO,1,[Whether we have GEOS_PREC_NO_TOPO])) -- do not attempt at preserving the topology
// AC_TRY_COMPILE(geos_c.h, GEOS_PREC_KEEP_COLLAPSED, AC_DEFINE(HAVE_GEOS_PREC_KEEP_COLLAPSED,1,[Whether we have GEOS_PREC_KEEP_COLLAPSED])) -- retain collapsed elements
AC_DEFINE('HAVE_GEOS_PREC_NO_TOPO',1,'Whether we have GEOS_PREC_NO_TOPO');
AC_DEFINE('HAVE_GEOS_PREC_KEEP_COLLAPSED',1,'Whether we have GEOS_PREC_KEEP_COLLAPSED');

EXTENSION("geos", "geos.c", 1);

} else {
WARNING("geos support can't be enabled, libraries or headers are missing")
PHP_GEOS = "no";
}

}
Loading