Second stab at :import
Adriaan de Groot <adridg-FlD2LfDziEhmR6Xm/[email protected]>
| Newsgroups | gmane.comp.tools.aap.devel |
|---|---|
| Message-ID | <[email protected]> |
Two diffs, one adding aap_import() to the code, the other adding docs for it. It Works For Me (tm), with libtool at least. I haven't tried D yet. -- pub 1024D/FEA2A3FE 2002-06-18 Adriaan de Groot <[email protected]> Key fingerprint = 934E 31AA 80A7 723F 54F9 50ED 76AC EE01 FEA2 A3FE
doc.diff
(text/x-diff, 6.1 KB)
Index: ref-commands.sgml
===================================================================
RCS file: /cvsroot/a-a-p/Exec/doc/ref-commands.sgml,v
retrieving revision 1.63
diff -u -3 -p -r1.63 ref-commands.sgml
--- ref-commands.sgml 22 Sep 2003 17:40:43 -0000 1.63
+++ ref-commands.sgml 23 Sep 2003 22:24:43 -0000
@@ -83,6 +83,10 @@
<entry> Include another recipe.</entry>
</row>
<row>
+ <entry> <link linkend="cmd-import">:import</link></entry>
+ <entry> Include a module from the &Aap; distribution.</entry>
+ </row>
+ <row>
<entry> <link linkend="cmd-execute">:execute</link></entry>
<entry> Execute a recipe.</entry>
</row>
@@ -1635,6 +1639,25 @@ In the commands below [redir] indicates
</listitem>
</varlistentry>
+ <varlistentry id='cmd-import'>
+ <term><cmdsynopsis>
+ <command>:import</command>
+ <arg choice='plain'><replaceable>name</replaceable></arg>
+ </cmdsynopsis></term>
+ <listitem>
+ <para>
+ Read a module stored in the main &Aap; directory.
+ This happens in a special scope, does not change
+ directory, and has no effect on the recipe
+ containing the <computeroutput>:import</computeroutput>
+ command <emphasis>except</emphasis>
+ that the actions, filetypes and routes
+ defined in the module become available globally.
+ This is the easiest way to add additional language
+ support to &Aap;.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry id='cmd-include'>
<term><cmdsynopsis>
@@ -1676,7 +1699,7 @@ In the commands below [redir] indicates
</tbody>
</tgroup>
</informaltable>
-
+
</listitem>
</varlistentry>
Index: tutor-include.sgml
===================================================================
RCS file: /cvsroot/a-a-p/Exec/doc/tutor-include.sgml,v
retrieving revision 1.15
diff -u -3 -p -r1.15 tutor-include.sgml
--- tutor-include.sgml 11 Sep 2003 18:01:16 -0000 1.15
+++ tutor-include.sgml 23 Sep 2003 22:24:45 -0000
@@ -86,12 +86,12 @@ use a scope is:
Several scope names are defined, such as "_recipe" for the current recipe and
"_top" for the toplevel recipe.
The full list of scope names can be found in the reference manual, chapter
-"Recipe Syntax and Semantics".
+<xref linkend="ref-varscope"/>"Recipe Syntax and Semantics".
When a variable is used without a scope name, it is looked up in the
local scope and surrounding scopes. Thus the variables from the parent recipe
are also available in the child. But when assigning to a variable without a
scope, it is always set in the local scope only. To make the variable appear
-in another scope you must give the scope name.
+in another scope you must give the scope name.
</para>
<para>
@@ -205,6 +205,53 @@ set in the included recipe. Be careful
scope isn't
used in one of the child recipes.
</para>
+
+<bridgehead>Sharing Modules</bridgehead>
+
+<para>
+Sometimes a group of settings is so generally useful
+that you want to use it in many different projects.
+A typical example of such a group of settings
+is language support for a specific programming language.
+In order to add support for a new language
+(say, <computeroutput>D</computeroutput>), you need
+to define actions, set variables, etc.
+It is tedious to use <computeroutput>:include</computeroutput>,
+so &Aap; allows you to store such settings in a <emphasis>module</emphasis>.
+</para>
+
+<para>
+A module is a recipe like any other, except it is stored in the
+main &Aap; directory (along with the system
+<filename>default.aap</filename>).
+You can read a module with the
+<computeroutput>:import</computeroutput> command.
+This works very much like the
+<computeroutput>:include</computeroutput> command, except:
+<orderedlist>
+<listitem>
+ <para>The recipe is read from the main &Aap; directory.</para>
+</listitem>
+<listitem>
+ <para>Each module is imported only once.</para>
+</listitem>
+</orderedlist>
+</para>
+
+<para>
+&Aap; includes modules for standard languages
+and build systems. It does not read these recipes
+by default because they add additional overhead,
+even when you do not use the languages they specify.
+Therefore, support for the D language, using libtool
+to build libraries, and KDE support (among others)
+is included in
+modules that you can use when needed.
+A full list of modules
+can be found in <xref linkend="user-language"/>.
+</para>
+
+
<bridgehead>Executing a Recipe</bridgehead>
Index: user-language.sgml
===================================================================
RCS file: /cvsroot/a-a-p/Exec/doc/user-language.sgml,v
retrieving revision 1.1
diff -u -3 -p -r1.1 user-language.sgml
--- user-language.sgml 22 Sep 2003 17:37:23 -0000 1.1
+++ user-language.sgml 23 Sep 2003 22:24:45 -0000
@@ -79,3 +79,31 @@
<para>
TODO: does this actually work?
</para>
+
+<bridgehead>Standard Modules</bridgehead>
+
+<para>
+The following modules are distributed with &Aap;:
+</para>
+
+<variablelist>
+<varlistentry>
+<term>default</term>
+<listitem><para>Not really a module, because it is <emphasis>always</emphasis>
+read, but <filename>default.aap</filename> in the main directory could
+be considered a module otherwise.
+</para></listitem>
+</varlistentry>
+
+<varlistentry>
+<term>libtool</term>
+<listitem>
+ <para>
+ Adds support for GNU libtool, so that you can use it to build
+ shared libraries in a portable manner.
+ Automatically imported if you use a <computeroutput>:ltlib</computeroutput>
+ target.
+ </para>
+</listitem>
+</varlistentry>
+</variablelist>
Index: version.sgml
===================================================================
RCS file: /cvsroot/a-a-p/Exec/doc/version.sgml,v
retrieving revision 1.119
diff -u -3 -p -r1.119 version.sgml
--- version.sgml 22 Sep 2003 17:39:27 -0000 1.119
+++ version.sgml 23 Sep 2003 22:24:45 -0000
@@ -1,6 +1,6 @@
<!-- vim: set ft=dtd:
THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT.
-->
-<!ENTITY builddate "2003 Sep 16 17:06:46 GMT
+<!ENTITY builddate "2003 Sep 22 17:29:25 GMT
">
-<!ENTITY aapversion "1.031">
+<!ENTITY aapversion "1.032">
py.diff
(text/x-diff, 3.8 KB)
Index: Commands.py
===================================================================
RCS file: /cvsroot/a-a-p/Exec/Commands.py,v
retrieving revision 1.103
diff -u -3 -p -r1.103 Commands.py
--- Commands.py 22 Sep 2003 17:40:11 -0000 1.103
+++ Commands.py 23 Sep 2003 21:57:56 -0000
@@ -2377,6 +2377,68 @@ def aap_include(line_nr, recdict, arg):
read_recipe(rpstack, recdict, recname, Global.at_toplevel,
optional = optiondict.get("quiet"))
+def aap_import(line_nr, recdict, arg):
+ """Handle :import commands. Also used automagically for :produce
+ targets, which specify a new language."""
+
+ from Scope import create_topscope, get_build_recdict
+ from DoAddDef import doadddef
+
+ # Boilerplate - find the work object and stack for the
+ # current recipe.
+ work = getwork(recdict)
+ rpstack = getrpstack(recdict, line_nr)
+
+ # Evaluate the options and arguments - there are no
+ # options, so complain if any are given.
+ optiondict, attrdict, args = get_args(line_nr, recdict, arg,
+ { } )
+ if attrdict:
+ option_error(rpstack, attrdict, ":import")
+ if optiondict:
+ option_error(rpstack, optiondict, ":import")
+
+ if len(args) != 1:
+ recipe_error(rpstack, _(":import requires one argument"))
+ args = dictlist_expand(args)
+
+ # Import only imports a given module once.
+ recname = args[0]["name"]
+ name = recname
+
+ # Calculate absolute path to imported file.
+ # TODO: Use a search path, so users can override builtin
+ # modules if needed.
+ if Global.aap_rootdir[-1] != "/" and recname[0] != "/":
+ recname = Global.aap_rootdir + "/" + recname
+ else:
+ recname = Global.aap_rootdir + recname
+ if recname[-4:] != ".aap":
+ recname += ".aap"
+
+ if did_read_recipe(work, recname):
+ msg_extra(recdict, _('Skipping recipe already imported: %s"') % recname)
+ return
+
+ # ":child" command without passing the current scope: Create a new
+ # toplevel scope and set the default values.
+ new_recdict = create_topscope(name).data
+ new_recdict["_default"] = recdict["_default"]
+ new_recdict["_start"] = recdict["_start"]
+
+ # Set the startup values from the "_start" scope. Do not read the
+ # startup recipes again, the dependencies and rules are already
+ # defined.
+ fromdict = recdict["_start"].data
+ for k in fromdict.keys():
+ if k[0] != '_':
+ new_recdict[k] = fromdict[k]
+
+ # Use the current Work object.
+ setwork(new_recdict, work)
+
+ read_recipe(rpstack, new_recdict, recname, 1)
+ doadddef(work, new_recdict, 0)
def maydo_recipe_cmd(rpstack):
"""Return non-zero if a ":recipe" command in the current recipe may be
Index: Process.py
===================================================================
RCS file: /cvsroot/a-a-p/Exec/Process.py,v
retrieving revision 1.61
diff -u -3 -p -r1.61 Process.py
--- Process.py 22 Sep 2003 17:34:22 -0000 1.61
+++ Process.py 23 Sep 2003 21:57:59 -0000
@@ -29,6 +29,7 @@ aap_cmd_toplevel = [
"rule",
"totype",
"variant",
+ "import",
]
# All possible names of ":" commands in a recipe, including toplevel-only ones.
@@ -851,6 +852,10 @@ def Process(fp, recdict, toplevel):
# command. The handling of the arguments may depend on the
# command.
#
+ # All AAP commands (including :include, :import, etc.) arrive
+ # here for processing and are turned into Python calls
+ # for functions in Commands.py.
+ #
# recipe: :cmd arg ...
# Python: aap_cmd(123, globals(),
script.append(indent_string + ('aap_%s(%d, globals(), '