Skip to content
Permalink
Browse files

Fix building-issues for PHP/Mapscript (native) in thread-safe environ…

…ments and windows
  • Loading branch information...
AlexanderGabriel committed Oct 11, 2018
1 parent 04a11bf commit 368d71155fcddc7ba250cdad8821541f4d61619e
@@ -17,19 +17,23 @@ SET(PHP5_POSSIBLE_INCLUDE_PATHS
/usr/include/php
/usr/local/include/php
/usr/local/apache/php
C:/php-sdk/phpmaster/vc15/x64/php-src
${PHP5_INCLUDES}
)

SET(PHP5_POSSIBLE_LIB_PATHS
/usr/lib
if(WIN32)
${PHP5_INCLUDES}/Release_TS
${PHP5_INCLUDES}/Release
${PHP5_INCLUDES}/x64/Release
${PHP5_INCLUDES}/x64/Release_TS
endif(WIN32)
)

find_library(PHP5_LIBRARY
NAMES php5ts.lib
PATHS /sw /opt/local ${PHP5_INCLUDES}/Release_TS
NAMES php5ts.lib php7ts.lib php5.lib php7.lib
PATHS /sw /opt/local C:/php-sdk/phpmaster/vc15/x64/php-src/Release_TS C:/php-sdk/phpmaster/vc15/x64/php-src/Release C:/php-sdk/phpmaster/vc15/x64/php-src/x64/Release C:/php-sdk/phpmaster/vc15/x64/php-src/x64/Release_TS
)

FIND_PATH(PHP5_FOUND_INCLUDE_PATH main/php.h
@@ -2,7 +2,14 @@ FIND_PACKAGE(PHP5 REQUIRED)
INCLUDE_DIRECTORIES(${PHP5_INCLUDE_PATH})

if(WIN32)
add_definitions(/DZEND_WIN32 /DPHP_WIN32 /DPHP5 /DZTS /DZEND_DEBUG=0 -DWIN32 -D_WIN32 -D_USE_32BIT_TIME_T -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(/DWIN32 /DZEND_WIN32 /DPHP_WIN32 /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)

IF(APPLE)
@@ -36,7 +43,7 @@ target_link_libraries(php_mapscript ${MAPSERVER_LIBMAPSERVER})
ENDIF(WIN32)

set_target_properties(php_mapscript PROPERTIES PREFIX "")
install(TARGETS php_mapscript DESTINATION ${PHP5_EXTENSION_DIR})
#install(TARGETS php_mapscript DESTINATION ${PHP5_EXTENSION_DIR})

#install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mapscript.py DESTINATION ${PYTHON_SITE_PACKAGES})
#install(TARGETS mapscript DESTINATION ${PYTHON_SITE_PACKAGES})
@@ -47,11 +47,7 @@ zval* mapscript_throw_exception(char *format TSRMLS_DC, ...)
{
va_list args;
char message[MAX_EXCEPTION_MSG];
#ifdef ZTS
va_start(args, TSRMLS_C);
#else
va_start(args, format);
#endif
vsprintf(message, format, args);
va_end(args);
return zend_throw_exception(mapscript_ce_mapscriptexception, message, 0 TSRMLS_CC);
@@ -76,11 +72,7 @@ zval* mapscript_throw_mapserver_exception(char *format TSRMLS_DC, ...)
ms_error = ms_error->next;
}

#ifdef ZTS
va_start(args, TSRMLS_C);
#else
va_start(args, format);
#endif
vsprintf(message, format, args);
va_end(args);
return mapscript_throw_exception(message TSRMLS_CC);
@@ -90,11 +82,7 @@ void mapscript_report_php_error(int error_type, char *format TSRMLS_DC, ...)
{
va_list args;
char message[MAX_EXCEPTION_MSG];
#ifdef ZTS
va_start(args, TSRMLS_C);
#else
va_start(args, format);
#endif
vsprintf(message, format, args);
va_end(args);
php_error_docref(NULL TSRMLS_CC, error_type, "%s,", message);
@@ -171,11 +171,7 @@ PHP_METHOD(OWSRequestObj, loadParams)
}
PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

#ifdef ZTS
thread_context = (void*)TSRMLS_C;
#else
thread_context = NULL;
#endif

php_owsrequest = MAPSCRIPT_OBJ_P(php_owsrequest_object, zobj);

@@ -999,10 +999,6 @@ PHP_MINIT_FUNCTION(mapscript)
memcpy(&mapscript_std_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
mapscript_std_object_handlers.clone_obj = NULL;

/* If you have defined globals, uncomment this line
ZEND_INIT_MODULE_GLOBALS(mapscript, phpms_init_globals, NULL);
*/

/* If you have INI entries, uncomment this line
REGISTER_INI_ENTRIES();
*/
@@ -13,7 +13,7 @@ FIND_PACKAGE(PHP7 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)
add_definitions(/DWIN32 /DZEND_WIN32 /DPHP_WIN32 /DZEND_DEBUG=0)
if(NOT CMAKE_CL_64)
add_definitions(-D_USE_32BIT_TIME_T)
endif(NOT CMAKE_CL_64)
@@ -37,7 +37,7 @@ 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)
target_compile_options(php_mapscriptng PRIVATE /DWIN32 /DZEND_WIN32 /DPHP_WIN32 /DZEND_DEBUG=0)
if(WITH_THREAD_SAFETY)
target_compile_options(php_mapscriptng PRIVATE /DZTS=1)
endif(WITH_THREAD_SAFETY)

0 comments on commit 368d711

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