From 0633ebcbb8fd67a2b95efe58db36866f512bb781 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 12 Oct 2016 07:22:21 +0200 Subject: php-ocramius-code-generator-utils: switch autoloader (backported from Fedora) --- php-ocramius-code-generator-utils.spec | 68 ++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 19 deletions(-) (limited to 'php-ocramius-code-generator-utils.spec') diff --git a/php-ocramius-code-generator-utils.spec b/php-ocramius-code-generator-utils.spec index b9630a5..44162fa 100644 --- a/php-ocramius-code-generator-utils.spec +++ b/php-ocramius-code-generator-utils.spec @@ -2,7 +2,7 @@ # # Fedora spec file for php-ocramius-code-generator-utils # -# Copyright (c) 2014-2015 Shawn Iwinski +# Copyright (c) 2014-2016 Shawn Iwinski # # License: MIT # http://opensource.org/licenses/MIT @@ -25,14 +25,13 @@ %global php_parser_max_ver 3 # Build using "--without tests" to disable tests -%global with_tests %{?_without_tests:0}%{!?_without_tests:1} +%global with_tests 0%{!?_without_tests:1} -%{!?phpdir: %global phpdir %{_datadir}/php} -%{!?__phpunit: %global __phpunit %{_bindir}/phpunit} +%{!?phpdir: %global phpdir %{_datadir}/php} Name: php-%{composer_vendor}-%{composer_project} Version: %{github_version} -Release: 1%{?github_release}%{?dist} +Release: 2%{?github_release}%{?dist} Summary: A set of code generator utilities built on top of PHP-Parsers Group: Development/Libraries @@ -42,7 +41,6 @@ Source0: %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{githu BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildArch: noarch -BuildRequires: %{_bindir}/phpab %if %{with_tests} # composer.json BuildRequires: php(language) >= %{php_min_ver} @@ -53,6 +51,8 @@ BuildRequires: php-composer(phpunit/phpunit) >= 5.0 BuildRequires: php-pcre BuildRequires: php-reflection BuildRequires: php-spl +# Autoloader +BuildRequires: php-composer(symfony/class-loader) %endif # composer.json @@ -62,6 +62,8 @@ Requires: php-composer(nikic/php-parser) < %{php_parser_max_ver} # phpcompatinfo (computed from version 0.4.0) Requires: php-pcre Requires: php-spl +# Autoloader +Requires: php-composer(symfony/class-loader) # Composer Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version} @@ -78,27 +80,51 @@ Autoloader: %{phpdir}/CodeGenerationUtils/autoload.php %build -%{_bindir}/phpab --output src/CodeGenerationUtils/autoload.php src/CodeGenerationUtils -cat << 'EOF' | tee -a src/CodeGenerationUtils/autoload.php +: Create autoloader +cat <<'AUTOLOAD' | tee src/CodeGenerationUtils/autoload.php +register(); +} + +$fedoraClassLoader->addPrefix('CodeGenerationUtils\\', dirname(__DIR__)); + +// Required dependency require_once '%{phpdir}/PhpParser2/autoload.php'; -EOF + +return $fedoraClassLoader; +AUTOLOAD %install rm -rf %{buildroot} -mkdir -pm 0755 %{buildroot}%{phpdir} -cp -rp src/* %{buildroot}%{phpdir}/ +mkdir -p %{buildroot}%{phpdir} +cp -rp src/CodeGenerationUtils %{buildroot}%{phpdir}/ %check %if %{with_tests} -mkdir vendor -%{_bindir}/phpab --output vendor/autoload.php tests -cat << 'EOF' | tee -a vendor/autoload.php -require_once '%{buildroot}%{phpdir}/CodeGenerationUtils/autoload.php'; -EOF - -%{_bindir}/phpunit --verbose +: Create tests bootstrap +cat <<'BOOTSTRAP' | tee bootstrap.php +addPrefix('CodeGenerationUtilsTest\\', __DIR__.'/tests'); +$fedoraClassLoader->addPrefix('CodeGenerationUtilsTestAsset\\', __DIR__.'/tests'); +BOOTSTRAP + +%{_bindir}/phpunit --verbose --bootstrap bootstrap.php %else : Tests skipped %endif @@ -112,11 +138,15 @@ rm -rf %{buildroot} %defattr(-,root,root,-) %{!?_licensedir:%global license %%doc} %license LICENSE -%doc *.md composer.json +%doc *.md +%doc composer.json %{phpdir}/CodeGenerationUtils %changelog +* Wed Oct 12 2016 Remi Collet - 0.4.0-2 +- switch from classmap autoloader to PSR-0 one (symfony) + * Wed Jun 29 2016 Remi Collet - 0.4.0-1 - update to 0.4.0 - raise dependency on php ~7.0 -- cgit