summaryrefslogtreecommitdiffstats
path: root/zephir.spec
blob: de3b4309123a70ab759c1d0f29a3632b441daa4e (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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# remirepo/fedora spec file for zephir
#
# Copyright (c) 2016-2019 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#

%if 0%{?scl:1}
%global with_tests   0
%scl_package zephyr-parser
%else
%global with_tests   0%{!?_without_tests:1}
%endif

# Get commit from PHP_PHALCON_ZEPVERSION in 
# https://github.com/phalcon/cphalcon/blob/master/ext/php_phalcon.h
%global gh_commit    1c107e0c8966233f0d35156419e2c97729dcc4ce
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
#global gh_date      20161126
%global gh_owner     phalcon
%global gh_project   zephir
%global ext_name     zephir_parser
%global parser_ver   1.1.1

Name:           %{?scl_prefix}%{gh_project}
Version:        0.12.7
Release:        2%{?gh_date:.%{gh_date}.%{gh_short}}%{?dist}
Summary:        Zephir language for creation of extensions for PHP.

License:        MIT
URL:            https://zephir-lang.com/
Source0:        https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}-%{gh_short}.tar.gz

# Adapt path used in RPM
Patch0:         %{gh_project}-rpm.patch
Patch1:         https://github.com/phalcon/zephir/commit/8380460c38d4e6d8f00c5596f8ebcd3a6be4f25a.patch
Patch2:         https://github.com/phalcon/zephir/commit/650708de9df9039f04eda0fc150bd94e5a5b9753.patch

BuildArch:      noarch
BuildRequires:  %{?scl_prefix}php-devel > 7.0
BuildRequires:  %{?scl_prefix}php-zephir-parser >= %{parser_ver}
%if %{with_tests}
BuildRequires:  %{?scl_prefix}php-json
BuildRequires:  %{?scl_prefix}php-hash
BuildRequires:  %{?scl_prefix}php-ctype
BuildRequires:  %{?scl_prefix}php-psr
BuildRequires:  %{_bindir}/phpab
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires: (php-composer(oneup/flysystem-bundle)        >= 1.14   with php-composer(oneup/flysystem-bundle)        < 4)
BuildRequires: (php-composer(symfony/cache)                 >= 3.4    with php-composer(symfony/cache)                 < 4)
BuildRequires: (php-composer(symfony/config)                >= 3.4    with php-composer(symfony/config)                < 4)
BuildRequires: (php-composer(symfony/console)               >= 3.4    with php-composer(symfony/console)               < 4)
BuildRequires: (php-composer(symfony/dependency-injection)  >= 3.4    with php-composer(symfony/dependency-injection)  < 4)
BuildRequires: (php-composer(symfony/event-dispatcher)      >= 3.4    with php-composer(symfony/event-dispatcher)      < 4)
BuildRequires: (php-composer(symfony/filesystem)            >= 3.4    with php-composer(symfony/filesystem)            < 4)
BuildRequires: (php-composer(symfony/finder)                >= 3.4    with php-composer(symfony/finder)                < 4)
BuildRequires: (php-composer(symfony/framework-bundle)      >= 3.4    with php-composer(symfony/framework-bundle)      < 4)
BuildRequires: (php-composer(symfony/http-kernel)           >= 3.4    with php-composer(symfony/http-kernel)           < 4)
BuildRequires: (php-composer(symfony/monolog-bridge)        >= 3.4    with php-composer(symfony/monolog-bridge)        < 4)
BuildRequires: (php-composer(symfony/monolog-bundle)        >= 3.3    with php-composer(symfony/monolog-bundle)        < 4)
BuildRequires: (php-composer(symfony/routing)               >= 3.4    with php-composer(symfony/routing)               < 4)
BuildRequires: (php-composer(symfony/yaml)                  >= 3.4    with php-composer(symfony/yaml)                  < 4)
%else
BuildRequires:  php-oneup-flysystem-bundle
BuildRequires:  php-symfony3-cache
BuildRequires:  php-symfony3-config
BuildRequires:  php-symfony3-console
BuildRequires:  php-symfony3-dependency-injection
BuildRequires:  php-symfony3-event-dispatcher
BuildRequires:  php-symfony3-filesystem
BuildRequires:  php-symfony3-finder
BuildRequires:  php-symfony3-framework-bundle
BuildRequires:  php-symfony3-http-kernel
BuildRequires:  php-symfony3-monolog-bridge
BuildRequires:  php-symfony-monolog-bundle
BuildRequires:  php-symfony3-routing
BuildRequires:  php-symfony3-yaml
%endif
# From composer.json, "require-dev"
#        "ext-gmp": "*",
#        "ext-pdo": "*",
#        "ext-pdo_sqlite": "*",
#        "ext-zip": "*",
#        "psr/log": "1.1.*",
#        "symfony/debug": "3.4.*",
#        "symfony/phpunit-bridge": "4.3.*"
BuildRequires:  %{?scl_prefix}php-gmp
BuildRequires:  %{?scl_prefix}php-pdo
BuildRequires:  %{?scl_prefix}php-pdo_sqlite
BuildRequires:  %{?scl_prefix}php-zip
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires: (php-composer(psr/log)                       >= 1.1    with php-composer(psr/log)                       < 2)
BuildRequires: (php-composer(symfony/debug)                 >= 3.4    with php-composer(symfony/debug)                 < 4)
BuildRequires: (php-composer(symfony/phpunit-bridge)        >= 3.4    with php-composer(symfony/phpunit-bridge)        < 4)
%else
BuildRequires:  php-PsrLog
BuildRequires:  php-symfony3-debug
BuildRequires:  php-symfony3-phpunit-bridge
%endif
BuildRequires:  %{_bindir}/phpunit7
%endif
# Autoloader
BuildRequires:  php-composer(fedora/autoloader)

