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

Add makefile to the project to make it easier to work on the tool #119

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions kin/grammar/PBXProjLexer.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion kin/grammar/PBXProjListener.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions kin/grammar/PBXProjParser.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down