Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP package numbers should be identical to the version for Antlr. #39

Open
kaby76 opened this issue May 25, 2023 · 1 comment
Open

PHP package numbers should be identical to the version for Antlr. #39

kaby76 opened this issue May 25, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@kaby76
Copy link

kaby76 commented May 25, 2023

✨ Feature request

Right now, packagist has version 0.8.0 of the PHP runtime for Antlr. That corresponds to Antlr 4.12.0. We have a new version for Antlr 4.13.0, and there should be a new version of the PHP runtime for Antlr. But, it would be best to have antlr4-php-runtime use version numbers correspond exactly to Antlr tool version, and which are used in all the other targets, e.g., 4.13.0. Antlr programs cannot use different runtime versions with the tool.

Motivation

Dependabot in Github parses build specification files and issues update PRs when an Antlr runtime is released. But, building an Antlr program also requires the Antlr tool version to match. I can run the antlr4 tool with a -v 4.13.0 option, where the version is extracted from a PHP Composer file, but I then have to map the runtime version string there for PHP Antlr of 0.9.0 to 4.13.0. This makes Dependabot useless for PHP because I don't know what the mapping is aprori. Will 0.10.0 map to 4.14.0 or 4.13.1 or what??? I don't know the mapping until the PHP Antlr runtime is actually released.

Alternatives

Manually update the PHP Antlr version and Antlr tool version in the templates for grammars-v4, and don't let Dependabot analyse PHP Composer files.

Additional context

Templates for PHP are here. The Dependabot update for PHP is here.

@kaby76 kaby76 added the enhancement New feature or request label May 25, 2023
@kaby76
Copy link
Author

kaby76 commented Sep 6, 2023

I am planning to re-add the testing of PHP targets for grammars-v4, fixing antlr/grammars-v4#3125

I have a workaround that finds the tool version that corresponds to the Antlr PHP runtime version in the composer.json file for a PHP driver. Not pretty, but it'll work as long as there are no major changes in how the package is published, how it is stored in the repo, and the version string in the source code.

The workaround involves a Bash script to extract the tool version from the source at

public const VERSION = '4.13.0';

But, this is not easy. And, it is fragile. But, there is no other solution. Every target tested in grammars-v4 is with potentially a different version of Antlr because the runtimes are published independently of each other.

Script:

    # Find runtime version in composer.json file.
    runtime_version=`grep antlr4 composer.json | awk '{print $2}' | tr -d '\r' | tr -d '\n' | tr -d ',' | tr -d '"'`

    # Get from online sources the commit version number that corresponds to the runtime version.
    rm -rf antlr4-php-runtime
    wget "https://packagist.org/packages/antlr/antlr4-php-runtime#$runtime_version"
    commit_version=`grep BSD-3-Clause antlr4-php-runtime | awk '{print $NF}' | sed 's/<.*//'`

    # Checkout the sources from the php runtime repo.
    rm -rf antlr4-php-runtime
    git clone https://github.com/antlr/antlr-php-runtime
    cd antlr-php-runtime
    git checkout $commit_version

    # Extract the tool version this damn runtime version corresponds to.
    tool_version=`grep 'public const VERSION' src/RuntimeMetaData.php | awk '{print $NF}' | sed "s/'//g" | sed 's/;//'`

    # Run the antlr4 tool.
    # antlr4 -version $tool_version ......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant