summaryrefslogtreecommitdiffstats
path: root/php_trie-build.patch
blob: a834161eeb86913fd5190d334ec35be7e7b2a30b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
From c2e76aa7daf1829502736ed7d2659813bba52792 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 9 Sep 2020 09:13:44 +0200
Subject: [PATCH 07/10] fix header config.m4

---
 config.m4 | 12 +++++-------
 trie.h    |  2 +-
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/config.m4 b/config.m4
index 2236ddf..52e086b 100644
--- a/config.m4
+++ b/config.m4
@@ -15,30 +15,28 @@ if test "$PHP_PHP_TRIE" != "no"; then
   AC_MSG_CHECKING([for Tessil/hat-trie library])
   if test -s $PHP_HATTRIE/$HATTRIE_HEADER; then
     AC_MSG_RESULT(found $HATTRIE_HEADER)
-    HATTRIE_LIB=$PHP_HATTRIE/$HATTRIE_HEADER
+    HATTRIE_LIB=$PHP_HATTRIE
   else
     for iter in $HEADER_INSTALL_DIRS; do
       if test -s $iter/$HATTRIE_CPP_DIR/$HATTRIE_CPP_HEADER; then
         AC_MSG_RESULT(found $HATTRIE_HEADER)
-        HATTRIE_LIB=$iter/$HATTRIE_CPP_DIR/$HATTRIE_CPP_HEADER
+        HATTRIE_LIB=$iter/$HATTRIE_CPP_DIR
       fi
     done
   fi
 
   if test -z "$HATTRIE_LIB"; then
     AC_MSG_RESULT(hattrie lib is not properly installed. You will not be able to use the HAT trie)
-    dnl AC_MSG_ERROR(Please install the hattrie library)
+    AC_MSG_ERROR(Please install the hattrie library)
   fi
 
   dnl add support for C++
-  CXXFLAGS="-std=c++11"
   PHP_REQUIRE_CXX()
+  PHP_ADD_INCLUDE($HATTRIE_LIB)
 
-  PHP_SUBST(PHP_TRIE_SHARED_LIBADD)
   
   dnl add C++11 standard library
-  PHP_ADD_LIBRARY(stdc++, 1, PHP_TRIE_SHARED_LIBADD)
   AC_DEFINE(HAVE_PHP_TRIE, 1, [ Have php_trie support ])
   
-  PHP_NEW_EXTENSION(php_trie, php_trie.cpp, $ext_shared)
+  PHP_NEW_EXTENSION(php_trie, php_trie.cpp, $ext_shared,, -std=c++11, cxx)
 fi
diff --git a/trie.h b/trie.h
index e653e80..b54918a 100644
--- a/trie.h
+++ b/trie.h
@@ -15,7 +15,7 @@
 #include <utility>
 #include <cstddef>
 #include <string>
-#include <hat-trie/include/tsl/htrie_map.h>
+#include <htrie_map.h>
 
 namespace trie
 {

From 8fff61e1dfd4fa2c22cc160711402bd68cdf525f Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 9 Sep 2020 09:14:42 +0200
Subject: [PATCH 08/10] fix test, seems order was wrong

---
 tests/trie/merge.phpt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/trie/merge.phpt b/tests/trie/merge.phpt
index e59f3b3..5c7bb9e 100644
--- a/tests/trie/merge.phpt
+++ b/tests/trie/merge.phpt
@@ -21,8 +21,8 @@ array(4) {
   string(3) "foo"
   ["baz"]=>
   int(12)
-  ["baff"]=>
-  bool(false)
   ["bar"]=>
   string(3) "bar"
-}
\ No newline at end of file
+  ["baff"]=>
+  bool(false)
+}

From 2b8feba9542c72339bf177169a776289212e2e5e Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 9 Sep 2020 09:21:49 +0200
Subject: [PATCH 09/10] add module dependency on json

---
 php_trie.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/php_trie.cpp b/php_trie.cpp
index 07d6015..1c766d7 100644
--- a/php_trie.cpp
+++ b/php_trie.cpp
@@ -488,10 +488,17 @@ PHP_MINIT_FUNCTION(php_trie)
 }
 /* }}} */
 
+static zend_module_dep php_trie_deps[] = {
+    ZEND_MOD_REQUIRED("json")
+    ZEND_MOD_END
+};
+
 /* {{{ php_trie_module_entry
  */
 zend_module_entry php_trie_module_entry = {
-    STANDARD_MODULE_HEADER,
+    STANDARD_MODULE_HEADER_EX,
+    NULL,
+    php_trie_deps,
     "php_trie",                          /* Extension name */
     trie_methods,                        /* zend_function_entry */
     PHP_MINIT(php_trie),                 /* PHP_MINIT - Module initialization */

From cf7c464594e7c7628fdeb30159f7a458c61699d3 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 9 Sep 2020 09:25:12 +0200
Subject: [PATCH 10/10] sort test result to avoid failure

---
 tests/trie/merge.phpt | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/tests/trie/merge.phpt b/tests/trie/merge.phpt
index 5c7bb9e..4cdb86b 100644
--- a/tests/trie/merge.phpt
+++ b/tests/trie/merge.phpt
@@ -13,16 +13,18 @@ $snd['baz'] = 12;
 $thd = new Trie;
 $thd['baff'] = false;
 
-var_dump($fst->merge($snd, $thd)->toArray());
+$res = $fst->merge($snd, $thd)->toArray();
+ksort($res);
+var_dump($res);
 ?>
 --EXPECT--
 array(4) {
-  ["foo"]=>
-  string(3) "foo"
-  ["baz"]=>
-  int(12)
-  ["bar"]=>
-  string(3) "bar"
   ["baff"]=>
   bool(false)
+  ["bar"]=>
+  string(3) "bar"
+  ["baz"]=>
+  int(12)
+  ["foo"]=>
+  string(3) "foo"
 }