cons-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

out-of-date derived Repository files


From: David Sanderson
Subject: out-of-date derived Repository files
Date: Wed, 29 Nov 2000 21:42:15 -0500

Cons 2.2.0 does not appear to check that derived files in a Repository
are up to date.

Say we have a source tree, c1, for a library, and a separate source
tree, c2, for a program that uses that library.  Let us further suppose
that c2 employs c1 as a Repository.  Here are two scenarios for using
this setup.  The first proceeds as expected, but the second does not.

1) If c1 contains no derived files and we descend into c2 and run cons,
   everything is fine.  Cons builds all the c1 and c2 stuff under c2.
   Moreover, if we then go and change the sources in c1, cons will
   rebuild things correctly in c2.

2) If we first build in c1, then build in c2, cons builds c2 using the
   derived files from c1.  But if we then go and change the sources
   in c1 (without rebuilding in c1) and then go to c2 and ask for a
   rebuild, cons says that everything is up to date, even though it is
   not.

   Is this behavior intentional?

   It seems to me that cons should check whether the derived files in
   the repository are current, and if they are not it should proceed as
   in (1) and build them locally.

   Is there a way to make cons do this?

I've appended some code to illustrate these examples.  You will probably
have to adjust CC and PATH in the two Construct files to make things
work.  The 'test1' script corresponds to (1) above, and the 'test2'
script corresponds to (2) above.

Thanks,

David Sanderson (address@hidden)

#!/bin/sh
# This is a shell archive (produced by shar 3.50)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 11/30/2000 01:48 UTC by address@hidden
# Source directory /local/dws/repos
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#    465 -rw-r--r-- c1/Construct
#    153 -rw-r--r-- c1/src/world/Conscript
#     86 -rw-r--r-- c1/src/world/world.c
#     18 -rw-r--r-- c1/src/world/world.h
#    567 -rw-r--r-- c2/Construct
#     94 -rw-r--r-- c2/src/hello/Conscript
#     66 -rw-r--r-- c2/src/hello/hello.c
#    549 -rwxr--r-- test1
#    618 -rwxr--r-- test2
#
# ============= c1/Construct ==============
if test ! -d 'c1'; then
    echo 'x - creating directory c1'
    mkdir 'c1'
fi
if test -f 'c1/Construct' -a X"$1" != X"-c"; then
        echo 'x - skipping c1/Construct (File already exists)'
else
echo 'x - extracting c1/Construct (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c1/Construct' &&
$EXPORT = "#export";
X
# Tell cons to build this directory (recursively) by default.
Default (
X    $EXPORT
);
X
# Standard directories for sharing products.
$INCLUDE = "$EXPORT/include";
$LIB     = "$EXPORT/lib";
$BIN     = "$EXPORT/bin";
X
$CONS = new cons(
X    CC  => 'gcc',
X    ENV => {
X       PATH => '/usr/bin:/usr/ccs/bin:/opt/bin',
X    },
X    CPPPATH => $INCLUDE,
);
X
Export qw( CONS INCLUDE LIB BIN );
X
Link 'build' => 'src';
X
Build qw(
X    build/world/Conscript
);
SHAR_EOF
chmod 0644 c1/Construct ||
echo 'restore of c1/Construct failed'
Wc_c="`wc -c < 'c1/Construct'`"
test 465 -eq "$Wc_c" ||
        echo 'c1/Construct: original size 465, current size' "$Wc_c"
fi
# ============= c1/src/world/Conscript ==============
if test ! -d 'c1/src'; then
    echo 'x - creating directory c1/src'
    mkdir 'c1/src'
fi
if test ! -d 'c1/src/world'; then
    echo 'x - creating directory c1/src/world'
    mkdir 'c1/src/world'
fi
if test -f 'c1/src/world/Conscript' -a X"$1" != X"-c"; then
        echo 'x - skipping c1/src/world/Conscript (File already exists)'
