Add PCH support for faster building.
This commit is contained in:
parent
14a5d8cfaa
commit
50a9232b94
|
@ -1,4 +1,5 @@
|
|||
.deps
|
||||
*.gch
|
||||
*.lo
|
||||
*.loT
|
||||
*.la
|
||||
|
|
44
config.m4
44
config.m4
|
@ -4,18 +4,54 @@ PHP_ARG_ENABLE(arma, for armadillo support,
|
|||
PHP_ARG_ENABLE(arma-operators, for operator overloading support in armadillo,
|
||||
[ --enable-arma-operators Enable operator overloading for armadillo ], no, no)
|
||||
|
||||
PHP_ARG_ENABLE(arma-pch, build PCH header of armadillo,
|
||||
[ --enable-arma-pch Enable building PCH header of armadillo ], no, no)
|
||||
|
||||
if test "$PHP_ARMA" != "no"; then
|
||||
PHP_REQUIRE_CXX()
|
||||
|
||||
EXTRA_CXXFLAGS="-std=c++17"
|
||||
# If enabled, try building pre-compiled header for armadillo.
|
||||
if test "$PHP_ARMA_PCH" != "no"; then
|
||||
CXX_INCLEDE_PATHS=($(echo | $CXX -xc++ -E -v - 2>&1 | grep -p '^ /'))
|
||||
PHP_INCLUDES=`php-config --includes`
|
||||
PCH_FILE='./build/armadillo.gch'
|
||||
# Note that '-D' option is valid when compiling PCH header, but not when using it.
|
||||
CXX_TMP_COMPILE_FLAGS="-std=c++17 -x c++-header $PHP_INCLUDES -DARMA_DONT_PRINT_ERRORS"
|
||||
if test -z "$PHP_DEBUG"; then
|
||||
CXX_TMP_COMPILE_FLAGS+=' -O2'
|
||||
else
|
||||
CXX_TMP_COMPILE_FLAGS+=' -g -O0'
|
||||
fi
|
||||
fi
|
||||
for TEMP_INCLUDE_DIR in "$CXX_INCLEDE_PATHS"; do
|
||||
ARMADILLO_HEADER_FILE=$TEMP_INCLUDE_DIR/armadillo
|
||||
if test -f "$ARMADILLO_HEADER_FILE"; then
|
||||
$CXX $CXX_TMP_COMPILE_FLAGS $TEMP_INCLUDE_DIR/armadillo -o $PCH_FILE
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Include PCH file if valid.
|
||||
EXTRA_CXXFLAGS="-std=c++17 -DARMA_DONT_PRINT_ERRORS"
|
||||
CLANG_TEST_STR=`$CXX --version | grep clang`
|
||||
if test -n "$CLANG_TEST_STR"; then
|
||||
EXTRA_CXXFLAGS+=" -Wno-undefined-var-template -Wno-deprecated-declarations"
|
||||
if test -f "$PCH_FILE"; then
|
||||
if test -n "$CLANG_TEST_STR"; then
|
||||
EXTRA_CXXFLAGS+=" -include-pch $PCH_FILE"
|
||||
# Define this only for clang, in gcc we still need the include directive.
|
||||
AC_DEFINE(PHP_ARMA_ENABLE_PCH, 1, [ Defined if using pre-compiled armadillo header. ])
|
||||
else
|
||||
EXTRA_CXXFLAGS+=' -I./build'
|
||||
fi
|
||||
fi
|
||||
|
||||
# Disable some clang warnings we don't care.
|
||||
if test -n "$CLANG_TEST_STR"; then
|
||||
EXTRA_CXXFLAGS+=' -Wno-undefined-var-template -Wno-deprecated-declarations'
|
||||
fi
|
||||
|
||||
# Enable/disable operator overloading support.
|
||||
OPERATORS_SRC="src/operators.cc"
|
||||
ARMA_SRC=`ls -1d src/*.cc | grep -v $OPERATORS_SRC`
|
||||
|
||||
if test "$PHP_ARMA_OPERATORS" != "no"; then
|
||||
AC_DEFINE(PHP_ARMA_OPERATORS, 1, [ Defined if operator overloading is enabled for armadillo. ])
|
||||
ARMA_SRC+=" $OPERATORS_SRC"
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
// @Author CismonX
|
||||
//
|
||||
|
||||
#include "php_arma.hh"
|
||||
#include "operators.hh"
|
||||
#include "complex.hh"
|
||||
#include "base.hh"
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
#include <php.h>
|
||||
#include <zend_exceptions.h>
|
||||
|
||||
#ifndef PHP_ARMA_ENABLE_PCH
|
||||
#include <armadillo>
|
||||
#endif
|
||||
|
||||
#define PHP_ARMA_VERSION "0.0.1"
|
||||
|
||||
|
@ -22,8 +24,6 @@
|
|||
#define ZEND_ACC_CTOR 0
|
||||
#endif
|
||||
|
||||
#define ARMA_DONT_PRINT_ERRORS
|
||||
|
||||
/// Helper macros for method entry.
|
||||
|
||||
#define PHP_ARMA_START_ME(cls, ...) \
|
||||
|
|
Reference in New Issue