/tags/rel-1.3.37/vms/genbuild.py

# · Python · 155 lines · 142 code · 8 blank · 5 comment · 7 complexity · 0a4c9d0b374c28a67779077b1f5d2b93 MD5 · raw file

  1. import os.path, string, posix, pyvms
  2. #
  3. #
  4. IDIR = ['swig_root:[source.swig]', 'swig_root:[source.doh.include]',
  5. 'swig_root:[source.include]', 'swig_root:[source.preprocessor]']
  6. def new_file(fg, dirname):
  7. global IDIR
  8. fn = 'swig_root:[vms.scripts]compil_' + os.path.basename(dirname) + '.com'
  9. print >> fg, '$ @' + fn
  10. f = open(fn, 'w')
  11. print >> f, '$!'
  12. print >> f, '$! Generated by genbuild.py'
  13. print >> f, '$!'
  14. print >> f, '$ libname = "swig_root:[vms.o_alpha]swig.olb"'
  15. print >> f, '$'
  16. print >> f, '$ set default', pyvms.crtl_to_vms(dirname)[0][0]
  17. print >> f, '$'
  18. print >> f, "$ idir := ", IDIR[0]
  19. for i in range(1, len(IDIR)):
  20. print >> f, '$ idir = idir + ",' + IDIR[i] + '"'
  21. print >> f, '$'
  22. print >> f, "$ iflags = \"/include=(''idir', sys$disk:[])\""
  23. print >> f, '$ oflags = \"/object=swig_root:[vms.o_alpha]'
  24. print >> f, "$ cflags = \"''oflags'''iflags'''dflags'\""
  25. print >> f, "$ cxxflags = \"''oflags'''iflags'''dflags'\""
  26. print >> f, '$'
  27. return f
  28. def end_file(f):
  29. print >>f,"""$ exit
  30. $!
  31. $!
  32. $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES
  33. $ V = 'F$Verify(0)
  34. $! P1 = What we are trying to make
  35. $! P2 = Command to make it
  36. $! P3 = Source file
  37. $! P4 - P8 What it depends on
  38. $
  39. $ modname = f$parse(p3,,,"name")
  40. $ set noon
  41. $ set message/nofacility/noident/noseverity/notext
  42. $ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname'
  43. $ set message/facility/ident/severity/text
  44. $ on error then exit
  45. $ open/read swigtmp swig_root:[vms]swiglib.tmp
  46. $! skip header
  47. $ read swigtmp r
  48. $ read swigtmp r
  49. $ read swigtmp r
  50. $ read swigtmp r
  51. $ read swigtmp r
  52. $ read swigtmp r
  53. $ read swigtmp r
  54. $ read swigtmp r
  55. $ read swigtmp r
  56. $!
  57. $
  58. $ read/end=module_not_found swigtmp r
  59. $ modfound = 1
  60. $ Time = f$cvtime(f$extract(49, 20, r))
  61. $ goto end_search_module
  62. $ module_not_found:
  63. $ modfound = 0
  64. $
  65. $ end_search_module:
  66. $ close swigtmp
  67. $ delete swig_root:[vms]swiglib.tmp;*
  68. $
  69. $ if modfound .eq. 0 then $ goto Makeit
  70. $
  71. $! Time = F$CvTime(F$File(P1,"RDT"))
  72. $arg=3
  73. $Loop:
  74. $ Argument = P'arg
  75. $ If Argument .Eqs. "" Then Goto Exit
  76. $ El=0
  77. $Loop2:
  78. $ File = F$Element(El," ",Argument)
  79. $ If File .Eqs. " " Then Goto Endl
  80. $ AFile = ""
  81. $Loop3:
  82. $ OFile = AFile
  83. $ AFile = F$Search(File)
  84. $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl
  85. $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit
  86. $ Goto Loop3
  87. $NextEL:
  88. $ El = El + 1
  89. $ Goto Loop2
  90. $EndL:
  91. $ arg=arg+1
  92. $ If arg .Le. 8 Then Goto Loop
  93. $ Goto Exit
  94. $
  95. $Makeit:
  96. $ VV=F$VERIFY(1)
  97. $ 'P2' 'P3'
  98. $ VV='F$Verify(VV)
  99. $Exit:
  100. $ If V Then Set Verify
  101. $ENDSUBROUTINE"""
  102. def listRep(args, dirname, filenames):
  103. fg = args[0]
  104. first = 1
  105. for fn in filenames:
  106. if fn[-2:] == '.c':
  107. if first:
  108. first = 0
  109. fc = new_file(fg, dirname)
  110. cstr = "\"cc ''cflags'\" "
  111. line = "$ call make swig_root:[vms.o_alpha]"
  112. line += fn[:-1] + 'obj -'
  113. print >> fc, line
  114. line = "\t" + cstr + fn
  115. print >> fc, line
  116. elif fn[-4:] == '.cxx':
  117. if first:
  118. first = 0
  119. fc = new_file(fg, dirname)
  120. cstr = "\"cxx ''cxxflags'\" "
  121. line = "$ call make swig_root:[vms.o_alpha]"
  122. line += fn[:-3] + 'obj -'
  123. print >> fc, line
  124. line = "\t" + cstr + fn
  125. print >> fc, line
  126. if first == 0:
  127. end_file(fc)
  128. fc.close()
  129. #
  130. def genbuild(f, dir):
  131. os.path.walk(dir, listRep, (f,))
  132. cmd = 'set default swig_root:[vms]'
  133. #
  134. f = open('swig_root:[vms.scripts]build_all.com','w')
  135. print >> f, '$!'
  136. print >> f, '$! Generated by genbuild.py'
  137. print >> f, '$!'
  138. print >> f, '$ set default swig_root:[vms]'
  139. print >> f, '$'
  140. print >> f, '$ @swig_root:[vms]build_init'
  141. #
  142. genbuild(f, '/swig_root/source')
  143. print >> f, '$'
  144. print >> f, '$ set default swig_root:[vms]'
  145. print >> f, '$'
  146. print >> f, '$ @swig_root:[vms]build_end'
  147. f.close