From 518840e305b44986a28aff2db042a932bf2fd650 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 9 May 2013 03:38:10 +0200 Subject: [PATCH] Complete MIME related support for image/package creation * Update MimeSet rule to use the MIME DB the build system creates. * Add CreateAppMimeDBEntries rule and call it from Link for targets that might be applications that need to be registered with the MIME DB. For the target the rule is invoked with it creates a directory into which the entries for the types to be registered are written. The directory is associated with the target via the HAIKU_MIME_DB_ENTRIES variable. * AddFilesToContainer: If a target is added that has MIME DB entries, also add those to the container. * build_haiku_package: Call mimeset for the package contents. --- build/jam/BeOSRules | 42 +++++++++++++++++++++++++++---- build/jam/ImageRules | 15 +++++++++++ build/jam/OverriddenJamRules | 8 +++++- build/jam/PackageRules | 2 ++ build/scripts/build_haiku_package | 12 ++++++--- 5 files changed, 70 insertions(+), 9 deletions(-) diff --git a/build/jam/BeOSRules b/build/jam/BeOSRules index 46b88025f3..a3a2cb95c3 100644 --- a/build/jam/BeOSRules +++ b/build/jam/BeOSRules @@ -163,20 +163,52 @@ actions SetType1 $(2[1]) -t $(TARGET_EXECUTABLE_MIME_TYPE) "$(1)" ; } -rule MimeSet +rule MimeSet target { - # MimeSet + # MimeSet ; - Depends $(1) : mimeset ; - MimeSet1 $(1) : mimeset ; + Depends $(target) : mimeset mime_db ; + MimeSet1 $(target) : mimeset mime_db ; } + actions MimeSet1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) - $(2[1]) -f "$(1)" ; + $(2[1]) -f --mimedb "$(2[2])" "$(1)" } + +rule CreateAppMimeDBEntries target +{ + # MimeSetApp ; + # Create the app meta MIME DB entries for the given target. The + # HAIKU_MIME_DB_ENTRIES variable on is set to the generated + # resulting target directory that contains the MIME DB entries. + + local appGrist = $(target:G) ; + local appMimeDB = $(target:BS)_mimedb ; + appMimeDB = $(appMimeDB:G=mimedb-app-$(appGrist:E=)) ; + MakeLocateDebug $(appMimeDB) ; + Depends $(appMimeDB) : mimeset $(target) mime_db ; + CreateAppMimeDBEntries1 $(appMimeDB) + : mimeset $(target) mime_db ; + + HAIKU_MIME_DB_ENTRIES on $(target) = $(appMimeDB) ; +} + + +actions CreateAppMimeDBEntries1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + + appMimeDB="$(1)" + $(RM) -rf "$appMimeDB" + $(MKDIR) "$appMimeDB" + $(2[1]) -f --apps --mimedb "$appMimeDB" --mimedb "$(2[3])" "$(2[2])" +} + + rule ResComp { # ResComp : ; diff --git a/build/jam/ImageRules b/build/jam/ImageRules index 82f3e1069b..8b5f7cfbcc 100644 --- a/build/jam/ImageRules +++ b/build/jam/ImageRules @@ -257,6 +257,21 @@ rule AddFilesToContainer container : directoryTokens : targets : destName : $(systemDirTokens) data locale catalogs $(signature) : $(catalogs) ; } + + # If the target is associated with MIME DB entries, add those, too. + local mimeDBEntries = [ on $(target) return $(HAIKU_MIME_DB_ENTRIES) ] ; + if $(mimeDBEntries) { + # Make sure we add the entries only once by tracking the containers + # we have already added it to. + local containers = [ on $(mimeDBEntries) + return $(HAIKU_MIME_DB_ENTRIES_IN_CONTAINERS) ] ; + if ! $(container) in $(containers) { + HAIKU_MIME_DB_ENTRIES_IN_CONTAINERS on $(mimeDBEntries) + = $(containers) $(container) ; + CopyDirectoryToContainer $(container) : data + : $(mimeDBEntries) : mime_db : : alwaysUpdate isTarget ; + } + } } } diff --git a/build/jam/OverriddenJamRules b/build/jam/OverriddenJamRules index 190e66f557..5f710c6661 100644 --- a/build/jam/OverriddenJamRules +++ b/build/jam/OverriddenJamRules @@ -34,9 +34,15 @@ rule Link on $(1) XRes $(1) : $(RESFILES) ; if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] { SetType $(1) ; - MimeSet $(1) ; + MimeSet $(1) : sharedObject ; SetVersion $(1) ; + # For applications for the target also generate the MIME DB entries. + if [ on $(1) return $(PLATFORM) ] != host + && [ on $(1) return $(RESFILES) ] { + CreateAppMimeDBEntries $(1) ; + } + # If the generic attribute emulation is enabled, make sure the tool to # remove the attributes is built first. if $(HOST_RM_ATTRS_TARGET) { diff --git a/build/jam/PackageRules b/build/jam/PackageRules index a35b578eaf..9502174e9e 100644 --- a/build/jam/PackageRules +++ b/build/jam/PackageRules @@ -314,6 +314,8 @@ rule BuildHaikuPackage package : packageInfo : [ on $(package) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] ; AddTargetVariableToScript $(script) : addattr ; AddTargetVariableToScript $(script) : copyattr ; + AddTargetVariableToScript $(script) : mime_db : mimeDB ; + AddTargetVariableToScript $(script) : mimeset ; AddTargetVariableToScript $(script) : package ; AddTargetVariableToScript $(script) : rc ; AddTargetVariableToScript $(script) : resattr ; diff --git a/build/scripts/build_haiku_package b/build/scripts/build_haiku_package index fbbefdfd81..b2e091f476 100755 --- a/build/scripts/build_haiku_package +++ b/build/scripts/build_haiku_package @@ -2,14 +2,16 @@ set -o errexit # The first argument is the shell script that initializes the variables: -# sourceDir -# outputDir -# tmpDir # addBuildCompatibilityLibDir +# mimeDB +# outputDir +# sourceDir +# tmpDir # updateOnly # # addattr # copyattr +# mimeset # package # rc # rmAttrs @@ -60,6 +62,10 @@ while [ $# -gt 0 ]; do done +# mimeset the whole package content +$mimeset --mimedb "$mimeDB" "$contentsDir" + + # create the package if [ ! $updateOnly ]; then rm -f "$packagePath"