mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-10-24 21:57:08 +08:00
[feat] add desktop license and source information pages
This commit is contained in:
@@ -43,6 +43,58 @@ def write_json(path, value):
|
||||
write(path, json.dumps(value, ensure_ascii=False, indent=2) + '\n')
|
||||
|
||||
|
||||
def write_about_resources(output, version):
|
||||
"""Supply the embedded catalog required by the shared desktop About UI."""
|
||||
def git(directory, *args):
|
||||
try:
|
||||
return subprocess.check_output(['git', '-C', str(directory), *args],
|
||||
text=True, stderr=subprocess.DEVNULL).strip()
|
||||
except (OSError, subprocess.CalledProcessError):
|
||||
return ''
|
||||
|
||||
revision = git(ROOT, 'rev-parse', 'HEAD')
|
||||
mini = git(ROOT / 'deps/submodules/minirtc', 'rev-parse', 'HEAD')
|
||||
repository = 'https://github.com/kunkundi/crossdesk'
|
||||
source = repository + (f'/tree/{revision}' if revision else '')
|
||||
gpl = {'title': 'GNU GPL v3', 'text': (ROOT / 'LICENSE').read_text()}
|
||||
components = [
|
||||
{'id': 'crossdesk', 'name': 'CrossDesk', 'version': version,
|
||||
'license': 'GPL-3.0-only', 'sourceURL': source, 'documents': [gpl]},
|
||||
{'id': 'minirtc', 'name': 'MiniRTC', 'version': mini[:12],
|
||||
'license': 'LGPL-3.0-only',
|
||||
'sourceURL': 'https://github.com/kunkundi/minirtc' + (f'/tree/{mini}' if mini else ''),
|
||||
'documents': [{'title': 'GNU LGPL v3',
|
||||
'text': (ROOT / 'deps/submodules/minirtc/LICENSE').read_text()}, gpl]},
|
||||
{'id': 'slint', 'name': 'Slint', 'version': '1.17.1', 'license': 'GPL-3.0-only',
|
||||
'sourceURL': 'https://github.com/slint-ui/slint/tree/v1.17.1',
|
||||
'documents': [{'title': 'Slint license', 'text': (SOURCE / 'LICENSE.md').read_text()}, gpl]},
|
||||
{'id': 'cpp-httplib', 'name': 'cpp-httplib', 'version': 'v0.26.0', 'license': 'MIT',
|
||||
'sourceURL': 'https://github.com/yhirose/cpp-httplib/tree/v0.26.0', 'documents': []}]
|
||||
shared = json.loads((ROOT / 'apps/ios/CrossDeskMobile/Resources/ThirdPartyLicenses.json').read_text())['components']
|
||||
shared += json.loads((ROOT / 'apps/android/licenses/additional-notices.json').read_text())
|
||||
seen = {item['id'] for item in components}
|
||||
for item in shared:
|
||||
name = item['id']
|
||||
package = APP / '.native/packages' / name[0] / name
|
||||
if name not in seen and any((package / tag).is_dir() for tag in
|
||||
[item['version'], item['version'].removeprefix('v'),
|
||||
'v' + item['version'].removeprefix('v')]):
|
||||
components.append(item)
|
||||
seen.add(name)
|
||||
components.sort(key=lambda item: (item['id'] != 'crossdesk', item['name'].lower()))
|
||||
data = json.dumps({'components': components, 'revision': revision[:12],
|
||||
'sourceURL': source,
|
||||
'buildURL': f'{repository}/blob/{revision or "main"}/apps/harmony/README.md'},
|
||||
ensure_ascii=False, sort_keys=True).encode()
|
||||
body = '\n'.join(','.join(str(byte) for byte in data[i:i + 32]) + ','
|
||||
for i in range(0, len(data), 32))
|
||||
write(output, '/*\n * @Author: DI JUNKUN\n * @Date: 2026-10-21\n'
|
||||
' * Copyright (c) 2026 by DI JUNKUN, All Rights Reserved.\n */\n\n'
|
||||
'#ifndef _ABOUT_RESOURCES_H_\n#define _ABOUT_RESOURCES_H_\n\n'
|
||||
'// Generated by the Harmony desktop build. Do not edit.\n'
|
||||
'inline constexpr unsigned char kAboutResources[] = {\n' + body + '\n};\n\n#endif\n')
|
||||
|
||||
|
||||
def main():
|
||||
bundle = json.loads((APP / 'AppScope/app.json5').read_text())['app']['bundleName']
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
@@ -157,6 +209,7 @@ def main():
|
||||
urllib.request.urlretrieve('https://raw.githubusercontent.com/yhirose/cpp-httplib/v0.26.0/httplib.h', header)
|
||||
if hashlib.sha256(header.read_bytes()).hexdigest() != '4a42da28ce477d06f53942c172197d3b83b4fe42b7e37b8af78c70e063c06da7':
|
||||
raise SystemExit('cpp-httplib source checksum mismatch')
|
||||
write_about_resources(generated / 'about_resources.h', args.version)
|
||||
legacy_types = PROJECT / 'entry/src/main/cpp/types/libslint_probe'
|
||||
if legacy_types.exists():
|
||||
run([studio / 'tools/hvigor/bin/hvigorw', 'clean', '--no-daemon'], cwd=PROJECT, env=env)
|
||||
|
||||
Reference in New Issue
Block a user