From bb5e70d3bd23e97857ac5ccb900816571a84f619 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 24 Feb 2021 12:36:49 +0100 Subject: [PATCH 1/3] Always use / as path separator in config.m4 When running zephir generate under Windows, paths are separated by \ instead of / --- CHANGELOG.md | 2 ++ Library/Compiler.php | 17 ++++++++++--- .../CompilerFile/CheckPathSeparatorTest.php | 24 +++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 tests/Zephir/CompilerFile/CheckPathSeparatorTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 08f53ef3a5..73ce8bd675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](http://semver.org). - Fixed missing kernel directory at build time [ice/framework#271](https://github.com/ice/framework/issues/271) - Fixed stubs generation for case with array declaration with square brackets in params - Fixed parameters positioning for `implode()` php function [#2120](https://github.com/phalcon/zephir/issues/2120) +- Fixed path separators in generated `config.m4` file on Windows [#2153](https://github.com/phalcon/zephir/issues/2153) + ## [0.12.19] - 2020-05-13 ### Fixed diff --git a/Library/Compiler.php b/Library/Compiler.php index e83f4077ae..8664a8b3f8 100644 --- a/Library/Compiler.php +++ b/Library/Compiler.php @@ -1113,9 +1113,9 @@ public function createConfigFiles($project) '%PROJECT_LOWER%' => strtolower($project), '%PROJECT_UPPER%' => strtoupper($project), '%PROJECT_CAMELIZE%' => ucfirst($project), - '%FILES_COMPILED%' => implode("\n\t", $compiledFiles), - '%HEADERS_COMPILED%' => implode(' ', $compiledHeaders), - '%EXTRA_FILES_COMPILED%' => implode("\n\t", $this->extraFiles), + '%FILES_COMPILED%' => implode("\n\t", $this->toUnixPaths($compiledFiles)), + '%HEADERS_COMPILED%' => implode(' ', $this->toUnixPaths($compiledHeaders)), + '%EXTRA_FILES_COMPILED%' => implode("\n\t", $this->toUnixPaths($this->extraFiles)), '%PROJECT_EXTRA_LIBS%' => $extraLibs, '%PROJECT_EXTRA_CFLAGS%' => $extraCflags, ]; @@ -2329,4 +2329,15 @@ private function getGccVersion() return '0.0.0'; } + + private function toUnixPaths(array $paths): array + { + return array_map( + static function(string $path): string + { + return str_replace(\DIRECTORY_SEPARATOR, '/', $path); + }, + $paths + ); + } } diff --git a/tests/Zephir/CompilerFile/CheckPathSeparatorTest.php b/tests/Zephir/CompilerFile/CheckPathSeparatorTest.php new file mode 100644 index 0000000000..e5ec7c1e7d --- /dev/null +++ b/tests/Zephir/CompilerFile/CheckPathSeparatorTest.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zephir\Test\CompilerFile; + +use PHPUnit\Framework\TestCase; + +class CheckPathSeparatorTest extends TestCase +{ + public function testExtendsClassThatDoesNotExist() + { + $configM4Path = realpath(__DIR__.'/../../../ext/config.m4'); + $configM4Contents = file_get_contents($configM4Path); + $this->assertTrue(strpos($configM4Contents, 'stub/oo/abstractstatic.zep.c') !== false); + } +} From 03fa1b1ec9c1f4d0e100c44c55721ac850534cac Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 5 Mar 2021 12:47:25 +0000 Subject: [PATCH 2/3] Fix code style --- Library/Compiler.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Library/Compiler.php b/Library/Compiler.php index 8664a8b3f8..8e1f0f30ac 100644 --- a/Library/Compiler.php +++ b/Library/Compiler.php @@ -2333,8 +2333,7 @@ private function getGccVersion() private function toUnixPaths(array $paths): array { return array_map( - static function(string $path): string - { + static function (string $path): string { return str_replace(\DIRECTORY_SEPARATOR, '/', $path); }, $paths From 8a412a186b4b975cd966f69cf74ffe64e2874202 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 5 Mar 2021 12:55:31 +0000 Subject: [PATCH 3/3] Bump version to 0.12.21 --- CHANGELOG.md | 12 ++++++++---- Library/Zephir.php | 2 +- ext/php_stub.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73ce8bd675..be0ee9e434 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,15 @@ # Change Log All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](http://keepachangelog.com) +The format based on [Keep a Changelog](http://keepachangelog.com) and this project adheres to [Semantic Versioning](http://semver.org). ## [Unreleased] + +## [0.12.21] - 2021-03-05 +### Fixed +- Fixed path separators in generated `config.m4` file on Windows [#2153](https://github.com/phalcon/zephir/issues/2153) + ## [0.12.20] - 2020-12-16 ### Added - Added supports void type return value for stubs @@ -15,8 +20,6 @@ and this project adheres to [Semantic Versioning](http://semver.org). - Fixed missing kernel directory at build time [ice/framework#271](https://github.com/ice/framework/issues/271) - Fixed stubs generation for case with array declaration with square brackets in params - Fixed parameters positioning for `implode()` php function [#2120](https://github.com/phalcon/zephir/issues/2120) -- Fixed path separators in generated `config.m4` file on Windows [#2153](https://github.com/phalcon/zephir/issues/2153) - ## [0.12.19] - 2020-05-13 ### Fixed @@ -423,7 +426,8 @@ and this project adheres to [Semantic Versioning](http://semver.org). - Fixed casting resource to int (only ZendEngine 3) [#1524](https://github.com/phalcon/zephir/issues/1524) -[Unreleased]: https://github.com/phalcon/zephir/compare/0.12.20...HEAD +[Unreleased]: https://github.com/phalcon/zephir/compare/0.12.21...HEAD +[0.12.21]: https://github.com/phalcon/zephir/compare/0.12.20...0.12.21 [0.12.20]: https://github.com/phalcon/zephir/compare/0.12.19...0.12.20 [0.12.19]: https://github.com/phalcon/zephir/compare/0.12.18...0.12.19 [0.12.18]: https://github.com/phalcon/zephir/compare/0.12.17...0.12.18 diff --git a/Library/Zephir.php b/Library/Zephir.php index 58342a5ceb..e6b0f8510a 100644 --- a/Library/Zephir.php +++ b/Library/Zephir.php @@ -16,7 +16,7 @@ */ final class Zephir { - const VERSION = '0.12.20-$Id$'; + const VERSION = '0.12.21-$Id$'; const LOGO = <<<'ASCII' _____ __ _ diff --git a/ext/php_stub.h b/ext/php_stub.h index 8ff72cf0a2..cc232ffcef 100644 --- a/ext/php_stub.h +++ b/ext/php_stub.h @@ -14,7 +14,7 @@ #define PHP_STUB_VERSION "1.0.0" #define PHP_STUB_EXTNAME "stub" #define PHP_STUB_AUTHOR "Phalcon Team and contributors" -#define PHP_STUB_ZEPVERSION "0.12.20-$Id$" +#define PHP_STUB_ZEPVERSION "0.12.21-$Id$" #define PHP_STUB_DESCRIPTION "Description test for
Test Extension." typedef struct _zephir_struct_db {