Skip to content
Permalink
Browse files

Add Support for PHP-NG MapScript (via SWIG) but don't yet build with …

…AppVeyor
  • Loading branch information...
AlexanderGabriel committed Aug 14, 2018
1 parent 3d24954 commit 7de2cd942fd5715e5b670651ebbb11e3feaafb17
@@ -3,6 +3,10 @@ language: php
php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- nightly

env:
global:
@@ -49,7 +53,8 @@ before_install:
- sudo apt-get remove postgresql*
- sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
- sudo apt-get update
- sudo apt-get install --allow-unauthenticated protobuf-c-compiler libprotobuf-c0-dev bison flex python-lxml libfribidi-dev swig cmake librsvg2-dev colordiff libpq-dev libpng12-dev libjpeg-dev libgif-dev libgeos-dev libgd2-xpm-dev libfreetype6-dev libfcgi-dev libcurl4-gnutls-dev libcairo2-dev libgdal1-dev libproj-dev libxml2-dev python-dev php5-dev libexempi-dev lcov lftp postgis postgresql-9.3 postgresql-9.3-postgis-2.2 postgresql-9.3-postgis-scripts libharfbuzz-dev gdal-bin
- sudo apt-get install --allow-unauthenticated protobuf-c-compiler libprotobuf-c0-dev bison flex python-lxml libfribidi-dev swig cmake librsvg2-dev colordiff libpq-dev libpng12-dev libjpeg-dev libgif-dev libgeos-dev libgd2-xpm-dev libfreetype6-dev libfcgi-dev libcurl4-gnutls-dev libcairo2-dev libgdal1-dev libproj-dev libxml2-dev python-dev libexempi-dev lcov lftp postgis libharfbuzz-dev gdal-bin
- sudo apt-get install --allow-unauthenticated php5-dev || sudo apt-get install --allow-unauthenticated php7-dev
- sudo pip install git+git://github.com/tbonfort/cpp-coveralls.git@extensions
- cd msautotest
- ./create_postgis_test_data.sh
@@ -142,6 +142,7 @@ option(WITH_THREAD_SAFETY "Choose if a thread-safe version of libmapserver shoul
option(WITH_GIF "Enable GIF support (for PIXMAP loading)" ON)
option(WITH_PYTHON "Enable Python mapscript support" OFF)
option(WITH_PHP "Enable PHP mapscript support" OFF)
option(WITH_PHPNG "Enable PHPNG (SWIG) mapscript support" OFF)
option(WITH_PERL "Enable Perl mapscript support" OFF)
option(WITH_RUBY "Enable Ruby mapscript support" OFF)
option(WITH_JAVA "Enable Java mapscript support" OFF)
@@ -864,6 +865,11 @@ if(WITH_PHP)
set(USE_PHP_MAPSCRIPT 1)
endif(WITH_PHP)

if(WITH_PHPNG)
add_subdirectory("mapscript/phpng")
set(USE_PHPNG_MAPSCRIPT 1)
endif(WITH_PHPNG)

if(WITH_APACHE_MODULE)
add_subdirectory("apache")
set(USE_APACHE_MODULE 1)
@@ -982,6 +988,7 @@ status_optional_feature("XML Mapfile support" "${USE_XMLMAPFILE}")
message(STATUS " * Mapscripts")
status_optional_feature("Python" "${USE_PYTHON_MAPSCRIPT}")
status_optional_feature("PHP" "${USE_PHP_MAPSCRIPT}")
status_optional_feature("PHPNG" "${USE_PHPNG_MAPSCRIPT}")
status_optional_feature("PERL" "${USE_PERL_MAPSCRIPT}")
status_optional_feature("RUBY" "${USE_RUBY_MAPSCRIPT}")
status_optional_feature("JAVA" "${USE_JAVA_MAPSCRIPT}")
@@ -0,0 +1,114 @@
# - Find PHP7
# This module finds if PHP7 is installed and determines where the include files
# and libraries are. It also determines what the name of the library is. This
# code sets the following variables:
#
# PHP7_INCLUDE_PATH = path to where php.h can be found
# PHP7_EXECUTABLE = full path to the php4 binary
#
# file is derived from FindPHP5.cmake
#

SET(PHP7_FOUND "NO")

SET(PHP7_POSSIBLE_INCLUDE_PATHS
/usr/include/php/*
/usr/local/include/php/*
/usr/include/php
/usr/local/include/php
/usr/local/apache/php
${PHP7_INCLUDES}
)

if(WIN32)
string(SUBSTRING $ENV{VSCMD_VER} 0 2 VSCMD_VER)
FOREACH(PHP7_POSSIBLE_INCLUDE_PATH ../../../php-sdk C:/php-sdk "$ENV{APPVEYOR_BUILD_FOLDER}")
SET(PHP7_POSSIBLE_INCLUDE_PATHS ${PHP7_POSSIBLE_INCLUDE_PATHS} "${PHP7_POSSIBLE_INCLUDE_PATH}/phpmaster/vc${VSCMD_VER}/$ENV{VSCMD_ARG_TGT_ARCH}/php-src")
ENDFOREACH()
endif(WIN32)

FIND_PATH(PHP7_FOUND_INCLUDE_PATH main/php.h ${PHP7_POSSIBLE_INCLUDE_PATHS})

find_library(PHP7_LIBRARY NAMES php7ts PATHS /sw /opt/local)
if(WIN32)
find_library(PHP7_LIBRARY NAMES php7 php7ts PATHS ${PHP7_FOUND_INCLUDE_PATH}/Release ${PHP7_FOUND_INCLUDE_PATH}/Release_TS)
if(CMAKE_CL_64)
find_library(PHP7_LIBRARY NAMES php7 php7ts PATHS ${PHP7_FOUND_INCLUDE_PATH}/$ENV{VSCMD_ARG_TGT_ARCH}/Release ${PHP7_FOUND_INCLUDE_PATH}/$ENV{VSCMD_ARG_TGT_ARCH}/Release_TS)
endif(CMAKE_CL_64)
endif(WIN32)

IF(PHP7_FOUND_INCLUDE_PATH)
SET(php7_paths "${PHP7_POSSIBLE_INCLUDE_PATHS}")
FOREACH(php7_path Zend main TSRM)
SET(php7_paths ${php7_paths} "${PHP7_FOUND_INCLUDE_PATH}/${php7_path}")
ENDFOREACH(php7_path Zend main TSRM)
SET(PHP7_INCLUDE_PATH "${php7_paths}" INTERNAL "PHP7 include paths")
ENDIF(PHP7_FOUND_INCLUDE_PATH)

FIND_PROGRAM(PHP7_EXECUTABLE
NAMES php7 php
PATHS
/usr/local/bin
)

MARK_AS_ADVANCED(
PHP7_EXECUTABLE
PHP7_FOUND_INCLUDE_PATH
)

IF( NOT PHP7_CONFIG_EXECUTABLE )
FIND_PROGRAM(PHP7_CONFIG_EXECUTABLE
NAMES php7-config php-config
)
ENDIF( NOT PHP7_CONFIG_EXECUTABLE )

IF(PHP7_CONFIG_EXECUTABLE)
EXECUTE_PROCESS(COMMAND ${PHP7_CONFIG_EXECUTABLE} --version
OUTPUT_VARIABLE PHP7_VERSION)
STRING(REPLACE "\n" "" PHP7_VERSION "${PHP7_VERSION}")

EXECUTE_PROCESS(COMMAND ${PHP7_CONFIG_EXECUTABLE} --extension-dir
OUTPUT_VARIABLE PHP7_EXTENSION_DIR)
STRING(REPLACE "\n" "" PHP7_EXTENSION_DIR "${PHP7_EXTENSION_DIR}")

EXECUTE_PROCESS(COMMAND ${PHP7_CONFIG_EXECUTABLE} --includes
OUTPUT_VARIABLE PHP7_INCLUDES)
STRING(REPLACE "-I" "" PHP7_INCLUDES "${PHP7_INCLUDES}")
STRING(REPLACE " " ";" PHP7_INCLUDES "${PHP7_INCLUDES}")
STRING(REPLACE "\n" "" PHP7_INCLUDES "${PHP7_INCLUDES}")
LIST(GET PHP7_INCLUDES 0 PHP7_INCLUDE_DIR)

set(PHP7_MAIN_INCLUDE_DIR ${PHP7_INCLUDE_DIR}/main)
set(PHP7_TSRM_INCLUDE_DIR ${PHP7_INCLUDE_DIR}/TSRM)
set(PHP7_ZEND_INCLUDE_DIR ${PHP7_INCLUDE_DIR}/Zend)
set(PHP7_REGEX_INCLUDE_DIR ${PHP7_INCLUDE_DIR}/regex)
set(PHP7_EXT_INCLUDE_DIR ${PHP7_INCLUDE_DIR}/ext)
set(PHP7_DATE_INCLUDE_DIR ${PHP7_INCLUDE_DIR}/ext/date/lib)
set(PHP7_STANDARD_INCLUDE_DIR ${PHP7_INCLUDE_DIR}/ext/standard)

MESSAGE(STATUS ${PHP7_MAIN_INCLUDE_DIR})

IF(NOT PHP7_INCLUDE_PATH)
set(PHP7_INCLUDE_PATH ${PHP7_INCLUDES})
ENDIF(NOT PHP7_INCLUDE_PATH)

IF(PHP7_VERSION LESS 5)
MESSAGE(FATAL_ERROR "PHP version is not 5 or later")
ENDIF(PHP7_VERSION LESS 5)

IF(PHP7_EXECUTABLE AND PHP7_INCLUDES)
set(PHP7_FOUND "yes")
MESSAGE(STATUS "Found PHP7-Version ${PHP7_VERSION} (using ${PHP7_CONFIG_EXECUTABLE})")
ENDIF(PHP7_EXECUTABLE AND PHP7_INCLUDES)

FIND_PROGRAM(PHPUNIT_EXECUTABLE
NAMES phpunit phpunit2
PATHS
/usr/local/bin
)

IF(PHPUNIT_EXECUTABLE)
MESSAGE(STATUS "Found phpunit: ${PHPUNIT_EXECUTABLE}")
ENDIF(PHPUNIT_EXECUTABLE)

ENDIF(PHP7_CONFIG_EXECUTABLE)
@@ -20,9 +20,10 @@ The mapscript family tree looks like this:
/ \
/ \
PHPMapScript \ SWIGMapScript
PHP4 +----+-----+----+----+----+
| | | | | |
Perl Python Ruby Java Tcl ...
PHP4 +----+-----+----+----+----+------------+
| | | | | | |
Perl Python Ruby Java Tcl PHP7 (PHPNG) ...



The Perl, Python, Ruby flavors are like brothers and sisters and the PHP3
@@ -30,7 +30,11 @@
============================================================================
*/

#ifdef SWIGPHP
%module mapscriptng
#else
%module mapscript
#endif

#ifdef SWIGCSHARP
%ignore frompointer;
@@ -0,0 +1,38 @@
FIND_PACKAGE(PHP7 REQUIRED)
FIND_PACKAGE(SWIG 3.0.11 REQUIRED)
INCLUDE(${SWIG_USE_FILE})

if(WIN32)
add_definitions(-D_WIN32 -D_WINDOWS -DWINDOWS=1 -DZEND_WIN32=1 -DPHP_WIN32=1 -DWIN32 -DNDebug -DNDEBUG -DZEND_DEBUG=0)
if(NOT CMAKE_CL_64)
add_definitions(-D_USE_32BIT_TIME_T)
endif(NOT CMAKE_CL_64)
if(WITH_THREAD_SAFETY)
add_definitions(-DZTS=1)
endif(WITH_THREAD_SAFETY)
endif(WIN32)

include_directories(${PHP7_FOUND_INCLUDE_PATH})
include_directories(${PHP7_FOUND_INCLUDE_PATH}/main)
include_directories(${PHP7_FOUND_INCLUDE_PATH}/Zend)
include_directories(${PHP7_FOUND_INCLUDE_PATH}/TSRM)

include_directories(${PROJECT_SOURCE_DIR}/mapscript/swiginc)
include_directories(${PROJECT_SOURCE_DIR}/mapscript/)
include_directories(${PROJECT_SOURCE_DIR}/mapscript/phpng)

if(WIN32)
include_directories(${PHP7_FOUND_INCLUDE_PATH}/win32)
endif(WIN32)
SWIG_ADD_MODULE(php_mapscriptng php7 ../mapscript.i)

if(WIN32)
target_compile_options(php_mapscriptng PRIVATE /D_WIN32 /D_WINDOWS /DWINDOWS=1 /DZEND_WIN32=1 /DPHP_WIN32=1 /DWIN32 /DNDebug /DNDEBUG /DZEND_DEBUG=0)
if(WITH_THREAD_SAFETY)
target_compile_options(php_mapscriptng PRIVATE /DZTS=1)
endif(WITH_THREAD_SAFETY)
SWIG_LINK_LIBRARIES(php_mapscriptng ${PHP7_LIBRARY})
endif(WIN32)
target_link_libraries(php_mapscriptng mapserver)

set_target_properties(${SWIG_MODULE_mapscript_REAL_NAME} PROPERTIES PREFIX "")
@@ -0,0 +1,79 @@
This readme covers building Mapserver from scatch on Windows.
We will download current development state of php.
If you need MapscriptNG for a different version of php, you have to fit the commands below.
For the first time, it is a good idea to build as shown below and after you have a working state, you can change whatever you want, knowing there is a working state you can return to.

All you need is Visual Studio 2017 Express (latest Version, check for updates) and GIT installed.

To begin, start x64 or x86 Native Tools Command Prompt for VS 2017 and just execute all Commands listed below.
Please always stay inside PHP-SDK-Shell to have wget and unzip available.

rem --------------------------------------------------------------------
rem Step 1: Create Directories
rem --------------------------------------------------------------------
mkdir C:\projects
mkdir C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%

rem --------------------------------------------------------------------
rem Step 2: Build PHP
rem --------------------------------------------------------------------
cd C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%
git clone https://github.com/Microsoft/php-sdk-binary-tools.git php-sdk
cd C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%\php-sdk
set VS_VERSION=%VSCMD_VER:~0,2%
phpsdk-vc%VS_VERSION%-%VSCMD_ARG_TGT_ARCH%.bat
phpsdk_buildtree phpmaster
git clone https://github.com/php/php-src.git
cd php-src
phpsdk_deps --update --branch master
buildconf
configure --enable-snapshot-build
nmake snap

rem --------------------------------------------------------------------
rem Step 3: Get GISInternals SDK
rem --------------------------------------------------------------------
cd C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%
mkdir packages
mkdir packages\gisinternals%VSCMD_ARG_TGT_ARCH%\
mkdir gisinternals%VSCMD_ARG_TGT_ARCH%
set GISInternalsArchitecture=-
if %VSCMD_ARG_TGT_ARCH% == x64 set GISInternalsArchitecture=-%VSCMD_ARG_TGT_ARCH%-
wget -O packages\gisinternals%VSCMD_ARG_TGT_ARCH%\release-1911%GISInternalsArchitecture%dev.zip http://download.gisinternals.com/sdk/downloads/release-1911%GISInternalsArchitecture%dev.zip
unzip -q -o packages\gisinternals%VSCMD_ARG_TGT_ARCH%\release-1911%GISInternalsArchitecture%dev.zip -d gisinternals%VSCMD_ARG_TGT_ARCH%
wget -O packages\gisinternals%VSCMD_ARG_TGT_ARCH%\release-1911%GISInternalsArchitecture%gdal-mapserver-src.zip http://download.gisinternals.com/sdk/downloads/release-1911%GISInternalsArchitecture%gdal-mapserver-src.zip
unzip -q -o packages\gisinternals%VSCMD_ARG_TGT_ARCH%\release-1911%GISInternalsArchitecture%gdal-mapserver-src.zip -d gisinternals%VSCMD_ARG_TGT_ARCH%
wget -O packages\gisinternals%VSCMD_ARG_TGT_ARCH%\release-1911%GISInternalsArchitecture%gdal-mapserver-libs.zip http://download.gisinternals.com/sdk/downloads/release-1911%GISInternalsArchitecture%gdal-mapserver-libs.zip
unzip -q -o packages\gisinternals%VSCMD_ARG_TGT_ARCH%\release-1911%GISInternalsArchitecture%gdal-mapserver-libs.zip -d gisinternals%VSCMD_ARG_TGT_ARCH%
wget -O packages\gisinternals%VSCMD_ARG_TGT_ARCH%\release-1911%GISInternalsArchitecture%gdal-mapserver.zip http://download.gisinternals.com/sdk/downloads/release-1911%GISInternalsArchitecture%gdal-mapserver.zip
unzip -q -o packages\gisinternals%VSCMD_ARG_TGT_ARCH%\release-1911%GISInternalsArchitecture%gdal-mapserver.zip -d gisinternals%VSCMD_ARG_TGT_ARCH%

rem --------------------------------------------------------------------
rem Step 4: Other Dependencies
rem --------------------------------------------------------------------
rem ### SWIG ###
cd C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%
git clone https://github.com/AlexanderGabriel/swig
mkdir swig\build
cd swig\build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build .
move swig.exe ..
rem ### gnulib ###
cd C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%
git clone git://git.savannah.gnu.org/gnulib.git

--------------------------------------------------------------------
Step 5: Build Mapserver with php_mapscriptng
--------------------------------------------------------------------
cd C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%
git clone https://github.com/mapserver/mapserver
cd mapserver
mkdir build
cd build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -Wno-dev -DCMAKE_PREFIX_PATH=C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%\gisinternals%VSCMD_ARG_TGT_ARCH%;C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%\gnulib\lib;C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%\gnulib\include;C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%\gisinternals%VSCMD_ARG_TGT_ARCH%\lib;C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%\gisinternals%VSCMD_ARG_TGT_ARCH%\include -DREGEX_DIR=C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%\gisinternals%VSCMD_ARG_TGT_ARCH%\regex-0.12
cmake .. -DWITH_POSTGIS=0 -DWITH_PROTOBUFC=0 -DWITH_THREAD_SAFETY=1
cmake .. -DWITH_PHPNG=1 -DSWIG_EXECUTABLE=C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%\swig\swig.exe -DSWIG_DIR=C:\projects\mapserver%VSCMD_ARG_TGT_ARCH%\swig
cmake --build .


@@ -86,7 +86,7 @@
return msWriteClassToString(self);
}

#ifdef SWIGJAVA
#if defined (SWIGJAVA) || defined (SWIGPHP)
%newobject cloneClass;
classObj *cloneClass()
#else
@@ -92,7 +92,7 @@
}
}

#ifdef SWIGJAVA
#if defined (SWIGJAVA) || defined(SWIGPHP)
%newobject cloneLayer;
layerObj *cloneLayer()
#else
@@ -52,7 +52,7 @@
msFreeMap(self);
}

#ifdef SWIGJAVA
#if defined (SWIGJAVA) || defined (SWIGPHP)
%newobject cloneMap;
mapObj *cloneMap()
#else
@@ -91,7 +91,7 @@
return;
}

#ifdef SWIGJAVA
#if defined (SWIGJAVA) || defined (SWIGPHP)
%newobject cloneShape;
shapeObj *cloneShape()
#else
@@ -87,7 +87,7 @@
return msWriteStyleToString(self);
}

#ifdef SWIGJAVA
#if defined (SWIGJAVA) || defined (SWIGPHP)
%newobject cloneStyle;
styleObj *cloneStyle()
#else

0 comments on commit 7de2cd9

Please sign in to comment.
You can’t perform that action at this time.