1SubDir HAIKU_TOP src data mime_db ; 2 3 4rule BuildMimeDB superTypes 5{ 6 local mimeDB = <mimedb>mime_db ; 7 MakeLocateCommonPlatform $(mimeDB) ; 8 9 # make the supertypes 10 local compiledSuperTypes ; 11 local superType ; 12 for superType in $(superTypes) { 13 local compiledSuperType = $(superType:S=.rsrc:G=mimedb-super) ; 14 ResComp $(compiledSuperType) : $(superType) ; 15 compiledSuperTypes += $(compiledSuperType) ; 16 } 17 18 Depends $(mimeDB) : <build>resattr $(compiledSuperTypes) ; 19 BuildMimeDBSuperTypes $(mimeDB) : <build>resattr $(compiledSuperTypes) ; 20 21 # make the subtypes for each supertype 22 for superType in $(superTypes) { 23 local subTypes = [ on $(superType) return $(HAIKU_MIMEDB_SUBTYPES) ] ; 24 local compiledSubTypes ; 25 for subType in $(subTypes) { 26 local compiledSubType = $(subType:BS).rsrc ; 27 # Note: The subtype name may contain '.'s. Hence we cannot use 28 # ":S=.rsrc". 29 compiledSubType = $(compiledSubType:G=mimedb-sub-$(superType:B)) ; 30 ResComp $(compiledSubType) : $(subType) ; 31 MakeLocate $(compiledSubType) 32 : [ FDirName $(COMMON_PLATFORM_LOCATE_TARGET) $(superType:B) ] ; 33 # need to relocate to avoid clashes between equally named 34 # subtypes of different supertypes 35 compiledSubTypes += $(compiledSubType) ; 36 } 37 38 if $(compiledSubTypes) { 39 Depends $(mimeDB) : $(superType) $(compiledSubTypes) ; 40 BuildMimeDBSubTypes $(mimeDB) 41 : <build>resattr $(superType) $(compiledSubTypes) ; 42 } 43 } 44} 45 46 47actions BuildMimeDBSuperTypes 48{ 49 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 50 51 # remove and re-create the directory 52 baseDirectory="$(1)" 53 $(RM) -rf "$baseDirectory" 54 mkdir "$baseDirectory" 55 56 resattr="$(2[1])" 57 58 for sourceFile in "$(2[2-])" ; do 59 type=`basename "$sourceFile" .rsrc` 60 targetDirectory="$baseDirectory/$type" 61 mkdir "$targetDirectory" 62 "$resattr" -O -o "$targetDirectory" "$sourceFile" 63 done 64} 65 66 67actions BuildMimeDBSubTypes 68{ 69 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 70 71 resattr="$(2[1])" 72 superType=`basename "$(2[2])" .super` 73 superTypeDirectory="$(1)/$superType" 74 75 for sourceFile in "$(2[3-])" ; do 76 type=`basename "$sourceFile" .rsrc` 77 targetFile="$superTypeDirectory/$type" 78 "$resattr" -O -o "$targetFile" "$sourceFile" 79 done 80} 81 82 83# glob the supertype source files 84local superTypeFiles = [ Glob $(SUBDIR) : *.super ] ; 85superTypeFiles = $(superTypeFiles:BSG=mimedb) ; 86SEARCH on $(superTypeFiles) = $(SUBDIR) ; 87 88# for each supertype glob the subtype source files 89local superType ; 90for superTypeFile in $(superTypeFiles) { 91 local superTypeDirectory = [ FDirName $(SUBDIR) $(superTypeFile:B) ] ; 92 local subTypeFiles = [ Glob $(superTypeDirectory) : * ] ; 93 94 local subTypes ; 95 local subType ; 96 for subType in $(subTypeFiles:BS) { 97 if $(subType) != "." && $(subType) != ".." { 98 subType = $(subType:G=mimedb-sub) ; 99 SEARCH on $(subType) = $(superTypeDirectory) ; 100 subTypes += $(subType) ; 101 } 102 } 103 104 HAIKU_MIMEDB_SUBTYPES on $(superTypeFile) = $(subTypes) ; 105} 106 107BuildMimeDB $(superTypeFiles) ; 108