Requires:       %{?scl_prefix}php-cli
Requires:       %{?scl_prefix}php-zephir-parser >= %{parser_ver}
# From composer.json, "require"
#        "php": ">=7.0.0 <8.0",
#        "ext-SPL": "*",
#        "ext-ctype": "*",
#        "ext-hash": "*",
#        "ext-json": "*",
#        "ext-mbstring": "*",
#        "ext-pcre": "*",
#        "ext-xml": "*"
#        "oneup/flysystem-bundle": "^1.14 || ^3.0",
#        "symfony/cache": "3.4.*",
#        "symfony/config": "3.4.*",
#        "symfony/console": "3.4.*",
#        "symfony/dependency-injection": "3.4.*",
#        "symfony/event-dispatcher": "3.4.*",
#        "symfony/filesystem": "3.4.*",
#        "symfony/finder": "3.4.*",
#        "symfony/framework-bundle": "3.4.*",
#        "symfony/http-kernel": "3.4.*",
#        "symfony/monolog-bridge": "3.4.*",
#        "symfony/monolog-bundle": "3.3.*",
#        "symfony/routing": "3.4.*",
#        "symfony/yaml": "3.4.*"
Requires:       %{?scl_prefix}php(language) >= 7.0
Requires:       %{?scl_prefix}php-spl
Requires:       %{?scl_prefix}php-ctype
Requires:       %{?scl_prefix}php-hash
Requires:       %{?scl_prefix}php-json
Requires:       %{?scl_prefix}php-mbstring
Requires:       %{?scl_prefix}php-pcre
Requires:       %{?scl_prefix}php-xml
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
Requires:      (php-composer(oneup/flysystem-bundle)        >= 1.14   with php-composer(oneup/flysystem-bundle)        < 4)
Requires:      (php-composer(symfony/cache)                 >= 3.4    with php-composer(symfony/cache)                 < 4)
Requires:      (php-composer(symfony/config)                >= 3.4    with php-composer(symfony/config)                < 4)
Requires:      (php-composer(symfony/console)               >= 3.4    with php-composer(symfony/console)               < 4)
Requires:      (php-composer(symfony/dependency-injection)  >= 3.4    with php-composer(symfony/dependency-injection)  < 4)
Requires:      (php-composer(symfony/event-dispatcher)      >= 3.4    with php-composer(symfony/event-dispatcher)      < 4)
Requires:      (php-composer(symfony/filesystem)            >= 3.4    with php-composer(symfony/filesystem)            < 4)
Requires:      (php-composer(symfony/finder)                >= 3.4    with php-composer(symfony/finder)                < 4)
Requires:      (php-composer(symfony/framework-bundle)      >= 3.4    with php-composer(symfony/framework-bundle)      < 4)
Requires:      (php-composer(symfony/http-kernel)           >= 3.4    with php-composer(symfony/http-kernel)           < 4)
Requires:      (php-composer(symfony/monolog-bridge)        >= 3.4    with php-composer(symfony/monolog-bridge)        < 4)
Requires:      (php-composer(symfony/monolog-bundle)        >= 3.3    with php-composer(symfony/monolog-bundle)        < 4)
Requires:      (php-composer(symfony/routing)               >= 3.4    with php-composer(symfony/routing)               < 4)
Requires:      (php-composer(symfony/yaml)                  >= 3.4    with php-composer(symfony/yaml)                  < 4)
%else
Requires:       php-oneup-flysystem-bundle
Requires:       php-symfony3-cache
Requires:       php-symfony3-config
Requires:       php-symfony3-console
Requires:       php-symfony3-dependency-injection
Requires:       php-symfony3-event-dispatcher
Requires:       php-symfony3-filesystem
Requires:       php-symfony3-finder
Requires:       php-symfony3-framework-bundle
Requires:       php-symfony3-http-kernel
Requires:       php-symfony3-monolog-bridge
Requires:       php-symfony-monolog-bundle
Requires:       php-symfony3-routing
Requires:       php-symfony3-yaml
%endif
# From phpcompatinfo
Requires:       %{?scl_prefix}php-reflection
Requires:       %{?scl_prefix}php-date
Requires:       %{?scl_prefix}php-gmp
Requires:       %{?scl_prefix}php-pdo
# Autoloader
Requires:       php-composer(fedora/autoloader)

