以åãã®ããã°ã§ãç´¹ä»ãããã¨ãããã¾ãããphp-build ã¨ãããã«ããã¼ã«ã便å©ã§ãæç¨ãã¦ãã¾ããphpenv 㨠php-build ãçµã¿åããã¦ä½¿ããã¨ã§ãè¤æ°ã®ãã¼ã¸ã§ã³ã® PHP ãå
±åå¯è½ãªå½¢ã§ã¤ã³ã¹ãã¼ã«ããåãæ¿ãã¦ä½¿ããã¨ãã§ãã¾ãããã¼ã¸ã§ã³ãã¨ã® PHP ã®åä½ãæ¯è¼ããããå¦çç³»ã®å®è£
ãå¤æ´ãã¦ç¬èªã«ãã«ãããç¨éã«ã便å©ã§ãã
github.com
php-build ã«ã¯ããã«ãã®åå¾ã«ã¦ã¼ã¶ãç¬èªã®å¦çãå®è¡ã§ããä»çµã¿ãç¨æããã¦ãã¾ããä»å㯠php-build ã®ã½ã¼ã¹ã³ã¼ãã追ããªããããã®ä»çµã¿ãå©ç¨ã㦠php-build ã®å¦çãã«ã¹ã¿ãã¤ãºããæ¹æ³ã説æãã¾ãã
php-build ã®ãã¡ã¤ã«æ§æ
ã¯ããã« php-build ã®ãã¡ã¤ã«æ§æã示ãã¾ããã½ã¼ã¹ããªã¼ã®ä¸é¨ãæç²ãããã®ã以ä¸ã«ãªãã¾ããbin/php-build ãå ¨ä½ã®å¦çãå®è¡ãã bash ã¹ã¯ãªããã§ããphp-build 㧠PHP ã®ãã«ããè¡ãã«ã¯ããã®ã¹ã¯ãªãããå®è¡ãã¾ã*1ã
$ LANG=C tree -F php-build/ php-build/ |-- CHANGELOG.md |-- CONTRIBUTING.md ... |-- bin/ | |-- php-build* ... |-- share/ | `-- php-build/ | |-- after-install.d/ | |-- before-install.d/ | |-- default_configure_options | |-- definitions/ | | |-- 5.2.17 | | |-- 5.3.10 ... | |-- extension/ | | |-- definition | | `-- extension.sh | |-- patches/ | | |-- gmp.c.patch | | |-- php-5.4.6-libxml2-2.9.patch ... | `-- plugins.d/ | |-- apc.sh | |-- composer.sh ... 11 directories, 173 files
share/php-build ãã£ã¬ã¯ããªä»¥ä¸ã«ãphp-build ã®å¦çãã«ã¹ã¿ãã¤ãºãããã¡ã¤ã«ãç½®ããã¦ãã¾ããbin/php-build ã¹ã¯ãªããã¯ãshare/php-build 以ä¸ã®ãã¡ã¤ã«ã source ã¾ãã¯ãµãããã»ã¹ã¨ãã¦å®è¡ããªããå¦çãé²ãã¾ããããã«ç¬èªã®ãã¡ã¤ã«ã追å ãããã¨ã§ãphp-build ã®åä½ãã«ã¹ã¿ãã¤ãºã§ãã¾ãã
definitions
definitions ãã£ã¬ã¯ããªã®åãã¡ã¤ã«ã¯ãPHP ã®åãã¼ã¸ã§ã³ã«ã¤ãã¦ããã«ãå ¨ä½ã®å¦çã®æµããè¨è¿°ãããã®ã§ããããã¤ãã®ãã¼ã¸ã§ã³ã«ã¤ãã¦å 容ãè¦ã¦ã¿ã¾ãã
PHP 5.6.16 ã§ã¯æ¬¡ã®ããã«ãªãã¾ããã½ã¼ã¹ã³ã¼ãã® URL ãæå®ããã¦ããã»ããXdebug 2.3.3 ãã¤ã³ã¹ãã¼ã«ãããã¨ãOPcache ãæå¹ã«ãããã¨ãæ示ããã¦ãã¾ãã
$ cat 5.6.16 install_package "https://secure.php.net/distributions/php-5.6.16.tar.bz2" install_xdebug "2.3.3" enable_builtin_opcache
PHP 7.0.0 ã§ã¯æ¬¡ã®ããã«ãªãã¾ããPHP 7.0.0 ã§ã¯ Xdebug ã®ãã¼ã¸ã§ã³ãæå®ããã« master ãã©ã³ãããåå¾ãã¦ã¤ã³ã¹ãã¼ã«ããããã§ãã
$ cat 7.0.0 install_package "https://secure.php.net/distributions/php-7.0.0.tar.bz2" install_xdebug_master enable_builtin_opcache
å¤ã PHP ã®ä¾ã¨ã㦠5.3.29 ãè¦ã¦ã¿ã¾ããPHP 5.3 ã«ã¯ OPcache ãå«ã¾ããªãã®ã§ enable_builtin_opcache ã®è¨è¿°ãããã¾ããã
$ cat 5.3.29 install_package "https://secure.php.net/distributions/php-5.3.29.tar.bz2" install_xdebug "2.2.7"
ãã¦ãå®ã¯ãããã®ãã¡ã¤ã«ã¯åãªã bash ã¹ã¯ãªããã§ãbin/php-build ã®ä»¥ä¸ã®ç®æ㧠source ããã¦å®è¡ãããä»çµã¿ã«ãªã£ã¦ãã¾ããã¤ã¾ããinstall_package ã install_xdebug, enable_builtin_opcache ã¨ãã£ãè¨è¿°ã¯ããããããbin/php-build ã¾ãã¯ãã®ä»ã®ãã¡ã¤ã«ã§å®ç¾©ãããé¢æ°åã§ãã
https://github.com/php-build/php-build/blob/51dc7e50c4cd18507e8f70087bef857e6a136901/bin/php-build#L723
install_package é¢æ°ã¯ãå¼æ°ã«æå®ããã URL ããã½ã¼ã¹ã³ã¼ãããã¦ã³ãã¼ããã¦å±éããã«ããã¤ã³ã¹ãã¼ã«ã¾ã§ãå®è¡ããé¢æ°ã§ãããã®é¢æ°ã§ php-build ã®æã主è¦ãªå¦çãå®è¡ããããã¨ã«ãªãã¾ããinstall_package é¢æ°ã®å®ç¾©ã¯ä»¥ä¸ã«ããã¾ããdownload é¢æ°ã§ã½ã¼ã¹ã³ã¼ãã®ãã¦ã³ãã¼ãã¨å±éãbuild_package é¢æ°ã§ãã«ããã¤ã³ã¹ãã¼ã«ãå®è¡ããã¾ãã
https://github.com/php-build/php-build/blob/14e5b43fb693ae7c0b9430859730d07e86aac378/bin/php-build#L400-L410
ãã®ãããªä»çµã¿ã«ãªã£ã¦ããã®ã§ãdefinitions ãã£ã¬ã¯ããªã®ãã¡ã¤ã«ãå¤æ´ã追å ãããã¨ã§ãç¬èªã®ãã«ãå¦çãè¨è¿°ã§ãã¾ããbash ã¹ã¯ãªãããªã®ã§å¥½ãã«æ¸ããã®ã§ãããé å¸ããã¦ãããã¡ã¤ã«ã«ã¯ã©ãããå¦çãæ¸ããã¦ããã®ããä¸è¦§ãè¦ã¦ã¿ã¾ãã
$ cat * | cut -f1 -d' ' | sort | uniq configure_option enable_builtin_opcache install_package install_package_from_github install_xdebug install_xdebug_master patch_file
ãããã®ãã¡ãinstall_xdebug 㨠install_xdebug_master 以å¤ã¯ bin/php-build ã§å®ç¾©ããã¦ãã¾ããconfigure_option 㯠./configure ã«æ¸¡ãããå¼æ°ãæå®ãããã®ã§ããpatch_file 㯠make ã³ãã³ãã®å®è¡åã« PHP ã®ã½ã¼ã¹ã³ã¼ãã«ããããå½ã¦ããã®ã§ã主ã«ãéå»ã® PHP ãç¾å¨ã®ç°å¢ã§ãã«ãããããã«ä½¿ããã¦ããããã§ã*2ã
install_xdebug 㨠install_xdebug_master ã¯ãplugins.d/xdebug.sh ãã¡ã¤ã«ã§å®ç¾©ããã¦ãã¾ããplugins.d ãã£ã¬ã¯ããªã¨ extension ãã£ã¬ã¯ããªã«ã¯ãphp-build ã§æ¡å¼µã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããããã®ä»æããããã¾ããããã«ã¤ãã¦ã¯æ¬è¨äºã®æå¾ã§èª¬æãã¾ãã
ã¨ããã§ãdefinitions ãã£ã¬ã¯ããªã®ãã¡ã¤ã«ãå¤æ´ããã追å ãããããã¨ãgit 管çä¸ã®ãã¡ã¤ã«ã«å·®åãçºçãã¾ããphp-build ã¯å®ç¾©ãã¡ã¤ã«ã®ãã¹ãæå®ãã¦å®è¡ãããã¨ãã§ããã®ã§ãå·®åã®çºçãé¿ããããã°ãä»»æã®ãã£ã¬ã¯ããªã«å®ç¾©ãã¡ã¤ã«ãä½æãã¦åé¡ããã¾ãããã¾ããdefinitions ãã£ã¬ã¯ããªã®ãã¹ã¯ãbin/php-build ã§ä»¥ä¸ã®ããã« PHP_BUILD_DEFINITION_PATH å¤æ°ã«è¨å®ããã¦ãã¾ãããããã£ã¦ããã®å¤æ°ãç°å¢å¤æ°ã«å®ç¾©ãã¦ããã°ãç¬èªã«ä½æãããã£ã¬ã¯ããªãæ¢å®ã®å ´æã«ãããã¨ãã§ãã¾ãã
# Initialize the builtin definition path. [ -z "$PHP_BUILD_DEFINITION_PATH" ] && PHP_BUILD_DEFINITION_PATH="$PHP_BUILD_ROOT/share/php-build/definitions"
default_configuration_options
default_configuration_options ãã¡ã¤ã«ã«ã¯ ./configure ã«æ¸¡ããããªãã·ã§ã³ã®æ¢å®å¤ãæ¸ããã¦ãã¾ããbin/php-build ãã¡ã¤ã«ã®ä»¥ä¸ã®ç®æ㧠CONFIGURE_OPTIONS å¤æ°ã«èªã¿è¾¼ã¾ãã¾ãã
https://github.com/php-build/php-build/blob/14e5b43fb693ae7c0b9430859730d07e86aac378/bin/php-build#L72-L74
ãã®ãã¡ã¤ã«ã®å 容ãå¤æ´ããã°ãPHP ãã«ãæã®æ¢å®ã®è¨å®ãå¤æ´ã§ãã¾ãããã¨ãã°ç§ã¯ PHP-FPM ã§ã¯ãªã Apache ã¢ã¸ã¥ã¼ã«ã使ã£ã¦ããã®ã§ãæå ã®ç°å¢ã§ã¯ --enable-fpm ã®è¡ãåé¤ã㦠--with-apxs2 ã追å ãã¦ãã¾ãã
./configure ã«æ¸¡ããªãã·ã§ã³ãã«ã¹ã¿ãã¤ãºããã«ã¯ãdefault_configuration_options ã®å
容ãç´æ¥æ¸ãæããæ¹æ³ã®ã»ãã«ãå
ã»ã©èª¬æããå®ç¾©ãã¡ã¤ã«ã« configure_option ãè¨è¿°ããæ¹æ³ãããã¾ããã¾ãããªãã·ã§ã³ã追å ããã ããªããPHP_BUILD_CONFIGURE_OPTS ã¾ã㯠CONFIGURE_OPTS ãæå®ããæ¹æ³ãããã¾ãããããäºã¤ã®å¤æ°ã¯ã以ä¸ã®ç®æ㧠CONFIGURE_OPTIONS ã«è¿½å ããã¾ãã
https://github.com/php-build/php-build/blob/14e5b43fb693ae7c0b9430859730d07e86aac378/bin/php-build#L86-L92
è¨å®ããã CONFIGURE_OPTIONS å¤æ°ã bin/php-build ã¹ã¯ãªããã®ã©ãã§å©ç¨ããã¦ããã®ããå¦çã®æµããç°¡åã«è¿½ã£ã¦ããã¾ããåç¯ã§ã¯ãbin/php-build ã¹ã¯ãªããããå®ç¾©ãã¡ã¤ã«ã source ããããããã install_package é¢æ°ãå®è¡ãããã½ã¼ã¹ã³ã¼ãããã¦ã³ãã¼ãããå¾ build_package é¢æ°ãå¼ã°ããã¨ããã¾ã§èª¬æãã¾ãããbuild_package é¢æ°ã®æ¬¡ã®ç®æã§configure_package é¢æ°ãå¼ã°ãã¾ãã
https://github.com/php-build/php-build/blob/14e5b43fb693ae7c0b9430859730d07e86aac378/bin/php-build#L319
configure_packages é¢æ°ã§ ./configure ãå®è¡ããã¾ãããã®ã¨ãã次ã®ããã« CONFIGURE_OPTIONS å¤æ°ã®å 容ããªãã·ã§ã³ã«æ¸¡ããã¾ãã
function configure_package() { ... local argv="--with-config-file-path="$PREFIX/etc" \ --with-config-file-scan-dir="$PREFIX/etc/conf.d" \ --prefix=$PREFIX \ --libexecdir=$PREFIX/libexec \ $CONFIGURE_OPTIONS" ... ./configure $argv > /dev/null ... }
before-install.d
before-install.d ãã£ã¬ã¯ããªã«ã¯ãPHP ããã«ãããåã«å®è¡ããããã¹ã¯ãªãããä½æã§ãã¾ããbin/php-build 㯠./configure ãå®è¡ããå¾ããã®ãã£ã¬ã¯ããªã«ç½®ããããã¡ã¤ã«ãé ã«å®è¡ãã¾ããå
·ä½çã«ã½ã¼ã¹ã³ã¼ãã追ã£ã¦ã¿ã¾ãããã次ã®ç®æ㧠trigger_before_install é¢æ°ãå¼ã°ãã¾ãã
https://github.com/php-build/php-build/blob/14e5b43fb693ae7c0b9430859730d07e86aac378/bin/php-build#L321
trigger_before_install é¢æ°ã¯æ¬¡ã®ããã«å®è£ ããã¦ãã¾ãããã®å®è£ ãããããããã«ãã¹ã¯ãªãã㯠source ãããã®ã§ã¯ãªããµãããã»ã¹ã¨ãã¦èµ·åããã¾ãã
function trigger_before_install() { export PHP_BUILD_ROOT export PREFIX export SOURCE_PATH="$1" local triggers_dir="$PHP_BUILD_ROOT/share/php-build/before-install.d/" local triggers=$(ls "$triggers_dir") if [ -n "$triggers" ]; then for trigger in "$triggers_dir"*; do log "Before Install Trigger" "$(basename $trigger)" /usr/bin/env PATH="$PREFIX/bin:$PATH" "$trigger" 2>&4 done fi }
ä½æããã¹ã¯ãªããå ã§ã¯ãPHP_BUILD_ROOT, PREFIX, SOURCE_PATH ã¨ããå¤æ°ãå©ç¨ã§ãã¾ãããã¨ãã°ãphp-build ã phpenv ã®ãã©ã°ã¤ã³ã¨ãã¦å°å ¥ããã¦ããç°å¢ã§ PHP 7.0.0 ãã¤ã³ã¹ãã¼ã«ããå ´åã次ã®è¡¨ã«ç¤ºããå¤ã«ãªãã¾ãã
å¤æ°å | æå³ | å¤ (PHP 7.0.0 ã¤ã³ã¹ãã¼ã«æ) |
---|---|---|
PHP_BUILD_ROOT | php-build ã®ã¤ã³ã¹ãã¼ã«ãã£ã¬ã¯ã㪠| $PHPENV_ROOT/plugins/php-build |
PREFIX | PHP ã®ã¤ã³ã¹ãã¼ã«ãã£ã¬ã¯ã㪠| $PHPENV_ROOT/versions/7.0.0 |
SOURCE_PATH | PHP ã®ã½ã¼ã¹ãã£ã¬ã¯ã㪠| /tmp/php-build/sources/7.0.0 |
before-install.d ã«ä½æããã¹ã¯ãªããã®ä¾ã示ãã¾ããç§ã¯æ¬¡ã®ãããªã¹ã¯ãªãããæ¸ãã¦å©ç¨ãã¦ãã¾ããããã¯ãApache ã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«å ããphp-build ã§ä½æããã PHP ã®ã¤ã³ã¹ãã¼ã«ãã£ã¬ã¯ããªé ä¸ã«å¤æ´ãããã®ã§ã*3ã./configure ã«ãã£ã¦çæããã Makefile ãå¤æ´ããæ¹æ³ã§å®ç¾ãã¦ãã¾ãã
#!/usr/bin/env bash if type apxs &>/dev/null; then apxs_libexecdir=$(apxs -q LIBEXECDIR) sed -i -e "s|'\$(INSTALL_ROOT)$apxs_libexecdir'|$PREFIX/libexec|g" $SOURCE_PATH/Makefile fi
ãªã before-install.d ãã£ã¬ã¯ããªã¯ .gitignore ã«å«ã¾ãã¦ãã¾ãããããã£ã¦ãããã«ä½æããã¹ã¯ãªãã㯠git ã®ç®¡çä¸ã«ã¯å ¥ãã¾ããã
patches.d
patches.d ãã£ã¬ã¯ããªã«ã¯ãPHP ã®ã½ã¼ã¹ããªã¼ã«é©ç¨ãããããããã¡ã¤ã«ãç½®ããã¦ãã¾ããbefore-install.d ãã£ã¬ã¯ããªã®ã¹ã¯ãªãããå®è¡ãããå¾ã«ãããããé©ç¨ããã¾ããããã¯ãbin/php-build ã®ä»¥ä¸ã®ç®æãã apply_patches é¢æ°ãå¼ã°ãã¦å¦çããã¾ãã
https://github.com/php-build/php-build/blob/14e5b43fb693ae7c0b9430859730d07e86aac378/bin/php-build#L323
patches.d ãã£ã¬ã¯ããªã«ç¬èªã®ããããã¡ã¤ã«ã追å ãã¦ããã°ãmake ã®å®è¡åã« PHP ã®ã½ã¼ã¹ã³ã¼ããä¿®æ£ã§ãã¾ããapply_patches é¢æ°ãèªãã¨å¦çã®å 容ããããã¨æãã¾ãã®ã§ãããã§ã¯èª¬æãçç¥ãã¾ãã
after-install.d
after-install.d ãã£ã¬ã¯ããªã«ã¯ãå®ç¾©ãã¡ã¤ã«ã«æ¸ããããã¹ã¦ã®å¦çãçµããå¾ã«å®è¡ãããã¹ã¯ãªãããä½æã§ãã¾ãããã¨ãã° PHP 7.0.0 ã®å®ç¾©ãã¡ã¤ã«ã¯æ¬¡ã®ã¨ããã§ããã®ã§ãPHP ã®ãã«ããã¤ã³ã¹ãã¼ã«ã ãã§ã¯ãªããXdebug ã®ã¤ã³ã¹ãã¼ã«ãOPcache ã®æå¹åã¨ãã£ãä¸é£ã®å¦çããã¹ã¦çµããå¾ã«å®è¡ããã¾ãã
install_package "https://secure.php.net/distributions/php-7.0.0.tar.bz2" install_xdebug_master enable_builtin_opcache
bin/php-build ã®æ¬¡ã®ç®æãã trigger_after_install é¢æ°ãå¼ã°ãã¾ããå®ç¾©ãã¡ã¤ã«ã source ãã¦å¦çãçµããç´å¾ã«å¼ã°ãã¦ãããã¨ããããã¾ãã
https://github.com/php-build/php-build/blob/14e5b43fb693ae7c0b9430859730d07e86aac378/bin/php-build#L726
é¢æ°ã®å®è£ ã¯ä»¥ä¸ã®ã¨ããã§ããtrigger_before_install é¢æ°ã¨åæ§ã«ãafter-install.d ãã£ã¬ã¯ããªã®åãã¡ã¤ã«ããµãããã»ã¹ã¨ãã¦å®è¡ãã¾ãã
function trigger_after_install() { export PHP_BUILD_ROOT export PREFIX after_install "$PREFIX" 2>&4 local triggers_dir="$PHP_BUILD_ROOT/share/php-build/after-install.d/" local triggers=$(ls "$triggers_dir") if [ -n "$triggers" ]; then for trigger in "$triggers_dir"*; do log "After Install Trigger" "$(basename $trigger)" /usr/bin/env PATH="$PREFIX/bin:$PATH" "$trigger" 2>&4 done fi }
trigger_after_install é¢æ°ããå¼ã°ãã¦ãã after_install é¢æ°ã¯ããã¼ã¸ã§ã³ãã¨ã«ç°ãªãå¦çãå®è¡ãããããã®ã¹ã¿ãã§ããbin/php-build ã§ã®å®è£ ã¯æ¬¡ã®ã¨ããã§ãç¹ã«ä½ãå¦çããã¾ãããå®ç¾©ãã¡ã¤ã«å ã§é¢æ°ãä¸æ¸ããã¦åå¥ã®å¦çãå®è£ ãããã¨ãæå³ãã¦ããããã§ãã
# after_install(BUILD_DIR) # # Gets called after install has finished. # Implement this function in your definitions. function after_install() { local stub=1 }
after-install.d ã«ä½æããã¹ã¯ãªããã®ä¾ã示ãã¾ããbefore-install.d ã®ä¾ã¨åæ§ã«ãç§ã®æå ã®ç°å¢ã§å©ç¨ãã¦ãããã®ã§ãã次ã®ã¹ã¯ãªããã§ã¯ php.ini ãã¡ã¤ã«ãæ¸ãæã㦠memory_limit ã 1024MB ã«ãã¿ã¤ã ã¾ã¼ã³ã Asia/Tokyo ã«è¨å®ãã¦ãã¾ãã
#!/usr/bin/env bash inifile="$PREFIX/etc/php.ini" if [ -f "$inifile" ]; then sed -i -e 's/^memory_limit =.*$/memory_limit = 1024M/' $inifile sed -i -e 's/^;date.timezone =.*$/date.timezone = Asia\/Tokyo/' $inifile fi
after-install.d ã .gitignore ã«å«ã¾ãã¦ããã®ã§ãä½æããã¹ã¯ãªãã㯠git ã®ç®¡çä¸ã«ã¯å ¥ãã¾ããã
extensions
ããã¾ã§ã«èª¬æãããã¹ã¦ã®å¦çãçµããå¾ã«ãæ¡å¼µã¢ã¸ã¥ã¼ã«ããã¦ã³ãã¼ããã¤ã³ã¹ãã¼ã«ãããã¨ãã§ãã¾ããããã«ã¯ã次ã®ããã« PHP_BUILD_INSTALL_EXTENSION å¤æ°ãè¨å®ã㦠php-build ãå®è¡ãã¾ãããã®ä¾ã§ã¯ããã¤ãã³ã¼ãå½ä»¤ããã³ããã vld ã¢ã¸ã¥ã¼ã«ã¨ PHP ããæ½è±¡æ§ææ¨ãæ±ããããã«ãã ast ã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããããã«æ示ãã¦ãã¾ãã
$ PHP_BUILD_INSTALL_EXTENSION='vld=@ ast=@' phpenv install 7.0.0
å®ã¯ãä¸è¨ã®ããã«å®è¡ããããã«ã¯ãããããã extensions ãã£ã¬ã¯ããªã«ãã definition ã¨ããååã®ãã¡ã¤ã«ãç·¨éãã¦ããå¿ è¦ãããã¾ããããã¯æ¬¡ã®ãã㪠csv å½¢å¼ã®ãã¡ã¤ã«ã§ãæ¡å¼µã¢ã¸ã¥ã¼ã«ã®ãã¦ã³ãã¼ã URL ãªã©ã管çãããã®ã§ãã
$ cat definition "name","url-dist","url_source","source_cwd","configure_args","extension_type","after_install" "apc","http://pecl.php.net/get/APC-$version.tgz","[email protected]:/pecl/caching/apc.git",,"--enable-apc","extension", "apcu","http://pecl.php.net/get/apcu-$version.tgz","https://github.com/krakjoe/apcu.git",,,"extension", ...
ãã¨ãã°ç§ã¯ãvld 㨠ast ãã¤ã³ã¹ãã¼ã«ããããã«æ¬¡ã®ããã«è¿½è¨ãã¦ãã¾ãã
... "ast",,"https://github.com/nikic/php-ast.git",,,"extension", "vld","http://pecl.php.net/get/vld-$version.tgz","https://github.com/derickr/vld.git",,,"extension",
åã«ã©ã ã®æå³ã¯æ¬¡ã®ã¨ããã§ãã1 åç®ã® name 㨠6 åç®ã® extension_type ã¯å¿ é ã§ããã¾ãã2 åç®ã® url-dist 㨠3 åç®ã® url_source ã®ããããä¸æ¹ã¯å¿ é ã§ãããã®ä»ã®ã«ã©ã ã¯ç©ºã§ãæ§ãã¾ããããã以éã§ã¯ãbin/php-build ã®ã½ã¼ã¹ã³ã¼ãã¨ç §ããåãããªããããããã®è¨è¿°ãã©ã®ããã«å©ç¨ãããã®ãã追ã£ã¦ã¿ã¾ãã
åçªå· | ã«ã©ã å | æå³ |
---|---|---|
1 | name | ã¢ã¸ã¥ã¼ã«å |
2 | url-dist | ãã¼ã¸ã§ã³æå®æã®ãã¦ã³ãã¼ã URL |
3 | url_source | git ãªãã¸ããªã® URL |
4 | source_cwd | ãã«ããå®è¡ãããã£ã¬ã¯ã㪠(ç¸å¯¾ãã¹) |
5 | configure_args | ./configure å®è¡æã®ãªãã·ã§ã³ |
6 | extension_type | extension ã¾ã㯠zend_extension |
7 | after_install | ã¤ã³ã¹ãã¼ã«å¾ã®è¿½å å¦çãè¡ãé¢æ°å |
bin/php-build ã®ä»¥ä¸ã®ç®æãã install_extensions é¢æ°ãå¼ã°ãããã¨ã§ãæ¡å¼µã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«å¦çãå§ã¾ãã¾ãããã㯠trigger_after_install é¢æ°ã®å¾ã«å¼ã°ãã¾ãã
https://github.com/php-build/php-build/blob/14e5b43fb693ae7c0b9430859730d07e86aac378/bin/php-build#L729
install_extensions é¢æ°ã®å®è£ ã¯ä»¥ä¸ã®ã¨ããã§ããPHP_BUILD_INSTALL_EXTENSION å¤æ°ããã¢ã¸ã¥ã¼ã«åã¨ãã¼ã¸ã§ã³ãåãåºã㦠install_extension_source é¢æ°ã¾ã㯠install_extension é¢æ°ãå¼ã³åºãã¾ããå³è¾ºã® 1 æåç®ã "@" ãªããªãã¸ã§ã³çªå·ã¨ã¿ãªã㦠install_extension_source é¢æ°ãããã以å¤ãªããã¼ã¸ã§ã³çªå·ã¨ã¿ãªã㦠install_extension é¢æ°ãå¼ã°ãã¾ãã
function install_extensions() { # handle extensions that should be installed by defined environment variable # variable must be in the format: extension_name=version extension_name=version for extension_def in $PHP_BUILD_INSTALL_EXTENSION; do local extension=$(echo $extension_def | cut -d"=" -f1) local version=$(echo $extension_def | cut -d"=" -f2) local first_char=$(echo $version | cut -c1 ) # if first character of version is an "@" it's meant to be a revision if [ $first_char = "@" ]; then local version=$(echo $version | cut -c"2-") install_extension_source $extension "$version" else install_extension $extension $version fi done }
install_extension_source é¢æ°ãinstall_extension é¢æ°ã¯ãã©ã¡ãã extension/extension.sh ã«å®ç¾©ããã¦ãã¾ããããã§å
ã»ã©ã® extension/definition ãã¡ã¤ã«ããã¢ã¸ã¥ã¼ã«åã®ä¸è´ããè¡ãèªã¿åãã_download_extension é¢æ°ã¾ã㯠_checkout_extension é¢æ°ãå¼ã³åºãã¦ã½ã¼ã¹ã³ã¼ããåå¾ãã¾ãã_download_extension é¢æ°ã§ã¯ 2 åç®ã® url-dist ãã_checkout_extension é¢æ°ã§ã¯ 3 åç®ã® url_source ãå©ç¨ããã¾ãããããã®å ´åã§ããã½ã¼ã¹ã³ã¼ãã®åå¾å¾ã« _build_extension é¢æ°ãå¼ã³åºãã¦ã¢ã¸ã¥ã¼ã«ããã«ããã¾ãã
https://github.com/php-build/php-build/blob/14e5b43fb693ae7c0b9430859730d07e86aac378/share/php-build/extension/extension.sh#L9-L44
_build_extension é¢æ°ã¯ãåããã¡ã¤ã«ã®ä»¥ä¸ã®ç®æã§å®è£
ããã¦ãã¾ãã
https://github.com/php-build/php-build/blob/14e5b43fb693ae7c0b9430859730d07e86aac378/share/php-build/extension/extension.sh#L115-L161
æ¡å¼µã¢ã¸ã¥ã¼ã«ããã«ãããå¦çã¯æ¬¡ã®ããã«å®è£ ããã¦ãã¾ããextension/definition ãã¡ã¤ã« 4 åç®ã® source_cwd ã«æå®ããããã£ã¬ã¯ããªå ã§ãã«ããå®è¡ãã¾ãã./configure ã¹ã¯ãªããã®å®è¡æã«ã¯ã5 åç®ã® configure_args ã«è¨è¿°ããããªãã·ã§ã³ã渡ããã¾ãã
... cd "$source_dir/$source_cwd" { $PREFIX/bin/phpize > /dev/null "$(pwd)/configure" --with-php-config=$PREFIX/bin/php-config \ $configure_args > /dev/null make > /dev/null make install > /dev/null } >&4 2>&1 ...
æ¡å¼µã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«å¾ã次ã®å®è£ ã«ãã£ã¦ãetc/conf.d ãã£ã¬ã¯ããªã«è¨å®ãã¡ã¤ã«ãä½æãã¾ãããã®ã¨ãã6 åç®ã® extension_type ã«ãããã£ã¦ extension ã¾ã㯠zend_extension ãåºåããã¾ãã
... local extension_ini="$PREFIX/etc/conf.d/$name.ini" if [ ! -f "$extension_ini" ]; then log "$name" "Installing $name configuration in $extension_ini" echo "$extension_type=\"$name.so\"" > $extension_ini fi ...
æå¾ã«ã7 åç®ã® after_install ã«é¢æ°åãæå®ããã¦ããã°ããã®é¢æ°ãå¼ã³åºãã¦ã¤ã³ã¹ãã¼ã«å¾ã®å¦çãå®è¡ãã¾ãããã¨ãã° Xebug ã§ã¯ xdebug_after_install é¢æ°ãæå®ããã¦ãã¾ãããã®é¢æ°ã¯ plugins.d/xdebug.sh ãã¡ã¤ã«ã«å®ç¾©ããã¦ãã¾ãã
... if [ -n "$after_install" ]; then # Zend extensions are not looked up in PHP's extension dir, so # we need to find the absolute path for the extension_dir. local extension_dir=$("$PREFIX/bin/php-config" --extension-dir) $after_install "$source_dir" "$extension_ini" "$extension_type" "$extension_dir" "$extension_home" fi ...
以ä¸ãæ¡å¼µã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããå¦çã®å®è£ ãé§ã足ã§è¦ã¦ãã¾ããããã®ãããªä»æãã§ãPHP_BUILD_INSTALL_EXTENSION å¤æ°ã®æå®ã«ããæ¡å¼µã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«ãè¡ãã¾ãã
æ¡å¼µã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããå¥ã®æ¹æ³ã¨ãã¦ãå®ç¾©ãã¡ã¤ã«ã«è¨è¿°ãããã¨ãã§ãã¾ãããã¨ãã° vld ãã¤ã³ã¹ãã¼ã«ããã«ã¯ãå®ç¾©ãã¡ã¤ã«ã«æ¬¡ã®ããã«æ¸ããã¨ãã§ãã¾ãããã®è¨è¿°ã«ãã£ã¦ãextension/extension.sh ã® install_extension_source é¢æ°ãç´æ¥å¼ã³åºãã㦠vld ãã¤ã³ã¹ãã¼ã«ããã¾ãã
... install_extension_source "vld"
ã¾ããplugins.d ãã£ã¬ã¯ããªã«ãã¡ã¤ã«ãä½æãããã¨ãã§ãã¾ããplugins.d/vld.sh ãã¡ã¤ã«ã次ã®ããã«ä½æãã¦ããã°ãå®ç¾©ãã¡ã¤ã«ã§ install_vld_master, install_vld ã¨ããè¨è¿°ã使ããããã«ãªãã¾ããåé ã«è¦ã install_xdebug_master, install_xdebug ãªã©ã¯ããã®æ¹å¼ã§å®è£ ããã¦ãã¾ãã
#!/usr/bin/env bash function install_vld_master { install_extension_source "vld" "$1" } function install_vld { install_extension "vld" "$1" }
ãªããé常ã¯ç¹ã«åé¡ã«ãªããªãã¨æãã¾ãããPHP_BUILD_INSTALL_EXTENSION å¤æ°ãæå®ãã¦æ¡å¼µã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããå ´åã¨ãå®ç¾©ãã¡ã¤ã«ã«è¨è¿°ãã¦ã¤ã³ã¹ãã¼ã«ããå ´åã§ã¯ãæ¡å¼µã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ãããã¿ã¤ãã³ã°ãç°ãªããã¨ã«æ³¨æãã¦ãã ãããPHP_BUILD_INSTALL_EXTENSION å¤æ°ãæå®ããå ´åã«ã¯ after_install.d ãã£ã¬ã¯ããªã®ã¹ã¯ãªããã®å®è¡å¾ã«ã¤ã³ã¹ãã¼ã«ããã¾ããä¸æ¹ãå®ç¾©ãã¡ã¤ã«ã«è¨è¿°ããå ´åã«ã¯ãafter_install.d ãã£ã¬ã¯ããªã®ã¹ã¯ãªãããå®è¡ããããããåã«æ¡å¼µã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããã¾ãã
ã¾ã¨ã
php-build ã®å®è£ ã追ããªãããå¦çãã«ã¹ã¿ãã¤ãºããæ¹æ³ãç´¹ä»ãã¾ãããã¾ã¨ããã¨ãphp-build ã§ã¯æ¬¡ã®æé 㧠PHP ããã«ããã¾ããå¦çã®åæã§ã¦ã¼ã¶ãä½æããã¹ã¯ãªãããå¼ã³åºããããã«ãªã£ã¦ããããããå©ç¨ã㦠php-build ã®å¦çãã«ã¹ã¿ãã¤ãºã§ãã¾ãã
- definitions ãã£ã¬ã¯ããªã«ç½®ãããå®ç¾©ãã¡ã¤ã«ã source ããã
- å®ç¾©ãã¡ã¤ã«ã®è¨è¿°ãã install_package é¢æ°ãå¼ã°ã㦠PHP ããã«ãããã
- ./configure 㨠make ã®é㧠before_install.d ãã£ã¬ã¯ããªã®ã¹ã¯ãªãããå®è¡ããã
- å®ç¾©ãã¡ã¤ã«ã«æ¸ãããå¦çã®çµäºå¾ã« after_install.d ãã£ã¬ã¯ããªã®ã¹ã¯ãªãããå®è¡ããã
- æå¾ã« PHP_BUILD_INSTALL_EXTENSION å¤æ°ã«æå®ãããæ¡å¼µã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããã
*1:bin ãã£ã¬ã¯ããªã«ãããã®ä»ã®ã¹ã¯ãªããã¯ãphp-build ã phpenv ã®ãã©ã°ã¤ã³ã¨ãã¦å©ç¨ããããã®ãã®ã§ãããã®è¨äºã§ã¯ bin/php-build 以å¤ã®ã¹ã¯ãªããã«ã¤ãã¦ã¯èª¬æãã¾ããã
*2:definitions ãã£ã¬ã¯ããªã®ãã¡ã¤ã«ã®ä¸ã§ patch_file ãæå®ããã¦ããã®ã¯ããã¹ã¦ PHP 5.4 以åã®ãã®ã§ããã
*3:anyenv + phpenv + php-build で複数のバージョンの PHP を切り替える - y_uti のブログ ã§ç´¹ä»ããå 容ãæ¸ãç´ãããã®ã§ãã