parameters: (toplevel_build_dir, generator_flags, open_out)
docstring: It's not sufficient to have the absolute path to the compiler, linker,
    etc. on Windows, as those tools rely on .dlls being in the PATH. We also
    need to support both x86 and x64 compilers within the same build (to support
    msvs_target_platform hackery). Different architectures require a different
    compiler binary, and different supporting environment variables (INCLUDE,
    LIB, LIBPATH). So, we extract the environment here, wrap all invocations
    of compiler tools (cl, link, lib, rc, midl, etc.) via win_tool.py which
    sets up the environment, and then we do not prefix the compiler with
    an absolute path, instead preferring something like "cl.exe" in the rule
    which will then run whichever the environment setup has put in the path.
docstring_summary: It's not sufficient to have the absolute path to the compiler, linker,
    etc. on Windows, as those tools rely on .dlls being in the PATH. We also
    need to support both x86 and x64 compilers within the same build (to support
    msvs_target_platform hackery). Different architectures require a different
    compiler binary, and different supporting environment variables (INCLUDE,
    LIB, LIBPATH). So, we extract the environment here, wrap all invocations
    of compiler tools (cl, link, lib, rc, midl, etc.) via win_tool.py which
    sets up the environment, and then we do not prefix the compiler with
    an absolute path, instead preferring something like "cl.exe" in the rule
    which will then run whichever the environment setup has put in the path.
docstring_tokens: It s not sufficient to have the absolute path to the compiler linker etc . on Windows as those tools rely on . dlls being in the PATH . We also need to support both x86 and x64 compilers within the same build ( to support msvs_target_platform hackery ) . Different architectures require a different compiler binary and different supporting environment variables ( INCLUDE LIB LIBPATH ) . So we extract the environment here wrap all invocations of compiler tools ( cl link lib rc midl etc . ) via win_tool . py which sets up the environment and then we do not prefix the compiler with an absolute path instead preferring something like cl . exe in the rule which will then run whichever the environment setup has put in the path .
function: def GenerateEnvironmentFiles(toplevel_build_dir, generator_flags, open_out):
    """It's not sufficient to have the absolute path to the compiler, linker,
    etc. on Windows, as those tools rely on .dlls being in the PATH. We also
    need to support both x86 and x64 compilers within the same build (to support
    msvs_target_platform hackery). Different architectures require a different
    compiler binary, and different supporting environment variables (INCLUDE,
    LIB, LIBPATH). So, we extract the environment here, wrap all invocations
    of compiler tools (cl, link, lib, rc, midl, etc.) via win_tool.py which
    sets up the environment, and then we do not prefix the compiler with
    an absolute path, instead preferring something like "cl.exe" in the rule
    which will then run whichever the environment setup has put in the path."""
    vs = GetVSVersion(generator_flags)
    for arch in ('x86', 'x64'):
      args = vs.SetupScript(arch)
      args.extend(('&&', 'set'))
      popen = subprocess.Popen(
          args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
      variables, _ = popen.communicate()
      env = _ExtractImportantEnvironment(variables)
      env_block = _FormatAsEnvironmentBlock(env)
      f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb')
      f.write(env_block)
      f.close()
function_tokens: def GenerateEnvironmentFiles ( toplevel_build_dir , generator_flags , open_out ) : vs = GetVSVersion ( generator_flags ) for arch in ( 'x86' , 'x64' ) : args = vs . SetupScript ( arch ) args . extend ( ( '&&' , 'set' ) ) popen = subprocess . Popen ( args , shell = True , stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) variables , _ = popen . communicate ( ) env = _ExtractImportantEnvironment ( variables ) env_block = _FormatAsEnvironmentBlock ( env ) f = open_out ( os . path . join ( toplevel_build_dir , 'environment.' + arch ) , 'wb' ) f . write ( env_block ) f . close ( )