diff --git a/build/jam/MiscRules b/build/jam/MiscRules index 7b3d53242e..ce6a89e75f 100644 --- a/build/jam/MiscRules +++ b/build/jam/MiscRules @@ -76,3 +76,44 @@ rule MakeLocateDebug } } +rule SearchAndReplace +{ + # SearchAndReplace : : : + # A code generator that searches and replaces text in a source file to + # produce another. + # : The file (a source file) being created by this + # search and replace code generation. + # : The file being used to generate . + # : The string to search for in . + # : The string to replace with in the new file. + # + # For example usage see the MarkAs Tracker add-on code. + # + local _new_file = [ FGristSourceFiles $(1) ] ; + Depends all : $(_new_file) ; + Depends $(_new_file) : $(2) ; + MakeLocate $(_new_file) : $(LOCATE_SOURCE) ; + SEARCH on $(_new_file) = $(LOCATE_SOURCE) ; + Sed $(_new_file) : $(2) -e s/$(3)/$(4)/g ; + Clean clean : $(_new_file) ; +} + +rule Sed +{ + # Sed : + # : The file (a source file) being created by this + # sed run. + # : The parameters to sed in a list. The first item is + # the source file being searched through, the rest + # are standard sed parameters. + + # We don't care about the parameters to sed + NoCare $(2[2-]) ; + NotFile $(2[2-]) ; +} + +actions Sed +{ + $(SED) $(2[2-]) $(2[1]) > $(1) +} +