From 4c55b0eed75d072d85af728e34b7fdcdf6d6e266 Mon Sep 17 00:00:00 2001 From: Serchinastico Date: Wed, 20 Nov 2024 01:24:01 +0100 Subject: [PATCH] Add makefile to the project to make it easier to work on the tool --- Makefile | 14 ++++++++++++++ README.md | 20 ++++++-------------- kin/grammar/PBXProjLexer.py | 4 ++-- kin/grammar/PBXProjListener.py | 2 +- kin/grammar/PBXProjParser.py | 4 ++-- 5 files changed, 25 insertions(+), 19 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7292784 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +compile: + cd kin/grammar; antlr PBXProj.g4 -Dlanguage=Python3 + +install: compile + pip install -e . + +test: install + ./tests/tester.py + +test_last: install + find tests -type f -name "*.pbxproj" -print0 \ + | xargs -0 stat -f "%m %N" \ + | sort -rn | head -1 | cut -f2- -d" " \ + | xargs kin \ No newline at end of file diff --git a/README.md b/README.md index 6eddc64..0d29a17 100644 --- a/README.md +++ b/README.md @@ -67,29 +67,21 @@ Emacs Feel free to add any useful feature to Kin, we will be glad to improve it with your help. -If you modify the grammar file (`PBXProj.g4`), make sure you compile it using [ANTLR](https://www.antlr.org/). ANLTR can be installed with the following command: +Kin uses [ANTLR](https://www.antlr.org/) to build a parser for pbxproj files. ANLTR can be installed with the following command: ```bash brew install antlr ``` -After changes have been made to the `PBXProj.g4` file it can be compiled with: +There is a [Makefile](./Makefile) that defines commands to work with Kin locally. -```bash -cd kin/grammar -antlr PBXProj.g4 -Dlanguage=Python3 -``` - -`kin` can optionally be symlinked by running this command in the root of the project: - -```bash -pip install -e . -``` +- `make compile` - Compiles the grammar into an ANTLR parser. Run it every time you make changes to the `PBXProj.g4` file. +- `make install` - Installs a symlink of kin in your machine so that you can run it your local build. +- `make test` - Runs all tests. +- `make test_last` - It builds and installs kin and then runs it against the latest modified test file. This is usually your go-to command while working on kin. Only the `PBXProj.g4` file needs to be committed, GitHub Actions will produce the compiled grammar files. -To run tests, first install the current version of kin by running `pip install .`. Then you can execute `./tests/tester.py` to run all the scenarios we created. - ## License Copyright 2023 Serchinastico diff --git a/kin/grammar/PBXProjLexer.py b/kin/grammar/PBXProjLexer.py index 36aed58..8f48af5 100644 --- a/kin/grammar/PBXProjLexer.py +++ b/kin/grammar/PBXProjLexer.py @@ -1,4 +1,4 @@ -# Generated from PBXProj.g4 by ANTLR 4.13.1 +# Generated from PBXProj.g4 by ANTLR 4.13.2 from antlr4 import * from io import StringIO import sys @@ -1434,7 +1434,7 @@ class PBXProjLexer(Lexer): def __init__(self, input=None, output:TextIO = sys.stdout): super().__init__(input, output) - self.checkVersion("4.13.1") + self.checkVersion("4.13.2") self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) self._actions = None self._predicates = None diff --git a/kin/grammar/PBXProjListener.py b/kin/grammar/PBXProjListener.py index dfa8d91..426e60a 100644 --- a/kin/grammar/PBXProjListener.py +++ b/kin/grammar/PBXProjListener.py @@ -1,4 +1,4 @@ -# Generated from PBXProj.g4 by ANTLR 4.13.1 +# Generated from PBXProj.g4 by ANTLR 4.13.2 from antlr4 import * if "." in __name__: from .PBXProjParser import PBXProjParser diff --git a/kin/grammar/PBXProjParser.py b/kin/grammar/PBXProjParser.py index 633ddc4..36a7918 100644 --- a/kin/grammar/PBXProjParser.py +++ b/kin/grammar/PBXProjParser.py @@ -1,4 +1,4 @@ -# Generated from PBXProj.g4 by ANTLR 4.13.1 +# Generated from PBXProj.g4 by ANTLR 4.13.2 # encoding: utf-8 from antlr4 import * from io import StringIO @@ -1339,7 +1339,7 @@ class PBXProjParser ( Parser ): def __init__(self, input:TokenStream, output:TextIO = sys.stdout): super().__init__(input, output) - self.checkVersion("4.13.1") + self.checkVersion("4.13.2") self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache) self._predicates = None