114 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			114 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| Import("env")
 | |
| 
 | |
| # HACHHACK
 | |
| # Currently injected to CPPPATH by libs - since they are built earlier and depend on assets
 | |
| # env.Append(
 | |
| #     CPPPATH=[
 | |
| #         Dir("./compiled"),
 | |
| #     ]
 | |
| # )
 | |
| 
 | |
| assetsenv = env.Clone(
 | |
|     tools=["fbt_assets"],
 | |
|     FW_LIB_NAME="assets",
 | |
| )
 | |
| assetsenv.ApplyLibFlags()
 | |
| 
 | |
| if not assetsenv["VERBOSE"]:
 | |
|     assetsenv.SetDefault(
 | |
|         ICONSCOMSTR="\tICONS\t${TARGET}",
 | |
|         PROTOCOMSTR="\tPROTO\t${SOURCE}",
 | |
|         DOLPHINCOMSTR="\tDOLPHIN\t${DOLPHIN_RES_TYPE}",
 | |
|         RESMANIFESTCOMSTR="\tMANIFEST\t${TARGET}",
 | |
|         PBVERCOMSTR="\tPBVER\t${TARGET}",
 | |
|     )
 | |
| 
 | |
| # Gathering icons sources
 | |
| icons_src = assetsenv.GlobRecursive("*.png", "icons")
 | |
| icons_src += assetsenv.GlobRecursive("frame_rate", "icons")
 | |
| 
 | |
| icons = assetsenv.IconBuilder(Dir("compiled"), Dir("#/assets/icons"))
 | |
| Depends(icons, icons_src)
 | |
| Alias("icons", icons)
 | |
| 
 | |
| 
 | |
| # Protobuf .proto -> .c + .h
 | |
| 
 | |
| proto_src = Glob("protobuf/*.proto", source=True)
 | |
| proto_options = Glob("protobuf/*.options", source=True)
 | |
| proto = assetsenv.ProtoBuilder(Dir("compiled"), proto_src)
 | |
| Depends(proto, proto_options)
 | |
| # Precious(proto)
 | |
| Alias("proto", proto)
 | |
| 
 | |
| 
 | |
| # Internal animations
 | |
| 
 | |
| dolphin_internal = assetsenv.DolphinSymBuilder(
 | |
|     Dir("compiled"),
 | |
|     Dir("#/assets/dolphin"),
 | |
|     DOLPHIN_RES_TYPE="internal",
 | |
| )
 | |
| Alias("dolphin_internal", dolphin_internal)
 | |
| 
 | |
| 
 | |
| # Blocking animations
 | |
| 
 | |
| dolphin_blocking = assetsenv.DolphinSymBuilder(
 | |
|     Dir("compiled"),
 | |
|     Dir("#/assets/dolphin"),
 | |
|     DOLPHIN_RES_TYPE="blocking",
 | |
| )
 | |
| Alias("dolphin_blocking", dolphin_blocking)
 | |
| 
 | |
| 
 | |
| # Protobuf version meta
 | |
| proto_ver = assetsenv.ProtoVerBuilder(
 | |
|     "compiled/protobuf_version.h",
 | |
|     "#/assets/protobuf/Changelog",
 | |
| )
 | |
| Depends(proto_ver, proto)
 | |
| Alias("proto_ver", proto_ver)
 | |
| 
 | |
| # Gather everything into a static lib
 | |
| assets_parts = (icons, proto, dolphin_blocking, dolphin_internal, proto_ver)
 | |
| 
 | |
| assetslib = assetsenv.Library("${FW_LIB_NAME}", assets_parts)
 | |
| assetsenv.Install("${LIB_DIST_DIR}", assetslib)
 | |
| 
 | |
| 
 | |
| # Resources for SD card
 | |
| 
 | |
| if assetsenv["IS_BASE_FIRMWARE"]:
 | |
|     # External dolphin animations
 | |
|     dolphin_external = assetsenv.DolphinExtBuilder(
 | |
|         Dir("#/assets/resources/dolphin"),
 | |
|         Dir("#/assets/dolphin"),
 | |
|         DOLPHIN_RES_TYPE="external",
 | |
|     )
 | |
|     NoClean(dolphin_external)
 | |
|     if assetsenv["FORCE"]:
 | |
|         AlwaysBuild(dolphin_external)
 | |
|     Alias("dolphin_ext", dolphin_external)
 | |
| 
 | |
|     # Resources manifest
 | |
| 
 | |
|     resources = assetsenv.Command(
 | |
|         "#/assets/resources/Manifest",
 | |
|         assetsenv.GlobRecursive("*", "resources", exclude="Manifest"),
 | |
|         action=Action(
 | |
|             '${PYTHON3} ${ASSETS_COMPILER} manifest "${TARGET.dir.posix}"',
 | |
|             "${RESMANIFESTCOMSTR}",
 | |
|         ),
 | |
|     )
 | |
|     Precious(resources)
 | |
|     NoClean(resources)
 | |
|     if assetsenv["FORCE"]:
 | |
|         AlwaysBuild(resources)
 | |
| 
 | |
|     # Exporting resources node to external environment
 | |
|     env["FW_RESOURCES"] = resources
 | |
|     Alias("resources", resources)
 | |
| 
 | |
| Return("assetslib")
 |