libobject and :tool gcc
Richard Boulton <[email protected]> Wed, 17 Dec 2003 11:47:46 +0000
| Newsgroups | gmane.comp.tools.aap.devel |
|---|---|
| Message-ID | <[email protected]> |
The following short A-A-P recipe file doesn't behave as I expect.
-----begin main.aap-----
:usetool gcc
foo.c:
:touch {force} foo.c
:lib foo : foo.c
-----end main.aap-----
I expected running aap in the same directory as this to build a static
library (containing essentially nothing).
Instead, I get:
Aap: Creating directory "/data/home/richard/stuff/tmp/build-Linux2_4_20_k7"
Aap: cc -MM foo.c > build-Linux2_4_20_k7/foo.c.aap
Aap: Error in recipe "/data/home/richard/Working/aap/Exec/default.aap"
line 640: Error executing commands for compile c: Error in recipe
"/data/home/richard/Working/aap/Exec/default.aap" line 267: No commands
defined for compile_gcc dllobject from c
This is on a Debian unstable system, using aap from CVS head (the same
behaviour results if using the Debian package).
If I remove the :usetool gcc, a library is built as expected:
Aap: cc -O2 -fPIC -c -o build-Linux2_4_20_k7/foo.sho foo.c
Aap: ld -shared -o libfoo.so build-Linux2_4_20_k7/foo.sho
Investigating further, I see that in tools/gcc.py, compile and build
actions are defined to use GCC and G++ to build and link with items of
type object, but not of libobject, dllobject or ltobject.
The attached patch fixes this in what I hope is a reasonable way, and
includes a regression test for the problem. I think there is still a
problem if libtool is used in conjunction with :usetool gcc, but thought
I should restrict the scope of my first attempt to patch aap.
PS: I'm a software developer who's been looking for a decent build
system for several years, and aap looks extremely promising. I spent a
fair while working on autotools a few years back, in particular fixing
the conditionals in automake so that they merely execute slowly rather
than exponentially slowly, so I have a good grasp of how that system
works. I'm looking to use aap to build a project I'm working on which
requires cross compiling with mingw, so I'll be hoping to iron out any
bugs in that code too. Hope my contributions will be useful - please
let me know how to make them more useful if I do anything wrong.
--
Richard
patch1
(text/plain, 3.6 KB)
Index: rectest/test017.py
===================================================================
RCS file: rectest/test017.py
diff -N rectest/test017.py
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ rectest/test017.py 17 Dec 2003 11:36:12 -0000
@@ -0,0 +1,72 @@
+# Part of the A-A-P recipe executive: Testing of :usetool gcc with :lib
+
+# Copyright (C) 2002-2003 Stichting NLnet Labs
+# 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
+
+#
+# This test checks that the following works properly:
+# - A recipe uses :usetool gcc to use the GCC toolchain.
+# - The recipe then tries to build a library from a trivial C file.
+#
+
+import sys, os, re, glob, shutil
+
+def runaap(args):
+ return os.system("%s ..%sMain.py %s" % (sys.argv[1], os.sep, args))
+
+os.chdir("rectest")
+
+# Create a recipe, run it and check the output.
+# Checks expanding $VAR.
+rec = "rectest.aap"
+out = "rectest.out"
+inp = "rectest.c"
+lib = "librectest.a"
+
+def cleanup():
+ for file in [ rec, out, inp, lib ]:
+ try:
+ os.remove(file)
+ except:
+ pass
+ try:
+ for dir in glob.glob('build-*'):
+ shutil.rmtree(dir)
+ except:
+ pass
+
+cleanup()
+
+# Create the recipe.
+f = open(rec, "w")
+f.write("""
+:usetool gcc
+:lib %s : %s
+all: %s
+ :print PASS
+""" % (lib, inp, lib))
+f.close()
+
+# Create the source file.
+f = open(inp, "w")
+f.write("""
+int foo() {return 0;}
+""")
+f.close()
+
+
+res = runaap("-f %s >%s" % (rec, out))
+
+f = open(out)
+l = f.read()
+if not re.search("PASS", l):
+ print 'Aap failed to behave as expected - output was:'
+ print l
+ res = 1
+f.close()
+
+cleanup()
+sys.exit(res)
+
+# vim: set sw=4 et sts=4 tw=79 fo+=l:
Index: tools/gcc.py
===================================================================
RCS file: /cvsroot/a-a-p/Exec/tools/gcc.py,v
retrieving revision 1.5
diff -u -r1.5 gcc.py
--- tools/gcc.py 16 Sep 2003 17:14:09 -0000 1.5
+++ tools/gcc.py 17 Dec 2003 11:36:13 -0000
@@ -44,24 +44,24 @@
rd = Global.globals
rpstack = [ RecPos("compile_gcc action") ]
- action_add(rpstack, rd, str2dictlist(rpstack, "compile_gcc object c"),
- ":buildcheck $OPTIMIZE $?DEBUG\n"
+ action_add(rpstack, rd, str2dictlist(rpstack, "compile_gcc object,dllobject,libobject c"),
+ ":buildcheck $OPTIMIZE $?DEBUG\n"
":sys $GCC $CPPFLAGS $?DEFINE $?INCLUDE `cflags_normal()` "
"$CFLAGS -o $target -c $source")
rpstack = [ RecPos("compile_gxx action") ]
- action_add(rpstack, rd, str2dictlist(rpstack, "compile_gxx object cpp"),
- ":buildcheck $OPTIMIZE $?DEBUG\n"
+ action_add(rpstack, rd, str2dictlist(rpstack, "compile_gxx object,dllobject,libobject cpp"),
+ ":buildcheck $OPTIMIZE $?DEBUG\n"
":sys $GXX $CPPFLAGS $?DEFINE $?INCLUDE `cflags_normal()` "
"$CXXFLAGS -o $target -c $source")
rpstack = [ RecPos("build_gcc action") ]
- action_add(rpstack, rd, str2dictlist(rpstack, "build_gcc object"),
- ":sys $GCC $LDFLAGS `cflags_normal()` -o $target $source $?LIBS")
+ action_add(rpstack, rd, str2dictlist(rpstack, "build_gcc object,dllobject,libobject"),
+ ":sys $GCC $?LDFLAGS `cflags_normal()` -o $target $source $?LIBS")
rpstack = [ RecPos("build_gxx action") ]
- action_add(rpstack, rd, str2dictlist(rpstack, "build_gxx object"),
- ":sys $GXX $LDFLAGS `cflags_normal()` -o $target $source $?LIBS")
+ action_add(rpstack, rd, str2dictlist(rpstack, "build_gxx object,dllobject,libobject"),
+ ":sys $GXX $?LDFLAGS `cflags_normal()` -o $target $source $?LIBS")
def use_actions(scope):
"""