/****************************************************************************
**
** Copyright (C) 2015 Jake Petroules.
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \qmltype bundle
    \inqmlmodule QbsModules
    \since Qbs 1.4

    \brief Provides Core Foundation bundle support.

    The \c bundle module contains properties and rules for building and working with
    Core Foundation bundles on Apple platforms (commonly known as CFBundles or simply \e bundles),
    directories with a standardized hierarchical structure that hold executable code and resources.
    Examples include applications, frameworks, and plugins.

    This module is available on all platforms but is currently only useful on Apple platforms.

    \note Core Foundation bundles are not to be confused with Mach-O loadable modules, which are
    also referred to as (loadable) \e bundles in Apple parlance.
    In \QBS, Core Foundation bundles are referred to as \e bundles,
    while Mach-O loadable bundles are referred to as \e {loadable modules}.

    \target dependency-parameters-bundle
    \section2 Dependency Parameters

    \table
    \header
        \li Parameter
        \li Type
        \li Since
        \li Default
        \li Description
    \row
        \li \c{isForMainBundle}
        \li \c{bool}
        \li 3.1
        \li true
        \li If \c{false}, the dependency will not be copied into this main bundle.
    \endtable

    \section2 Relevant File Tags
    \target filetags-bundle

    \table
    \header
        \li Tag
        \li Auto-tagged File Names
        \li Since
        \li Description
    \row
        \li \c{"bundle.content"}
        \li -
        \li 1.8
        \li Attached to the output artifacts of the rule that produces the
            bundle.
    \row
        \li \c{"infoplist"}
        \li \c{Info.plist}, \c{*-Info.plist}
        \li 1.5
        \li Source files with this tag are Info property lists files or fragments that are merged
            into the bundle's final \c Info.plist.
    \row
        \li \c{"bundle.input.public_hpp"}
        \li n/a
        \li 3.0
        \li Source files with this tag will be copied to the \c{Headers} directory within a bundle.
    \row
        \li \c{"bundle.input.private_hpp"}
        \li n/a
        \li 3.0
        \li Source files with this tag will be copied to the \c{PrivateHeaders} directory within
            a bundle.
    \row
        \li \c{"bundle.input.resources"}
        \li n/a
        \li 3.0
        \li Source files with this tag will be copied to the \c{Resources} directory within
            a bundle.
    \endtable

    \section2 Main bundles

    It is possible to create a bundle that contains other products within itself. This is useful
    for big applications which depend on custom frameworks and/or other applications.

    Creating a main bundle is quite easy, simply set the \l{isMainBundle} property to \c true
    and all dependencies will be copied automatically to appropriate locations:
    \code
    CppApplication {
        name: "main"
        files: "main.cpp"
        Depends { name: "mylib" }
        Depends { name: "bundle" }
        bundle.isMainBundle: true
    }
    DynamicLibrary {
        name: "mylib"
        Depends { name: "cpp" }
        files: "mylib.cpp"
        install: false // skip installing the framework
    }
    \endcode

    In order to exclude a dependency from the main bundle, set the \l{bundle::isForMainBundle}
    property to \c false in the product:
    \code
    DynamicLibrary {
        name: "otherlib"
        Depends { name: "bundle" }
        bundle.isForMainBundle: false
    }
    \endcode
    Alternatively, set the \c{bundle.isForMainBundle} dependency parameter in the main bundle
    itself:
    \code
    CppApplication {
        name: "main"
        Depends { name: "otherlib"; bundle.isForMainBundle: false }
        // ...
    }
    \endcode
    See the full example the the
    \l{https://github.com/qbs/qbs/tree/master/examples/main-bundle}{examples} folder.

    \note Currently, static frameworks and libraries are not supported as an input to a main bundle.
*/

/*!
    \qmlproperty bool bundle::isBundle

    Whether the product should actually be packaged as a bundle as opposed to a
    flat file. This allows a product indirectly dependent on the \c{bundle}
    module to retain control of whether it should actually be built as a bundle.

    \defaultvalue \c{true} for applications and dynamic libraries on Apple
    platforms, \c{false} otherwise.
*/

/*!
    \qmlproperty bool bundle::isForMainBundle
    \since Qbs 3.1

    Set this property to \c false to skip copying of this product into any dependent main bundle.

    \defaultvalue \c true.
    \sa isMainBundle
*/

/*!
    \qmlproperty bool bundle::isMainBundle
    \since Qbs 3.1

    Whether to copy dependencies into this bundle.

    \defaultvalue \c false
    \sa isForMainBundle
*/

/*!
    \qmlproperty bool bundle::isShallow
    \readonly

    Whether the bundle directory tree is \e shallow. That is, whether it lacks a
    \c Contents subdirectory. This is the default on all platforms other than
    macOS.

    \defaultvalue \c{false} on macOS, otherwise \c{true}.
*/

