Changeset 145
- Timestamp:
- 02/23/06 12:44:47 (3 years ago)
- Files:
-
- branches/larsivi-elf/utils/ArgParser.d (modified) (1 diff)
- branches/larsivi-elf/utils/bless.d (modified) (8 diffs)
- branches/larsivi-elf/utils/bless_bn.d (modified) (1 diff)
- branches/larsivi-elf/utils/ddlinfo.d (modified) (3 diffs)
- branches/larsivi-elf/utils/ddlinfo_bn.d (modified) (1 diff)
- branches/larsivi-elf/utils/insitu.d (modified) (4 diffs)
- branches/larsivi-elf/utils/insitu_bn.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/larsivi-elf/utils/ArgParser.d
r133 r145 168 168 else { 169 169 argData = argData[prefix.length..$]; 170 } 170 } 171 171 foreach (PrefixCallback cb; bindings[prefix]) { 172 172 if (argData.length < cb.id.length) continue; branches/larsivi-elf/utils/bless.d
r127 r145 29 29 30 30 private import ddl.all; 31 private import ddl.FileBuffer; 31 32 private import ddl.ddl.DDLLoader; 32 33 private import ddl.ddl.DDLBinary; 33 34 35 private import mango.io.File; 36 private import mango.io.FilePath; 37 34 38 private import utils.bless_bn; 35 39 private import utils.ArgParser; 36 40 41 enum PathPart{ 42 Ext = 1, 43 Name = 2, 44 Path = 4, 45 Root = 8, 46 Suffix = 16 47 } 48 49 char[] filePathPart(FilePath path,PathPart parts){ 50 char[] result; 51 52 if(parts | PathPart.Root) result ~= path.getRoot; 53 if(parts | PathPart.Path) result ~= path.getPath; 54 if(parts | PathPart.Name) result ~= path.getName; 55 if(parts | PathPart.Suffix) result ~= path.getSuffix; 56 if(parts | PathPart.Ext) result ~= path.getExtension; 57 58 return result; 59 } 60 37 61 38 62 char[] helpText = 39 63 "Bless - DDL wrapper utility - V1.2 Build %d 40 Copyright (C) 2005 Eric Anderton64 Copyright (C) 2005,2006 Eric Anderton 41 65 Documentation: http://www.dsource.org/projects/ddl 42 66 … … 71 95 72 96 // get the filename 73 DDLFile file; 74 file.create(args[1]); 75 76 char[] originalOutputFile = file.getName ~ ".ddl"; 97 File file = new File(args[1]); 98 99 char[] originalOutputFile = filePathPart(file.getPath,PathPart.Root | PathPart.Path | PathPart.Name | PathPart.Suffix); 77 100 78 101 // pick through the options (if any) … … 157 180 158 181 // validate a few things 182 /* 159 183 if(!file.exists){ 160 184 Stdout.println("File '%s' does not exist.",file.filename); 161 185 return 1; 162 186 } 187 */ 163 188 164 189 // load it up! 165 190 //NOTE: rather than just be satisfied with what loader likes this file 166 191 // we load the entire file via its loader to ensure that it will work later. 167 file.load(); 168 DynamicLibrary lib = registry.load(file); 192 DynamicLibrary lib = registry.load(file.getPath.toString()); 169 193 170 194 if(!lib){ 171 Stdout.println("Cannot load '%s'",file. filename);195 Stdout.println("Cannot load '%s'",file.getPath); 172 196 return 1; 173 197 } … … 175 199 // output 176 200 if(verbose){ 177 Stdout.println("filename: '%s'",file. filename);201 Stdout.println("filename: '%s'",file.getPath); 178 202 Stdout.println("type: '%s'",lib.getType); 179 203 } … … 181 205 if(extract){ 182 206 if(lib.getType != DDLLoader.typeName){ 183 Stdout.println("cannot extract from a non-ddl file ('%s').",file. filename);207 Stdout.println("cannot extract from a non-ddl file ('%s').",file.getPath); 184 208 return 1; 185 209 } 186 210 } 187 211 else if(lib.getType == DDLLoader.typeName){ 188 Stdout.println("'%s' already appears to be a ddl file.",file. filename);212 Stdout.println("'%s' already appears to be a ddl file.",file.getPath); 189 213 return 1; 190 214 } … … 192 216 if(extract){ 193 217 // coerce complete load of the ddl binary file 194 DDLBinary binary = new DDLBinary(file.buffer); 218 DDLBinary binary = new DDLBinary(); 219 binary.load(new FileBuffer(file.getPath)); 195 220 196 221 // save to output file … … 223 248 // save the easy fields 224 249 binary.binaryType = lib.getType; 225 binary.binaryData = file.buffer;250 binary.binaryData = cast(ubyte[])file.read(); 226 251 binary.attributes = attributes; 227 252 228 253 if(!("std.filename" in attributes)){ 229 attributes["std.filename"] = file.get Name ~ "." ~ file.getExtension;254 attributes["std.filename"] = file.getPath.getName ~ "." ~ file.getPath.getExtension; 230 255 } 231 256 … … 257 282 258 283 if(!noCreate){ 259 binary.save( outputFileName);284 binary.save(new FileBuffer(outputFileName)); 260 285 if(verbose) Stdout.println("Created '%s'",outputFileName); 261 286 } branches/larsivi-elf/utils/bless_bn.d
r117 r145 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 199;4 long auto_build_number = 254; branches/larsivi-elf/utils/ddlinfo.d
r127 r145 30 30 private import utils.ddlinfo_bn; 31 31 private import ddl.all; 32 private import ddl.FileBuffer; 32 33 private import utils.ArgParser; 33 34 … … 61 62 62 63 // get the filename 63 DDLFile file; 64 file.load(args[1]); 64 FileBuffer file = new FileBuffer(args[1]); 65 65 66 66 // pick through the options (if any) … … 92 92 93 93 // validate a few things 94 if(!file.exists){94 /* if(!file.exists){ 95 95 Stdout.println("file '%s' does not exist.",file.filename); 96 96 return 1; 97 97 } 98 99 //TODO: make sure the file is supported 100 file.load(); 101 98 */ 102 99 // (attempt to) load the binary file 103 100 DynamicLibrary lib = regsitry.load(file); 104 101 105 102 if(!lib){ 106 Stdout.println("file '%s' is not supported.",file. filename);103 Stdout.println("file '%s' is not supported.",file.getPath); 107 104 return 1; 108 105 } 109 106 110 Stdout.println("filename: '%s'",file. filename);107 Stdout.println("filename: '%s'",file.getPath); 111 108 Stdout.println("type: '%s'",lib.getType); 112 109 branches/larsivi-elf/utils/ddlinfo_bn.d
r117 r145 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 199;4 long auto_build_number = 254; branches/larsivi-elf/utils/insitu.d
r127 r145 30 30 31 31 private import ddl.all; 32 private import ddl. Utils;32 private import ddl.FileBuffer; 33 33 private import ddl.insitu.all; 34 34 … … 56 56 by DMD. 57 57 "; 58 // -d Create a .d file with a SituLibrary class instead59 //With the -d switch, <filename>_InSitu.d will be used instead.60 58 61 59 int main(char[][] args){ … … 73 71 74 72 // get the filename 75 DDLFile inputFile; 76 inputFile.create(args[1]); 73 FileBuffer inputFile = new FileBuffer(args[1]); 77 74 78 75 // determine the output file 79 char[] outputFilename = inputFile.getName; 80 bit dOutput = false; 76 char[] outputFilename = inputFile.getPath.toString; 81 77 bit filenameOverride = false; 82 78 … … 101 97 }); 102 98 103 // parser.bind("d",delegate void(){104 // dOutput = true;105 // });106 99 107 100 parser.parse(args[2..$]); 108 101 109 102 // load the .map file and get what we need 110 inputFile.load();111 103 InSituMapBinary inputBinary = new InSituMapBinary(); 112 104 inputBinary.load(inputFile); 113 105 114 debugLog("%d bytes loaded",inputFile.buffer.length); 115 116 debugLog("%d exports total",inputBinary.getAllSymbols().values.length); 106 //debugLog("%d bytes loaded",inputFile.buffer.length); 107 //debugLog("%d exports total",inputBinary.getAllSymbols().values.length); 117 108 118 DDLFile outputFile; 119 outputFile.create(outputFilename); 109 FileBuffer outputFile = new FileBuffer(outputFilename); 120 110 121 // if(!dOutput){ 122 if(!filenameOverride) outputFile.filename ~= ".situ"; 123 // commit the data to the lib-style binary 124 InSituLibBinary outputBinary = new InSituLibBinary(); 125 outputBinary.setAllSymbols(inputBinary.getAllSymbols()); 126 outputBinary.save(outputFile,compressionLevel); 127 /* } 128 else{ 129 // create .d sourcecode to use instead 130 WriteCursor cursor = new WriteCursor(); 131 132 cursor.writeText( 133 "//Auto-generated by the DDL In-Situ tool 134 import ddl.insitu.InSituStubLibrary; 135 import ddl.ExportSymbol; 111 if(!filenameOverride) outputFile.filename ~= ".situ"; 112 // commit the data to the lib-style binary 113 InSituLibBinary outputBinary = new InSituLibBinary(); 114 outputBinary.setAllSymbols(inputBinary.getAllSymbols()); 115 outputBinary.save(outputFile,compressionLevel); 136 116 137 const ExportSymbol[char[]] symbols=["138 );139 140 // create buffers141 foreach(ExportSymbol exp; inputBinary.getAllSymbols()){142 cursor.writeText("\n\t\t\"" ~ exp.name ~ "\" : {cast(void*)" ~ uintToString(cast(uint)exp.address) ~ ",\"" ~ exp.name ~ "\"},");143 }144 cursor.writeText(145 "146 ];147 148 class InSituLibrary : InSituStubLibrary{149 public this(){150 super(symbols);151 }152 }"153 );154 if(!filenameOverride) outputFile.filename ~= "_InSitu.d";155 outputFile.save(cursor.getData());156 } */157 117 return 0; 158 118 } branches/larsivi-elf/utils/insitu_bn.d
r117 r145 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 199;4 long auto_build_number = 254;
