1 2rule SetupObjectsDir 3{ 4 local relPath = [ FDirName $(SUBDIR_TOKENS[2-]) ] ; 5 COMMON_PLATFORM_LOCATE_TARGET = 6 [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) $(relPath) ] ; 7 8 local var ; 9 for var in COMMON_ARCH COMMON_DEBUG DEBUG_$(HAIKU_DEBUG_LEVELS) { 10 HOST_$(var)_LOCATE_TARGET 11 = [ FDirName $(HOST_$(var)_OBJECT_DIR) $(relPath) ] ; 12 TARGET_$(var)_LOCATE_TARGET 13 = [ FDirName $(TARGET_$(var)_OBJECT_DIR) $(relPath) ] ; 14 } 15 16 LOCATE_TARGET = $(COMMON_PLATFORM_LOCATE_TARGET) ; 17 LOCATE_SOURCE = $(LOCATE_TARGET) ; 18 SEARCH_SOURCE = $(SUBDIR) $(LOCATE_SOURCE) 19 $(HOST_COMMON_DEBUG_LOCATE_TARGET) # Also add the standard output 20 $(TARGET_COMMON_DEBUG_LOCATE_TARGET) # dirs for generated sources. 21 ; 22} 23 24rule SubIncludeGPL 25{ 26 # SubInclude rule that can be used to conditionally include GPL licensed 27 # add-ons 28 if $(INCLUDE_GPL_ADDONS) = 1 { 29 SubInclude $(1) ; 30 } 31} 32 33 34# pragma mark - MakeLocate variants 35 36 37rule MakeLocateCommonPlatform 38{ 39 MakeLocate $(1) : $(COMMON_PLATFORM_LOCATE_TARGET) ; 40} 41 42rule MakeLocatePlatform 43{ 44 local files = $(1) ; 45 local file ; 46 for file in $(files) { 47 if [ on $(file) return $(PLATFORM) ] = host { 48 MakeLocate $(file) : $(HOST_COMMON_ARCH_LOCATE_TARGET) ; 49 } else { 50 MakeLocate $(file) : $(TARGET_COMMON_ARCH_LOCATE_TARGET) ; 51 } 52 } 53} 54 55rule MakeLocateArch 56{ 57 local files = $(1) ; 58 local file ; 59 for file in $(files) { 60 if [ on $(file) return $(PLATFORM) ] = host { 61 MakeLocate $(file) : $(HOST_COMMON_DEBUG_LOCATE_TARGET) ; 62 } else { 63 MakeLocate $(file) : $(TARGET_COMMON_DEBUG_LOCATE_TARGET) ; 64 } 65 } 66} 67 68rule MakeLocateDebug 69{ 70 local files = $(1) ; 71 local file ; 72 for file in $(files) { 73 on $(file) { 74 if $(PLATFORM) = host { 75 MakeLocate $(file) : $(HOST_DEBUG_$(DEBUG)_LOCATE_TARGET) ; 76 } else { 77 MakeLocate $(file) : $(TARGET_DEBUG_$(DEBUG)_LOCATE_TARGET) ; 78 } 79 } 80 } 81} 82 83 84# pragma mark - Deferred SubIncludes 85 86 87# The variable used to collect the deferred SubIncludes. 88HAIKU_DEFERRED_SUB_INCLUDES = ; 89 90rule DeferredSubInclude params 91{ 92 # DeferredSubInclude <subdir tokens> ; 93 # 94 # Takes the same parameter as SubInclude. The the subdirectory referred to 95 # by <subdir tokens> will be included when ExecuteDeferredSubIncludes is 96 # invoked, i.e. at the end of the root Jamfile. 97 98 HAIKU_DEFERRED_SUB_INCLUDES += "/" $(params) ; 99} 100 101rule ExecuteDeferredSubIncludes 102{ 103 # ExecuteDeferredSubIncludes ; 104 # 105 # Performs the deferred SubIncludes scheduled by DeferredSubInclude. 106 107 local tokensList = $(HAIKU_DEFERRED_SUB_INCLUDES) ; 108 while $(tokensList) { 109 # chop off leading "/" 110 tokensList = $(tokensList[2-]) ; 111 112 # get the tokens for the next include 113 local tokens ; 114 while $(tokensList) && $(tokensList[1]) != "/" { 115 tokens += $(tokensList[1]) ; 116 tokensList = $(tokensList[2-]) ; 117 } 118 119 # perform the include 120 if $(tokens) { 121 SubInclude $(tokens) ; 122 } 123 } 124} 125 126rule HaikuSubInclude tokens 127{ 128 # HaikuSubInclude <tokens> ; 129 # 130 # Current subdir relative SubInclude. 131 # <tokens> - subdir tokens specifying the subdirectory to be include 132 # (relative to the current subdir) 133 134 if $(tokens) { 135 SubInclude HAIKU_TOP $(SUBDIR_TOKENS) $(tokens) ; 136 } 137} 138 139 140# pragma mark - Unique IDs/targets 141 142 143# private to NextID; incremented with each NextID invocation 144HAIKU_NEXT_ID = 0 ; 145 146rule NextID 147{ 148 # NextID ; 149 150 local result = $(HAIKU_NEXT_ID:J=) ; 151 HAIKU_NEXT_ID = [ AddNumAbs $(HAIKU_NEXT_ID) : 1 ] ; 152 return $(result) ; 153} 154 155rule NewUniqueTarget basename 156{ 157 # NewUniqueTarget [ basename ] ; 158 159 local id = [ NextID ] ; 160 return $(basename[1]:E=_target:G=unique!target)_$(id) ; 161} 162 163 164# pragma mark - RunCommandLine 165 166 167rule RunCommandLine commandLine 168{ 169 # RunCommandLine <commandLine> 170 # 171 # Creates a pseudo target that, when made by jam, causes the supplied shell 172 # command line to be executed. Elements of <commandLine> with the prefix ":" 173 # are replaced by the rule. After stripping the prefix such a string specifies 174 # a build system target and the finally executed command line will contain 175 # a path to the target instead. 176 # The pseudo target will depend on all targets thus identified. Each 177 # invocation of this rule creates a different pseudo target, which is 178 # returned to the caller. 179 180 # collect the targets in the command line and replace them by $targetX* 181 # variables 182 local substitutedCommandLine ; 183 local targets ; 184 185 local targetVarName = target ; 186 local i ; 187 for i in $(commandLine) { 188 # targets are marked by the ":" prefix 189 local target = [ Match :(.*) : $(i) ] ; 190 if $(target) { 191 targets += $(target) ; 192 targetVarName = $(targetVarName)X ; 193 i = "$"$(targetVarName) ; 194 } 195 196 substitutedCommandLine += $(i) ; 197 } 198 199 # define the "run" target 200 local run = [ NewUniqueTarget run ] ; 201 COMMAND_LINE on $(run) = $(substitutedCommandLine) ; 202 NotFile $(run) ; 203 Always $(run) ; 204 Depends $(run) : $(targets) ; 205 RunCommandLine1 $(run) : $(targets) ; 206 207 return $(run) ; 208} 209 210actions RunCommandLine1 { 211 target=target; 212 for t in $(2) ; do 213 target+=X 214 eval "${target}=${t}" 215 done 216 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 217 $(COMMAND_LINE) 218} 219 220