parameters: (toplevel_build_dir, generator_flags, open_out)
return_statement: return cl_paths
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.
    When the following procedure to generate environment files does not
    meet your requirement (e.g. for custom toolchains), you can pass
    "-G ninja_use_custom_environment_files" to the gyp to suppress file
    generation and use custom environment files prepared by yourself.
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.
    When the following procedure to generate environment files does not
    meet your requirement (e.g. for custom toolchains), you can pass
    "-G ninja_use_custom_environment_files" to the gyp to suppress file
    generation and use custom environment files prepared by yourself.
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 . When the following procedure to generate environment files does not meet your requirement ( e . g . for custom toolchains ) you can pass - G ninja_use_custom_environment_files to the gyp to suppress file generation and use custom environment files prepared by yourself .
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.
    When the following procedure to generate environment files does not
    meet your requirement (e.g. for custom toolchains), you can pass
    "-G ninja_use_custom_environment_files" to the gyp to suppress file
    generation and use custom environment files prepared by yourself."""
    archs = ('x86', 'x64')
    if generator_flags.get('ninja_use_custom_environment_files', 0):
      cl_paths = {}
      for arch in archs:
        cl_paths[arch] = 'cl.exe'
      return cl_paths
    vs = GetVSVersion(generator_flags)
    cl_paths = {}
    for arch in archs:
      # Extract environment variables for subprocesses.
      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()
  
      # Find cl.exe location for this architecture.
      args = vs.SetupScript(arch)
      args.extend(('&&',
        'for', '%i', 'in', '(cl.exe)', 'do', '@echo', 'LOC:%~$PATH:i'))
      popen = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)
      output, _ = popen.communicate()
      cl_paths[arch] = _ExtractCLPath(output)
    return cl_paths
function_tokens: def GenerateEnvironmentFiles ( toplevel_build_dir , generator_flags , open_out ) : archs = ( 'x86' , 'x64' ) if generator_flags . get ( 'ninja_use_custom_environment_files' , 0 ) : cl_paths = { } for arch in archs : cl_paths [ arch ] = 'cl.exe' return cl_paths vs = GetVSVersion ( generator_flags ) cl_paths = { } for arch in archs : # Extract environment variables for subprocesses. 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 ( ) # Find cl.exe location for this architecture. args = vs . SetupScript ( arch ) args . extend ( ( '&&' , 'for' , '%i' , 'in' , '(cl.exe)' , 'do' , '@echo' , 'LOC:%~$PATH:i' ) ) popen = subprocess . Popen ( args , shell = True , stdout = subprocess . PIPE ) output , _ = popen . communicate ( ) cl_paths [ arch ] = _ExtractCLPath ( output ) return cl_paths