mkspecs/hb_functions.prf
author hgs
Mon, 18 Oct 2010 18:23:13 +0300
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
hgs
parents: 7
diff changeset
     1
#
hgs
parents: 7
diff changeset
     2
#############################################################################
hgs
parents: 7
diff changeset
     3
##
hgs
parents: 7
diff changeset
     4
## Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents: 7
diff changeset
     5
## All rights reserved.
hgs
parents: 7
diff changeset
     6
## Contact: Nokia Corporation (developer.feedback@nokia.com)
hgs
parents: 7
diff changeset
     7
##
hgs
parents: 7
diff changeset
     8
## This file is part of the UI Extensions for Mobile.
hgs
parents: 7
diff changeset
     9
##
hgs
parents: 7
diff changeset
    10
## GNU Lesser General Public License Usage
hgs
parents: 7
diff changeset
    11
## This file may be used under the terms of the GNU Lesser General Public
hgs
parents: 7
diff changeset
    12
## License version 2.1 as published by the Free Software Foundation and
hgs
parents: 7
diff changeset
    13
## appearing in the file LICENSE.LGPL included in the packaging of this file.
hgs
parents: 7
diff changeset
    14
## Please review the following information to ensure the GNU Lesser General
hgs
parents: 7
diff changeset
    15
## Public License version 2.1 requirements will be met:
hgs
parents: 7
diff changeset
    16
## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
hgs
parents: 7
diff changeset
    17
##
hgs
parents: 7
diff changeset
    18
## In addition, as a special exception, Nokia gives you certain additional
hgs
parents: 7
diff changeset
    19
## rights.  These rights are described in the Nokia Qt LGPL Exception
hgs
parents: 7
diff changeset
    20
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
hgs
parents: 7
diff changeset
    21
##
hgs
parents: 7
diff changeset
    22
## If you have questions regarding the use of this file, please contact
hgs
parents: 7
diff changeset
    23
## Nokia at developer.feedback@nokia.com.
hgs
parents: 7
diff changeset
    24
##
hgs
parents: 7
diff changeset
    25
#############################################################################
hgs
parents: 7
diff changeset
    26
#
hgs
parents: 7
diff changeset
    27
hgs
parents: 7
diff changeset
    28
defineReplace(hbLibraryTarget) {
hgs
parents: 7
diff changeset
    29
    unset(LIBRARY_NAME)
hgs
parents: 7
diff changeset
    30
    LIBRARY_NAME = $$1
hgs
parents: 7
diff changeset
    31
    # the following leads to ugly vcproj names but had to be commented
hgs
parents: 7
diff changeset
    32
    # out, because it broke vcproj generator dependency checks
hgs
parents: 7
diff changeset
    33
    #!debug_and_release|build_pass { <-- 
hgs
parents: 7
diff changeset
    34
        CONFIG(debug, debug|release) {
hgs
parents: 7
diff changeset
    35
            mac:RET = $$member(LIBRARY_NAME, 0)_debug
hgs
parents: 7
diff changeset
    36
            else:win32:RET = $$member(LIBRARY_NAME, 0)d
hgs
parents: 7
diff changeset
    37
        }
hgs
parents: 7
diff changeset
    38
    #}
hgs
parents: 7
diff changeset
    39
    isEmpty(RET):RET = $$LIBRARY_NAME
hgs
parents: 7
diff changeset
    40
    return($$RET)
hgs
parents: 7
diff changeset
    41
}
hgs
parents: 7
diff changeset
    42
hgs
parents: 7
diff changeset
    43
# params: <collection/library>
hgs
parents: 7
diff changeset
    44
# eg. hbAddLibrary(hbcore/HbCore)
hgs
parents: 7
diff changeset
    45
defineTest(hbAddLibrary) {
hgs
parents: 7
diff changeset
    46
    PARTS = $$split(1, "/")
hgs
parents: 7
diff changeset
    47
    COLLECTION = $$lower($$first(PARTS))
hgs
parents: 7
diff changeset
    48
    LIBRARY = $$last(PARTS)
hgs
parents: 7
diff changeset
    49
hgs
parents: 7
diff changeset
    50
    INCLUDEPATH *= $${HB_BUILD_DIR}/include/$${COLLECTION}
hgs
parents: 7
diff changeset
    51
    INCLUDEPATH *= $${HB_BUILD_DIR}/include/$${COLLECTION}/restricted
hgs
parents: 7
diff changeset
    52
    INCLUDEPATH *= $${HB_BUILD_DIR}/include/$${COLLECTION}/private
hgs
parents: 7
diff changeset
    53
    DEPENDPATH *= $${HB_BUILD_DIR}/include/$${COLLECTION}
hgs
parents: 7
diff changeset
    54
    DEPENDPATH *= $${HB_BUILD_DIR}/include/$${COLLECTION}/restricted
hgs
parents: 7
diff changeset
    55
    DEPENDPATH *= $${HB_BUILD_DIR}/include/$${COLLECTION}/private
hgs
parents: 7
diff changeset
    56
hgs
parents: 7
diff changeset
    57
    LIBS *= -L$${HB_BUILD_DIR}/lib
hgs
parents: 7
diff changeset
    58
    LIBS *= -l$$hbLibraryTarget($$LIBRARY)
hgs
parents: 7
diff changeset
    59
    unix:HB_COVERAGE_EXCLUDE += \"*/$$COLLECTION/*\"
hgs
parents: 7
diff changeset
    60
hgs
parents: 7
diff changeset
    61
    export(LIBS)
hgs
parents: 7
diff changeset
    62
    export(INCLUDEPATH)
hgs
parents: 7
diff changeset
    63
    export(DEPENDPATH)
hgs
parents: 7
diff changeset
    64
    export(HB_COVERAGE_EXCLUDE)
hgs
parents: 7
diff changeset
    65
    return(true)
hgs
parents: 7
diff changeset
    66
}
hgs
parents: 7
diff changeset
    67
hgs
parents: 7
diff changeset
    68
# params: <path>
hgs
parents: 7
diff changeset
    69
# eg. foo_path = $$hbStripDriveLetter($$PWD)/foo.txt
hgs
parents: 7
diff changeset
    70
defineReplace(hbStripDriveLetter) {
hgs
parents: 7
diff changeset
    71
    stripped_path = $$1
hgs
parents: 7
diff changeset
    72
    symbian {
hgs
parents: 7
diff changeset
    73
        contains(QMAKE_HOST.os, Windows) {
hgs
parents: 7
diff changeset
    74
            colons_found = $$find( stripped_path, "\\:" )
hgs
parents: 7
diff changeset
    75
            !isEmpty(colons_found) {
hgs
parents: 7
diff changeset
    76
                stripped_path = $$section(stripped_path, ":", 1)
hgs
parents: 7
diff changeset
    77
            }         
hgs
parents: 7
diff changeset
    78
        }
hgs
parents: 7
diff changeset
    79
    }
hgs
parents: 7
diff changeset
    80
    return($$stripped_path)
hgs
parents: 7
diff changeset
    81
}
hgs
parents: 7
diff changeset
    82
hgs
parents: 7
diff changeset
    83
# params: <sourcepath> <targetpath>
hgs
parents: 7
diff changeset
    84
# e.g. hbPrjExport("$${PWD}/foo.txt", "$${EPOCROOT}epoc32/release/foo.txt")
hgs
parents: 7
diff changeset
    85
defineTest(hbPrjExport) {
hgs
parents: 7
diff changeset
    86
    BLD_INF_RULES.prj_exports += "$$hbStripDriveLetter($$1) $$hbStripDriveLetter($$2)"
hgs
parents: 7
diff changeset
    87
    export(BLD_INF_RULES.prj_exports)
hgs
parents: 7
diff changeset
    88
    return(true)
hgs
parents: 7
diff changeset
    89
}
hgs
parents: 7
diff changeset
    90
hgs
parents: 7
diff changeset
    91
# params: <sourcepath> <targetpath>
hgs
parents: 7
diff changeset
    92
# e.g. hbToolExport("$${HB_BUILD_DIR}/bin/docml2bin", "$${HB_BIN_DIR}/docml2bin")
hgs
parents: 7
diff changeset
    93
