* github: bundling debug folder with scripts; docs: fixes & updates; fbt: added FAP_EXAMPLES variable to enable building example apps. Disabled by default. fbt: added TERM to list of proxied environment variables * fbt: better help output; disabled implicit_deps_unchanged; added color to import validator reports * fbt: moved debug configuration to separate tool * fbt: proper dependency tracker for SDK source file; renamed linker script for external apps * fbt: fixed debug elf path * fbt: packaging sdk archive * scripts: fixed sconsdist.py * fbt: reworked sdk packing; docs: updates * docs: info on cli target; linter fixes * fbt: moved main code to scripts folder * scripts: packing update into .tgz * fbt, scripts: reworked copro_dist to build .tgz * scripts: fixed naming for archived updater package * Scripts: fix ぐるぐる回る Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
		
			
				
	
	
		
			86 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
from dataclasses import dataclass
 | 
						|
import os
 | 
						|
 | 
						|
import struct
 | 
						|
from dataclasses import dataclass, field
 | 
						|
 | 
						|
from .appmanifest import FlipperApplication
 | 
						|
 | 
						|
 | 
						|
_MANIFEST_MAGIC = 0x52474448
 | 
						|
 | 
						|
 | 
						|
@dataclass
 | 
						|
class ElfManifestBaseHeader:
 | 
						|
    manifest_version: int
 | 
						|
    api_version: int
 | 
						|
    hardware_target_id: int
 | 
						|
 | 
						|
    manifest_magic: int = 0x52474448
 | 
						|
 | 
						|
    def as_bytes(self):
 | 
						|
        return struct.pack(
 | 
						|
            "<IIIh",
 | 
						|
            self.manifest_magic,
 | 
						|
            self.manifest_version,
 | 
						|
            self.api_version,
 | 
						|
            self.hardware_target_id,
 | 
						|
        )
 | 
						|
 | 
						|
 | 
						|
@dataclass
 | 
						|
class ElfManifestV1:
 | 
						|
    stack_size: int
 | 
						|
    app_version: int
 | 
						|
    name: str = ""
 | 
						|
    icon: bytes = field(default=b"")
 | 
						|
 | 
						|
    def as_bytes(self):
 | 
						|
        return struct.pack(
 | 
						|
            "<hI32s?32s",
 | 
						|
            self.stack_size,
 | 
						|
            self.app_version,
 | 
						|
            bytes(self.name.encode("ascii")),
 | 
						|
            bool(self.icon),
 | 
						|
            self.icon,
 | 
						|
        )
 | 
						|
 | 
						|
 | 
						|
def assemble_manifest_data(
 | 
						|
    app_manifest: FlipperApplication,
 | 
						|
    hardware_target: int,
 | 
						|
    sdk_version,
 | 
						|
):
 | 
						|
    image_data = b""
 | 
						|
    if app_manifest.fap_icon:
 | 
						|
        from flipper.assets.icon import file2image
 | 
						|
 | 
						|
        image = file2image(os.path.join(app_manifest._apppath, app_manifest.fap_icon))
 | 
						|
        if (image.width, image.height) != (10, 10):
 | 
						|
            raise ValueError(
 | 
						|
                f"Flipper app icon must be 10x10 pixels, but {image.width}x{image.height} was given"
 | 
						|
            )
 | 
						|
        if len(image.data) > 32:
 | 
						|
            raise ValueError(
 | 
						|
                f"Flipper app icon must be 32 bytes or less, but {len(image.data)} bytes were given"
 | 
						|
            )
 | 
						|
        image_data = image.data
 | 
						|
 | 
						|
    app_version_as_int = ((app_manifest.fap_version[0] & 0xFFFF) << 16) | (
 | 
						|
        app_manifest.fap_version[1] & 0xFFFF
 | 
						|
    )
 | 
						|
 | 
						|
    data = ElfManifestBaseHeader(
 | 
						|
        manifest_version=1,
 | 
						|
        api_version=sdk_version,
 | 
						|
        hardware_target_id=hardware_target,
 | 
						|
    ).as_bytes()
 | 
						|
    data += ElfManifestV1(
 | 
						|
        stack_size=app_manifest.stack_size,
 | 
						|
        app_version=app_version_as_int,
 | 
						|
        name=app_manifest.name,
 | 
						|
        icon=image_data,
 | 
						|
    ).as_bytes()
 | 
						|
 | 
						|
    return data
 |