Add initial version of asset inclusion in binary
This commit is contained in:
parent
7a7c5d7398
commit
7cefa4f969
7 changed files with 47 additions and 13 deletions
5
build/.gitignore
vendored
5
build/.gitignore
vendored
|
@ -1,3 +1,6 @@
|
|||
*
|
||||
!README.md
|
||||
!.gitignore
|
||||
!.gitignore
|
||||
!packer.py
|
||||
!build.sh
|
||||
!run.sh
|
|
@ -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
3
build/build.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
python3 packer.py
|
||||
cmake ..
|
||||
cmake --build .
|
19
build/packer.py
Normal file
19
build/packer.py
Normal 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
2
build/run.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
./build.sh
|
||||
./elnutris
|
Loading…
Add table
Add a link
Reference in a new issue