summaryrefslogtreecommitdiffstats
path: root/2774.patch
blob: c3c7a084da292ed09ce3725987b853ee0f250220 (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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
From 379c258e03959a8a1482d8cb498b67b8de7f0bc0 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Thu, 4 Sep 2014 15:02:31 +0200
Subject: [PATCH] add --without-non-free build option to disable non-free
 minifiers

---
 ext/assets/filters/cssmin.c        |  4 ++++
 ext/assets/filters/jsmin.c         |  4 ++++
 ext/assets/filters/nocssminifier.c | 31 +++++++++++++++++++++++++++++++
 ext/assets/filters/nocssminifier.h | 27 +++++++++++++++++++++++++++
 ext/assets/filters/nojsminifier.c  | 31 +++++++++++++++++++++++++++++++
 ext/assets/filters/nojsminifier.h  | 27 +++++++++++++++++++++++++++
 ext/config.m4                      | 13 +++++++++++--
 7 files changed, 135 insertions(+), 2 deletions(-)
 create mode 100644 ext/assets/filters/nocssminifier.c
 create mode 100644 ext/assets/filters/nocssminifier.h
 create mode 100644 ext/assets/filters/nojsminifier.c
 create mode 100644 ext/assets/filters/nojsminifier.h

diff --git a/ext/assets/filters/cssmin.c b/ext/assets/filters/cssmin.c
index 3cfc89e..b490ae4 100644
--- a/ext/assets/filters/cssmin.c
+++ b/ext/assets/filters/cssmin.c
@@ -18,7 +18,11 @@
 */
 
 #include "assets/filters/cssmin.h"
+#ifdef PHALCON_NON_FREE
 #include "assets/filters/cssminifier.h"
+#else
+#include "assets/filters/nocssminifier.h"
+#endif
 #include "assets/filterinterface.h"
 
 #include "kernel/main.h"
diff --git a/ext/assets/filters/jsmin.c b/ext/assets/filters/jsmin.c
index 26197de..2b2791c 100644
--- a/ext/assets/filters/jsmin.c
+++ b/ext/assets/filters/jsmin.c
@@ -18,7 +18,11 @@
 */
 
 #include "assets/filters/jsmin.h"
+#ifdef PHALCON_NON_FREE
 #include "assets/filters/jsminifier.h"
+#else
+#include "assets/filters/nojsminifier.h"
+#endif
 #include "assets/filterinterface.h"
 
 #include "kernel/main.h"
diff --git a/ext/assets/filters/nocssminifier.c b/ext/assets/filters/nocssminifier.c
new file mode 100644
index 0000000..efebc82
--- /dev/null
+++ b/ext/assets/filters/nocssminifier.c
@@ -0,0 +1,31 @@
+/*
+  +------------------------------------------------------------------------+
+  | Phalcon Framework                                                      |
+  +------------------------------------------------------------------------+
+  | Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com)       |
+  +------------------------------------------------------------------------+
+  | This source file is subject to the New BSD License that is bundled     |
+  | with this package in the file docs/LICENSE.txt.                        |
+  |                                                                        |
+  | If you did not receive a copy of the license and are unable to         |
+  | obtain it through the world-wide-web, please send an email             |
+  | to license@phalconphp.com so we can send you a copy immediately.       |
+  +------------------------------------------------------------------------+
+  | Authors: Remi Collet <remi@famillecollet.com>                          |
+  +------------------------------------------------------------------------+
+*/
+
+/* placeholder for non-free csssminifier.c */
+
+
+#include "php_phalcon.h"
+
+#include "assets/filters/nocssminifier.h"
+#include "assets/exception.h"
+#include "kernel/exception.h"
+
+int phalcon_cssmin(zval *return_value, zval *style TSRMLS_DC) {
+
+	PHALCON_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, "Non-free csssminifier not available");
+	return FAILURE;
+}
diff --git a/ext/assets/filters/nocssminifier.h b/ext/assets/filters/nocssminifier.h
new file mode 100644
index 0000000..6ac8b07
--- /dev/null
+++ b/ext/assets/filters/nocssminifier.h
@@ -0,0 +1,27 @@
+/*
+  +------------------------------------------------------------------------+
+  | Phalcon Framework                                                      |
+  +------------------------------------------------------------------------+
+  | Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com)       |
+  +------------------------------------------------------------------------+
+  | This source file is subject to the New BSD License that is bundled     |
+  | with this package in the file docs/LICENSE.txt.                        |
+  |                                                                        |
+  | If you did not receive a copy of the license and are unable to         |
+  | obtain it through the world-wide-web, please send an email             |
+  | to license@phalconphp.com so we can send you a copy immediately.       |
+  +------------------------------------------------------------------------+
+  | Authors: Remi Collet <remi@famillecollet.com>                          |
+  +------------------------------------------------------------------------+
+*/
+
+/* placeholder for non-free csssminifier.h */
+
+#ifndef PHALCON_ASSETS_FILTERS_CSSMINIFIER_H
+#define PHALCON_ASSETS_FILTERS_CSSMINIFIER_H
+
+#include <Zend/zend.h>
+
+int phalcon_cssmin(zval *return_value, zval *style TSRMLS_DC);
+
+#endif /* PHALCON_ASSETS_FILTERS_CSSMINIFIER_H */
diff --git a/ext/assets/filters/nojsminifier.c b/ext/assets/filters/nojsminifier.c
new file mode 100644
index 0000000..885035b
--- /dev/null
+++ b/ext/assets/filters/nojsminifier.c
@@ -0,0 +1,31 @@
+/*
+  +------------------------------------------------------------------------+
+  | Phalcon Framework                                                      |
+  +------------------------------------------------------------------------+
+  | Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com)       |
+  +------------------------------------------------------------------------+
+  | This source file is subject to the New BSD License that is bundled     |
+  | with this package in the file docs/LICENSE.txt.                        |
+  |                                                                        |
+  | If you did not receive a copy of the license and are unable to         |
+  | obtain it through the world-wide-web, please send an email             |
+  | to license@phalconphp.com so we can send you a copy immediately.       |
+  +------------------------------------------------------------------------+
+  | Authors: Remi Collet <remi@famillecollet.com>                          |
+  +------------------------------------------------------------------------+
+*/
+
+/* placeholder for non-free jsminifier.c */
+
+
+#include "php_phalcon.h"
+
+#include "assets/filters/nojsminifier.h"
+#include "assets/exception.h"
+#include "kernel/exception.h"
+
+int phalcon_jsmin(zval *return_value, zval *script TSRMLS_DC) {
+
+	PHALCON_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, "Non-free jsminifier not available");
+	return FAILURE;
+}
diff --git a/ext/assets/filters/nojsminifier.h b/ext/assets/filters/nojsminifier.h
new file mode 100644
index 0000000..95829cc
--- /dev/null
+++ b/ext/assets/filters/nojsminifier.h
@@ -0,0 +1,27 @@
+/*
+  +------------------------------------------------------------------------+
+  | Phalcon Framework                                                      |
+  +------------------------------------------------------------------------+
+  | Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com)       |
+  +------------------------------------------------------------------------+
+  | This source file is subject to the New BSD License that is bundled     |
+  | with this package in the file docs/LICENSE.txt.                        |
+  |                                                                        |
+  | If you did not receive a copy of the license and are unable to         |
+  | obtain it through the world-wide-web, please send an email             |
+  | to license@phalconphp.com so we can send you a copy immediately.       |
+  +------------------------------------------------------------------------+
+  | Authors: Remi Collet <remi@famillecollet.com>                          |
+  +------------------------------------------------------------------------+
+*/
+
+/* placeholder for non-free jsminifier.h */
+
+#ifndef PHALCON_ASSETS_FILTERS_JSMINIFIER_H
+#define PHALCON_ASSETS_FILTERS_JSMINIFIER_H
+
+#include <Zend/zend.h>
+
+int phalcon_jsmin(zval *return_value, zval *script TSRMLS_DC);
+
+#endif /* PHALCON_ASSETS_FILTERS_JSMINIFIER_H */
diff --git a/ext/config.m4 b/ext/config.m4
index 88f8e4c..2df6dcd 100644
--- a/ext/config.m4
+++ b/ext/config.m4
@@ -1,4 +1,5 @@
 PHP_ARG_ENABLE(phalcon, whether to enable phalcon framework, [ --enable-phalcon   Enable phalcon framework])