/*!
    \qmlproperty string bundle::identifierPrefix

    A prefix for the product's bundle identifier. If \l{bundle::}{identifier}
    is left unset, the bundle identifier will be a concatenation of this value
    and the \l{Product::targetName}{Product.targetName} property formatted as
    an RFC-1034 identifier, separated by a period (.). This corresponds to the
    organization identifier in Xcode.

    \defaultvalue \c{org.example}
*/

/*!
    \qmlproperty string bundle::identifier

    The bundle's identifier. If left unset, the bundle identifier will be a
    concatenation of the \l{bundle::}{identifierPrefix} value and the
    \l{Product::targetName}{Product.targetName} propertyy formatted as an
    RFC-1034 identifier, separated by a period (.).

    \defaultvalue A combination of \l{bundle::}{identifierPrefix} and the
    product's target name formatted as an RFC-1034 identifier.
*/

/*!
    \qmlproperty string bundle::extension

    The extension of the bundle's wrapper directory, without the leading period
    (.).

    This property should not normally need to be set unless creating a custom
    bundle type.

    \defaultvalue \c{"app"} for \c{"APPL"} packages, \c{"framework"} for
    \c{"FMWK"} packages, and \c{"bundle"} for \c{"BNDL"} and custom packages.
*/

/*!
    \qmlproperty string bundle::packageType

    The four-letter file type code of the bundle, specified in the bundle's
    \c PkgInfo file and in the bundle's \c Info.plist as the value for the
    \c CFBundlePackageType key.

    This property should almost never need to be changed, even though specifying
    an alternative package type for custom bundles is allowed.

    \defaultvalue \c{"APPL"} for applications, \c{"FMWK"} for frameworks, and
    \c{"BNDL"} for custom bundles.
*/

/*!
    \qmlproperty bool bundle::generatePackageInfo
    \since Qbs 1.5

    Whether to generate a \c PkgInfo file for the bundle.

    This property should almost never need to be changed, even though enabling
    it when specifying an alternative package type for custom bundles using
    \l{bundle::}{packageType} is allowed.

    \defaultvalue \c{true} for applications, otherwise \c{false}.
*/

/*!
    \qmlproperty string bundle::signature

    The four-letter signature specific to the bundle, also known as the creator
    code, specified in the bundle's \c PkgInfo file and in the bundle's
    \c Info.plist as the value for the \c CFBundleSignature key.

    This property should normally never need to be set.

    \defaultvalue \c{"????"}
*/

/*!
    \qmlproperty string bundle::bundleName

    The file name of the bundle's wrapper directory.

    This property should not normally need to be changed.

    \defaultvalue A combination of the product's \l{Product::}{targetName} and
    bundle's \l{bundle::}{extension}.
*/

/*!
    \qmlproperty string bundle::frameworkVersion

    For framework bundles, the version of the framework. Not used for other
    package types.

    \defaultvalue \c{"A"}
*/

/*!
    \qmlproperty pathList bundle::publicHeaders

    A list of public header files to copy to a framework bundle's \c Headers
    subdirectory.

    It is recommended to attach the \c{"bundle.input.public_hpp"} file tag to headers instead:
    \code
    CppApplication {
        Depends { name: "bundle" }
        files: "main.cpp"
        Group {
            name: "public headers"
            files: ["header.h"]
            fileTags: ["bundle.input.public_hpp", "hpp"]
        }
    }
    \endcode
    \note Since \l{Group::fileTags}{Group.fileTags} property replaces file tags attached by
    the \l{FileTagger} item, the \c{"hpp"} tag should also be present.

    \nodefaultvalue
*/

/*!
    \qmlproperty pathList bundle::privateHeaders

    A list of private header files to copy to a framework bundle's
    \c PrivateHeaders subdirectory

    It is recommended to attach the \c{"bundle.input.private_hpp"} file tag to headers instead:
    \code
    CppApplication {
        Depends { name: "bundle" }
        files: "main.cpp"
        Group {
            name: "private headers"
            files: ["header.h"]
            fileTags: ["bundle.input.private_hpp", "hpp"]
        }
    }
    \endcode
    \note Since \l{Group::fileTags}{Group.fileTags} property replaces file tags attached by
    the \l{FileTagger} item, the \c{"hpp"} tag should also be present.

    \nodefaultvalue
*/

/*!
    \qmlproperty pathList bundle::resources

    A list of resources to copy to a bundle's \c Resources subdirectory. Files
    will automatically be copied into \c lproj subdirectories corresponding to
    the input files' paths.

    It is recommended to attach the \c{"bundle.input.resources"} file tag to resources instead:
    \code
    CppApplication {
        Depends { name: "bundle" }
        files: "main.cpp"
        Group {
            name: "resources"
            files: ["file.txt"]
            fileTags: ["bundle.input.resources"]
        }
    }
    \endcode

    \nodefaultvalue
*/

/*!
    \qmlproperty var bundle::infoPlist

    A dictionary of key-value pairs to add to the bundle's \c Info.plist.

    The contents of this property will be aggregated with the values from any
    \c plist files. If this property and any \c plist files contain the same
    key, this property will take precedence. However, it might be overridden
    during postprocessing (see \l{bundle::}{processInfoPlist}).

    If \c undefined, will not be taken into account.

    \nodefaultvalue
*/

