|
1 | 1 | #!/usr/bin/env bash
|
2 |
| -# php-ast installation and configuration script, taken from Etsy/Phan |
3 |
| - |
4 |
| -function build { |
5 |
| - phpize |
6 |
| - ./configure |
7 |
| - make |
8 |
| -} |
9 |
| - |
10 |
| -function cleanBuild { |
11 |
| - make clean |
12 |
| - build |
13 |
| -} |
14 |
| - |
15 |
| -function install { |
16 |
| - make install |
17 |
| - echo "extension=ast.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini |
18 |
| -} |
19 |
| - |
20 |
| -# Ensure the build directory exists |
21 |
| -[[ -d "build" ]] || mkdir build |
22 |
| - |
23 |
| -# Ensure that the PHP version hasn't changed under us. If it has, we'll have to |
24 |
| -# rebuild the extension. |
25 |
| -if [[ -e "build/phpversion.txt" ]]; then |
26 |
| - if ! diff -q build/phpversion.txt <(php -r "echo PHP_VERSION_ID;"); then |
27 |
| - # Something has changed, so nuke the build/ast directory if it exists. |
28 |
| - echo "New version of PHP detected. Removing build/ast so we can do a fresh build." |
29 |
| - rm -rf build/ast |
30 |
| - fi |
31 |
| -fi |
32 |
| - |
33 |
| -# Ensure that we have a copy of the ast extension source code. |
34 |
| -if [[ ! -e "build/ast/config.m4" ]]; then |
35 |
| - # If build/ast exists, but build/ast/config.m4 doesn't, nuke it and start over. |
36 |
| - [[ ! -d "build/ast" ]] || rm -rf build/ast |
37 |
| - git clone --depth 1 https://github.com/nikic/php-ast.git build/ast |
38 |
| -fi |
39 |
| - |
40 |
| -# Install the ast extension |
41 |
| -pushd ./build/ast |
42 |
| - # If we don't have ast.so, we have to build it. |
43 |
| - if [[ ! -e "modules/ast.so" ]]; then |
44 |
| - echo "No cached extension found. Building..." |
45 |
| - build |
46 |
| - else |
47 |
| - # If there are new commits, we need to rebuild the extension. |
48 |
| - git fetch origin master |
49 |
| - newCommits=$(git rev-list HEAD...origin/master --count) |
50 |
| - if [[ "$newCommits" != "0" ]]; then |
51 |
| - echo "New commits found upstream. Updating and rebuilding..." |
52 |
| - git pull origin master |
53 |
| - cleanBuild |
54 |
| - else |
55 |
| - echo "Using cached extension." |
56 |
| - fi |
57 |
| - fi |
58 |
| - |
59 |
| - # No matter what, we still have to move the .so into place and enable it. |
60 |
| - install |
61 |
| -popd |
62 |
| - |
63 |
| -# Note the PHP version for later builds. |
64 |
| -php -r "echo PHP_VERSION_ID;" > build/phpversion.txt |
| 2 | +# This has been tested with 0.1.5 but not any other versions |
| 3 | +pecl install -f ast-0.1.5 |
65 | 4 |
|
66 | 5 | # Disable xdebug, since we aren't currently gathering code coverage data and
|
67 | 6 | # having xdebug slows down Composer a bit.
|
|
0 commit comments