defineTest(hbToolExport) {
hgs
parents: 7
diff changeset
    94
    contains(QMAKE_HOST.os, Windows) {
hgs
parents: 7
diff changeset
    95
        1 = "$${1}.exe"
hgs
parents: 7
diff changeset
    96
        2 = "$${2}.exe"
hgs
parents: 7
diff changeset
    97
    }
hgs
parents: 7
diff changeset
    98
    exists($$1) {
hgs
parents: 7
diff changeset
    99
        hbPrjExport($$1, $$2)
hgs
parents: 7
diff changeset
   100
        return(true)
hgs
parents: 7
diff changeset
   101
    }
hgs
parents: 7
diff changeset
   102
    return(false)
hgs
parents: 7
diff changeset
   103
}
hgs
parents: 7
diff changeset
   104
hgs
parents: 7
diff changeset
   105
# params: <collection>
hgs
parents: 7
diff changeset
   106
# NOTE: exports PUBLIC_HEADERS, RESTRICTED_HEADERS and CONVENIENCE_HEADERS
hgs
parents: 7
diff changeset
   107
# eg. hbExportHeaders(hbcore)
hgs
parents: 7
diff changeset
   108
defineTest(hbExportHeaders) {
hgs
parents: 7
diff changeset
   109
    for(PUBLIC_HEADER, PUBLIC_HEADERS) {
hgs
parents: 7
diff changeset
   110
        contains(QMAKE_HOST.os, Windows):PUBLIC_HEADER = $$section(PUBLIC_HEADER, ":", 1)
hgs
parents: 7
diff changeset
   111
        EXPORT_PATH = $$sprintf($$HB_EXPORT_DIR, $$1, $$basename(PUBLIC_HEADER))
hgs
parents: 7
diff changeset
   112
        BLD_INF_RULES.prj_exports *= "$$PUBLIC_HEADER $$EXPORT_PATH"
hgs
parents: 7
diff changeset
   113
    }
hgs
parents: 7
diff changeset
   114
    for(RESTRICTED_HEADER, RESTRICTED_HEADERS) {
hgs
parents: 7
diff changeset
   115
        contains(QMAKE_HOST.os, Windows):RESTRICTED_HEADER = $$section(RESTRICTED_HEADER, ":", 1)
hgs
parents: 7
diff changeset
   116
        EXPORT_PATH = $$sprintf($$HB_RESTRICTED_EXPORT_DIR, $$1, $$basename(RESTRICTED_HEADER))
hgs
parents: 7
diff changeset
   117
        BLD_INF_RULES.prj_exports *= "$$RESTRICTED_HEADER $$EXPORT_PATH"
hgs
parents: 7
diff changeset
   118
    }
hgs
parents: 7
diff changeset
   119
    for(CONVENIENCE_HEADER, CONVENIENCE_HEADERS) {
hgs
parents: 7
diff changeset
   120
        contains(QMAKE_HOST.os, Windows):CONVENIENCE_HEADER = $$section(CONVENIENCE_HEADER, ":", 1)
hgs
parents: 7
diff changeset
   121
        EXPORT_PATH = $$sprintf($$HB_EXPORT_DIR, $$1, $$basename(CONVENIENCE_HEADER))
hgs
parents: 7
diff changeset
   122
        BLD_INF_RULES.prj_exports *= "$$CONVENIENCE_HEADER $$EXPORT_PATH"
hgs
parents: 7
diff changeset
   123
    }
hgs
parents: 7
diff changeset
   124
    export(BLD_INF_RULES.prj_exports)
hgs
parents: 7
diff changeset
   125
    return(true)
hgs
parents: 7
diff changeset
   126
}
hgs
parents: 7
diff changeset
   127
hgs
parents: 7
diff changeset
   128
# params: -
hgs
parents: 7
diff changeset
   129
# eg. $$hbUnixStyle():CMD=/path/to/cmd else:CMD=\path\to\cmd
hgs
parents: 7
diff changeset
   130