/*!
    \qmlproperty bool bundle::processInfoPlist

    Whether to perform post-processing on the aggregated \c Info.plist contents.

    If this property is \c{true}, various post-processing operations will be
    applied to the bundle's property list dictionary after it has been
    aggregated from the contents of any \c plist files on disk, and the
    \l{bundle::}{infoPlist} property.

    First, values from a list of defaults will be added to the dictionary if
    they were not already present. Second, values from the \c AdditionalInfo key
    of the platform SDK's \c Info.plist file will be added to the dictionary if
    they were not already present, as well as some other miscellaneous keys,
    such as \c BuildMachineOSBuild and \c UIDeviceFamily (on iOS). Finally,
    variable expansions will be performed such that substrings of the form
    \c $(VAR) or \c ${VAR} will be replaced with their corresponding environment
    variables.

    \defaultvalue \c{true}
*/

/*!
    \qmlproperty bool bundle::embedInfoPlist

    Whether to create a \c{__TEXT} section in the product's executable
    containing the processed \c Info.plist.

    Only applies to command line applications.

    \defaultvalue \c{true} if the product is a command line tool, otherwise
    \c{false}.
*/

/*!
    \qmlproperty string bundle::infoPlistFormat

    The file format to write the product's resulting \c Info.plist in.

    Possible values are:

    \list
        \li \c{"binary1"}
        \li \c{"json"}
        \li \c{"same-as-input"}
        \li \c{"xml1"}
    \endlist

    \defaultvalue \c{"binary1"} for iOS, \c{"same-as-input"} or \c{"xml1"}
    for macOS depending on whether a \c plist file is used, and \c{undefined}
    for all other operating systems.
*/

/*!
    \qmlproperty string bundle::infoPlistPath
    \readonly

    The path that the \c Info.plist file will be written to.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::infoStringsPath
    \readonly
    \since Qbs 1.5

    The path that the \c InfoPlist.strings file will be written to.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::pkgInfoPath
    \readonly

    The path that the \c PkgInfo file will be written to.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::versionPlistPath
    \readonly

    The path that the \c version.plist file will be written to.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::executablePath
    \readonly

    The path that the main executable file will be written to.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::contentsFolderPath
    \readonly

    The path of the bundle's \c Contents subdirectory.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::applicationsFolderPath
    \readonly

    The path of the directory where dependent applications will be copied.

    This property applies only if \l{isMainBundle} is \c true.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::documentationFolderPath
    \readonly
    \since Qbs 1.5

    The path of the directory where documentation will be written.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::executableFolderPath
    \readonly

    The path of the directory where the main exectuable will be written.

    The path is relative to the directory that contains the bundle.

    Not to be confused with \l{bundle::}{executablesFolderPath}.
*/

/*!
    \qmlproperty string bundle::executablesFolderPath
    \readonly

    The path of the directory where auxiliary executables will be copied.

    The path is relative to the directory that contains the bundle.

    Not to be confused with \l{bundle::}{executableFolderPath}.
*/

/*!
    \qmlproperty string bundle::frameworksFolderPath
    \readonly

    The path of the directory where internal frameworks will be copied.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::javaFolderPath
    \readonly
    \since Qbs 1.5

    The path of the directory where Java content will be written.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::localizedResourcesFolderPath
    \readonly
    \since Qbs 1.5

    The path of the directory where localized resource files will be copied.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::pluginsFolderPath
    \readonly

    The path of the directory where plugins will be copied.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::privateHeadersFolderPath
    \readonly

    The path of the directory where private header files will be copied.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::publicHeadersFolderPath
    \readonly

    The path of the directory where public headers files will be copied.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::scriptsFolderPath
    \readonly

    The path of the directory where script files will be copied.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::sharedFrameworksFolderPath
    \readonly

    The path of the directory where shared frameworks will be copied.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::sharedSupportFolderPath
    \readonly

    The path of the directory where shared support files will be copied.

    The path is relative to the directory that contains the bundle.
*/

/*!
    \qmlproperty string bundle::unlocalizedResourcesFolderPath
    \readonly

    The path of the directory where non-localized resource files will be copied.

    The path is relative to the directory that contains the bundle.

    This is the same as the base resources path.
*/

/*!
    \qmlproperty bool bundle::useBuiltinXcodeBuildSpecs

    Set this property to \c true to use Xcode \c .xcspec files shipped with \QBS.

    This property can be used as a workaround when using a new Xcode version that is not supported
    by \QBS yet.

    \default false
*/

/*!
    \qmlproperty string bundle::versionsFolderPath
    \readonly
    \since Qbs 1.5

    The path of the bundle's \c Versions subdirectory.

    The path is relative to the directory that contains the bundle.

    This is only relevant for (non-shallow) framework bundles.
*/
