Changeset 9ce911d in mainline
- Timestamp:
- 2017-06-02T20:06:13Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f98434b8
- Parents:
- 7367c31
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/autotool.py
r7367c31 r9ce911d 849 849 check_app(["make", "--version"], "Make utility", "preferably GNU Make") 850 850 check_app(["makedepend", "-f", "-"], "Makedepend utility", "usually part of imake or xutils") 851 check_app(["unzip"], "unzip utility", "usually part of zip/unzip utilities") 851 852 852 853 # Compiler -
tools/mkarray.py
r7367c31 r9ce911d 28 28 # 29 29 """ 30 C structure creator30 Binary inline data packer 31 31 """ 32 32 33 33 import sys 34 34 import os 35 import struct 35 import zlib 36 import zipfile 37 import binascii 36 38 37 39 def usage(prname): 38 40 "Print usage syntax" 39 print("%s <DESTINATION> <LABEL> <AS_PROLOG> [SOURCE ...]" % prname) 41 print("%s [--deflate] <DESTINATION> <LABEL> <AS_PROLOG> [SOURCE ...]" % prname) 42 43 def arg_check(): 44 if (len(sys.argv) < 4): 45 usage(sys.argv[0]) 46 sys.exit() 47 48 def deflate(data): 49 "Compress using deflate algorithm (without any headers)" 50 return zlib.compress(data, 9)[2:-4] 51 52 def chunks(string, length): 53 "Produce string chunks" 54 for start in range(0, len(string), length): 55 yield string[start:start + length] 40 56 41 57 def main(): 42 if (len(sys.argv) < 4): 43 usage(sys.argv[0]) 44 return 58 arg_check() 59 60 if sys.argv[1] == "--deflate": 61 sys.argv.pop(1) 62 arg_check() 63 compress = True 64 else: 65 compress = False 45 66 46 67 dest = sys.argv[1] … … 49 70 50 71 header_ctx = [] 72 desc_ctx = [] 73 size_ctx = [] 51 74 data_ctx = [] 75 76 src_cnt = 0 52 77 53 78 for src in sys.argv[4:]: 54 79 basename = os.path.basename(src) 80 plainname = os.path.splitext(basename)[0] 55 81 symbol = basename.replace(".", "_") 56 82 … … 61 87 src_in.close() 62 88 63 data_rec = "\t.byte "89 length = len(src_data) 64 90 65 fmt = 'B' 66 item_size = struct.calcsize(fmt) 67 offset = 0 68 cnt = 0 91 if compress: 92 src_data = deflate(src_data) 69 93 70 while (len(src_data[offset:]) >= item_size): 71 byte = struct.unpack_from(fmt, src_data, offset) 72 73 if (offset > 0): 74 if ((cnt % 15) == 0): 75 data_rec += "\n\t.byte " 76 else: 77 data_rec += ", " 78 79 data_rec += "0x%x" % byte 80 offset += item_size 81 cnt += 1 94 if sys.version_info < (3,): 95 src_data = bytearray(src_data) 82 96 83 data_rec += "\n"97 length_out = len(src_data) 84 98 85 header_ctx.append("extern uint64_t %s_size;" % symbol)86 99 header_ctx.append("extern uint8_t %s[];" % symbol) 87 88 data_ctx.append(".globl %s_size" % symbol) 89 data_ctx.append(".balign 8"); 90 data_ctx.append(".size %s_size, 8" % symbol) 91 data_ctx.append("%s_size:" % symbol) 92 data_ctx.append("\t.quad %u\n" % offset) 100 header_ctx.append("extern size_t %s_size;" % symbol) 93 101 94 102 data_ctx.append(".globl %s" % symbol) 95 103 data_ctx.append(".balign 8") 96 data_ctx.append(".size %s, %u" % (symbol, offset))104 data_ctx.append(".size %s, %u" % (symbol, length_out)) 97 105 data_ctx.append("%s:" % symbol) 98 data_ctx.append(data_rec) 106 data_ctx.append("\t.byte 0x" + ', 0x'.join(chunks(binascii.b2a_hex(src_data), 2)) + "\n") 107 108 desc_field = [] 109 desc_field.append("\t{") 110 desc_field.append("\t\t.name = \"%s\"," % plainname) 111 desc_field.append("\t\t.addr = (void *) %s," % symbol) 112 desc_field.append("\t\t.size = %u," % length_out) 113 desc_field.append("\t\t.inflated = %u" % length) 114 desc_field.append("\t}") 115 116 desc_ctx.append("\n".join(desc_field)) 117 118 size_ctx.append("size_t %s_size = %u;" % (symbol, length_out)) 119 120 src_cnt += 1 99 121 100 header = open("%s.h" % dest, "w")122 archive = zipfile.ZipFile("%s.zip" % dest, "w", zipfile.ZIP_STORED) 101 123 102 header.write('/***************************************\n') 103 header.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n') 104 header.write(' * Generated by: tools/mkarray.py *\n') 105 header.write(' ***************************************/\n\n') 106 header.write("#ifndef %s_H_\n" % label) 107 header.write("#define %s_H_\n\n" % label) 108 header.write("#include <stddef.h>\n") 109 header.write("#include <stdint.h>\n\n") 110 header.write("\n".join(header_ctx)) 111 header.write("\n\n") 112 header.write("#endif\n") 124 data = '' 125 data += '/***************************************\n' 126 data += ' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n' 127 data += ' * Generated by: tools/mkarray.py *\n' 128 data += ' ***************************************/\n\n' 129 data += "#ifndef %sS_H_\n" % label.upper() 130 data += "#define %sS_H_\n\n" % label.upper() 131 data += "#include <stddef.h>\n" 132 data += "#include <stdint.h>\n\n" 133 data += "#define %sS %u\n\n" % (label.upper(), src_cnt) 134 data += "typedef struct {\n" 135 data += "\tconst char *name;\n" 136 data += "\tvoid *addr;\n" 137 data += "\tsize_t size;\n" 138 data += "\tsize_t inflated;\n" 139 data += "} %s_t;\n\n" % label 140 data += "extern %s_t %ss[];\n\n" % (label, label) 141 data += "\n".join(header_ctx) 142 data += "\n\n" 143 data += "#endif\n" 144 archive.writestr("%s.h" % dest, data) 113 145 114 header.close() 146 data = '' 147 data += '/***************************************\n' 148 data += ' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n' 149 data += ' * Generated by: tools/mkarray.py *\n' 150 data += ' ***************************************/\n\n' 151 data += as_prolog 152 data += '.data\n\n' 153 data += "\n".join(data_ctx) 154 data += "\n" 155 archive.writestr("%s.s" % dest, data) 115 156 116 data = open("%s.s" % dest, "w") 157 data = '' 158 data += '/***************************************\n' 159 data += ' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n' 160 data += ' * Generated by: tools/mkarray.py *\n' 161 data += ' ***************************************/\n\n' 162 data += "#include \"%s.h\"\n\n" % dest 163 data += "%s_t %ss[] = {\n" % (label, label) 164 data += ",\n".join(desc_ctx) 165 data += "\n" 166 data += "};\n\n" 167 data += "\n".join(size_ctx) 168 data += "\n" 169 archive.writestr("%s_desc.c" % dest, data) 117 170 118 data.write('/***************************************\n') 119 data.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n') 120 data.write(' * Generated by: tools/mkarray.py *\n') 121 data.write(' ***************************************/\n\n') 122 data.write(as_prolog) 123 data.write('.data\n\n') 124 data.write("\n".join(data_ctx)) 125 126 data.close() 171 archive.close() 127 172 128 173 if __name__ == '__main__': -
uspace/app/barber/Makefile
r7367c31 r9ce911d 44 44 MATH = y 45 45 46 IMG = image 47 IMGS = $(IMG)s 48 46 49 SOURCES = \ 47 50 barber.c \ 48 images.s 51 $(IMGS).s \ 52 $(IMGS)_desc.c 49 53 50 54 IMAGES = \ … … 80 84 gfx/frame30.tga.gz 81 85 82 PRE_DEPEND = images.s images.h83 EXTRA_CLEAN = images.s images.h86 PRE_DEPEND = $(IMGS).s $(IMGS).h $(IMGS)_desc.c 87 EXTRA_CLEAN = $(IMGS).s $(IMGS).h $(IMGS)_desc.c $(IMGS).zip 84 88 85 89 include $(USPACE_PREFIX)/Makefile.common 86 90 87 images.s images.h: $(IMAGES) 88 $(ROOT_PATH)/tools/mkarray.py images COMPOSITOR_IMAGES "$(AS_PROLOG)" $^ 91 $(IMGS).s: $(IMGS).zip 92 unzip -p $< $@ > $@ 93 94 $(IMGS).h: $(IMGS).zip 95 unzip -p $< $@ > $@ 96 97 $(IMGS)_desc.c: $(IMGS).zip 98 unzip -p $< $@ > $@ 99 100 $(IMGS).zip: $(IMAGES) 101 $(ROOT_PATH)/tools/mkarray.py $(IMGS) $(IMG) "$(AS_PROLOG)" $^ -
uspace/app/barber/barber.c
r7367c31 r9ce911d 51 51 #define NAME "barber" 52 52 53 #define FRAMES 3053 #define FRAMES IMAGES 54 54 55 55 #define MIN_FPS 1 … … 99 99 static bool decode_frames(void) 100 100 { 101 frames[0] = decode_tga_gz((void *) frame01_tga_gz, frame01_tga_gz_size, 0); 102 frames[1] = decode_tga_gz((void *) frame02_tga_gz, frame02_tga_gz_size, 0); 103 frames[2] = decode_tga_gz((void *) frame03_tga_gz, frame03_tga_gz_size, 0); 104 frames[3] = decode_tga_gz((void *) frame04_tga_gz, frame04_tga_gz_size, 0); 105 frames[4] = decode_tga_gz((void *) frame05_tga_gz, frame05_tga_gz_size, 0); 106 frames[5] = decode_tga_gz((void *) frame06_tga_gz, frame06_tga_gz_size, 0); 107 frames[6] = decode_tga_gz((void *) frame07_tga_gz, frame07_tga_gz_size, 0); 108 frames[7] = decode_tga_gz((void *) frame08_tga_gz, frame08_tga_gz_size, 0); 109 frames[8] = decode_tga_gz((void *) frame09_tga_gz, frame09_tga_gz_size, 0); 110 frames[9] = decode_tga_gz((void *) frame10_tga_gz, frame10_tga_gz_size, 0); 111 frames[10] = decode_tga_gz((void *) frame11_tga_gz, frame11_tga_gz_size, 0); 112 frames[11] = decode_tga_gz((void *) frame12_tga_gz, frame12_tga_gz_size, 0); 113 frames[12] = decode_tga_gz((void *) frame13_tga_gz, frame13_tga_gz_size, 0); 114 frames[13] = decode_tga_gz((void *) frame14_tga_gz, frame14_tga_gz_size, 0); 115 frames[14] = decode_tga_gz((void *) frame15_tga_gz, frame15_tga_gz_size, 0); 116 frames[15] = decode_tga_gz((void *) frame16_tga_gz, frame16_tga_gz_size, 0); 117 frames[16] = decode_tga_gz((void *) frame17_tga_gz, frame17_tga_gz_size, 0); 118 frames[17] = decode_tga_gz((void *) frame18_tga_gz, frame18_tga_gz_size, 0); 119 frames[18] = decode_tga_gz((void *) frame19_tga_gz, frame19_tga_gz_size, 0); 120 frames[19] = decode_tga_gz((void *) frame20_tga_gz, frame20_tga_gz_size, 0); 121 frames[20] = decode_tga_gz((void *) frame21_tga_gz, frame21_tga_gz_size, 0); 122 frames[21] = decode_tga_gz((void *) frame22_tga_gz, frame22_tga_gz_size, 0); 123 frames[22] = decode_tga_gz((void *) frame23_tga_gz, frame23_tga_gz_size, 0); 124 frames[23] = decode_tga_gz((void *) frame24_tga_gz, frame24_tga_gz_size, 0); 125 frames[24] = decode_tga_gz((void *) frame25_tga_gz, frame25_tga_gz_size, 0); 126 frames[25] = decode_tga_gz((void *) frame26_tga_gz, frame26_tga_gz_size, 0); 127 frames[26] = decode_tga_gz((void *) frame27_tga_gz, frame27_tga_gz_size, 0); 128 frames[27] = decode_tga_gz((void *) frame28_tga_gz, frame28_tga_gz_size, 0); 129 frames[28] = decode_tga_gz((void *) frame29_tga_gz, frame29_tga_gz_size, 0); 130 frames[29] = decode_tga_gz((void *) frame30_tga_gz, frame30_tga_gz_size, 0); 131 132 for (unsigned int frame = 0; frame < FRAMES; frame++) { 133 if (frames[frame] == NULL) { 134 printf("Unable to decode frame %u.\n", frame); 101 for (unsigned int i = 0; i < FRAMES; i++) { 102 frames[i] = decode_tga_gz(images[i].addr, images[i].size, 0); 103 if (frames[i] == NULL) { 104 printf("Unable to decode frame %u.\n", i); 135 105 return false; 136 106 } -
uspace/app/vlaunch/Makefile
r7367c31 r9ce911d 43 43 MATH = y 44 44 45 IMG = image 46 IMGS = $(IMG)s 47 45 48 SOURCES = \ 46 49 vlaunch.c \ 47 images.s 50 $(IMGS).s \ 51 $(IMGS)_desc.c 48 52 49 53 IMAGES = \ 50 54 gfx/helenos.tga 51 55 52 PRE_DEPEND = images.s images.h53 EXTRA_CLEAN = images.s images.h56 PRE_DEPEND = $(IMGS).s $(IMGS).h $(IMGS)_desc.c 57 EXTRA_CLEAN = $(IMGS).s $(IMGS).h $(IMGS)_desc.c $(IMGS).zip 54 58 55 59 include $(USPACE_PREFIX)/Makefile.common 56 60 57 images.s images.h: $(IMAGES) 58 $(ROOT_PATH)/tools/mkarray.py images COMPOSITOR_IMAGES "$(AS_PROLOG)" $^ 61 $(IMGS).s: $(IMGS).zip 62 unzip -p $< $@ > $@ 63 64 $(IMGS).h: $(IMGS).zip 65 unzip -p $< $@ > $@ 66 67 $(IMGS)_desc.c: $(IMGS).zip 68 unzip -p $< $@ > $@ 69 70 $(IMGS).zip: $(IMAGES) 71 $(ROOT_PATH)/tools/mkarray.py $(IMGS) $(IMG) "$(AS_PROLOG)" $^
Note:
See TracChangeset
for help on using the changeset viewer.