From da13fc45b7b2cdac449b18fda0bfdd9d00dcd48f Mon Sep 17 00:00:00 2001
From: diosmosis <benakamoorthi@fastmail.fm>
Date: Wed, 20 Aug 2014 12:22:15 -0700
Subject: [PATCH] Automate building of xhprof through composer install/update.

---
 composer.json                 | 10 +++++++++-
 misc/composer/build-xhprof.sh | 23 +++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 misc/composer/build-xhprof.sh

diff --git a/composer.json b/composer.json
index 061ed97b8f..f223fe4027 100644
--- a/composer.json
+++ b/composer.json
@@ -48,5 +48,13 @@
             "type": "vcs",
             "url": "https://github.com/phacility/xhprof"
         }
-    ]
+    ],
+    "scripts": {
+        "post-update-cmd": [
+            "misc/composer/build-xhprof.sh"
+        ],
+        "post-install-cmd": [
+            "misc/composer/build-xhprof.sh"
+        ]
+    }
 }
diff --git a/misc/composer/build-xhprof.sh b/misc/composer/build-xhprof.sh
new file mode 100644
index 0000000000..2d961e0889
--- /dev/null
+++ b/misc/composer/build-xhprof.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+cd vendor/facebook/xhprof/extension
+
+echo "Building xhprof..."
+
+git fetch origin pull/33/head:33_pull_request
+git merge 33_pull_request
+
+if ! phpize; then
+    echo "Fatal error: phpize failed!"
+    exit 1
+fi
+
+if ! ./configure; then
+    echo "Fatal error: configure script failed!"
+    exit 2
+fi
+
+if ! make; then
+    echo "Fatal error: could not build extension (make failed)!"
+    exit 3
+fi
-- 
GitLab