summaryrefslogtreecommitdiffstats
path: root/doc/user/variants.in
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-10-23 16:14:15 (GMT)
committerSteven Knight <knight@baldmt.com>2003-10-23 16:14:15 (GMT)
commitdd8e3d92024d02b4e133b0e0624886ce4cd8fe11 (patch)
tree7093612a93255b5c8aebbbbc4567cc1cd0f28d73 /doc/user/variants.in
parent8ea748f67747b589b407db59acbe15d62962ba33 (diff)
downloadSCons-dd8e3d92024d02b4e133b0e0624886ce4cd8fe11.zip
SCons-dd8e3d92024d02b4e133b0e0624886ce4cd8fe11.tar.gz
SCons-dd8e3d92024d02b4e133b0e0624886ce4cd8fe11.tar.bz2
Initialize the new branch.
Diffstat (limited to 'doc/user/variants.in')
-rw-r--r--doc/user/variants.in114
1 files changed, 45 insertions, 69 deletions
diff --git a/doc/user/variants.in b/doc/user/variants.in
index 1fb461a..ceab8f6 100644
--- a/doc/user/variants.in
+++ b/doc/user/variants.in
@@ -27,66 +27,6 @@
=head1 Variant builds
-
-=head2 Hello, World! for baNaNa and peAcH OS's
-
-Variant builds require just another simple extension. Let's take as an
-example a requirement to allow builds for both the baNaNa and peAcH
-operating systems. In this case, we are using a distributed file system,
-such as NFS to access the particular system, and only one or the other of
-the systems has to be compiled for any given invocation of C<cons>. Here's
-one way we could set up the F<Construct> file for our B<Hello, World!>
-application:
-
- # Construct file for Hello, World!
-
- die qq(OS must be specified) unless $OS = $ARG{OS};
- die qq(OS must be "peach" or "banana")
- if $OS ne "peach" && $OS ne "banana";
-
- # Where to put all our shared products.
- $EXPORT = "#export/$OS";
-
- Export qw( CONS INCLUDE LIB BIN );
-
- # Standard directories for sharing products.
- $INCLUDE = "$EXPORT/include";
- $LIB = "$EXPORT/lib";
- $BIN = "$EXPORT/bin";
-
- # A standard construction environment.
- $CONS = new cons (
- CPPPATH => $INCLUDE, # Include path for C Compilations
- LIBPATH => $LIB, # Library path for linking programs
- LIBS => '-lworld', # List of standard libraries
- );
-
- # $BUILD is where we will derive everything.
- $BUILD = "#build/$OS";
-
- # Tell cons where the source files for $BUILD are.
- Link $BUILD => 'src';
-
- Build (
- "$BUILD/hello/Conscript",
- "$BUILD/world/Conscript",
- );
-
-Now if we login to a peAcH system, we can build our B<Hello, World!>
-application for that platform:
-
- % cons export OS=peach
- Install build/peach/world/world.h as export/peach/include/world.h
- cc -Iexport/peach/include -c build/peach/hello/hello.c -o build/peach/hello/hello.o
- cc -Iexport/peach/include -c build/peach/world/world.c -o build/peach/world/world.o
- ar r build/peach/world/libworld.a build/peach/world/world.o
- ar: creating build/peach/world/libworld.a
- ranlib build/peach/world/libworld.a
- Install build/peach/world/libworld.a as export/peach/lib/libworld.a
- cc -o build/peach/hello/hello build/peach/hello/hello.o -Lexport/peach/lib -lworld
- Install build/peach/hello/hello as export/peach/bin/hello
-
-
=head2 Variations on a theme
Other variations of this model are possible. For example, you might decide
@@ -122,26 +62,59 @@ is pretty smart about rebuilding things when you change options.
<scons_example name="ex_variants">
<file name="SConstruct" printme="1">
- platform = ARGUMENT.get('OS', Platform())
+ platform = ARGUMENTS.get('OS', Platform())
include = "#export/$PLATFORM/include"
lib = "#export/$PLATFORM/lib"
bin = "#export/$PLATFORM/bin"
env = Environment(PLATFORM = platform,
+ BINDIR = bin,
+ INCDIR = include,
+ LIBDIR = lib,
CPPPATH = [include],
- LIB = lib,
- LIBS = '-lworld')
+ LIBPATH = [lib],
+ LIBS = 'world')
Export('env')
- SConscript('src/SConscript', build_dir='build/$PLATFORM')
+ env.SConscript('src/SConscript', build_dir='build/$PLATFORM')
#
#BuildDir("#build/$PLATFORM", 'src')
#SConscript("build/$PLATFORM/hello/SConscript")
#SConscript("build/$PLATFORM/world/SConscript")
</file>
+ <directory name="src"></directory>
+ <directory name="src/hello"></directory>
+ <directory name="src/world"></directory>
+ <file name="src/SConscript">
+ Import('env')
+ SConscript('hello/SConscript')
+ SConscript('world/SConscript')
+ </file>
+ <file name="src/hello/SConscript">
+ Import('env')
+ hello = env.Program('hello.c')
+ env.Install('$BINDIR', hello)
+ </file>
+ <file name="src/hello/hello.c">
+ #include "world.h"
+ int main(int argc, char *argv[]) { printf "hello.c\n"; world(); }
+ </file>
+ <file name="src/world/SConscript">
+ Import('env')
+ world = env.Library('world.c')
+ env.Install('$LIBDIR', world)
+ env.Install('$INCDIR', 'world.h')
+ </file>
+ <file name="src/world/world.h">
+ #define STRING "world.h"
+ extern int world();
+ </file>
+ <file name="src/world/world.c">
+ int world() { printf "world.c\n"; }
+ </file>
</scons_example>
<para>
@@ -152,7 +125,7 @@ is pretty smart about rebuilding things when you change options.
</para>
<scons_output example="ex_variants" os="posix">
- <command>scons OS=linux</command>
+ <command>scons -Q OS=linux</command>
</scons_output>
<para>
@@ -162,18 +135,21 @@ is pretty smart about rebuilding things when you change options.
</para>
<scons_output example="ex_variants" os="win32">
- <command>scons OS=windows</command>
+ <command>scons -Q OS=windows</command>
</scons_output>
+ <!--
+
<scons_example name="ex_var2">
- <programlisting>
<file name="SConstruct" printme="1">
- env = Environment(OS = )
+ env = Environment(OS = ARGUMENTS.get('OS'))
for os in ['newell', 'post']:
SConscript('src/SConscript', build_dir='build/' + os)
</file>
</scons_example>
<scons_output example="ex_var2">
- % <userinput>scons</userinput>
+ <command>scons -Q</command>
</scons_output>
+
+ -->