Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

125 righe
4.5 KiB

  1. #!/usr/bin/env python3
  2. # -*- Coding: UTF-8 -*-
  3. # ---------------------------------------------------------------------------
  4. # Open Asset Import Library (ASSIMP)
  5. # ---------------------------------------------------------------------------
  6. #
  7. # Copyright (c) 2006-2010, ASSIMP Development Team
  8. #
  9. # All rights reserved.
  10. #
  11. # Redistribution and use of this software in source and binary forms,
  12. # with or without modification, are permitted provided that the following
  13. # conditions are met:
  14. #
  15. # * Redistributions of source code must retain the above
  16. # copyright notice, this list of conditions and the
  17. # following disclaimer.
  18. #
  19. # * Redistributions in binary form must reproduce the above
  20. # copyright notice, this list of conditions and the
  21. # following disclaimer in the documentation and/or other
  22. # materials provided with the distribution.
  23. #
  24. # * Neither the name of the ASSIMP team, nor the names of its
  25. # contributors may be used to endorse or promote products
  26. # derived from this software without specific prior
  27. # written permission of the ASSIMP Development Team.
  28. #
  29. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. # ---------------------------------------------------------------------------
  41. """Shared stuff for the gen_db and run scripts """
  42. # -------------------------------------------------------------------------------
  43. def hashing(file,pp):
  44. """ Map an input file and a postprocessing config to an unique hash.
  45. The hash is used to store the item in the database. It
  46. needs to be persistent across different python implementations
  47. and platforms, so we implement the hashing manually.
  48. """
  49. def myhash(instring):
  50. # sdbm hash
  51. res = 0
  52. for t in instring:
  53. res = (ord(t) + (res<<6) + (res<<16) - res) % 2**32
  54. return res
  55. return hex(myhash(file.replace('\\','/')+":"+pp))
  56. assimp_bin_path = None
  57. # -------------------------------------------------------------------------------
  58. def find_assimp_or_die():
  59. """Find assimp_cmd's binary for the current platform.
  60. The path to the binary is stored in assimp_bin_path, the process
  61. is aborted if it can't be found.
  62. """
  63. import os
  64. import platform
  65. import sys
  66. def locate_file(f_list):
  67. for f in f_list:
  68. try:
  69. fl = open(f,"rb")
  70. except IOError:
  71. continue
  72. fl.close()
  73. return f
  74. return None
  75. global assimp_bin_path
  76. if os.name == "nt":
  77. search_x86 = [
  78. os.path.join("..","..","bin","assimpcmd_release-dll_Win32","assimp.exe"),
  79. os.path.join("..","..","bin","x86","assimp"),
  80. os.path.join("..","..","bin","Release","assimp.exe")
  81. ]
  82. if platform.machine() == "x86":
  83. search = search_x86
  84. else: # amd64, hopefully
  85. search = [
  86. os.path.join("..","..","bin","assimpcmd_release-dll_x64","assimp.exe"),
  87. os.path.join("..","..","bin","x64","assimp")
  88. ]
  89. # x64 platform does not guarantee a x64 build. Also look for x86 as last paths.
  90. search += search_x86
  91. assimp_bin_path = locate_file(search)
  92. if assimp_bin_path is None:
  93. print("Can't locate assimp_cmd binary")
  94. print("Looked in", search)
  95. sys.exit(-5)
  96. print("Located assimp/assimp_cmd binary from", assimp_bin_path)
  97. elif os.name == "posix":
  98. #search = [os.path.join("..","..","bin","gcc","assimp"),
  99. # os.path.join("/usr","local","bin",'assimp')]
  100. assimp_bin_path = "assimp"
  101. print("Taking system-wide assimp binary")
  102. else:
  103. print("Unsupported operating system")
  104. sys.exit(-5)
  105. if __name__ == '__main__':
  106. find_assimp_or_die()
  107. # vim: ai ts=4 sts=4 et sw=4