Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace resource tools with python scripts
May fix pipeline failures on ghactions where makeico or toarray just exit with a non-zero status for no reason. Also makes it easier (possible, rather) to build TPT using a cross-compiling msvc toolchain on windows; you can't have two different msvc toolchains in PATH on windows because of course you can't. toarray had been python before, maybe I converted it to cpp to avoid pulling in python as a dependency, I'm not sure. With android vanilla development (hopefully) gaining traction soon, we'll be relying anyway on helper scripts I've written in python, so python will be a dependency sooner or later. Meson implicitly makes python a dependency, but there could be Meson implementations out there that don't rely on python, who knows.
- Loading branch information
Showing
7 changed files
with
71 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import struct | ||
import sys | ||
|
||
( | ||
script, | ||
output_ico, | ||
*input_pngs, | ||
) = sys.argv | ||
|
||
input_pngs_size = len(input_pngs) | ||
assert(input_pngs_size <= 255) | ||
|
||
ico_header = b'' | ||
ico_data = b'' | ||
data_offset = 6 + 16 * input_pngs_size | ||
for input_png in input_pngs: | ||
with open(input_png, 'rb') as input_png_f: | ||
data = input_png_f.read() | ||
data_size = len(data) | ||
assert(data_size >= 0x21) | ||
magic, width, height, bit_depth, color_type = struct.unpack('>QxxxxxxxxLLBBxxxxxxx', data[0 : 0x21]) | ||
assert(magic == 0x89504E470D0A1A0A) | ||
assert(width <= 256) | ||
assert(height <= 256) | ||
assert(bit_depth == 8) | ||
assert(color_type == 6) | ||
if width == 256: | ||
width = 0 | ||
if height == 256: | ||
height = 0 | ||
ico_header += struct.pack('<BBxxHHLL', width, height, 1, 32, data_size, data_offset) | ||
data_offset += data_size | ||
ico_data += data | ||
|
||
with open(output_ico, 'wb') as output_ico_f: | ||
output_ico_f.write(struct.pack('<xxHH', 1, input_pngs_size)) | ||
output_ico_f.write(ico_header) | ||
output_ico_f.write(ico_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import sys | ||
|
||
( | ||
script, | ||
output_cpp_path, | ||
output_h_path, | ||
input_path, | ||
symbol_name, | ||
) = sys.argv | ||
|
||
with open(input_path, 'rb') as input_f: | ||
data = input_f.read() | ||
data_size = len(data) | ||
bytes_str = ', '.join([ str(ch) for ch in data ]) | ||
|
||
with open(output_cpp_path, 'w') as output_cpp_f: | ||
output_cpp_f.write(f''' | ||
#include "{output_h_path}" | ||
const unsigned char {symbol_name}[] = {{ {bytes_str} }}; | ||
const unsigned int {symbol_name}_size = {data_size}; | ||
''') | ||
|
||
with open(output_h_path, 'w') as output_h_f: | ||
output_h_f.write(f''' | ||
#pragma once | ||
extern const unsigned char {symbol_name}[]; | ||
extern const unsigned int {symbol_name}_size; | ||
''') |