Added a few new rules that do some search and replacing using sed. AFAIK all

our build platforms should have sed support (it is built into Jambase at
least.) I use these rules to do some code generation in my soon to be committed
MarkAs Tracker add-ons.

This works pretty nifty if I do say so myself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19481 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood 2006-12-13 08:04:23 +00:00
parent a26cf893d0
commit dd481a03fc

View File

@ -76,3 +76,44 @@ rule MakeLocateDebug
}
}
rule SearchAndReplace
{
# SearchAndReplace <newFile> : <sourceFile> : <stringToFind> : <stringToReplaceWith>
# A code generator that searches and replaces text in a source file to
# produce another.
# <newFile>: The file (a source file) being created by this
# search and replace code generation.
# <sourceFile>: The file being used to generate <newFile>.
# <stringToFind>: The string to search for in <sourceFile>.
# <stringToReplaceWith>: 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 <newFile> : <parameters>
# <newFile>: The file (a source file) being created by this
# sed run.
# <parameters>: 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)
}