inonego attribute

"Lars Ivar Igesund" <[email protected]>
Newsgroups gmane.comp.tools.aap.devel
Message-ID <0e6701c392ec$2d2fcb70$0200000a@mesmer>
Hi

I have implemented the {inonego} option for the targets
:program, :dll and :lib. I have partly documented it and
tested it with the d module.

Patches attached, more will come.

Lars Ivar Igesund
addef.diff (application/octet-stream, 17.2 KB)
Index: DoAddDef.py
===================================================================
RCS file: /cvsroot/a-a-p/Exec/DoAddDef.py,v
retrieving revision 1.44
diff -u -r1.44 DoAddDef.py
--- DoAddDef.py	22 Sep 2003 17:42:41 -0000	1.44
+++ DoAddDef.py	14 Oct 2003 08:51:49 -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")
+    inonego = cmd_attr.get("inonego")
+    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 inonego:
+        if type == "ltlib":
+            msg_warning(rpstack, _("The 'inonego' attribute is not supported"
+                                  + " for the :ltlib target.")) 
+            return
+        add_inonego_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 inonego:
+            # 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_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_inonego_build(rpstack, work, recdict,
+                           type, cmd_attr, targetlist, build_attr, sourcelist):
+    """Adds an inonego build"""
+    
+    buildaction = cmd_attr.get("buildaction")
+    if type == "dll":
+        if not buildaction:
+            buildaction = "builddllinonego"
+    elif type == "lib":
+        if not buildaction:
+            buildaction = "buildlibinonego"
+    elif type == "program":
+        if not buildaction:
+            buildaction = "buildinonego"
+    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:
d.diff (application/octet-stream, 1.6 KB)
Index: d.aap
===================================================================
RCS file: /cvsroot/a-a-p/Exec/modules/d.aap,v
retrieving revision 1.4
diff -u -r1.4 d.aap
--- d.aap	8 Oct 2003 07:27:43 -0000	1.4
+++ d.aap	14 Oct 2003 19:42:03 -0000
@@ -4,7 +4,7 @@
 # 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 06
+# Last Change: 2003 Oct 11
 
 # Info on this module/ TODO:
 
@@ -68,6 +68,37 @@
 	:do $D_BUILD_ACTION {target = $target} $source
     @else:
 	:sys $DMD $?DLINKFLAGS -of$target $source
+
+# :do buildinonego to build targets directly from "d" source
+
+:action d_buildinonego 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 buildinonego default d
+    @if _no.get("D_BUILDINONEGO_ACTION"):
+        :do $D_BUILDINONEGO_ACTION {target = $target} $source
+    @else:
+        :do d_buildinonego {target = $target} $source
+
+:action builddllinonego default d
+    @if _no.get("D_BUILDDLLINONEGO_ACTION"):
+        :do $D_BUILDDLLINONEGO_ACTION {target = $target} $source
+    @else:
+        :do d_buildinonego {target = $target} $source
+
+:action buildlibinonego default d
+    @if _no.get("D_BUILDLIBINONEGO_ACTION"):
+        :do $D_BUILDLIBINONEGO_ACTION {target = $target} $source
+    @else:
+        :do d_buildinonego {target = $target} $source
 
 # default route
dmd.diff (application/octet-stream, 1.3 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	14 Oct 2003 19:42:18 -0000
@@ -40,7 +40,18 @@
     rpstack = [ RecPos("build_dmd action") ]
     action_add(rpstack, rd, str2dictlist(rpstack, "build_dmd object,dllobject,libobject"),
             ":sys $DMD $?DLINKFLAGS -of$target $source")
-    
+    rpstack = [ RecPos("buildinonego_dmd d action") ]
+    action_add(rpstack, rd, str2dictlist(rpstack, "buildinonego_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")
+        
     if not rd["_top"].get("DMD"):
         rd["_top"]["DMD"] = "dmd"
 
@@ -51,5 +62,8 @@
     """
     scope["D_COMPILE_ACTION"] = "compile_dmd"
     scope["D_BUILD_ACTION"] = "build_dmd"
+    scope["D_BUILDINONEGO_ACTION"] = "buildinonego_dmd"
+    scope["D_BUILDDLLINONEGO_ACTION"] = "buildinonego_dmd"
+    scope["D_BUILDLIBINONEGO_ACTION"] = "buildinonego_dmd"
 
 # vim: set sw=4 et sts=4 tw=79 fo+=l:
doccom.diff (application/octet-stream, 3.2 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	14 Oct 2003 19:42:39 -0000
@@ -1342,12 +1342,19 @@
         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, "{inonego}" can be used to make A-A-P build the library
+        without creating intermediate object files if it is supported by the
+        compiler tool (see <xref linkend="ref-tools"/>). This solution might 
+        be better for very fast compilers.
+      </para>
         <para>
         "{attr = val}" is an optional attribute that apply to the generated
         dependencies.  Use the "scope" attribute to
@@ -1806,13 +1813,20 @@
       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, "{inonego}" can be used to make A-A-P build the library
+        without creating intermediate object files if it is supported by the
+        compiler tool (see <xref linkend="ref-tools"/>). This solution might 
+        be better for very fast compilers.
+      </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 +2258,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, "{inonego}" 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.