<?xml version='1.0'?>

<!--
SPDX-FileCopyrightText: Copyright The SCons Foundation (https://scons.org)
SPDX-License-Identifier: MIT
SPDX-FileType: DOCUMENTATION

This file is processed by the bin/SConsDoc.py module.
-->

<!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-parse-flags"
         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 http://www.scons.org/dbxsd/v1.0/scons.xsd">
<title>Merging Options While Creating Environment: the <parameter>parse_flags</parameter> Parameter</title>

 <para>

 It is also possible to merge &consvar; values from arguments
 given to the &f-link-Environment; call itself.
 If the <parameter>parse_flags</parameter> keyword argument
 is given, its value is distributed to &consvars; in the
 new environment in the same way as
 described for the &MergeFlags; method.
 This also works when calling &f-link-env-Clone;,
 as well as in overrides to builder methods
 (see <xref linkend="sect-builder-overrides"/>).

 </para>

 <scons_example name="parse_flags_ex1">
   <file name="SConstruct" printme="1">
env = Environment(parse_flags="-I/opt/include -L/opt/lib -lfoo")
for k in ('CPPPATH', 'LIBPATH', 'LIBS'):
    print("%s:" % k, env.get(k))
env.Program("f1.c")
   </file>
   <file name="f1.c">
int main() { return 0; }
   </file>
 </scons_example>

 <scons_output example="parse_flags_ex1" os="posix" suffix="1">
    <scons_output_command>scons -Q</scons_output_command>
 </scons_output>

</section>
