PageRenderTime 43ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/Code/Tools/BuildScripts/mac-specific/CopyResources.lua

http://angel-engine.googlecode.com/
Lua | 143 lines | 104 code | 11 blank | 28 comment | 20 complexity | 9ba131afdec5d8ed54329dcd968cc09c MD5 | raw file
Possible License(s): 0BSD, BSD-3-Clause, LGPL-2.1, GPL-2.0, LGPL-2.0, LGPL-3.0, GPL-3.0
  1. ------------------------------------------------------------------------------
  2. -- Copyright (C) 2008-2012, Shane Liesegang
  3. -- All rights reserved.
  4. --
  5. -- Redistribution and use in source and binary forms, with or without
  6. -- modification, are permitted provided that the following conditions are met:
  7. --
  8. -- * Redistributions of source code must retain the above copyright
  9. -- notice, this list of conditions and the following disclaimer.
  10. -- * Redistributions in binary form must reproduce the above copyright
  11. -- notice, this list of conditions and the following disclaimer in the
  12. -- documentation and/or other materials provided with the distribution.
  13. -- * Neither the name of the copyright holder nor the names of any
  14. -- contributors may be used to endorse or promote products derived from
  15. -- this software without specific prior written permission.
  16. --
  17. -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  21. -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  24. -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  25. -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26. -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  27. -- POSSIBILITY OF SUCH DAMAGE.
  28. ------------------------------------------------------------------------------
  29. if (package.path == nil) then
  30. package.path = ""
  31. end
  32. local mydir = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]]
  33. if (mydir == nil) then
  34. mydir = "."
  35. end
  36. mydir = mydir .. "/../"
  37. package.path = mydir .. "?.lua;" .. package.path
  38. package.path = package.path .. ";" .. mydir .. "lua-lib/penlight-1.0.2/lua/?/init.lua"
  39. package.path = package.path .. ";" .. mydir .. "lua-lib/penlight-1.0.2/lua/?.lua"
  40. package.path = package.path .. ";" .. mydir .. "lua-lib/penlight-1.0.2/lua/pl/?.lua"
  41. require "angel_build"
  42. require "lfs"
  43. require "pl"
  44. lfs.chdir(fulljoin(os.getenv('PROJECT_DIR'), '..', 'Angel', 'Scripting', 'EngineScripts'):gsub('"', ''))
  45. function building_for_iphone()
  46. if ((os.getenv('PLATFORM_NAME') == "iphonesimulator") or (os.getenv('PLATFORM_NAME') == "iphoneos")) then
  47. return true
  48. else
  49. return false
  50. end
  51. end
  52. local dest = ""
  53. if (building_for_iphone()) then
  54. dest = fulljoin(
  55. os.getenv('TARGET_BUILD_DIR'),
  56. os.getenv('EXECUTABLE_NAME') .. '.app',
  57. 'Angel',
  58. 'Resources',
  59. 'Scripts'
  60. )
  61. elseif (os.getenv('CONFIGURATION') == 'Debug') then
  62. dest = fulljoin(
  63. os.getenv('PROJECT_DIR'),
  64. 'Resources',
  65. 'Scripts'
  66. )
  67. else
  68. dest = fulljoin(
  69. os.getenv('BUILT_PRODUCTS_DIR'),
  70. os.getenv('EXECUTABLE_NAME') .. '.app',
  71. 'Contents',
  72. 'Resources',
  73. 'Scripts'
  74. )
  75. end
  76. if (not path.exists(dest:gsub('"', ''))) then
  77. makedirs(dest:gsub('"', ''))
  78. end
  79. for _, filename in pairs(dir.getfiles(lfs.currentdir(), ".lua")) do
  80. if (not _isdotfile(filename)) then
  81. local dstname = fulljoin(dest, path.basename(filename))
  82. dir.copyfile(filename, dstname:gsub('"', ''))
  83. end
  84. end
  85. if (os.getenv('CONFIGURATION') == 'Debug' and building_for_iphone() == false) then
  86. os.exit(0)
  87. end
  88. local source = fulljoin(os.getenv('PROJECT_DIR'), 'Resources')
  89. if (building_for_iphone()) then
  90. dest = fulljoin(
  91. os.getenv('TARGET_BUILD_DIR'),
  92. os.getenv('EXECUTABLE_NAME') .. '.app',
  93. 'Angel',
  94. 'Resources'
  95. )
  96. else
  97. dest = fulljoin(
  98. os.getenv('BUILT_PRODUCTS_DIR'),
  99. os.getenv('EXECUTABLE_NAME') .. '.app',
  100. 'Contents',
  101. 'Resources'
  102. )
  103. end
  104. recursive_copy(source, dest)
  105. source = fulljoin(os.getenv('PROJECT_DIR'), 'Config')
  106. if (building_for_iphone()) then
  107. dest = fulljoin(
  108. os.getenv('TARGET_BUILD_DIR'),
  109. os.getenv('EXECUTABLE_NAME') .. '.app',
  110. 'Angel',
  111. 'Config'
  112. )
  113. else
  114. dest = fulljoin(
  115. os.getenv('BUILT_PRODUCTS_DIR'),
  116. os.getenv('EXECUTABLE_NAME') .. '.app',
  117. 'Contents',
  118. 'Config'
  119. )
  120. end
  121. recursive_copy(source, dest)
  122. if (building_for_iphone() == false) then
  123. local log_path = fulljoin(
  124. os.getenv('BUILT_PRODUCTS_DIR'),
  125. os.getenv('EXECUTABLE_NAME') .. '.app',
  126. 'Contents',
  127. 'Logs'
  128. )
  129. if not path.exists(log_path) then
  130. makedirs(log_path)
  131. end
  132. end