本文整理汇总了Python中GPS.get_target方法的典型用法代码示例。如果您正苦于以下问题:Python GPS.get_target方法的具体用法?Python GPS.get_target怎么用?Python GPS.get_target使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GPS
的用法示例。
在下文中一共展示了GPS.get_target方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_gnatemu_name
# 需要导入模块: import GPS [as 别名]
# 或者: from GPS import get_target [as 别名]
def get_gnatemu_name(self):
target = GPS.get_target()
if target:
prefix = target + '-'
else:
prefix = ""
return prefix + "gnatemu"
示例2: get_gnat_driver_cmd
# 需要导入模块: import GPS [as 别名]
# 或者: from GPS import get_target [as 别名]
def get_gnat_driver_cmd():
"""
Return the name of the GNAT driver that is suitable for the current
project's target. For instance: "gnat" for native targets or
"powerpc-elf-gnat" for cross PowerPC ELF targets.
"""
target = GPS.get_target()
return '{}-gnat'.format(target) if target else 'gnat'
示例3: _populate_menu
# 需要导入模块: import GPS [as 别名]
# 或者: from GPS import get_target [as 别名]
def _populate_menu(self):
""" Populate the Help menu for the AdaCore tools """
help_actions = []
for exec_name in _DOC_ENTRIES.keys():
executable = exec_name
if exec_name == 'gnatls' and GPS.get_target():
executable = '{}-gnatls'.format(GPS.get_target())
ex = os_utils.locate_exec_on_path(executable)
if ex:
for descr, tup in _DOC_ENTRIES[exec_name].iteritems():
html_files, menu_base = tup
menu_path = menu_base + '/' + descr
action_descr = 'display documentation {}'.format(descr)
# Do not create a menu if the action already exists
if GPS.Action(action_descr).exists():
continue
# As a convenience, html_files can either be a string or a
# list of strings. Deal with this here.
if type(html_files) != list:
html_files = [html_files]
for file in html_files:
path = os.path.realpath(
os.path.join(os.path.dirname(ex),
'..', 'share', 'doc', file)
)
if os.path.isfile(path):
action = HTMLAction(action_descr, path,
'/Help/{}'.format(menu_path))
help_actions.append(action)
break
help_actions.sort(key=lambda x: x.menu_path)
for a in help_actions:
a.menu(a.menu_path, ref='About', add_before=False)
示例4: get_compiler_search_paths
# 需要导入模块: import GPS [as 别名]
# 或者: from GPS import get_target [as 别名]
def get_compiler_search_paths(project_name, language,
logger=None, use_cache=True):
logger = logger or GPS.Logger("LIBCLANG.SEARCH_PATHS")
# First find the driver.
# Heuristic for finding the driver:
# A) we look for an explicitly set Compiler'Driver setting
# B) if this is not explicitely set, we use
# <target>gcc for C
# <target>c++ for C++
ccs = {'c': 'gcc', 'c++': 'c++'}
"map of languages -> compilers"
# Put the language in lowercase
language = language.lower()
compiler = ''
try:
logger.log('Trying to get the Compiler.Driver attribute for the '
'project')
compiler = GPS.Project(project_name).get_attribute_as_string(
'driver', package='compiler', index=language
)
except Exception:
logger.log(
'No project {}, trying to determine the compiler in a project'
'agnostic way'.format(project_name)
)
if not compiler:
compiler = "-".join(filter(bool, [GPS.get_target(), ccs[language]]))
logger.log('Compiler: {}'.format(compiler))
# We use a tuple (compiler, language) for the cache, because it is possible
# that the user defined the same driver for both C and C++. The cache needs
# to be able to distinguish between the two
if use_cache:
ret = paths_cache.get((compiler, language), None)
if ret:
logger.log('Returning cached search paths: {}'.format(ret))
return ret
# Spawn the compiler, get the include paths
try:
logger.log('Spawning {} to find the search paths'.format(compiler))
cmd = "echo | {} -x {} -E -v -".format(compiler, language)
logger.log("Compiler command : {}".format(cmd))
out = subprocess.check_output(
cmd, shell=True, stderr=subprocess.STDOUT,
# This is needed for consoleless processes under windows - OB11-026
stdin=subprocess.PIPE
)
logger.log("Compiler's output: {}".format(out))
m = re.findall(r'\> search starts here:(.*) ?End', out, re.DOTALL)[0]
ret = map(str.strip, m.strip().splitlines())
except Exception as e:
import traceback
logger.log('Spawning failed !')
logger.log(traceback.format_exc(e))
ret = []
logger.log('Returning {}'.format(ret))
# NOTE: Since the spawning logic is *exactly* the same each time, we'll
# cache the results *even when spawning failed*, so that we don't try to
# spawn executables repeatedly
paths_cache[(compiler, language)] = ret
return ret