Add initial version of asset inclusion in binary

This commit is contained in:
Elnu 2022-03-10 15:58:05 -08:00
parent 7a7c5d7398
commit 7cefa4f969
7 changed files with 47 additions and 13 deletions

5
build/.gitignore vendored
View file

@ -1,3 +1,6 @@
*
!README.md
!.gitignore
!.gitignore
!packer.py
!build.sh
!run.sh

View file

@ -2,14 +2,19 @@
This build setup is only working/tested for GNU/Linux systems. In order to have the required development dependencies, install them using your system's package manager. This is `libsfml-dev` on Debian-based systems and `sfml` on Arch-based systems (untested). They package must be at version 2.5.
First, `cd` into this folder, then run Cmake to generate the Makefile. If you ever update `CMakeLists.txt`, run this command again.
To compile:
```SH
cmake ..
./build.sh
```
To compile and run:
```SH
cmake --build . && ./elnutris
./run.sh
```
To run:
```
./elnutris
```

3
build/build.sh Executable file
View file

@ -0,0 +1,3 @@
python3 packer.py
cmake ..
cmake --build .

19
build/packer.py Normal file
View file

@ -0,0 +1,19 @@
import os
RES_DIR = "../res/"
RES_FILE = "../include/res.hpp"
resources = os.fsencode(RES_DIR)
res = ""
for resource in os.listdir(resources):
encoded = f"const unsigned char {os.path.splitext(resource)[0].decode().upper()}[] = {'{'} "
file = open(RES_DIR + resource.decode(), "rb") # read binary
for byte in file.read():
encoded += f"0x{byte.to_bytes(1, byteorder='little').hex()}, "
encoded = encoded[:-2] + " };"
res += encoded + "\n"
res_file = open(RES_FILE, "w")
res_file.write(res)
res_file.close()

2
build/run.sh Executable file
View file

@ -0,0 +1,2 @@
./build.sh
./elnutris