functions.pri 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. Q_OS = $$lower( $$QMAKE_HOST.os )
  2. Q_OS_BUILD = $$Q_OS
  3. win32:Q_OS_BUILD = windows
  4. win32:!isEqual( Q_OS, "windows" ):CONFIG *= win32_crossbuild
  5. SLASH = "/"
  6. BACKSLASH = $$escape_expand( "\\" )
  7. # lupdate/lrelease too buggy ( not full qmake interpreter ), so avoid functions def in this case
  8. isEmpty( translations_pass ) {
  9. # return the list of directories recursively from a given path ($$1)
  10. # Forbidden filters can be given ($$2)
  11. defineReplace( getFolders ) {
  12. q_paths = $$1
  13. q_filters = $$2 .svn
  14. q_folders =
  15. for( q_path, q_paths ) {
  16. command = "ls -RQ1 \"$$q_path\" | grep \":\" | sed \"s/://g\" | sed \"s/'/\\\\\\'/g\""
  17. mac|win32:command = ls -R1 \"$$q_path\" | grep \":\" | sed \"s/://g\" | sed \"s/\'/\\\\\\\'/g\" | sed \"s/\\(.*\\)/\\\"\\1\\\"/g\"
  18. win32:isEqual( Q_OS, windows ):command = "for /D /R \"$$q_path\" %i in (*) do @echo \"%i\""
  19. _q_folders = $$system( $$command )
  20. _q_folders *= $$1
  21. _q_folders = $$replace( _q_folders, $$BACKSLASH, $$SLASH )
  22. # loop paths
  23. for( q_folder, _q_folders ) {
  24. # check filters
  25. filtered = false
  26. for( q_filter, q_filters ) {
  27. result = $$find( q_folder, $$q_filter )
  28. !isEmpty( result ):filtered = true
  29. }
  30. isEqual( filtered, false ):exists( $$q_folder ) {
  31. q_folders *= $$q_folder
  32. }
  33. }
  34. }
  35. #message( Getting folders for $$q_paths: $$q_folders )
  36. return( $$q_folders )
  37. }
  38. # return relative paths for the given paths ($$1)
  39. # according to root path ($$2)
  40. # new root path can be given ($$3)
  41. # Forbidden filters can be given ($$4)
  42. defineReplace( getRelativeFolders ) {
  43. q_paths = $$1
  44. q_root_path = $$2
  45. q_new_root_path = $$3
  46. q_filters = $$4
  47. q_folders = $$getFolders( $$q_paths, $$q_filters )
  48. q_folders = $$replace( q_folders, $$q_root_path, $$q_new_root_path )
  49. #message( Getting relative folders for $$q_paths: $$q_folders )
  50. return( $$q_folders )
  51. }
  52. # return the project build mode
  53. defineReplace( buildMode ) {
  54. CONFIG( debug, debug|release ) {
  55. return( debug )
  56. } else {
  57. return( release )
  58. }
  59. }
  60. # return the target name ($$1) according to build mode($$2)
  61. defineReplace( targetForMode ) {
  62. q_target = $$1
  63. q_mode = $$2
  64. isEmpty( q_mode ):q_mode = $$buildMode()
  65. isEqual( q_mode, release ) {
  66. q_target = $$quote( $$q_target )
  67. } else {
  68. unix:q_target = $$quote( $$join( q_target, , , _debug ) )
  69. else:q_target = $$quote( $$join( q_target, , , d ) )
  70. }
  71. return( $$q_target )
  72. }
  73. # this function set the target name ($$1) according to the build mode ($$2)
  74. defineTest( setTarget ) {
  75. TARGET = $$targetForMode( $$1, $$2 )
  76. export( TARGET )
  77. }
  78. defineTest( setTemporaryDirectories ) {
  79. q_build_path = $$1
  80. q_mode = $$buildMode()
  81. OBJECTS_DIR = $${q_build_path}/$${q_mode}/$${q_os}/obj
  82. UI_DIR = $${q_build_path}/$${q_mode}/$${q_os}/ui
  83. MOC_DIR = $${q_build_path}/$${q_mode}/$${q_os}/moc
  84. RCC_DIR = $${q_build_path}/$${q_mode}/$${q_os}/rcc
  85. export( OBJECTS_DIR )
  86. export( UI_DIR )
  87. export( MOC_DIR )
  88. export( RCC_DIR )
  89. }
  90. } else {
  91. defineReplace( getFolders ) {
  92. }
  93. defineReplace( getRelativeFolders ) {
  94. }
  95. defineReplace( buildMode ) {
  96. }
  97. defineReplace( targetForMode ) {
  98. }
  99. defineTest( setTarget ) {
  100. }
  101. defineTest( setTemporaryDirectories ) {
  102. }
  103. }