gpt4 book ai didi

c++ - 如何将 GYP 目标移动到单独的包含文件

转载 作者:行者123 更新时间:2023-11-28 03:12:19 25 4
gpt4 key购买 nike

我希望许多 gyp 脚本有一个共同的目标。所以我决定将它移到一个单独的包含文件中。产生错误的最简单的测试用例:

foo.gyp

{
'includes' : [
'bar.gypi',
],
}

bar.gypi

{
'targets': [
{
'target_name' : 'phony',
'type' : 'none',
'actions' : [
{
'action_name' : '_phony_',
'inputs' : ['',],
'outputs' : ['',],
'action' : ['_phony_',],
'message' : '_phony_',
},
],
},
],
}

产生错误:

IndexError: string index out of range while reading includes offoo.gyp while tr ying to load foo.gyp

一些观察:

  • 如果我从目标中删除actions,一切都解析良好

  • 如果我将 targets(带有操作)移动到 foo.gyp,一切都可以很好地解析

我做错了什么吗?

最佳答案

看起来“输出”列表不能为空或包含空字符串:

# gyp/make.py:893
self.WriteLn("%s: obj := $(abs_obj)" % QuoteSpaces(outputs[0]))

您的输入可能为空,但在这种情况下,虚假 Action 只会触发一次。我在 GYP 文档中没有发现任何关于虚假操作的提及,但我有以下变体在工作:

# bar.gypi
{
'targets': [
{
'target_name' : 'phony',
'type' : 'none',
'actions' : [
{
'action_name' : '_phony_',
'inputs' : ['./bar.gypi'], # The action depends on this file
'outputs' : ['test'], # Some dummy file
'action' : ['echo', 'test'],
'message' : 'Running phony target',
},
],
},
],

如果你告诉我更多关于你试图解决的任务,我可以尝试找到更好的方法。

关于c++ - 如何将 GYP 目标移动到单独的包含文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18102858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com