Add chdir option for Flatpak
* The --chdir CLI option to doodle will set a working directory for the game to switch to on startup. Flatpak builds place the files at /app/share/doodle where the ./rtp and ./guidebook files are relative to and this allows the game to find its sound effects and such.
This commit is contained in:
parent
580aaca2c5
commit
c78cd38c1d
13
Building.md
13
Building.md
|
@ -1,6 +1,7 @@
|
||||||
# Building Doodle
|
# Building Doodle
|
||||||
|
|
||||||
* [Linux](#linux)
|
* [Linux](#linux)
|
||||||
|
* [Flatpak for Linux](#flatpak-for-linux)
|
||||||
* [Windows Cross-Compile from Linux](#windows-cross-compile-from-linux)
|
* [Windows Cross-Compile from Linux](#windows-cross-compile-from-linux)
|
||||||
* [Mac OS](#mac os)
|
* [Mac OS](#mac os)
|
||||||
|
|
||||||
|
@ -16,6 +17,14 @@ You'll need the following git repositories:
|
||||||
The [doodle-docker](https://git.kirsle.net/apps/doodle-docker) repo will
|
The [doodle-docker](https://git.kirsle.net/apps/doodle-docker) repo will
|
||||||
be more up-to-date than the instructions below.
|
be more up-to-date than the instructions below.
|
||||||
|
|
||||||
|
The `bootstrap.py` script should attempt to git clone most dependencies into a
|
||||||
|
folder named `deps/` relative to the root of the doodle repo. For example,
|
||||||
|
`deps/render` would be a git clone of `git.kirsle.net/go/render`. By updating
|
||||||
|
Doodle's go.mod file to replace these dependencies, you can produce a fully
|
||||||
|
self-contained source directory that can fully build the app. The
|
||||||
|
[Flatpak repo](#flatpak-for-linux) makes use of this. Below is how you would
|
||||||
|
do this process very manually:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Clone all the repos down to your project folder
|
# Clone all the repos down to your project folder
|
||||||
git clone git@git.kirsle.net:apps/doodle-rtp rtp
|
git clone git@git.kirsle.net:apps/doodle-rtp rtp
|
||||||
|
@ -147,6 +156,10 @@ sudo dnf -y install golang SDL2-devel SDL2_ttf-devel SDL2_mixer-devel
|
||||||
sudo apt -y install golang libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-devel
|
sudo apt -y install golang libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Flatpak for Linux
|
||||||
|
|
||||||
|
The repo for this is at <https://code.sketchymaze.com/game/flatpak>.
|
||||||
|
|
||||||
## Mac OS
|
## Mac OS
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -63,6 +63,10 @@ func main() {
|
||||||
Aliases: []string{"d"},
|
Aliases: []string{"d"},
|
||||||
Usage: "enable debug level logging",
|
Usage: "enable debug level logging",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "chdir",
|
||||||
|
Usage: "working directory for the game's runtime package",
|
||||||
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "edit",
|
Name: "edit",
|
||||||
Aliases: []string{"e"},
|
Aliases: []string{"e"},
|
||||||
|
@ -84,6 +88,14 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Action = func(c *cli.Context) error {
|
app.Action = func(c *cli.Context) error {
|
||||||
|
// --chdir into a different working directory? e.g. for Flatpak especially.
|
||||||
|
if doodlePath := c.String("chdir"); doodlePath != "" {
|
||||||
|
if err := os.Chdir(doodlePath); err != nil {
|
||||||
|
log.Error("--chdir: couldn't enter '%s': %s", doodlePath, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var filename string
|
var filename string
|
||||||
if c.NArg() > 0 {
|
if c.NArg() > 0 {
|
||||||
filename = c.Args().Get(0)
|
filename = c.Args().Get(0)
|
||||||
|
@ -143,6 +155,10 @@ func main() {
|
||||||
engine.Maximize()
|
engine.Maximize()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log what Doodle thinks its working directory is, for debugging.
|
||||||
|
pwd, _ := os.Getwd()
|
||||||
|
log.Debug("PWD: %s", pwd)
|
||||||
|
|
||||||
game.Run()
|
game.Run()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user