defineTest(hbUnixStyle) {
hgs
parents: 7
diff changeset
   131
    contains(QMAKE_HOST.os, Windows):isEmpty(QMAKE_SH) {
hgs
parents: 7
diff changeset
   132
        unixstyle = false
hgs
parents: 7
diff changeset
   133
    } else {
hgs
parents: 7
diff changeset
   134
        unixstyle = true
hgs
parents: 7
diff changeset
   135
    }
hgs
parents: 7
diff changeset
   136
    return($$unixstyle)
hgs
parents: 7
diff changeset
   137
}
hgs
parents: 7
diff changeset
   138
hgs
parents: 7
diff changeset
   139
# params: <path>
hgs
parents: 7
diff changeset
   140
# eg. features.path = $$hbNativePath($$[QMAKE_MKSPECS]/features)
hgs
parents: 7
diff changeset
   141
defineReplace(hbNativePath) {
hgs
parents: 7
diff changeset
   142
    contains(QMAKE_HOST.os, Windows) {
hgs
parents: 7
diff changeset
   143
        isEmpty(QMAKE_SH) {
hgs
parents: 7
diff changeset
   144
            1 = $$replace(1, \\\\, $$QMAKE_DIR_SEP)
hgs
parents: 7
diff changeset
   145
            1 = $$replace(1, /, $$QMAKE_DIR_SEP)
hgs
parents: 7
diff changeset
   146
        } else {
hgs
parents: 7
diff changeset
   147
            1 = $$replace(1, \\\\, /)
hgs
parents: 7
diff changeset
   148
            1 = $$replace(1, /, /)
hgs
parents: 7
diff changeset
   149
        }
hgs
parents: 7
diff changeset
   150
    } else {
hgs
parents: 7
diff changeset
   151
        1 = $$replace(1, \\\\, $$QMAKE_DIR_SEP)
hgs
parents: 7
diff changeset
   152
        1 = $$replace(1, /, $$QMAKE_DIR_SEP)
hgs
parents: 7
diff changeset
   153
    }
hgs
parents: 7
diff changeset
   154
    
hgs
parents: 7
diff changeset
   155
    return($$quote(\"$$1\"))
hgs
parents: 7
diff changeset
   156
}
hgs
parents: 7
diff changeset
   157
hgs
parents: 7
diff changeset
   158
# params: <tool name>
hgs
parents: 7
diff changeset
   159
# eg. hbfoo.command = $$hbToolCommand(hbfoo)
hgs
parents: 7
diff changeset
   160
defineReplace(hbToolCommand) {
hgs
parents: 7
diff changeset
   161
    symbian {
hgs
parents: 7
diff changeset
   162
        # tool in PATH?
hgs
parents: 7
diff changeset
   163
        exists(/dev/null) {
hgs
parents: 7
diff changeset
   164
            DEVNULL = /dev/null
hgs
parents: 7
diff changeset
   165
        } else {
hgs
parents: 7
diff changeset
   166
            DEVNULL = nul
hgs
parents: 7
diff changeset
   167
        }
hgs
parents: 7
diff changeset
   168
        system($$1 > $$DEVNULL 2>&1):return($$1)
hgs
parents: 7
diff changeset
   169
hgs
parents: 7
diff changeset
   170
        # host build is runnable?
hgs
parents: 7
diff changeset
   171
        !isEmpty(HB_BUILD_DIR) {
hgs
parents: 7
diff changeset
   172
            hbtoolcmd = $$hbNativePath($$HB_BUILD_DIR/bin/$$1)
hgs
parents: 7
diff changeset
   173
            system($$hbtoolcmd > $$DEVNULL 2>&1):return($$hbtoolcmd)
hgs
parents: 7
diff changeset
   174
        }
hgs
parents: 7
diff changeset
   175
hgs
parents: 7
diff changeset
   176
        # tool in HB_BIN_DIR?
hgs
parents: 7
diff changeset
   177
        hbtoolcmd = $$hbNativePath($$HB_BIN_DIR/$$1)
hgs
parents: 7
diff changeset
   178
        system($$hbtoolcmd > $$DEVNULL 2>&1):return($$hbtoolcmd)
hgs
parents: 7
diff changeset
   179
hgs
parents: 7
diff changeset
   180
        # pre-built tool is runnable?
hgs
parents: 7
diff changeset
   181
        hbtoolcmd = $$hbNativePath($$sprintf("%1%2", $$HB_SOURCE_DIR/bin/$$1, "_symbian.exe"))
hgs
parents: 7
diff changeset
   182
        system($$hbtoolcmd > $$DEVNULL 2>&1):return($$hbtoolcmd)
hgs
parents: 7
diff changeset
   183
    }
hgs
parents: 7
diff changeset
   184
hgs
parents: 7
diff changeset
   185
    !isEmpty(HB_BUILD_DIR) {
hgs
parents: 7
diff changeset
   186
        # prefer <builddir>/bin
hgs
parents: 7
diff changeset
   187
        return($$hbNativePath($$HB_BUILD_DIR/bin/$$1))
hgs
parents: 7
diff changeset
   188
    } else {
hgs
parents: 7
diff changeset
   189
        # fall back to <bindir>
hgs
parents: 7
diff changeset
   190
        return($$hbNativePath($$HB_BIN_DIR/$$1))
hgs
parents: 7
diff changeset
   191
    }
hgs
parents: 7
diff changeset
   192
}
hgs
parents: 7
diff changeset
   193
hgs
parents: 7
diff changeset
   194
# params: <file> <dir>
hgs
parents: 7
diff changeset
   195
defineReplace(hbCopyCommand) {
hgs
parents: 7
diff changeset
   196
    file = $$hbNativePath($$1)
hgs
parents: 7
diff changeset
   197
    dir = $$hbNativePath($$2)
hgs
parents: 7
diff changeset
   198
hgs
parents: 7
diff changeset
   199
    contains(QMAKE_HOST.os, Windows):isEmpty(QMAKE_SH) {
hgs
parents: 7
diff changeset
   200
        chk_dir_exists = if not exist $$dir
hgs
parents: 7
diff changeset
   201
        mkdir = mkdir $$dir
hgs
parents: 7
diff changeset
   202
        copy = copy /y $$file $$dir
hgs
parents: 7
diff changeset
   203
    } else {
hgs
parents: 7
diff changeset
   204
        chk_dir_exists = test -d $$dir
hgs
parents: 7
diff changeset
   205
        mkdir = mkdir -p $$dir
hgs
parents: 7
diff changeset
   206
        copy = cp $$file $$dir
hgs
parents: 7
diff changeset
   207
    }
hgs
parents: 7
diff changeset
   208
hgs
parents: 7
diff changeset
   209
    hbUnixStyle(): chk_dir_exists_mkdir = $$chk_dir_exists || $$mkdir
hgs
parents: 7
diff changeset
   210
    else:chk_dir_exists_mkdir = $$chk_dir_exists $$mkdir
hgs
parents: 7
diff changeset
   211
hgs
parents: 7
diff changeset
   212
    return(($$chk_dir_exists_mkdir) && $$copy)
hgs
parents: 7
diff changeset
   213
}
hgs
parents: 7
diff changeset
   214
hgs
parents: 7
diff changeset
   215
defineReplace(hbCreateDir) {
hgs
parents: 7
diff changeset
   216
    dir = $$hbNativePath($$1)
hgs
parents: 7
diff changeset
   217
hgs
parents: 7
diff changeset
   218
    contains(QMAKE_HOST.os, Windows):isEmpty(QMAKE_SH) {
hgs
parents: 7
diff changeset
   219
        chk_dir_exists = if not exist $$dir
hgs
parents: 7
diff changeset
   220
        mkdir = mkdir $$dir
hgs
parents: 7
diff changeset
   221
    } else {
hgs
parents: 7
diff changeset
   222
        chk_dir_exists = test -d $$dir
hgs
parents: 7
diff changeset
   223
        mkdir = mkdir -p $$dir
hgs
parents: 7
diff changeset
   224
    }
hgs
parents: 7
diff changeset
   225
hgs
parents: 7
diff changeset
   226
    hbUnixStyle(): chk_dir_exists_mkdir = $$chk_dir_exists || $$mkdir
hgs
parents: 7
diff changeset
   227
    else:chk_dir_exists_mkdir = $$chk_dir_exists $$mkdir
hgs
parents: 7
diff changeset
   228
hgs
parents: 7
diff changeset
   229
    return($$chk_dir_exists_mkdir)
hgs
parents: 7
diff changeset
   230
}