jGenPyCode.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ##############################################################
  2. #
  3. # This module should be invoked by a shell-script that says:
  4. #
  5. # python -c "import direct.ffi.jGenPyCode" <arguments>
  6. #
  7. # Before invoking python, the shell-script may need to set
  8. # these environment variables, to make sure that everything
  9. # can be located appropriately.
  10. #
  11. # PYTHONPATH
  12. # PATH
  13. # LD_LIBRARY_PATH
  14. #
  15. ##############################################################
  16. import sys, os
  17. ##############################################################
  18. #
  19. # Locate the 'direct' tree and the 'pandac' tree.
  20. #
  21. ##############################################################
  22. DIRECT=None
  23. PANDAC=None
  24. for dir in sys.path:
  25. if (DIRECT is None):
  26. if (dir != "") and os.path.exists(os.path.join(dir,"direct")):
  27. DIRECT=os.path.join(dir,"direct")
  28. if (PANDAC is None):
  29. if (dir != "") and (os.path.exists(os.path.join(dir,"pandac"))):
  30. PANDAC=os.path.join(dir,"pandac")
  31. if (DIRECT is None):
  32. sys.exit("Could not locate the 'direct' python modules")
  33. if (PANDAC is None):
  34. sys.exit("Could not locate the 'pandac' python modules")
  35. ##############################################################
  36. #
  37. # Locate direct/src/extensions.
  38. #
  39. # It could be inside the direct tree. It may be underneath
  40. # a 'src' subdirectory. Or, the direct tree may actually be
  41. # a stub that points to the source tree.
  42. #
  43. ##############################################################
  44. EXTENSIONS=None
  45. if (EXTENSIONS is None):
  46. if os.path.isdir(os.path.join(DIRECT,"src","extensions_native")):
  47. EXTENSIONS=os.path.join(DIRECT,"src","extensions_native")
  48. if (EXTENSIONS is None):
  49. if os.path.isdir(os.path.join(DIRECT,"extensions_native")):
  50. EXTENSIONS=os.path.join(DIRECT,"extensions_native")
  51. if (EXTENSIONS is None):
  52. if os.path.isdir(os.path.join(DIRECT,"..","..","direct","src","extensions_native")):
  53. EXTENSIONS=os.path.join(DIRECT,"..","..","direct","src","extensions_native")
  54. if (EXTENSIONS is None):
  55. sys.exit("Could not locate direct/src/extensions_native")
  56. ##############################################################
  57. #
  58. # Call genpycode with default paths.
  59. #
  60. ##############################################################
  61. from direct.ffi import DoGenPyCode
  62. from direct.ffi import FFIConstants
  63. DoGenPyCode.outputCodeDir = PANDAC
  64. DoGenPyCode.outputHTMLDir = os.path.join(PANDAC,"..","doc")
  65. DoGenPyCode.directDir = DIRECT
  66. DoGenPyCode.extensionsDir = EXTENSIONS
  67. DoGenPyCode.interrogateLib = r'libdtoolconfig'
  68. DoGenPyCode.codeLibs = ['libpandaexpress','libpanda','libpandaphysics','libpandafx','libdirect','libpandaegg']
  69. DoGenPyCode.etcPath = [os.path.join(PANDAC,"input")]
  70. DoGenPyCode.pythonSourcePath = [DIRECT]
  71. DoGenPyCode.native = 1
  72. #print "outputDir = ", DoGenPyCode.outputDir
  73. #print "directDir = ", DoGenPyCode.directDir
  74. #print "extensionsDir = ", DoGenPyCode.extensionsDir
  75. #print "interrogateLib = ", DoGenPyCode.interrogateLib
  76. #print "codeLibs = ", DoGenPyCode.codeLibs
  77. #print "etcPath = ", DoGenPyCode.etcPath
  78. #print "native = ", DoGenPyCode.native
  79. DoGenPyCode.run()