Provides:       %{?scl_prefix}php-composer(%{gh_owner}/%{gh_project}) = %{version}

%description
Zephir - Ze(nd Engine) Ph(p) I(nt)r(mediate) - is a high level language
that eases the creation and maintainability of extensions for PHP.
Zephir extensions are exported to C code that can be compiled and
optimized by major C compilers such as gcc/clang/vc++. Functionality
is exposed to the PHP language.

Main features:
* Both dynamic/static typing
* Reduced execution overhead compared with full interpretation
* Restricted procedural programming, promoting OOP
* Memory safety
* Ahead-of-time (AOT) compiler to provide predictable performance

Compiler design goals:
* Multi-pass compilation
* Type speculation/inference
* Allow runtime profile-guided optimizations, pseudo-constant propagation
  and indirect/virtual function inlining


%prep
%setup -q -n %{gh_project}-%{gh_commit}

%patch0 -p0 -b .rpm
%patch1 -p1 -b .up
%patch2 -p1 -b .up

sed -e 's/\$Id\$/%{gh_short}/' \
    -i Library/Zephir.php

find . -name \*.php -exec chmod -x {} \;

cat << 'EOF' >autoload.php
<?php
/* Autoloader for %{name} and its dependencies */
require_once '%{_datadir}/php/Fedora/Autoloader/autoload.php';

\Fedora\Autoloader\Autoload::addPsr4('Zephir\\', __DIR__ . '/Library');
\Fedora\Autoloader\Dependencies::required([
    __DIR__ . '/Library/functions.php',
    '%{_datadir}/php/Oneup/FlysystemBundle/autoload.php',
    '%{_datadir}/php/Symfony3/Component/Cache/autoload.php',
    '%{_datadir}/php/Symfony3/Component/Config/autoload.php',
    '%{_datadir}/php/Symfony3/Component/Console/autoload.php',
    '%{_datadir}/php/Symfony3/Component/DependencyInjection/autoload.php',
    '%{_datadir}/php/Symfony3/Component/EventDispatcher/autoload.php',
    '%{_datadir}/php/Symfony3/Component/Filesystem/autoload.php',
    '%{_datadir}/php/Symfony3/Component/Finder/autoload.php',
    '%{_datadir}/php/Symfony3/Bundle/FrameworkBundle/autoload.php',
    '%{_datadir}/php/Symfony3/Component/HttpKernel/autoload.php',
    '%{_datadir}/php/Symfony3/Bridge/Monolog/autoload.php',
    '%{_datadir}/php/Symfony3/Component/Routing/autoload.php',
    '%{_datadir}/php/Symfony3/Component/Yaml/autoload.php',
    '%{_datadir}/php/Symfony/Bundle/MonologBundle/autoload.php',
]);
EOF

mv %{gh_project} %{gh_project}.php
cat << 'EOF' | tee zephir.sh
#!/bin/sh
%{_bindir}/php -d memory_limit=2G -d extension=zephir_parser.so %{_datadir}/%{gh_project}/%{gh_project}.php $*


