Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openwrt package #146

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,22 @@ curl_dep = dependency(
],
)

xxd_prog = find_program('xxd', required: true)
xxd_generator = generator(
xxd_prog,
binh_prog = find_program('scripts/bin2header.py', required: true)
binh_generator = generator(
binh_prog,
output: '@[email protected]',
arguments: ['-n', '@EXTRA_ARGS@', '-i', '@INPUT@', '@OUTPUT@'],
arguments: ['-v', '@EXTRA_ARGS@', '-i', '@INPUT@', '-o', '@OUTPUT@'],
)

# FIXME: the explicit 'B612_Regular_ttf' below would ideally be @[email protected]() above except substitution does not work there

font_b612_c = xxd_generator.process(
font_b612_c = binh_generator.process(
'src/fonts/polarsys-b612/fonts/ttf/B612-Regular.ttf',
extra_args: 'B612_Regular_ttf',
)

font_mdi_c = xxd_generator.process(

font_mdi_c = binh_generator.process(
'src/fonts/MaterialDesign-Webfont/fonts/materialdesignicons-webfont.ttf',
extra_args: 'mdi_ttf',
)
Expand Down Expand Up @@ -167,7 +168,6 @@ endif

incdir = include_directories('./src/')

openssl_dep = dependency('openssl')
zlib_dep = dependency('zlib')

if get_option('front-ftxui').enabled()
Expand Down Expand Up @@ -195,7 +195,6 @@ if get_option('front-ftxui').enabled()
ftxui_screen_dep,
ftxui_dom_dep,
ftxui_component_dep,
openssl_dep,
zlib_dep,
libatomic,
],
Expand All @@ -220,7 +219,6 @@ executable(
json_dep,
thread_dep,
curl_dep,
openssl_dep,
zlib_dep,
libatomic,
],
Expand Down Expand Up @@ -260,7 +258,6 @@ if get_option('front-lvgl').enabled()
curl_dep,
lvgl_dep,
sdl2_dep,
openssl_dep,
zlib_dep,
libatomic,
date_dep,
Expand Down
34 changes: 34 additions & 0 deletions openwrt-package/voorkant/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# FIXME: license text here

include $(TOPDIR)/rules.mk

PKG_NAME:=voorkant
PKG_RELEASE:=0_git

PKG_LICENSE:=MIT

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/meson.mk

define Package/voorkant
SECTION:=utils
CATEGORY:=Utilities
DEPENDS:=+libcurl +nlohmannjson +libatomic +libstdcpp
TITLE:=Non-web Home Assistant frontend
endef

define Package/voorkant/description
FIXME
endef

define Package/voorkant/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/openwrt-build/voorkant-lvgl $(1)/usr/bin/
endef

MESON_ARGS += \
--prefer-static -Dlvgl-driver=fbdev -Dfront-ftxui=disabled

TARGET_LDFLAGS += -latomic -static -lstdc++ -lgcc_eh

$(eval $(call BuildPackage,voorkant))
1 change: 1 addition & 0 deletions openwrt-package/voorkant/src
41 changes: 41 additions & 0 deletions scripts/bin2header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3

# taken and modified from https://github.com/user-none/Bin-Headers/blob/aaebde3891957b39e4cc4c7844e1ecdecabeaaa2/bin2header.py, with gratitude
# that repo is licensed under MIT

import argparse
import sys

def bin2header(data, var_name='var'):
out = []
out.append('unsigned char {var_name}[] = {{'.format(var_name=var_name))
l = [ data[i:i+12] for i in range(0, len(data), 12) ]
for i, x in enumerate(l):
line = ', '.join([ '0x{val:02x}'.format(val=c) for c in x ])
out.append(' {line}{end_comma}'.format(line=line, end_comma=',' if i<len(l)-1 else ''))
out.append('};')
out.append('unsigned int {var_name}_len = {data_len};'.format(var_name=var_name, data_len=len(data)))
return '\n'.join(out).encode('ascii')

def main():
parser = argparse.ArgumentParser(description='Generate binary header output')
parser.add_argument('-i', '--input', required=True , help='Input file')
parser.add_argument('-o', '--out', required=True , help='Output file')
parser.add_argument('-v', '--var', required=True , help='Variable name to use in file')

args = parser.parse_args()
if not args:
return 1

with open(args.input, 'rb') as f:
data = f.read()

out = bin2header(data, args.var)
with open(args.out, 'wb') as f:
f.write(out)
f.write(b'\n')

return 0

if __name__ == '__main__':
sys.exit(main())
Loading