else
echo 'x - extracting c1/src/world/Conscript (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c1/src/world/Conscript' &&
Import qw( CONS INCLUDE LIB );
X
Install_Local $CONS $LIB, 'libworld.a';
Install_Local $CONS $INCLUDE, 'world.h';
X
Library $CONS 'libworld.a', 'world.c';
SHAR_EOF
chmod 0644 c1/src/world/Conscript ||
echo 'restore of c1/src/world/Conscript failed'
Wc_c="`wc -c < 'c1/src/world/Conscript'`"
test 153 -eq "$Wc_c" ||
        echo 'c1/src/world/Conscript: original size 153, current size' "$Wc_c"
fi
# ============= c1/src/world/world.c ==============
if test -f 'c1/src/world/world.c' -a X"$1" != X"-c"; then
        echo 'x - skipping c1/src/world/world.c (File already exists)'
else
echo 'x - extracting c1/src/world/world.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c1/src/world/world.c' &&
#include <stdio.h>
#include <world.h>
X
void
world(void)
{
X    puts("hello, world");
}
SHAR_EOF
chmod 0644 c1/src/world/world.c ||
echo 'restore of c1/src/world/world.c failed'
Wc_c="`wc -c < 'c1/src/world/world.c'`"
test 86 -eq "$Wc_c" ||
        echo 'c1/src/world/world.c: original size 86, current size' "$Wc_c"
fi
# ============= c1/src/world/world.h ==============
if test -f 'c1/src/world/world.h' -a X"$1" != X"-c"; then
        echo 'x - skipping c1/src/world/world.h (File already exists)'
else
echo 'x - extracting c1/src/world/world.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c1/src/world/world.h' &&
void
world(void);
SHAR_EOF
chmod 0644 c1/src/world/world.h ||
echo 'restore of c1/src/world/world.h failed'
Wc_c="`wc -c < 'c1/src/world/world.h'`"
test 18 -eq "$Wc_c" ||
        echo 'c1/src/world/world.h: original size 18, current size' "$Wc_c"
fi
# ============= c2/Construct ==============
if test ! -d 'c2'; then
    echo 'x - creating directory c2'
    mkdir 'c2'
fi
if test -f 'c2/Construct' -a X"$1" != X"-c"; then
        echo 'x - skipping c2/Construct (File already exists)'
else
echo 'x - extracting c2/Construct (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c2/Construct' &&
Repository DirPath '../c1';
X
$EXPORT = "#export";
X
# Tell cons to build this directory (recursively) by default.
Default (
X    $EXPORT
);
X
# Standard directories for sharing products.
$INCLUDE = "$EXPORT/include";
$LIB     = "$EXPORT/lib";
$BIN     = "$EXPORT/bin";
X
$CONS = new cons(
X    CC  => 'gcc',
X    ENV => {
X       PATH => '/usr/bin:/usr/ccs/bin:/opt/bin',
X    },
X    CPPPATH => $INCLUDE,
X    LIBPATH => $LIB,
X    LIBS    => '-lworld',
);
X
Export qw( CONS INCLUDE LIB BIN );
X
Link 'build' => 'src';
X
Build qw(
X    build/hello/Conscript
X    build/world/Conscript
);
SHAR_EOF
chmod 0644 c2/Construct ||
echo 'restore of c2/Construct failed'
Wc_c="`wc -c < 'c2/Construct'`"
test 567 -eq "$Wc_c" ||
        echo 'c2/Construct: original size 567, current size' "$Wc_c"
fi
# ============= c2/src/hello/Conscript ==============
if test ! -d 'c2/src'; then
    echo 'x - creating directory c2/src'
    mkdir 'c2/src'
fi
if test ! -d 'c2/src/hello'; then
    echo 'x - creating directory c2/src/hello'
    mkdir 'c2/src/hello'
fi
if test -f 'c2/src/hello/Conscript' -a X"$1" != X"-c"; then
        echo 'x - skipping c2/src/hello/Conscript (File already exists)'