%build
: test extension
%{_bindir}/php -d memory_limit=2G -d extension=zephir_parser.so zephir.php clean
%{_bindir}/php -d memory_limit=2G -d extension=zephir_parser.so zephir.php fullclean
%{_bindir}/php -d memory_limit=2G -d extension=zephir_parser.so zephir.php generate
%{_bindir}/php -d memory_limit=2G -d extension=zephir_parser.so zephir.php stubs
%{_bindir}/php -d memory_limit=2G -d extension=zephir_parser.so zephir.php api

cd ext
%{_bindir}/phpize
%configure
make %{?_smp_mflags}



%install
: Library and resources
mkdir -p     %{buildroot}%{_datadir}/%{gh_project}
for i in *php Library kernels prototypes templates
do
   cp -pr $i %{buildroot}%{_datadir}/%{gh_project}/$i
done

: Command
install -Dpm 755 %{gh_project}.sh %{buildroot}%{_bindir}/%{gh_project}



%check
%if %{with_tests}

# TODO try when symfony/phpunit-bridge 4.3 available
rm unit-tests/Extension/Oo/DeprecatedMethodsTest.php

sed -e 's:%{_datadir}:%{buildroot}%{_datadir}:' \
     %{gh_project}.php > %{gh_project}.test
%{_bindir}/php %{gh_project}.test --version
%{_bindir}/php %{gh_project}.test --version | grep %{version}

%{_bindir}/php %{_bindir}/phpab -o bs.php unit-tests/fixtures/mocks
cat << 'EOF' | tee -a bs.php
require '%{buildroot}%{_datadir}/%{gh_project}/autoload.php';
\Fedora\Autoloader\Dependencies::required([
    '%{_datadir}/php/Psr/Log/autoload.php',
    '%{_datadir}/php/Symfony3/Component/Debug/autoload.php',
    '%{_datadir}/php/Symfony3/Bridge/PhpUnit/autoload.php',
]);
\Fedora\Autoloader\Autoload::addPsr4('Zephir\\Test\\',    __DIR__ . '/unit-tests/Zephir/Test/');
\Fedora\Autoloader\Autoload::addPsr4('Extension\\',       __DIR__ . '/unit-tests/Extension/');
EOF

: Run test suite
%{_bindir}/php \
  -d extension=zephir_parser.so \
    %{_bindir}/phpunit7 \
      --bootstrap bs.php \
      --no-coverage \
      --testsuite Zephir \
      --verbose

case %{php_version} in
   7.0.*) test_suite="Extension_Php70";;
   7.1.*) test_suite="Extension_Php70";;
   *)     test_suite="Extension_Php72";;
esac

%{_bindir}/php \
  -d extension=zephir_parser.so \
  -d extension=$PWD/ext/modules/test.so \
    %{_bindir}/phpunit7 \
      --bootstrap bs.php \
      --no-coverage \
      --testsuite ${test_suite} \
      --verbose

%else
: Test suite disabled
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md
%doc composer.json
%{_bindir}/%{gh_project}
%{_datadir}/%{gh_project}


%changelog
* Fri Oct  4 2019 Remi Collet <remi@remirepo.net> - 0.12.7-2
- add upstream patches for 1946 and 1949

* Fri Oct  4 2019 Remi Collet <remi@remirepo.net> - 0.12.7-1
- update to 0.12.7
- switch to phpunit7
- open https://github.com/phalcon/zephir/issues/1946
  undefined symbol ZEPHIR_NULL

* Fri Oct  4 2019 Remi Collet <remi@remirepo.net> - 0.12.6-2
- test build for https://github.com/phalcon/zephir/issues/1940

* Fri Oct  4 2019 Remi Collet <remi@remirepo.net> - 0.12.6-1
- update to 0.12.6

* Thu Oct  3 2019 Remi Collet <remi@remirepo.net> - 0.12.5-1
- update to 0.12.5
- open https://github.com/phalcon/zephir/issues/1940 broken build

* Mon Sep 23 2019 Remi Collet <remi@remirepo.net> - 0.12.4-1
- update to 0.12.4

* Thu Aug 29 2019 Remi Collet <remi@remirepo.net> - 0.12.2-1
- update to 0.12.2

* Fri Jun 21 2019 Remi Collet <remi@remirepo.net> - 0.12.0-1
- update to 0.12.0
- raise minimal PHP version to 7.0

* Mon Mar 25 2019 Remi Collet <remi@remirepo.net> - 0.11.12-1
- update to 0.11.12

* Wed Feb 27 2019 Remi Collet <remi@remirepo.net> - 0.11.11-1
- update to 0.11.11