+PHP_ARG_WITH(non-free, wheter to enable non-free css and js minifier, [ --without-non-free Disable non-free minifiers], yes, no)
 
 if test "$PHP_PHALCON" = "yes"; then
 	AC_DEFINE(HAVE_PHALCON, 1, [Whether you have Phalcon Framework])
@@ -340,8 +341,6 @@ validation/validator/inclusionin.c \
 validation/validator/stringlength.c \
 validation/validator/url.c \
 validation/validator.c \
-assets/filters/jsminifier.c \
-assets/filters/cssminifier.c \
 mvc/model/query/parser.c \
 mvc/model/query/scanner.c \
 mvc/view/engine/volt/parser.c \
@@ -364,6 +363,16 @@ psr/log/loglevel.c \
 psr/log/nulllogger.c \
 registry.c"
 
+	AC_MSG_CHECKING([Include non-free minifiers])
+	if test "$PHP_NON_FREE" = "yes"; then
+		phalcon_sources="$phalcon_sources assets/filters/jsminifier.c assets/filters/cssminifier.c "
+		AC_DEFINE([PHALCON_NON_FREE], [1], [Whether non-free minifiers are available])
+		AC_MSG_RESULT([yes, css and js])
+	else
+		phalcon_sources="$phalcon_sources assets/filters/nojsminifier.c assets/filters/nocssminifier.c "
+		AC_MSG_RESULT([no])
+	fi
+
 	PHP_NEW_EXTENSION(phalcon, $phalcon_sources, $ext_shared)
 	PHP_ADD_EXTENSION_DEP([phalcon], [spl])