Define what to do in .ini or .xml file, or create a DSL for it
An .ini/.xml file shall define what amake
has to do. This is primarily the information
- which information it has to read from a file
- where to write the information into
The source file is defined by a file name in from-file
and a regex in from-regex
, and so is the destination (to-file
and to-regex
).
Each group may contain one source ("from") and one or more destinations ("to"). The group's name is just for documentation, it is not used anyway.
INI example
[version]
from-file = source\M_Module.def
from-regex = Public +Const +APPVERSION +.*= +"([0-9]+\.[0-9]+\.[0-9]+)"
to-file = AMake-Setup.iss
to-regex = ^#define +MyAppVersion +"([0-9.]*)"$
XML example
<AccessMake version="1.0">
<item name="Version">
<source>
<file>source\M_Module.def</file>
<regex>Public +Const +APPVERSION +.*= +"([0-9]+\.[0-9]+\.[0-9]+)"</regex>
</source>
<destination>
<file>AMake-Setup.iss</file>
<regex>^#define +MyAppVersion +"([0-9.]*)"$</regex>
</destination>
</item>
<item name="Hash">
<source>
<file>hash</file>
<regex>([0-9A-F]{7,})</regex>
</source>
<destination>
<file>source\M_Module.def</file>
<regex>^Public Const APPHASH = "([0-9A-F]*)"$</regex>
</destination>
<destination>
<file>AMake-Setup.iss</file>
<regex>^#define +MyAppHash +"([0-9A-F]*)"$</regex>
</destination>
</item>
</AccessMake>
DSL example
read [source\M_Module.def] using Public +Const +APPVERSION +.*= +"([0-9]+\.[0-9]+\.[0-9]+)"
write [setup\setup.iss] using ^#define +MyAppVersion +"([0-9.]*)"$
or, shorter:
read FILENAME using REGEX
write FILENAME using REGEX
In this DSL every read
would retrieve and store the first regular expression group's content in a variable. Every subsequent write
would then replace its first regular expression group's content by the previously stored data, and then write back the line. So you can read one information and write it into many other positions.
Edited by Christoph Jüngling