Jamrules 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. CSC ?= gmcs ;
  2. NCC ?= ncc.exe ;
  3. LOCATE_TARGETS ?= $(TOP) ;
  4. CSFLAGS ?= -debug -warn:4 -nowarn:1591 ;
  5. rule AntLR {
  6. local sources = [ SearchSource $(>) ] ;
  7. local target = $(<:G=antlr) ;
  8. MakeLocate $(target) : $(SUBDIR) ;
  9. antlr $(target) : $(sources) ;
  10. Depends $(target) : $(sources) ;
  11. Clean clean : $(target) ;
  12. OUTDIR on $(target) = $(<:D) ;
  13. return $(target) ;
  14. }
  15. actions antlr {
  16. rm -f $(<) ;
  17. CLASSPATH=tools/antlr/antlr.jar:$CLASSPATH java antlr.Tool -o $(OUTDIR) $(>)
  18. }
  19. rule SearchSource {
  20. local sources ;
  21. for s in $(<) {
  22. if $(s:G) {
  23. sources += $(s) ;
  24. } else {
  25. local source = $(s:G=$(SOURCE_GRIST:E)) ;
  26. sources += $(source) ;
  27. SEARCH on $(source) = $(SEARCH_SOURCE) ;
  28. }
  29. }
  30. return $(sources) ;
  31. }
  32. # CSharp target : sources : resources
  33. rule CSharp {
  34. local sources = [ SearchSource $(>) ] ;
  35. local resources = [ SearchSource $(3) ] ;
  36. local target = $(<) ;
  37. MakeLocate $(target) : $(SUBDIR) ;
  38. MonoCSharp $(target) : $(sources) ;
  39. CSFLAGS on $(target) = $(CSFLAGS) ;
  40. RESOURCES on $(target) = $(resources) ;
  41. if $(target:S) = .dll {
  42. TARGET on $(target) = library ;
  43. } else if $(<:S) = .exe {
  44. TARGET on $(target) = exe ;
  45. }
  46. Depends $(target) : $(sources) $(resources) ;
  47. Depends all : $(target) ;
  48. Clean clean : $(target) $(target).xml $(target).mdb ;
  49. Clean clean$(<) : $(target) ;
  50. }
  51. # Nemerle target : sources : resources
  52. rule Nemerle {
  53. local sources = [ SearchSource $(>) ] ;
  54. local resources = [ SearchSource $(3) ] ;
  55. local target = $(<) ;
  56. MakeLocate $(target) : $(SUBDIR) ;
  57. Ncc $(target) : $(sources) ;
  58. if $(target:S) = .dll {
  59. TARGET on $(target) = library ;
  60. } else if $(<:S) = .exe {
  61. TARGET on $(target) = exe ;
  62. }
  63. NFLAGS on $(target) = $(NFLAGS) ;
  64. RESOURCES on $(target) = $(resources) ;
  65. Depends $(target) : $(sources) ;
  66. Depends $(target) : $(resources) ;
  67. Depends all : $(target) ;
  68. Clean clean : $(target) ;
  69. Clean clean$(<) : $(target) ;
  70. }
  71. rule LinkWith {
  72. LIBS on $(<) += $(>) ;
  73. Depends $(<) : $(>) ;
  74. }
  75. actions MonoCSharp bind RESOURCES {
  76. $(CSC) $(CSFLAGS) -out:$(<) -doc:$(<).xml -target:$(TARGET) -r:$(LIBS) -resource:$(RESOURCES) $(>)
  77. }
  78. actions Ncc bind RESOURCES {
  79. $(NCC) $(NFLAGS) -out:$(<) -target:$(TARGET) -r:$(LIBS) -resource:$(RESOURCES),$(RESOURCES:BS) $(>)
  80. }
  81. ## ConcatDirs dirs
  82. ## Concatenates a set of directories. This is a substitute for FDirName in
  83. ## Jambase. It works also correctly for several rooted paths, where FDirName
  84. ## fails.
  85. ## The advantage over $(dir1)/$(dir2) is that this also works correctly if
  86. ## $(dir1) or $(dir2) is not set.
  87. rule ConcatDirs
  88. {
  89. local i ;
  90. local result = $(<[1]) ;
  91. if ! $(result) { $result = "" ; }
  92. local dir1 dir2 ;
  93. for i in $(<[2-])
  94. {
  95. # eleminate multiple slashes because jam is somewhat buggy here
  96. dir1 = [ MATCH (.*[^/]?) : $(result) ] ;
  97. dir2 = [ MATCH ([^/].*) : $(i) ] ;
  98. if ! $(dir1) { dir1 = "" ; }
  99. if $(dir1) != "" { dir1 = $(dir1)/ ; }
  100. if ! $(dir2) { dir2 = "" ; }
  101. result = $(dir1)$(dir2) ;
  102. }
  103. return $(result) ;
  104. }
  105. ## Wildcard [ dir : ] patterns
  106. ## Create a list of files in a directory which match the pattern. You can
  107. ## optionally specify a subdirectory. The files will be returned with
  108. ## stripped pathnames. The difference from GLOB is that this rule respects
  109. ## subdirectories which may have been entered with the SubDir rule.
  110. rule Wildcard
  111. {
  112. local files dir sdir wildcards ;
  113. # Is a directory given?
  114. if $(>) {
  115. dir = $(<)/ ;
  116. sdir = $(<) ;
  117. wildcards = $(>) ;
  118. } else {
  119. dir = "" ;
  120. sdir = "" ;
  121. wildcards = $(<) ;
  122. }
  123. files = [ GLOB [ ConcatDirs $(SUBDIR) $(dir) ] : $(wildcards) ] ;
  124. return $(files:BSR=$(sdir)) ;
  125. }
  126. # fix bug in Jambase where SubInclude in the middle of a jam file made it break
  127. rule SubInclude
  128. {
  129. if ! $($(<[1]))
  130. {
  131. Exit SubInclude $(<[1]) without prior SubDir $(<[1]) ;
  132. }
  133. local save_SUBDIR_TOKENS = $(SUBDIR_TOKENS) ;
  134. SubDir $(<) ;
  135. include $(JAMFILE:D=$(SUBDIR)) ;
  136. SubDir $(<[1]) $(save_SUBDIR_TOKENS) ;
  137. }
  138. SUBDIRRULES += FixSubDirPath ;
  139. rule FixSubDirPath
  140. {
  141. LOCATE_SOURCE = [ ConcatDirs $(LOCATE_OBJECTS) $(SUBDIR_TOKENS) ] ;
  142. LOCATE_TARGET = [ ConcatDirs $(LOCATE_OBJECTS) $(SUBDIR_TOKENS) ] ;
  143. }
  144. ## IsElem element : list
  145. ## Returns "true" if the elemnt is in the list. Otherwise nothing is
  146. ## returned.
  147. rule IsElem
  148. {
  149. local i ;
  150. for i in $(>)
  151. {
  152. if $(i) = $(<)
  153. {
  154. return "true" ;
  155. }
  156. }
  157. return ;
  158. }
  159. ## Filter list : filter
  160. ## Returns the list without the words contained in filter.
  161. rule Filter
  162. {
  163. local i result ;
  164. for i in $(<)
  165. {
  166. if ! [ IsElem $(i) : $(>) ]
  167. {
  168. result += $(i) ;
  169. }
  170. }
  171. return $(result) ;
  172. }