diff --git a/.gitattributes b/.gitattributes index 59a302b..59a5a69 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,6 +5,7 @@ *.php diff=php * export-ignore +/protoc-gen-php -export-ignore /src/ -export-ignore /src/** -export-ignore /CHANGELOG.md -export-ignore diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index ab45b70..824c727 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -11,7 +11,6 @@ ->setFinder( Finder::create() ->in(__DIR__ . '/src') - ->in(__DIR__ . '/bin') ->in(__DIR__ . '/tests') ->exclude(['snapshots']) ->append([ diff --git a/Makefile b/Makefile index 889898c..ff691ff 100644 --- a/Makefile +++ b/Makefile @@ -144,11 +144,11 @@ check: fixer-check rector-check composer-validate composer-normalize-check deps- .PHONY: check executable: - chmod +x bin/compiler.php + chmod +x protoc-gen-php generate: executable rm -rf compiled/* - protoc -I./protos --plugin=protoc-gen-php-plugin=./bin/compiler.php ./protos/*.proto --php-plugin_out=compiled + protoc -I./protos --plugin=protoc-gen-php-plugin=./protoc-gen-php ./protos/*.proto --php-plugin_out=compiled .PHONY: generate # ----------------------- diff --git a/box.json b/box.json index 94918ab..4806f0e 100644 --- a/box.json +++ b/box.json @@ -1,11 +1,13 @@ { "chmod": "0755", "directories": [ - "bin", "src", "vendor" ], - "main": "bin/compiler.php", + "files": [ + "protoc-gen-php" + ], + "main": "protoc-gen-php", "output": "protoc-gen-php", "shebang": "#!/usr/bin/env php" } \ No newline at end of file diff --git a/composer.json b/composer.json index 50f45f1..7753288 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "php": "^8.4", "ext-bcmath": "*", "ext-filter": "*", + "composer-runtime-api": "^2.2", "nette/php-generator": "^4.2.1", "thesis/package-version": "^0.1.2", "thesis/protobuf": "^0.2", @@ -43,7 +44,7 @@ } }, "bin": [ - "bin/compiler.php" + "protoc-gen-php" ], "config": { "lock": false, diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 3116f1c..f8a92c6 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -7,7 +7,6 @@ parameters: level: max paths: - src - - bin - tests excludePaths: - tests/snapshots diff --git a/bin/compiler.php b/protoc-gen-php similarity index 92% rename from bin/compiler.php rename to protoc-gen-php index febf52a..4dec642 100755 --- a/bin/compiler.php +++ b/protoc-gen-php @@ -3,7 +3,7 @@ declare(strict_types=1); -require_once __DIR__ . '/../vendor/autoload.php'; +require_once $_composer_autoload_path ?? __DIR__ . '/vendor/autoload.php'; if (is_string($configuredMemoryLimit = getenv('THESIS_PLUGIN_MEMORY_LIMIT'))) { @ini_set('memory_limit', $configuredMemoryLimit); diff --git a/tests/CompilerMemoryLimitTest.php b/tests/CompilerMemoryLimitTest.php index 4f280e7..9f4b2cb 100644 --- a/tests/CompilerMemoryLimitTest.php +++ b/tests/CompilerMemoryLimitTest.php @@ -32,7 +32,7 @@ public function testCompilerRaisesDefaultMemoryLimitTo512M(): void private static function runCompilerScript(string $initialMemoryLimit, ?string $envMemoryLimit = null): string { $code = <<<'PHP' -require 'bin/compiler.php'; +require 'protoc-gen-php'; fwrite(STDERR, "\nMEMORY_LIMIT=" . ini_get('memory_limit') . "\n"); PHP; diff --git a/tests/tools/generate-snapshots.sh b/tests/tools/generate-snapshots.sh index d25d707..d118309 100755 --- a/tests/tools/generate-snapshots.sh +++ b/tests/tools/generate-snapshots.sh @@ -3,7 +3,7 @@ set -euo pipefail FIXTURES_ROOT="tests/fixtures" SNAPSHOTS_ROOT="tests/snapshots" -PLUGIN="$(realpath "$(pwd)/bin/compiler.php")" +PLUGIN="$(realpath "$(pwd)/protoc-gen-php")" if [[ ! -x "$PLUGIN" ]]; then echo "Plugin not executable: $PLUGIN" >&2