Improved the makefile dramatically and updated the README to use it.

This commit is contained in:
Zed A. Shaw 2024-09-10 21:48:14 -04:00
parent 152d4cf037
commit 1badbd5942
2 changed files with 28 additions and 28 deletions

View file

@ -1,11 +1,17 @@
all: build test
reset:
powershell -executionpolicy bypass .\scripts\reset_build.ps1
patch:
powershell "cp ./patches/process.h ./subprojects/libgit2-1.8.1/src/util/process.h"
build:
build: patch
meson compile -j 4 -C builddir
config:
powershell "cp tarpit_sample.json .tarpit.json"
test:
meson test -C builddir --suite turings_tarpit

View file

@ -79,29 +79,22 @@ git clone https://git.learnjsthehardway.com/learn-code-the-hard-way/turings-tarp
Then change into the directory and run my setup script:
```shell
powershell -executionpolicy bypass .\scripts\reset_build.ps1
make reset
```
That should setup your meson build with everything you need, so now you run it:
```shell
meson compile -C builddir
make
```
One thing I ran into is that there's an error in `libgit2`'s code. If you get a build error in
`utils\process.h` then run this command to fix it:
```shell
cp .\patches\process.h .\subprojects\libgit2-1.8.1\src\util\process.h
```
This will build it assuming you used my setup scripts and have `make`. If you don't then look in the `Makefile` for the commands to run.
The next dumb as hell thing is even though I've told `meson` to build a static binary it refuses.
You have to copy a couple .dll files to your local directory for the easiest way to play with it:
```shell
cp .\builddir\subprojects\libgit2-1.8.1\*.dll .
cp .\builddir\subprojects\efsw\*.dll .
ls *.dll
make install
```
You should then see the `libefsw.dll` and `liblibgit2package.dll` files in the local directory which
@ -112,33 +105,34 @@ will let you run the `escape_turings_tarpit.exe` game locally.
> active, so when you build `builddir/escape_turings_tarpit.exe` it'll fail if you're also running
> it. Copy it all up and then you can run builds in the game while you work on the game.
Then hang out for a while and it should build. You can then do your first run. First, run the
tests:
```shell
.\builddir\runtests
make test
```
If those run then try to run the game on its own code:
```shell
cp .\builddir\escape_turings_tarpit.exe . ; .\escape_turings_tarpit.exe .\ "meson compile -C builddir"
```
Now it's playing, so all you have to do is open one of the .cpp files, make a mistake, save it, and watch the game play.
## Configuration
There's a file `.tarpit.json` that configures everything for the game. You can set your own sounds,
the build directory, and the build command to use. Just open it and you'll see. If you don't want
to hear me laughing at you then set the sounds to `nothing.mp3` and it'll be silent.
There's a file `tarpit_sample.json` that configures everything for the game. You can set your own
sounds, the build directory, and the build command to use. Just open it and you'll see. If you
don't want to hear me laughing at you then set the sounds to `nothing.mp3` and it'll be silent.
I have an example file `tarpit_example.json` which you can copy to `.tarpit.json` to get started:
```shell
cp tarpit_example.json .tarpit.json
make config
```
You can edit this file to change the build command and sounds used during building, just in case my
silky smooth radio quality voice is not to your liking.
You can edit the `.tarpit.json` file to change the build command and sounds used during building,
just in case my silky smooth radio quality voice is not to your liking.
## Running
If those run then try to run the game on its own code:
```shell
make run
```
Now it's playing, so all you have to do is open one of the .cpp files, make a mistake, save it, and watch the game play.