diff options
Diffstat (limited to 'doc/user/parseflags.xml')
-rw-r--r-- | doc/user/parseflags.xml | 179 |
1 files changed, 99 insertions, 80 deletions
diff --git a/doc/user/parseflags.xml b/doc/user/parseflags.xml index 4bf572a..d5012e1 100644 --- a/doc/user/parseflags.xml +++ b/doc/user/parseflags.xml @@ -1,6 +1,27 @@ +<?xml version='1.0'?> +<!DOCTYPE sconsdoc [ + <!ENTITY % scons SYSTEM "../scons.mod"> + %scons; + + <!ENTITY % builders-mod SYSTEM "../generated/builders.mod"> + %builders-mod; + <!ENTITY % functions-mod SYSTEM "../generated/functions.mod"> + %functions-mod; + <!ENTITY % tools-mod SYSTEM "../generated/tools.mod"> + %tools-mod; + <!ENTITY % variables-mod SYSTEM "../generated/variables.mod"> + %variables-mod; +]> + +<section id="sect-parseflags" + xmlns="http://www.scons.org/dbxsd/v1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0/scons.xsd scons.xsd"> +<title>Separating Compile Arguments into their Variables: the &ParseFlags; Function</title> + <!-- - Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation + Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -57,24 +78,24 @@ </para> - <programlisting> - env = Environment() - d = env.ParseFlags("-I/opt/include -L/opt/lib -lfoo") - for k,v in sorted(d.items()): - if v: - print k, v - env.MergeFlags(d) - env.Program('f1.c') - </programlisting> - - <screen> - % <userinput>scons -Q</userinput> - CPPPATH ['/opt/include'] - LIBPATH ['/opt/lib'] - LIBS ['foo'] - cc -o f1.o -c -I/opt/include f1.c - cc -o f1 f1.o -L/opt/lib -lfoo - </screen> + <scons_example name="parseflags_ex1"> + <file name="SConstruct" printme="1"> +env = Environment() +d = env.ParseFlags("-I/opt/include -L/opt/lib -lfoo") +for k,v in sorted(d.items()): + if v: + print k, v +env.MergeFlags(d) +env.Program('f1.c') + </file> + <file name="f1.c"> +int main() { return 0; } + </file> + </scons_example> + + <scons_output example="parseflags_ex1" os="posix" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -84,15 +105,9 @@ </para> - <screen> - C:\><userinput>scons -Q</userinput> - CPPPATH ['/opt/include'] - LIBPATH ['/opt/lib'] - LIBS ['foo'] - cl /Fof1.obj /c f1.c /nologo /I\opt\include - link /nologo /OUT:f1.exe /LIBPATH:\opt\lib foo.lib f1.obj - embedManifestExeCheck(target, source, env) - </screen> + <scons_output example="parseflags_ex1" os="win32" suffix="2"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -102,22 +117,24 @@ </para> - <programlisting> - env = Environment() - d = env.ParseFlags("-whatever") - for k,v in sorted(d.items()): - if v: - print k, v - env.MergeFlags(d) - env.Program('f1.c') - </programlisting> - - <screen> - % <userinput>scons -Q</userinput> - CCFLAGS -whatever - cc -o f1.o -c -whatever f1.c - cc -o f1 f1.o - </screen> + <scons_example name="parseflags_ex2"> + <file name="SConstruct" printme="1"> +env = Environment() +d = env.ParseFlags("-whatever") +for k,v in sorted(d.items()): + if v: + print k, v +env.MergeFlags(d) +env.Program('f1.c') + </file> + <file name="f1.c"> + int main() { return 0; } + </file> + </scons_example> + + <scons_output example="parseflags_ex2" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -126,24 +143,24 @@ </para> - <programlisting> - env = Environment() - d = env.ParseFlags(["-I/opt/include", ["-L/opt/lib", "-lfoo"]]) - for k,v in sorted(d.items()): - if v: - print k, v - env.MergeFlags(d) - env.Program('f1.c') - </programlisting> - - <screen> - % <userinput>scons -Q</userinput> - CPPPATH ['/opt/include'] - LIBPATH ['/opt/lib'] - LIBS ['foo'] - cc -o f1.o -c -I/opt/include f1.c - cc -o f1 f1.o -L/opt/lib -lfoo - </screen> + <scons_example name="parseflags_ex3"> + <file name="SConstruct" printme="1"> +env = Environment() +d = env.ParseFlags(["-I/opt/include", ["-L/opt/lib", "-lfoo"]]) +for k,v in sorted(d.items()): + if v: + print k, v +env.MergeFlags(d) +env.Program('f1.c') + </file> + <file name="f1.c"> +int main() { return 0; } + </file> + </scons_example> + + <scons_output example="parseflags_ex3" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -153,24 +170,24 @@ </para> - <programlisting> - env = Environment() - d = env.ParseFlags(["!echo -I/opt/include", "!echo -L/opt/lib", "-lfoo"]) - for k,v in sorted(d.items()): - if v: - print k, v - env.MergeFlags(d) - env.Program('f1.c') - </programlisting> - - <screen> - % <userinput>scons -Q</userinput> - CPPPATH ['/opt/include'] - LIBPATH ['/opt/lib'] - LIBS ['foo'] - cc -o f1.o -c -I/opt/include f1.c - cc -o f1 f1.o -L/opt/lib -lfoo - </screen> + <scons_example name="parseflags_ex4"> + <file name="SConstruct" printme="1"> +env = Environment() +d = env.ParseFlags(["!echo -I/opt/include", "!echo -L/opt/lib", "-lfoo"]) +for k,v in sorted(d.items()): + if v: + print k, v +env.MergeFlags(d) +env.Program('f1.c') + </file> + <file name="f1.c"> +int main() { return 0; } + </file> + </scons_example> + + <scons_output example="parseflags_ex4" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -178,3 +195,5 @@ consult the man page for details about those currently recognized. </para> + +</section> |