* Mon Feb 25 2019 Remi Collet <remi@remirepo.net> - 0.11.10-1
- update to 0.11.10

* Wed Jan 16 2019 Remi Collet <remi@remirepo.net> - 0.11.9-1
- update to 0.11.9

* Mon Dec  3 2018 Remi Collet <remi@remirepo.net> - 0.11.8-1
- update to 0.11.8

* Wed Nov 28 2018 Remi Collet <remi@remirepo.net> - 0.11.7-1
- update to 0.11.7

* Tue Nov 20 2018 Remi Collet <remi@remirepo.net> - 0.11.6-1
- update to 0.11.6

* Mon Nov 19 2018 Remi Collet <remi@remirepo.net> - 0.11.4-1
- update to 0.11.4
- raise minimal PHP version to 5.6
- add dependency on league/container 2.4
- add dependency on league/flysystem 1.0
- add dependency on symfony/console 3.4

* Sat Oct 20 2018 Remi Collet <remi@remirepo.net> - 0.11.1-1
- update to 0.11.1

* Thu Aug 16 2018 Remi Collet <remi@remirepo.net> - 0.11.0-1
- update to 0.11.0

* Fri May 25 2018 Remi Collet <remi@remirepo.net> - 0.10.10-1
- update to 0.10.10

* Wed May  2 2018 Remi Collet <remi@remirepo.net> - 0.10.9-1
- update to 0.10.9

* Tue Apr 17 2018 Remi Collet <remi@remirepo.net> - 0.10.8-1
- update to 0.10.8

* Fri Dec 29 2017 Remi Collet <remi@remirepo.net> - 0.10.7-1
- Update to 0.10.7

* Sun Nov 12 2017 Remi Collet <remi@remirepo.net> - 0.10.6-1
- Update to 0.10.6

* Fri Nov 10 2017 Remi Collet <remi@remirepo.net> - 0.10.5-1
- Update to 0.10.5
- raise dependency on php-zephir-parser 1.1.1

* Mon Oct 23 2017 Remi Collet <remi@remirepo.net> - 0.10.4-1
- version 0.10.4

* Fri Oct 13 2017 Remi Collet <remi@remirepo.net> - 0.10.3-2
- disable timecop which breaks zephir
  see https://github.com/phalcon/zephir/pull/1588

* Fri Oct 13 2017 Remi Collet <remi@remirepo.net> - 0.10.3-1
- version 0.10.3
- raise dependency on php-zephir-parser 1.1.0

* Wed Oct 11 2017 Remi Collet <remi@remirepo.net> - 0.10.2-1
- version 0.10.2
- drop zephir-parser sub-package
- add dependency on php-zephir-parser

* Fri Aug  4 2017 Remi Collet <remi@remirepo.net> - 0.9.11-1
- version 0.9.11

* Tue Aug  1 2017 Remi Collet <remi@remirepo.net> - 0.9.10-1
- version 0.9.10

* Tue Jul 18 2017 Remi Collet <remi@remirepo.net> - 0.9.9-2
- rebuild for PHP 7.2.0beta1 new API

* Wed Jun 21 2017 Remi Collet <remi@remirepo.net> - 0.9.9-1
- version 0.9.9

* Mon May 22 2017 Remi Collet <remi@remirepo.net> - 0.9.8-1
- version 0.9.8

* Wed Apr  5 2017 Remi Collet <remi@fedoraproject.org> - 0.9.7-1
- version 0.9.7

* Tue Feb 21 2017 Remi Collet <remi@fedoraproject.org> - 0.9.6-1
- version 0.9.6

* Sun Nov 27 2016 Remi Collet <remi@fedoraproject.org> - 0.9.5-1
- version 0.9.5

* Fri Oct 14 2016 Remi Collet <remi@fedoraproject.org> - 0.9.4-2.20161014git23856e1
- new snapshot to fix PHP 7.1 compatibility of generated code

* Mon Oct 10 2016 Remi Collet <remi@fedoraproject.org> - 0.9.4-1.20160929git22f6632
- new snapshot to fix PHP 7.1 compatibility of generated code

* Wed Sep 14 2016 Remi Collet <remi@fedoraproject.org> - 0.9.3-2.20160728gite716dbe
- rebuild for PHP 7.1 new API version

* Sat Jul 30 2016 Remi Collet <remi@fedoraproject.org> - 0.9.0-1.20160728gite716dbe
- Initial package