Skip to content

Commit

Permalink
C: Simplify ios.AssetCatalog (includes some parameter changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjensen committed Feb 26, 2017
1 parent 76410b5 commit bc14b00
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
39 changes: 28 additions & 11 deletions bin/modules/c/toolchain/clang/ios-shared.jam
Expand Up @@ -1279,31 +1279,48 @@ if $(NT) {
}


rule ios.AssetCatalog PARENT : TARGET_GRIST : DESTINATION_PATH : ASSET_CATALOG_PATH : APP_ICON_NAME : LAUNCH_IMAGE_NAME {
rule ios.AssetCatalog PARENT : ASSET_CATALOG_PATH : APP_ICON_NAME : LAUNCH_IMAGE_NAME : DESTINATION_PATH {
ASSET_CATALOG_PATH = $(ASSET_CATALOG_PATH:R=$(SUBDIR)) ;

local target = [ ios.GetBundleTarget ] ;
local cleanTarget = $(CLEAN_BUNDLE_TARGET:Z=$(C.ACTIVE_TOOLCHAIN_TARGET)) ;
local bundlePath = [ ios.GetBundlePath ] ;
if ! $(DESTINATION_PATH) {
DESTINATION_PATH = $(bundlePath) ;
}
ASSET_CATALOG_PATH = $(ASSET_CATALOG_PATH:R=$(SUBDIR)) ;

local COLON = ":" ;
LuaString "
local ospath = require 'ospath'

local parent = jam_getvar('PARENT')[1]
local targetGrist = jam_getvar('TARGET_GRIST')[1]
local parent = jam_getvar('target')[1]
local targetGrist = jam_getvar('C.ACTIVE_TOOLCHAIN_TARGET_GRIST')[1]
targetGrist = targetGrist .. '|assetcatalog'
local assetCatalogPath = jam_getvar('ASSET_CATALOG_PATH')[1]
local destinationPath = jam_getvar('DESTINATION_PATH')[1]
local cleanTarget = jam_getvar('cleanTarget')[1]

local destinationTargets = {}
local sourceTargets = {}

local appIcon = jam_getvar('APP_ICON_NAME')[1]
local launchImage = jam_getvar('LAUNCH_IMAGE_NAME')[1]
local appIcon = jam_getvar('APP_ICON_NAME')
if appIcon then
appIcon = appIcon[1]
end
local launchImage = jam_getvar('LAUNCH_IMAGE_NAME')
if launchImage then
launchImage = launchImage[1]
end
local NT = jam_getvar('NT')[1]

local appIcons = {}
local launchImages = {}

if appIcon ~= '' then
local at = '@'
local dollar = '$'

if appIcon and appIcon ~= '' then
local sourcePath = ospath.join(assetCatalogPath, appIcon .. '.appiconset')
local contentsJsonFilename = ospath.join(sourcePath, 'Contents.json')
local contents = require 'cjson'.decode(ospath.read_file(contentsJsonFilename))
Expand Down Expand Up @@ -1338,12 +1355,12 @@ rule ios.AssetCatalog PARENT : TARGET_GRIST : DESTINATION_PATH : ASSET_CATALOG_P
sourceTargets[#sourceTargets + 1] = inputTarget
end

local at = '@'
appIcons[#appIcons + 1] = jam_expand(at .. '(' .. outputTarget .. ':BS)')[1]
local textToExpand = at .. '(' .. outputTarget:gsub(':', dollar .. '(COLON)') .. ':BS)'
appIcons[#appIcons + 1] = jam_expand(textToExpand)[1]
until true end
end

if launchImage ~= '' then
if launchImage and launchImage ~= '' then
local sourcePath = ospath.join(assetCatalogPath, launchImage .. '.launchimage')
local contentsJsonFilename = ospath.join(sourcePath, 'Contents.json')
local contents = require 'cjson'.decode(ospath.read_file(contentsJsonFilename))
Expand Down Expand Up @@ -1421,10 +1438,10 @@ rule ios.AssetCatalog PARENT : TARGET_GRIST : DESTINATION_PATH : ASSET_CATALOG_P
sourceTargets[#sourceTargets + 1] = inputTarget
end

local expansionString = '@'
local textToExpand = at .. '(' .. outputTarget:gsub(':', dollar .. '(COLON)') .. ':B)'
launchImages[#launchImages + 1] = {
osVersion = entry['minimum-system-version'],
fileTitle = jam_expand(expansionString .. '(' .. outputTarget .. ':B)')[1],
fileTitle = jam_expand(textToExpand)[1],
orientation = entry.orientation,
-- imageSize = '{' .. entry.size .. '}',
}
Expand Down
7 changes: 3 additions & 4 deletions docs/module_ios.dox
Expand Up @@ -158,20 +158,19 @@ In order to output a final <tt>.ipa</tt> to be installed on an iOS device, \c io


<hr>
\section rule_ios_AssetCatalog rule ios.AssetCatalog TARGET : TARGET_GRIST : DESTINATION_PATH : ASSET_CATALOG_PATH : APP_ICON_NAME : LAUNCH_IMAGE_NAME
\section rule_ios_AssetCatalog rule ios.AssetCatalog TARGET : ASSET_CATALOG_PATH : APP_ICON_NAME : LAUNCH_IMAGE_NAME : DESTINATION_PATH
\addindex rule_ios_AssetCatalog

Takes a provided asset catalog and builds it into its individual components.

\param TARGET The target to build the asset catalog for. \c TARGET is optional if \ref rule_ActiveTarget has been specified.
\param TARGET_GRIST A grist to preface the derived asset catalog entries against.
\param DESTINATION_PATH The output directory for the generated assets.
\param ASSET_CATALOG_PATH The path to the <tt>.xcassets</tt> directory containing the asset catalog components.
\param APP_ICON_NAME (optional) The name of the <tt>.appiconset</tt> to process. Generally, the name is \c AppIcon.
\param LAUNCH_IMAGE_NAME (optional) The name of the <tt>.launchimage</tt> to process. Generally, the name is \c LaunchImage.
\param DESTINATION_PATH (optional) The output directory for the generated assets. Defaults to the bundle path.

\code
ios.AssetCatalog [ ios.GetBundleTarget ] : assets : [ ios.GetBundlePath ] : Unity-iPhone/Images.xcassets : AppIcon : LaunchImage ;
ios.AssetCatalog : Unity-iPhone/Images.xcassets : AppIcon : LaunchImage ;
\endcode


Expand Down

0 comments on commit bc14b00

Please sign in to comment.