#!/usr/bin/env python # Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
"""Wrapper script to run java command as action with gn."""
import os import subprocess import sys
EXIT_SUCCESS = 0
EXIT_FAILURE = 1
def IsExecutable(path): """Returns whether file at |path| exists and is executable.
Args:
path: absolute or relative path to test.
Returns: Trueif the file at |path| exists, False otherwise. """ return os.path.isfile(path) and os.access(path, os.X_OK)
def FindCommand(command): """Looks up for |command| in PATH.
Args:
command: name of the command to lookup, if command is a relative or
absolute path (i.e. contains some path separator) then only that
path will be tested.
Returns:
Full path to command orNoneif the command was not found.
On Windows, this respects the PATHEXT environment variable when the
command name does not have an extension. """
fpath, _ = os.path.split(command) if fpath: if IsExecutable(command): return command
if sys.platform == 'win32': # On Windows, if the command does not have an extension, cmd.exe will # try all extensions from PATHEXT when resolving the full path.
command, ext = os.path.splitext(command) ifnot ext:
exts = os.environ['PATHEXT'].split(os.path.pathsep) else:
exts = [ext] else:
exts = ['']
for path in os.environ['PATH'].split(os.path.pathsep): for ext in exts:
path = os.path.join(path, command) + ext if IsExecutable(path): return path
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.