Re: inonego attribute
"Lars Ivar Igesund" <[email protected]>
| Newsgroups | gmane.comp.tools.aap.devel |
|---|---|
| Message-ID | <041c01c3949b$8551fb10$0200000a@mesmer> |
----- Original Message ----- From: "Bram Moolenaar" <[email protected]> > Can you redo your patch with "onestep"? Ok, here it is together with documentation for it, both in general and for D. Also, I have made the dll-production easier for the programmer. Lars Ivar Igesund
doctools.diff
(application/octet-stream, 1.6 KB)
Index: ref-tools.sgml
===================================================================
RCS file: /cvsroot/a-a-p/Exec/doc/ref-tools.sgml,v
retrieving revision 1.2
diff -u -r1.2 ref-tools.sgml
--- ref-tools.sgml 9 Oct 2003 21:01:56 -0000 1.2
+++ ref-tools.sgml 17 Oct 2003 09:28:21 -0000
@@ -32,10 +32,22 @@
<listitem>
<anchor id="tool-dmd"/>
<para>
- Support for the Digital Mars D compiler. In addition to using
- the variables in the <link linkend="mod-d">D module</link>,
- the tool uses the <link linkend="var-debug">$DEBUG</link> and
- the <link linkend="var-optimize">$OPTIMIZE</link> variables
+ Support for the Digital Mars D compiler.
+ </para>
+ <para>
+ The "{onestep}" option is supported for this compiler. Also,
+ if the <link linkend="cmd-dll">:dll</link> target is used,
+ it will check for existence of DllMain. If it isn't found, it
+ will be added. Export definitions are delegated to the
+ programmer through using either '.def'-files or the 'export'
+ attribute (recommended). Note that DMD currently supports dll's
+ only for the Win32 platform.
+ </para>
+ <para>
+ In addition to using the variables in the
+ <link linkend="mod-d">D module</link>,the tool uses the
+ <link linkend="var-debug">$DEBUG</link> and the
+ <link linkend="var-optimize">$OPTIMIZE</link> variables
if set. If <link linkend="var-optimize">$OPTIMIZE</link> is set
to a value larger than 0, the "-O" switch is passed to the
compiler. Optimization is on by default. If <link linkend="var-debug">
doccom.diff
(application/octet-stream, 2.9 KB)
Index: ref-commands.sgml
===================================================================
RCS file: /cvsroot/a-a-p/Exec/doc/ref-commands.sgml,v
retrieving revision 1.67
diff -u -r1.67 ref-commands.sgml
--- ref-commands.sgml 3 Oct 2003 18:59:43 -0000 1.67
+++ ref-commands.sgml 17 Oct 2003 09:27:38 -0000
@@ -1342,12 +1342,17 @@
On Unix this builds libfoo.so and libbar.so.
</para>
<para>
- See <link linkend="cmd-produce">:produce</link> for the options.
+ See <link linkend="cmd-produce">:produce</link> for the most important
+ options.
The default values used for ":dll" are:
$DLLSUF for "targetsuffix", $DLLPRE for "targetprefix"
$DLLOBJSUF for "objectsuffix", "dllobject" for "objecttype",
"INSTALL_DLL" for "installvar" and "builddll" for "buildaction".
</para>
+ <para>
+ In addition, the "{onestep}" option explained
+ <link linkend="cmd-program">here</link> can be used.
+ </para>
<para>
"{attr = val}" is an optional attribute that apply to the generated
dependencies. Use the "scope" attribute to
@@ -1806,13 +1811,18 @@
On Unix this builds libfoo.a and libbar.a.
</para>
<para>
- See <link linkend="cmd-produce">:produce</link> for the options.
+ See <link linkend="cmd-produce">:produce</link> for the most important
+ options.
The default values used for ":lib" are:
$LIBSUF for "targetsuffix", $LIBPRE for "targetprefix"
$LIBOBJSUF for "objectsuffix", "libobject" for "objecttype",
"INSTALL_LIB" for "installvar" and "buildlib" for "buildaction".
</para>
<para>
+ In addition, the "{onestep}" option explained
+ <link linkend="cmd-program">here</link> can be used.
+ </para>
+ <para>
"{attr = val}" is an optional attribute that apply to the generated
dependencies. Use the "scope" attribute to
specify a user scope to be used before other scopes
@@ -2244,11 +2254,18 @@
On MS-Windows this builds foo.exe and bar.exe.
</para>
<para>
- See <link linkend="cmd-produce">:produce</link> for the options.
+ See <link linkend="cmd-produce">:produce</link> for the most important
+ options.
The default values used for ":program" are:
$EXESUF for "targetsuffix", nothing for "targetprefix"
$OBJSUF for "objectsuffix", "object" for "objecttype", "INSTALL_EXEC"
for "installvar" and "build" for "buildaction".
+ </para>
+ <para>
+ In addition, "{onestep}" can be used to make A-A-P build the program
+ without creating intermediate object files if it is supported by the
+ tools (see <xref linkend="ref-tools"/>). This solution might be faster
+ for very fast compilers.
</para>
<para>
"{attr = val}" is an optional attribute that apply to the generated
docmod.diff
(application/octet-stream, 6 KB)
Index: ref-modules.sgml
===================================================================
RCS file: /cvsroot/a-a-p/Exec/doc/ref-modules.sgml,v
retrieving revision 1.4
diff -u -r1.4 ref-modules.sgml
--- ref-modules.sgml 8 Oct 2003 07:30:15 -0000 1.4
+++ ref-modules.sgml 17 Oct 2003 09:28:59 -0000
@@ -60,40 +60,88 @@
</entry>
</row>
<row>
- <entry valign="top"><anchor id="var-dflags"/> $DFLAGS </entry>
- <entry valign="top"> user </entry>
- <entry valign="top"> Compiler arguments passed to the D
+ <entry valign="top"><anchor id="var-d_builddll_action"/> $D_BUILDDLL_ACTION
+ </entry>
+ <entry valign="top"> Aap </entry>
+ <entry valign="top"> When not empty, specifies the action name to be
+ executed for building a dynamic link library from object files compiled
+ by a D compiler. A "buildaction" attribute on one of the object files
+ is used before $D_BUILDDLL_ACTION. See <xref linkend="user-tools"/>.
+ </entry>
+ </row>
+ <row>
+ <entry valign="top"><anchor id="var-d_buildlib_action"/> $D_BUILDLIB_ACTION
+ </entry>
+ <entry valign="top"> Aap </entry>
+ <entry valign="top"> When not empty, specifies the action name to be
+ executed for building a static library from object files compiled
+ by a D compiler. A "buildaction" attribute on one of the object files
+ is used before $D_BUILDLIB_ACTION. See <xref linkend="user-tools"/>.
+ </entry>
+ </row>
+ <row>
+ <entry valign="top"><anchor id="var-d_buildonestep_action"/> $D_BUILDONESTEP_ACTION
+ </entry>
+ <entry valign="top"> Aap </entry>
+ <entry valign="top"> When not empty, specifies the action name to be
+ executed for building a program directly from D source.
+ See <xref linkend="user-tools"/>.
+ </entry>
+ </row>
+ <row>
+ <entry valign="top"><anchor id="var-d_builddllonestep_action"/> $D_BUILDDLLONESTEP_ACTION
+ </entry>
+ <entry valign="top"> Aap </entry>
+ <entry valign="top"> When not empty, specifies the action name to be
+ executed for building a dynamic link library directly from D
+ source. See <xref linkend="user-tools"/>.
+ </entry>
+ </row>
+ <row>
+ <entry valign="top"><anchor id="var-d_buildlibonestep_action"/> $D_BUILDLIBONESTEP_ACTION
+ </entry>
+ <entry valign="top"> Aap </entry>
+ <entry valign="top"> When not empty, specifies the action name to
+ be executed for building a static library directly from D source.
+ See <xref linkend="user-tools"/>.
+ </entry>
+ </row>
+ <row>
+ <entry valign="top"><anchor id="var-dflags"/> $DFLAGS </entry>
+ <entry valign="top"> user </entry>
+ <entry valign="top"> Compiler arguments passed to the D
compiler. </entry>
- </row>
- <row>
- <entry valign="top"><anchor id="var-dlinkflags"/> $DLINKFLAGS </entry>
- <entry valign="top"> user </entry>
- <entry valign="top"> Arguments passed to the linker; in most cases
+ </row>
+ <row>
+ <entry valign="top"><anchor id="var-dlinkflags"/> $DLINKFLAGS </entry>
+ <entry valign="top"> user </entry>
+ <entry valign="top"> Arguments passed to the linker; in most cases
libraries to link with. </entry>
- </row>
- <row>
- <entry valign="top"><anchor id="var-ddebug"/> $DIMPORT </entry>
- <entry valign="top"> user </entry>
- <entry valign="top"> Import directories used for the D compiler.
+ </row>
+ <row>
+ <entry valign="top"><anchor id="var-ddebug"/> $DIMPORT </entry>
+ <entry valign="top"> user </entry>
+ <entry valign="top"> Import directories used for the D compiler.
Always use the "-Idir" form, the tool will convert it to what
the compiler actually uses.</entry>
- </row>
- <row>
- <entry valign="top"><anchor id="var-dversion"/> $DVERSION </entry>
- <entry valign="top"> user </entry>
- <entry valign="top"> Version arguments passed to the D compiler.
- Always use the "-version=..." form, the tool will convert it to
- what the compiler actually uses.</entry>
- </row>
- <row>
- <entry valign="top"><anchor id="var-ddebug"/> $DDEBUG </entry>
- <entry valign="top"> user </entry>
- <entry valign="top"> Debug arguments passed to the D compiler.
+ </row>
+ <row>
+ <entry valign="top"><anchor id="var-dversion"/> $DVERSION </entry>
+ <entry valign="top"> user </entry>
+ <entry valign="top"> Version arguments passed to the D compiler.
+ Always use the "-version=..." form, the tool will convert it to
+ what the compiler actually uses.</entry>
+ </row>
+ <row>
+ <entry valign="top"><anchor id="var-ddebug"/> $DDEBUG </entry>
+ <entry valign="top"> user </entry>
+ <entry valign="top"> Debug arguments passed to the D compiler.
Always use the "-debug"/"-debug=..." form, the tool will convert
it to what the compiler actually uses. To enable symbolic debug
information, set the the <link linkend="var-debug">$DEBUG</link>
to "yes". For other language independent debugging switches, like
- enabling profiling hooks, use $DFLAGS.</entry>
+ enabling profiling hooks, use $DFLAGS.
+ </entry>
</row>
</tbody>
</tgroup>
dmd.diff
(application/octet-stream, 4.9 KB)
Index: dmd.py
===================================================================
RCS file: /cvsroot/a-a-p/Exec/tools/dmd.py,v
retrieving revision 1.4
diff -u -r1.4 dmd.py
--- dmd.py 8 Oct 2003 07:26:55 -0000 1.4
+++ dmd.py 17 Oct 2003 09:27:06 -0000
@@ -27,6 +27,7 @@
Define the actions that DMD can accomplish.
"""
rd = Global.globals
+ # Compile one sourcefile at the time
rpstack = [ RecPos("compile_dmd d action") ]
action_add(rpstack, rd, str2dictlist(rpstack, "compile_dmd object,dllobject,libobject d"),
"opt =\n"
@@ -37,10 +38,56 @@
"@if _no.DEBUG == 'yes':\n"
" dbg = -g\n"
":sys $DMD $?DFLAGS $?DVERSION $opt $dbg $?DDEBUG $?DIMPORT -of$target -c $source")
+ # Build a program/static lib from object files
rpstack = [ RecPos("build_dmd action") ]
action_add(rpstack, rd, str2dictlist(rpstack, "build_dmd object,dllobject,libobject"),
":sys $DMD $?DLINKFLAGS -of$target $source")
-
+ # Build a dll from object files
+ rpstack = [ RecPos("builddll_dmd action") ]
+ action_add(rpstack, rd, str2dictlist(rpstack, "builddll_dmd dllobject"),
+ "@exec \"import tools.dmd\"\n"
+ "@if not tools.dmd.find_dll_main_object(source):\n"
+ " @f = file(\"aap_dllmain.d\", 'w')\n"
+ " @f.write(tools.dmd.dll_main_source())\n"
+ " @f.close()\n"
+ " :do compile {target = aap_dllmain.obj} aap_dllmain.d\n"
+ " source += aap_dllmain.obj\n"
+ ":sys $DMD $?DLINKFLAGS -of$target $source\n"
+ ":del {f} {q} aap_dllmain.*")
+ # Build a program/static lib directly from source
+ rpstack = [ RecPos("builddllonestep_dmd d action") ]
+ action_add(rpstack, rd, str2dictlist(rpstack, "builddllonestep_dmd d"),
+ "opt =\n"
+ "@if _no.OPTIMIZE and int(_no.OPTIMIZE) > 0:\n"
+ " opt = -O\n"
+ "dbg =\n"
+ "DEBUG ?=\n"
+ "@if _no.DEBUG == 'yes':\n"
+ " dbg = -g\n"
+ ":sys $DMD $?DFLAGS $?DVERSION $opt $dbg $?DDEBUG $?DIMPORT"
+ " $?DLINKFLAGS -of$target $source\n"
+ ":del {f} {q} *.obj")
+ # Build a dll directly from source
+ rpstack = [ RecPos("builddllonestep_dmd d action") ]
+ action_add(rpstack, rd, str2dictlist(rpstack, "builddllonestep_dmd d"),
+ "opt =\n"
+ "@if _no.OPTIMIZE and int(_no.OPTIMIZE) > 0:\n"
+ " opt = -O\n"
+ "dbg =\n"
+ "DEBUG ?=\n"
+ "@if _no.DEBUG == 'yes':\n"
+ " dbg = -g\n"
+ "@exec \"import tools.dmd\"\n"
+ "@if not tools.dmd.find_dll_main_source(source):\n"
+ " @f = file(\"aap_dllmain.d\", 'w')\n"
+ " @f.write(tools.dmd.dll_main_source())\n"
+ " @f.close()\n"
+ " source += aap_dllmain.d\n"
+ ":sys $DMD $?DFLAGS $?DVERSION $opt $dbg $?DDEBUG $?DIMPORT"
+ " $?DLINKFLAGS -of$target $source\n"
+ ":del {f} {q} aap_dllmain.d\n"
+ ":del {q} *.obj")
+
if not rd["_top"].get("DMD"):
rd["_top"]["DMD"] = "dmd"
@@ -51,5 +98,70 @@
"""
scope["D_COMPILE_ACTION"] = "compile_dmd"
scope["D_BUILD_ACTION"] = "build_dmd"
+ scope["D_BUILDLIB_ACTION"] = "build_dmd"
+ scope["D_BUILDDLL_ACTION"] = "builddll_dmd"
+ scope["D_BUILDONESTEP_ACTION"] = "buildonestep_dmd"
+ scope["D_BUILDDLLONESTEP_ACTION"] = "builddllonestep_dmd"
+ scope["D_BUILDLIBONESTEP_ACTION"] = "buildonestep_dmd"
+
+def find_dll_main_source(sourcestr):
+ import re
+ m = re.compile(r"BOOL\s+DllMain\s*\(\s*HINSTANCE")
+ for si in var2list(sourcestr):
+ f = file2string(si)
+ if m.search(f):
+ return 1
+
+ return None
+
+def find_dll_main_object(sourcestr):
+ for si in var2list(sourcestr):
+ f = file2string(si)
+ from string import find
+ if find(f, "_DllMain@12") > -1:
+ return 1
+
+ return None
+
+def dll_main_source():
+ source = """
+ import windows;
+
+ HINSTANCE g_hInst;
+
+ extern (C)
+ {
+ void gc_init();
+ void gc_term();
+ void _minit();
+ void _moduleCtor();
+ }
+
+ extern (Windows)
+ BOOL DllMain(HINSTANCE hInstance,
+ ULONG ulReason,
+ LPVOID pvReserved)
+ {
+ switch (ulReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ gc_init();
+ _minit();
+ _moduleCtor();
+ break;
+
+ case DLL_PROCESS_DETACH:
+ gc_term();
+ break;
+
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ return false;
+ }
+ g_hInst = hInstance;
+ return true;
+ }
+ """
+ return source
# vim: set sw=4 et sts=4 tw=79 fo+=l:
d.diff
(application/octet-stream, 3.8 KB)
Index: d.aap
===================================================================
RCS file: /cvsroot/a-a-p/Exec/modules/d.aap,v
retrieving revision 1.5
diff -u -r1.5 d.aap
--- d.aap 13 Oct 2003 21:18:31 -0000 1.5
+++ d.aap 17 Oct 2003 09:38:34 -0000
@@ -4,15 +4,11 @@
# Permission to copy and use this file is specified in the file COPYING.
# If this file is missing you can find it here: http://www.a-a-p.org/COPYING
#
+
# Last Change: 2003 Oct 12
# Info on this module/ TODO:
-# At the moment there are no differences between program objects,
-# dllobjects and libobjects when compiling D source. This might change,
-# especially for dllobjects when shared libraries are supported on other
-# platforms than Windows. 2003-09-13
-#
# :action depend has not been implemented. 2003-09-13
#
# Documentation must be written. DMD, DFLAGS, DLINKFLAGS must be mentioned
@@ -40,11 +36,7 @@
# :do compile
-:action compile object,libobject,dllobject,default d
- @if not _no.get("target"):
- target = `src2obj(fname)`
- # Use the d_build action for building and also for :dll and :lib.
- :attr {buildaction = d_build} $target
+:action d_compile object,libobject,dllobject,default d
@if _no.get("D_COMPILE_ACTION"):
:do $D_COMPILE_ACTION {target = $target} $source
@else:
@@ -55,7 +47,25 @@
DEBUG ?=
@if _no.DEBUG == "yes":
dbg = -g
- :sys $DMD $?DFLAGS $?DVERSION $opt $dbg $?DDEBUG $?DIMPORT -of$target -c $source
+ :sys $DMD $?DFLAGS $?DVERSION $opt $dbg $?DDEBUG $?DIMPORT
+ -of$target -c $source
+
+:action compile object,libobject,default d
+ @if not _no.get("target"):
+ target = `src2obj(fname)`
+ # Use the d_build action for building and also for :lib.
+ :attr {buildaction = d_build} $target
+ :do d_compile {target = $target} $source
+
+:action compile dllobject d
+ @if _top.OSTYPE == "mswin":
+ @if not _no.get("target"):
+ target = `src2obj(fname)`
+ # Use the d_builddll action for building
+ :attr {buildaction = d_builddll} $target
+ :do d_compile {target = $target} $source
+ @else:
+ :print Dynamic link libraries aren't supported on non-win32 platforms.
:rule {global}{default} %$OBJSUF : {buildcheck = $DMD $?DFLAGS $?DVERSION $?DDEBUG $?DIMPORT } %.d
:do compile {target = $target} $source
@@ -67,6 +77,46 @@
:do $D_BUILD_ACTION {target = $target} $source
@else:
:sys $DMD $?DLINKFLAGS -of$target $source
+
+:action d_builddll default
+ @if _no.get("D_BUILDDLL_ACTION"):
+ :do $D_BUILDDLL_ACTION {target = $target} $source
+ @else:
+ :print No default action for building dll's from D.
+
+# :do buildonestep to build targets directly from "d" source
+
+:action d_buildonestep default d
+ opt =
+ @if _no.OPTIMIZE and int(_no.OPTIMIZE) > 0:
+ opt = -O
+ dbg =\n"
+ DEBUG ?=
+ @if _no.DEBUG == 'yes':
+ dbg = -g
+ :sys $DMD $?DFLAGS $?DVERSION $opt $dbg $?DDEBUG $?DIMPORT"
+ $?DLINKFLAGS -of$target $source")
+
+:action buildonestep default d
+ @if _no.get("D_BUILDONESTEP_ACTION"):
+ :do $D_BUILDONESTEP_ACTION {target = $target} $source
+ @else:
+ :do d_buildonestep {target = $target} $source
+
+:action builddllonestep default d
+ @if _top.OSTYPE == "mswin":
+ @if _no.get("D_BUILDDLLONESTEP_ACTION"):
+ :do $D_BUILDDLLONESTEP_ACTION {target = $target} $source
+ @else:
+ :do d_buildonestep {target = $target} $source
+ @else:
+ :print Dynamic link libraries aren't supported on non-win32 platforms.
+
+:action buildlibonestep default d
+ @if _no.get("D_BUILDLIBONESTEP_ACTION"):
+ :do $D_BUILDLIBONESTEP_ACTION {target = $target} $source
+ @else:
+ :do d_buildonestep {target = $target} $source
# default route
addef.diff
(application/octet-stream, 17.2 KB)
Index: DoAddDef.py
===================================================================
RCS file: /cvsroot/a-a-p/Exec/DoAddDef.py,v
retrieving revision 1.45
diff -u -r1.45 DoAddDef.py
--- DoAddDef.py 13 Oct 2003 21:19:50 -0000 1.45
+++ DoAddDef.py 17 Oct 2003 09:24:54 -0000
@@ -209,7 +209,6 @@
"sourcelist" is a dictlist with the sources.
"""
# TODO: implement "cmd_attr".
-
if type != "totype":
target = work.find_node(targetlist[0]["name"])
if target and target.get_first_build_dependency():
@@ -228,190 +227,205 @@
# are multiple sources, compile each source into an object and
# build all the objects into the target.
installvar = cmd_attr.get("installvar")
- objtype = cmd_attr.get("objecttype")
- buildaction = cmd_attr.get("buildaction")
+ onestep = cmd_attr.get("onestep")
+ cleanfiles = []
if type == "dll":
- if not objtype:
- objtype = "dllobject"
if installvar is None:
installvar = "INSTALL_DLL"
- if not buildaction:
- buildaction = "builddll"
elif type == "lib":
- if not objtype:
- objtype = "libobject"
if installvar is None:
installvar = "INSTALL_LIB"
- if not buildaction:
- buildaction = "buildlib"
- elif type == "ltlib":
- if not objtype:
- objtype = "ltobject"
- if installvar is None:
- installvar = "INSTALL_LTLIB"
- if not buildaction:
- buildaction = "buildltlib"
elif type == "program":
- if not objtype:
- objtype = "object"
if installvar is None:
- installvar = "INSTALL_EXEC"
- if not buildaction:
- buildaction = "build"
- elif type == "totype":
- objtype = targetlist[0]["name"]
- else:
- if not objtype:
- recipe_error(rpstack, _("Missing objecttype attribute"))
- if not buildaction:
- recipe_error(rpstack, _("Missing buildaction attribute"))
- if installvar is None:
- installvar = "INSTALL_EXEC"
+ installvar = "INNSTALL_EXEC"
- objectsuffix = cmd_attr.get("objectsuffix")
- if type == "totype" and targetlist[0].get("suffix"):
- objectsuffix = targetlist[0].get("suffix")
- sufname = None
- if not objectsuffix:
- if objtype == "dllobject":
- sufname = "DLLOBJSUF"
- elif objtype == "libobject":
- sufname = "LIBOBJSUF"
- elif objtype == "ltobject":
- sufname = "LTOBJSUF"
- elif objtype == "object":
- sufname = "OBJSUF"
-
- objectprefix = cmd_attr.get("objectprefix")
- if type == "totype" and targetlist[0].get("prefix"):
- objectprefix = targetlist[0].get("prefix")
-
- found_cpp = 0
-
- # Go over all source files and figure out a way to turn each one
- # into an object file.
- build_obj = []
- cleanfiles = []
- for si in sourcelist:
- node = work.get_node(si["name"], 1, si)
- in_ftype = node.get_ftype(recdict)
-
- if in_ftype == objtype:
- # The source is an object file: add it directly.
- build_obj.append(si)
+ if onestep:
+ if type == "ltlib":
+ msg_warning(rpstack, _("The 'onestep' attribute is not supported"
+ + " for the :ltlib target."))
+ return
+ add_onestep_build(rpstack, work, recdict, type, cmd_attr, targetlist,
+ build_attr, sourcelist)
+ else:
+ objtype = cmd_attr.get("objecttype")
+ buildaction = cmd_attr.get("buildaction")
+ if type == "dll":
+ if not objtype:
+ objtype = "dllobject"
+ if not buildaction:
+ buildaction = "builddll"
+ elif type == "lib":
+ if not objtype:
+ objtype = "libobject"
+ if not buildaction:
+ buildaction = "buildlib"
+ elif type == "ltlib":
+ if not objtype:
+ objtype = "ltobject"
+ if installvar is None:
+ installvar = "INSTALL_LTLIB"
+ if not buildaction:
+ buildaction = "buildltlib"
+ elif type == "program":
+ if not objtype:
+ objtype = "object"
+ if not buildaction:
+ buildaction = "build"
+ elif type == "totype":
+ objtype = targetlist[0]["name"]
else:
- # Make the object name by prepending $BDIR and changing the
- # extension to $OBJSUF/$LIBOBJSUF/$DLLOBJSUF/nothing.
- n = srcitem2obj(recdict, si["name"], attrdict = si,
+ if not objtype:
+ recipe_error(rpstack, _("Missing objecttype attribute"))
+ if not buildaction:
+ recipe_error(rpstack, _("Missing buildaction attribute"))
+ if installvar is None:
+ installvar = "INSTALL_EXEC"
+
+ objectsuffix = cmd_attr.get("objectsuffix")
+ if type == "totype" and targetlist[0].get("suffix"):
+ objectsuffix = targetlist[0].get("suffix")
+ sufname = None
+ if not objectsuffix:
+ if objtype == "dllobject":
+ sufname = "DLLOBJSUF"
+ elif objtype == "libobject":
+ sufname = "LIBOBJSUF"
+ elif objtype == "ltobject":
+ sufname = "LTOBJSUF"
+ elif objtype == "object":
+ sufname = "OBJSUF"
+
+ objectprefix = cmd_attr.get("objectprefix")
+ if type == "totype" and targetlist[0].get("prefix"):
+ objectprefix = targetlist[0].get("prefix")
+
+ found_cpp = 0
+
+ # Go over all source files and figure out a way to turn each one
+ # into an object file.
+ build_obj = []
+ for si in sourcelist:
+ node = work.get_node(si["name"], 1, si)
+ in_ftype = node.get_ftype(recdict)
+
+ if in_ftype == objtype:
+ # The source is an object file: add it directly.
+ build_obj.append(si)
+ else:
+ # Make the object name by prepending $BDIR and changing the
+ # extension to $OBJSUF/$LIBOBJSUF/$DLLOBJSUF/nothing.
+ n = srcitem2obj(recdict, si["name"], attrdict = si,
sufname = sufname)
- if objectprefix:
- n = os.path.join(os.path.dirname(n),
+ if objectprefix:
+ n = os.path.join(os.path.dirname(n),
objectprefix + os.path.basename(n))
- if objectsuffix:
- n = n + objectsuffix
- bsi = {"name" : n}
- build_obj.append(bsi)
-
- if in_ftype == "cpp":
- found_cpp = 1
-
- # If there is no build rule for the object file, add one.
- target = work.find_node(n)
- if target and target.get_first_build_dependency():
- # There already is a dependency for this target.
- if len(si) > 1:
- msg_warning(recdict, _('%s: Ignoring attributes for "%s", a build rule already exists') % (str(rpstack[-1]), si["name"]))
- else:
-
- # Find the route to the object file.
- route = work.find_route(in_ftype, objtype)
- if not route:
- recipe_error(br_rpstack, _('Do not know how to make an %s out of "%s"') % (objtype, si["name"]))
-
- # Inits to avoid a warning from pychecker.
- trg = None
- out_ftype = None
-
- # Loop over all steps in the route.
- for i in range(len(route.steplist)):
- # Get the action and filename by processing the line.
- # TODO: catch errors
- route.rpstack[-1].line_nr = route.lnumlist[i] - 1
- fp = ParsePos(route.rpstack, string = "_x = "
+ if objectsuffix:
+ n = n + objectsuffix
+ bsi = {"name" : n}
+ build_obj.append(bsi)
+
+ if in_ftype == "cpp":
+ found_cpp = 1
+
+ # If there is no build rule for the object file, add one.
+ target = work.find_node(n)
+ if target and target.get_first_build_dependency():
+ # There already is a dependency for this target.
+ if len(si) > 1:
+ msg_warning(recdict, _('%s: Ignoring attributes for "%s", a build rule already exists') % (str(rpstack[-1]), si["name"]))
+ else:
+
+ # Find the route to the object file.
+ route = work.find_route(in_ftype, objtype)
+ if not route:
+ recipe_error(br_rpstack, _('Do not know how to make an %s out of "%s"') % (objtype, si["name"]))
+
+ # Inits to avoid a warning from pychecker.
+ trg = None
+ out_ftype = None
+
+ # Loop over all steps in the route.
+ for i in range(len(route.steplist)):
+ # Get the action and filename by processing the line.
+ # TODO: catch errors
+ route.rpstack[-1].line_nr = route.lnumlist[i] - 1
+ fp = ParsePos(route.rpstack, string = "_x = "
+ route.steplist[i] + '\n')
- rd = get_build_recdict(recdict, route.recdict,
+ rd = get_build_recdict(recdict, route.recdict,
route.rpstack, keep_current_scope = 1,
xscope = build_attr.get("scope"))
- rd["source"] = si["name"]
- Process(fp, rd, 0)
- l = string.split(rd["_x"], None, 1)
- action = l[0]
-
- if i == 0:
- src_dict = si.copy()
- src = si["name"]
- dnode = node
- else:
- src_dict = {"name" : trg}
- src = trg
- in_ftype = out_ftype
- dnode = work.find_node(src)
-
- # Set "depdir" for the auto-depend recipe. Required if the
- # source file is built twice with different $BDIR.
- # Also add the recipe to the files to be cleaned now,
- # because $BDIR may change afterwards.
- if not src_dict.get("depdir"):
- src_dict["depdir"] = get_var_val_int(recdict, "BDIR")
- depaction, recipe = find_autodep_items(work, recdict,
+ rd["source"] = si["name"]
+ Process(fp, rd, 0)
+ l = string.split(rd["_x"], None, 1)
+ action = l[0]
+
+ if i == 0:
+ src_dict = si.copy()
+ src = si["name"]
+ dnode = node
+ else:
+ src_dict = {"name" : trg}
+ src = trg
+ in_ftype = out_ftype
+ dnode = work.find_node(src)
+
+ # Set "depdir" for the auto-depend recipe. Required if the
+ # source file is built twice with different $BDIR.
+ # Also add the recipe to the files to be cleaned now,
+ # because $BDIR may change afterwards.
+ if not src_dict.get("depdir"):
+ src_dict["depdir"] = get_var_val_int(recdict, "BDIR")
+ depaction, recipe = find_autodep_items(work, recdict,
in_ftype, dnode, src_dict)
- if depaction:
- add_cleanfiles(recdict, recipe.get_name())
+ if depaction:
+ add_cleanfiles(recdict, recipe.get_name())
- if i == len(route.steplist) - 1:
- trg = n
- out_ftype = objtype
- else:
- trg = l[1]
- out_ftype = route.typelist[i + 1][0]
- if (not os.path.isabs(trg)
- and string.find(trg, "build-") != 0):
- trg = os.path.join(get_var_val_int(recdict,
+ if i == len(route.steplist) - 1:
+ trg = n
+ out_ftype = objtype
+ else:
+ trg = l[1]
+ out_ftype = route.typelist[i + 1][0]
+ if (not os.path.isabs(trg)
+ and string.find(trg, "build-") != 0):
+ trg = os.path.join(get_var_val_int(recdict,
"BDIR"), trg)
- # Add a dependency to execute the action.
- cmd = " :do %s {target = %s} %s" % (action, trg, src)
- msg_depend(recdict, _('Adding dependency:\n\t%s : %s\n\t%s')
+ # Add a dependency to execute the action.
+ cmd = " :do %s {target = %s} %s" % (action, trg, src)
+ msg_depend(recdict, _('Adding dependency:\n\t%s : %s\n\t%s')
% (trg, dictlist2str([src_dict]), cmd))
- src_dict["filetype"] = in_ftype
- trg_dict = {"name": trg, "filetype" : out_ftype}
- work.add_dependency(br_rpstack,
+ src_dict["filetype"] = in_ftype
+ trg_dict = {"name": trg, "filetype" : out_ftype}
+ work.add_dependency(br_rpstack,
Depend([ trg_dict ], build_attr,
[ src_dict ], work,
rpcopy(route.rpstack, route.lnumlist[i]),
cmd + '\n', recdict = recdict))
- cleanfiles.append({"name": trg})
+ cleanfiles.append({"name": trg})
- if in_ftype == "cpp":
- found_cpp = 1
+ if in_ftype == "cpp":
+ found_cpp = 1
if type != "totype":
- # Add a dependency to build the program or library in the form:
- # targetlist : {buildcheck = xxx} sourcelist
- # do buildaction {target = $target} $source
- build_obj_str = dictlist2str(build_obj)
targets_str = dictlist2str(targetlist)
- cmd = (" :do %s {target = $+target} $source" % buildaction)
- if found_cpp:
- # Need to use $CXX for building when $LD isn't set.
- cmd = " USECXXLD = yes\n" + cmd
+ if not onestep:
+ # Add a dependency to build the program or library in the form:
+ # targetlist : {buildcheck = xxx} sourcelist
+ # do buildaction {target = $target} $source
+ build_obj_str = dictlist2str(build_obj)
+ cmd = (" :do %s {target = $+target} $source" % buildaction)
+ if found_cpp:
+ # Need to use $CXX for building when $LD isn't set.
+ cmd = " USECXXLD = yes\n" + cmd
- msg_depend(recdict, _('Adding dependency:\n\t%s : %s\n\t%s')
+ msg_depend(recdict, _('Adding dependency:\n\t%s : %s\n\t%s')
% (targets_str, build_obj_str, cmd))
- work.add_dependency(br_rpstack,
- Depend(targetlist, build_attr, build_obj, work,
- br_rpstack, cmd + '\n', recdict = recdict))
+ work.add_dependency(br_rpstack,
+ Depend(targetlist, {}, build_obj, work,
+ br_rpstack, cmd + '\n', recdict = recdict))
+
cleanfiles.extend(targetlist)
# Add target to INSTALL_EXEC, INSTALL_LIB or INSTALL_DLL.
@@ -427,5 +441,23 @@
l = filter(lambda x: not x.get("nodist"), sourcelist)
add_distfiles(recdict, dictlist2str(l, Expand(0)))
-
+def add_onestep_build(rpstack, work, recdict,
+ type, cmd_attr, targetlist, build_attr, sourcelist):
+ """Adds an onestep build"""
+
+ buildaction = cmd_attr.get("buildaction")
+ if type == "dll":
+ if not buildaction:
+ buildaction = "builddllonestep"
+ elif type == "lib":
+ if not buildaction:
+ buildaction = "buildlibonestep"
+ elif type == "program":
+ if not buildaction:
+ buildaction = "buildonestep"
+ cmd = (" :do %s {target =$+target} $source" % buildaction)
+ work.add_dependency(rpstack,
+ Depend(targetlist, {}, sourcelist, work,
+ rpstack, cmd + '\n', recdict = recdict))
+
# vim: set sw=4 et sts=4 tw=79 fo+=l: