mkspecs/hb_functions.prf
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    63     export(DEPENDPATH)
    63     export(DEPENDPATH)
    64     export(HB_COVERAGE_EXCLUDE)
    64     export(HB_COVERAGE_EXCLUDE)
    65     return(true)
    65     return(true)
    66 }
    66 }
    67 
    67 
       
    68 # params: <path>
       
    69 # eg. foo_path = $$hbStripDriveLetter($$PWD)/foo.txt
       
    70 defineReplace(hbStripDriveLetter) {
       
    71     stripped_path = $$1
       
    72     symbian {
       
    73         contains(QMAKE_HOST.os, Windows) {
       
    74             colons_found = $$find( stripped_path, "\\:" )
       
    75             !isEmpty(colons_found) {
       
    76                 stripped_path = $$section(stripped_path, ":", 1)
       
    77             }         
       
    78         }
       
    79     }
       
    80     return($$stripped_path)
       
    81 }
       
    82 
       
    83 # params: <sourcepath> <targetpath>
       
    84 # e.g. hbPrjExport("$${PWD}/foo.txt", "$${EPOCROOT}epoc32/release/foo.txt")
       
    85 defineTest(hbPrjExport) {
       
    86     BLD_INF_RULES.prj_exports += "$$hbStripDriveLetter($$1) $$hbStripDriveLetter($$2)"
       
    87     export(BLD_INF_RULES.prj_exports)
       
    88     return(true)
       
    89 }
       
    90 
       
    91 # params: <sourcepath> <targetpath>
       
    92 # e.g. hbToolExport("$${HB_BUILD_DIR}/bin/docml2bin", "$${HB_BIN_DIR}/docml2bin")
       
    93 defineTest(hbToolExport) {
       
    94     contains(QMAKE_HOST.os, Windows) {
       
    95         1 = "$${1}.exe"
       
    96         2 = "$${2}.exe"
       
    97     }
       
    98     exists($$1) {
       
    99         hbPrjExport($$1, $$2)
       
   100         return(true)
       
   101     }
       
   102     return(false)
       
   103 }
       
   104 
    68 # params: <collection>
   105 # params: <collection>
    69 # NOTE: exports PUBLIC_HEADERS, RESTRICTED_HEADERS and CONVENIENCE_HEADERS
   106 # NOTE: exports PUBLIC_HEADERS, RESTRICTED_HEADERS and CONVENIENCE_HEADERS
    70 # eg. hbExportHeaders(hbcore)
   107 # eg. hbExportHeaders(hbcore)
    71 defineTest(hbExportHeaders) {
   108 defineTest(hbExportHeaders) {
    72     for(PUBLIC_HEADER, PUBLIC_HEADERS) {
   109     for(PUBLIC_HEADER, PUBLIC_HEADERS) {
    73         PUBLIC_HEADER = $$section(PUBLIC_HEADER, ":", 1)
   110         contains(QMAKE_HOST.os, Windows):PUBLIC_HEADER = $$section(PUBLIC_HEADER, ":", 1)
    74         EXPORT_PATH = $$sprintf($$HB_EXPORT_DIR, $$1, $$basename(PUBLIC_HEADER))
   111         EXPORT_PATH = $$sprintf($$HB_EXPORT_DIR, $$1, $$basename(PUBLIC_HEADER))
    75         BLD_INF_RULES.prj_exports *= "$$PUBLIC_HEADER $$EXPORT_PATH"
   112         BLD_INF_RULES.prj_exports *= "$$PUBLIC_HEADER $$EXPORT_PATH"
    76     }
   113     }
    77     for(RESTRICTED_HEADER, RESTRICTED_HEADERS) {
   114     for(RESTRICTED_HEADER, RESTRICTED_HEADERS) {
    78         RESTRICTED_HEADER = $$section(RESTRICTED_HEADER, ":", 1)
   115         contains(QMAKE_HOST.os, Windows):RESTRICTED_HEADER = $$section(RESTRICTED_HEADER, ":", 1)
    79         EXPORT_PATH = $$sprintf($$HB_RESTRICTED_EXPORT_DIR, $$1, $$basename(RESTRICTED_HEADER))
   116         EXPORT_PATH = $$sprintf($$HB_RESTRICTED_EXPORT_DIR, $$1, $$basename(RESTRICTED_HEADER))
    80         BLD_INF_RULES.prj_exports *= "$$RESTRICTED_HEADER $$EXPORT_PATH"
   117         BLD_INF_RULES.prj_exports *= "$$RESTRICTED_HEADER $$EXPORT_PATH"
    81     }
   118     }
    82     for(CONVENIENCE_HEADER, CONVENIENCE_HEADERS) {
   119     for(CONVENIENCE_HEADER, CONVENIENCE_HEADERS) {
    83         CONVENIENCE_HEADER = $$section(CONVENIENCE_HEADER, ":", 1)
   120         contains(QMAKE_HOST.os, Windows):CONVENIENCE_HEADER = $$section(CONVENIENCE_HEADER, ":", 1)
    84         EXPORT_PATH = $$sprintf($$HB_EXPORT_DIR, $$1, $$basename(CONVENIENCE_HEADER))
   121         EXPORT_PATH = $$sprintf($$HB_EXPORT_DIR, $$1, $$basename(CONVENIENCE_HEADER))
    85         BLD_INF_RULES.prj_exports *= "$$CONVENIENCE_HEADER $$EXPORT_PATH"
   122         BLD_INF_RULES.prj_exports *= "$$CONVENIENCE_HEADER $$EXPORT_PATH"
    86     }
   123     }
    87     export(BLD_INF_RULES.prj_exports)
   124     export(BLD_INF_RULES.prj_exports)
    88     return(true)
   125     return(true)
   129             DEVNULL = nul
   166             DEVNULL = nul
   130         }
   167         }
   131         system($$1 > $$DEVNULL 2>&1):return($$1)
   168         system($$1 > $$DEVNULL 2>&1):return($$1)
   132 
   169 
   133         # host build is runnable?
   170         # host build is runnable?
   134         hbtoolcmd = $$hbNativePath($$HB_BUILD_DIR/bin/$$1)
   171         !isEmpty(HB_BUILD_DIR) {
   135         system($$hbtoolcmd > $$DEVNULL 2>&1):return($$hbtoolcmd)
   172             hbtoolcmd = $$hbNativePath($$HB_BUILD_DIR/bin/$$1)
       
   173             system($$hbtoolcmd > $$DEVNULL 2>&1):return($$hbtoolcmd)
       
   174         }
   136 
   175 
   137         # tool in HB_BIN_DIR?
   176         # tool in HB_BIN_DIR?
   138         hbtoolcmd = $$hbNativePath($$HB_BIN_DIR/$$1)
   177         hbtoolcmd = $$hbNativePath($$HB_BIN_DIR/$$1)
   139         system($$hbtoolcmd > $$DEVNULL 2>&1):return($$hbtoolcmd)
   178         system($$hbtoolcmd > $$DEVNULL 2>&1):return($$hbtoolcmd)
   140 
   179 
   141         # pre-built tool is runnable?
   180         # pre-built tool is runnable?
   142         hbtoolcmd = $$hbNativePath($$sprintf("%1%2", $$HB_SOURCE_DIR/bin/$$1, "_symbian.exe"))
   181         hbtoolcmd = $$hbNativePath($$sprintf("%1%2", $$HB_SOURCE_DIR/bin/$$1, "_symbian.exe"))
   143         system($$hbtoolcmd > $$DEVNULL 2>&1):return($$hbtoolcmd)
   182         system($$hbtoolcmd > $$DEVNULL 2>&1):return($$hbtoolcmd)
   144     }
   183     }
   145     # fall back to <builddir>/bin
   184 
   146     return($$hbNativePath($$HB_BUILD_DIR/bin/$$1))
   185     !isEmpty(HB_BUILD_DIR) {
       
   186         # prefer <builddir>/bin
       
   187         return($$hbNativePath($$HB_BUILD_DIR/bin/$$1))
       
   188     } else {
       
   189         # fall back to <bindir>
       
   190         return($$hbNativePath($$HB_BIN_DIR/$$1))
       
   191     }
   147 }
   192 }
   148 
   193 
   149 # params: <file> <dir>
   194 # params: <file> <dir>
   150 defineReplace(hbCopyCommand) {
   195 defineReplace(hbCopyCommand) {
   151     file = $$hbNativePath($$1)
   196     file = $$hbNativePath($$1)
   164     hbUnixStyle(): chk_dir_exists_mkdir = $$chk_dir_exists || $$mkdir
   209     hbUnixStyle(): chk_dir_exists_mkdir = $$chk_dir_exists || $$mkdir
   165     else:chk_dir_exists_mkdir = $$chk_dir_exists $$mkdir
   210     else:chk_dir_exists_mkdir = $$chk_dir_exists $$mkdir
   166 
   211 
   167     return(($$chk_dir_exists_mkdir) && $$copy)
   212     return(($$chk_dir_exists_mkdir) && $$copy)
   168 }
   213 }
       
   214 
       
   215 defineReplace(hbCreateDir) {
       
   216     dir = $$hbNativePath($$1)
       
   217 
       
   218     contains(QMAKE_HOST.os, Windows):isEmpty(QMAKE_SH) {
       
   219         chk_dir_exists = if not exist $$dir
       
   220         mkdir = mkdir $$dir
       
   221     } else {
       
   222         chk_dir_exists = test -d $$dir
       
   223         mkdir = mkdir -p $$dir
       
   224     }
       
   225 
       
   226     hbUnixStyle(): chk_dir_exists_mkdir = $$chk_dir_exists || $$mkdir
       
   227     else:chk_dir_exists_mkdir = $$chk_dir_exists $$mkdir
       
   228 
       
   229     return($$chk_dir_exists_mkdir)
       
   230 }