Skip to content

Commit 67cdd23

Browse files
lhearachelhuderlem
andauthored
Provide a Makefile for integration in pret-based projects as a submodule (#80)
* Provide a Makefile for integration in pret-based projects as a submodule Fixes: #78 * Override `TARGET` for native-Windows Co-authored-by: Marcus Huderle <huderlem@gmail.com>
1 parent 2a49a7d commit 67cdd23

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Makefile for use as a subproject of pokeemerald, et al
2+
# The enforced contract is to provide a default target to compile the tool and a
3+
# "clean" target to sweep everything up
4+
5+
.PHONY: all clean
6+
7+
TARGET := poryscript
8+
ifeq ($(OS),Windows_NT)
9+
TARGET := $(TARGET).exe
10+
endif
11+
12+
# Add any new packages to this variable to pick up underlying source files
13+
PACKAGES := ast emitter lexer parser
14+
GOFILES := main.go $(foreach package,$(PACKAGES),$(wildcard $(package)/*.go))
15+
SOURCES := $(filter-out %_test.go,$(GOFILES))
16+
17+
$(TARGET): $(SOURCES)
18+
go build -o $@
19+
20+
all: $(TARGET)
21+
22+
clean:
23+
go clean
24+
rm -f $(TARGET)

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ View the [Changelog](https://github.com/huderlem/poryscript/blob/master/CHANGELO
1515

1616
**Table of Contents**
1717
- [Usage](#usage)
18+
* [Basic Installation](#basic-installation)
19+
* [Install as a Git Submodule](#install-as-a-git-submodule)
1820
* [Convert Existing Scripts](#convert-existing-scripts)
1921
* [Using Poryscript in Your Favorite IDE or Text Editor](#extensions)
2022
- [Poryscript Syntax (How to Write Scripts)](#poryscript-syntax-how-to-write-scripts)
@@ -81,6 +83,7 @@ Convert a `.pory` script to a compiled `.inc` script, which can be directly incl
8183
./poryscript -i data/scripts/myscript.pory -o data/scripts/myscript.inc
8284
```
8385

86+
## Basic Installation
8487
To automatically convert your Poryscript scripts when compiling a decomp project, perform these two steps:
8588
1. Create a new `tools/poryscript/` directory, and add the `poryscript` command-line executable tool to it. Also copy `command_config.json` and `font_config.json` to the same location.
8689
```
@@ -117,6 +120,60 @@ generated: $(AUTO_GEN_TARGETS)
117120
+ data/%.inc: data/%.pory; $(SCRIPT) -i $< -o $@ -fc tools/poryscript/font_config.json -cc tools/poryscript/command_config.json
118121
```
119122

123+
## Install as a Git Submodule
124+
Users may wish to install Poryscript as a dependency of their project if they work with other collaborators and require all contributors to use the same version. To accomplish this, we can integrate the tool as a [Git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules). This has an additional benefit of automatically rebuilding Poryscript from source when bumping to a new version.
125+
126+
1. Initialize the Git submodule. If you use a fork of Poryscript to implement custom features, replace the `https://github.com/huderlem/poryscript` URL with the appropriate URL for your fork.
127+
128+
```bash
129+
cd path/to/your/pokeemerald
130+
git submodule add https://github.com/huderlem/poryscript tools/poryscript
131+
```
132+
133+
2. Pin your submodule to the latest release (or to your desired target version, if they differ).
134+
135+
```bash
136+
cd tools/poryscript
137+
git checkout 3.5.2
138+
cd -
139+
git add tools/poryscript
140+
```
141+
142+
3. Make the following changes to `make_tools.mk`:
143+
144+
```diff
145+
- TOOL_NAMES := aif2pcm bin2c gbafix gbagfx jsonproc mapjson mid2agb preproc ramscrgen rsfont scaninc
146+
+ TOOL_NAMES := aif2pcm bin2c gbafix gbagfx jsonproc mapjson mid2agb preproc ramscrgen rsfont scaninc poryscript
147+
```
148+
149+
4. Make the changes to `Makefile` as described above in [Basic Installation](#basic-installation).
150+
151+
5. Commit your changes and push to the remote.
152+
153+
This installation method necessitates some changes in your project's workflow. When cloning your project to a fresh local copy, you should specify the `--recursive` option, which will ensure that Poryscript is checked out alongside your repository:
154+
155+
```bash
156+
git clone --recursive https://github.com/YOUR_USERNAME/pokeemerald.git
157+
```
158+
159+
After receiving the updates to integrate the submodule, existing local copies of the repository must do the following:
160+
161+
```bash
162+
git submodule update --init
163+
```
164+
165+
Finally, if/when new changes are pushed to Poryscript that you wish to receive, update the submodule like you would any other Git repository:
166+
167+
```bash
168+
cd tools/poryscript
169+
git fetch
170+
git checkout REF # REF can be a version tag, a branch, or a commit hash
171+
cd -
172+
git add tools/poryscript
173+
git commit
174+
git push
175+
```
176+
120177
## Convert Existing Scripts
121178
If you're working on a large project, you may want to convert all of the existing `scripts.inc` files to their `scripts.pory` equivalents. Since there are a large number of script files in the Gen 3 projects, you can save yourself a lot of time by following these instructions. **Again, this is completely optional, and you would only want to perform this bulk conversion if you're emabarking on large project where it would be useful to have all the existing scripts setup as Poryscript files.**
122179

0 commit comments

Comments
 (0)