else
echo 'x - extracting c2/src/hello/Conscript (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c2/src/hello/Conscript' &&
Import qw( CONS BIN );
X
Install_Local $CONS $BIN, 'hello';
X
Program $CONS 'hello', 'hello.c';
SHAR_EOF
chmod 0644 c2/src/hello/Conscript ||
echo 'restore of c2/src/hello/Conscript failed'
Wc_c="`wc -c < 'c2/src/hello/Conscript'`"
test 94 -eq "$Wc_c" ||
        echo 'c2/src/hello/Conscript: original size 94, current size' "$Wc_c"
fi
# ============= c2/src/hello/hello.c ==============
if test -f 'c2/src/hello/hello.c' -a X"$1" != X"-c"; then
        echo 'x - skipping c2/src/hello/hello.c (File already exists)'
else
echo 'x - extracting c2/src/hello/hello.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c2/src/hello/hello.c' &&
#include "world.h"
X
int
main(void)
{
X    world();
X    return 0;
}
SHAR_EOF
chmod 0644 c2/src/hello/hello.c ||
echo 'restore of c2/src/hello/hello.c failed'
Wc_c="`wc -c < 'c2/src/hello/hello.c'`"
test 66 -eq "$Wc_c" ||
        echo 'c2/src/hello/hello.c: original size 66, current size' "$Wc_c"
fi
# ============= test1 ==============
if test -f 'test1' -a X"$1" != X"-c"; then
        echo 'x - skipping test1 (File already exists)'
else
echo 'x - extracting test1 (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'test1' &&
#!/bin/sh
X
cleanup() {
X    rm -rf c1/build c1/export c2/build c2/export
}
cleanup
X
(
X    cd c2
X
X    echo
X    echo Building in c2.
X    echo
X
X    cons
X
X    echo
X    echo Modifying sources in c1.  This makes c2 out of date.
X    echo
X
X    f=../c1/src/world/world.h
X
X    mv $f $f.bak
X    { cat $f.bak; echo "/* new comment */"; } > $f
X
X    echo
X    echo Rebuilding in c2.
X    echo If this says \"export\" is up-to-date, there is a problem.
X    echo
X
X    cons
X
X    echo
X    echo Restoring sources in c1.
X    echo
X
X    rm -f $f
X    mv $f.bak $f
)
X
cleanup
SHAR_EOF
chmod 0744 test1 ||
echo 'restore of test1 failed'
Wc_c="`wc -c < 'test1'`"
test 549 -eq "$Wc_c" ||
        echo 'test1: original size 549, current size' "$Wc_c"
fi
# ============= test2 ==============
if test -f 'test2' -a X"$1" != X"-c"; then
        echo 'x - skipping test2 (File already exists)'
else
echo 'x - extracting test2 (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'test2' &&
#!/bin/sh
X
cleanup() {
X    rm -rf c1/build c1/export c2/build c2/export
}
cleanup
X
(
X    cd c1
X
X    echo
X    echo Building in c1.
X    echo
X
X    cons
)
X
(
X    cd c2
X
X    echo
X    echo Building in c2.
X    echo
X
X    cons
X
X    echo
X    echo Modifying sources in c1.  This makes c2 out of date.
X    echo
X
X    f=../c1/src/world/world.h
X
X    mv $f $f.bak
X    { cat $f.bak; echo "/* new comment */"; } > $f
X
X    echo
X    echo Rebuilding in c2.
X    echo If this says \"export\" is up-to-date, there is a problem.
X    echo
X
X    cons
X
X    echo
X    echo Restoring sources in c1.
X    echo
X
X    rm -f $f
X    mv $f.bak $f
)
X
cleanup
SHAR_EOF
chmod 0744 test2 ||
echo 'restore of test2 failed'
Wc_c="`wc -c < 'test2'`"
test 618 -eq "$Wc_c" ||
        echo 'test2: original size 618, current size' "$Wc_c"
fi
exit 0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]