我正在使用GYP来生成Visual Studio Projects,Make Files和Xcode Projects。
我想拥有一个命令前构建步骤,该步骤调用命令行工具,该工具生成了我后来编译的某些代码,这是可能的吗?
顺便说一句,在Cmake中,我使用一个项目构建步骤,我依靠我作为一种解决方法,因为那里没有预构建,所以后构建步骤也很好。
我可以看到,我可以使用<!()
语法在一代时间调用任意命令,但是我真的更喜欢一次生成项目,然后在编译中生成代码生成步骤。
我使用动作到达某个地方...
我有一个小应用程序:
main.c
#include <stdio.h>
int main() {
#include "some_output"
return 0;
}
和此输入文件
some_input
printf("Hello World!n");
,因此我可以在.gyp文件中像Windows有关的一些(即特定于Windows的代码生成)(即将文件打印为标准并将其重定向到文件中,是的,是的,是的,但希望可以说明点):
gypping.gyp
{
'targets': [
{
'target_name': 'gypping',
'type': 'executable',
'sources': [
'main.c',
'<(INTERMEDIATE_DIR)/some_output',
],
'actions': [{
'action_name': 'create_something_generated',
'inputs': [
'some_input'
],
'outputs': [
'<(INTERMEDIATE_DIR)/some_output',
],
'action': ['type', '<@(_inputs)', '>', '<@(_outputs)'],
},
],
},
],
}
这似乎几乎可以工作,就像我在Visual Studio中构建(运行gyp --depth=.
)时,我会收到以下错误:
1>------ Build started: Project: gypping, Configuration: Default Win32 ------
1> create_something_generated
1> '"C:devcodeSandpitgypping.setup_env.bat"' is not recognized as an internal or external command,
1> operable program or batch file.
1>C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我在路径中找不到setup_env.bat
。
我创建了一个空的setup_env.bat文件,然后通过删除>
简化了操作(我想逃脱的问题是错误的)。现在我明白了:
'bash' is not recognized as an internal or external command,
我没有在Windows上的bash。
我认为GYP为我完成了,我想我会坚持使用Cmake。
actions
正是您想要的。它们是在预编译前运行的,git文档显示它们用于生成要在编译步骤中使用的文件。
我已经安装了Windows的git,并使用它,而不是cygwin
,用于通过Visual Studio运行生成的操作。这是我的setenv.bat
:
REM Set up to use Git Bash for running "cygwin" actions.
REM CD to where this file lives to avoid path relativization problems.
cd %~dp0
set PATH=%PATH%;C:Program FilesGitbin
我还看到了安装在窗口中的git %USERPROFILE%AppDataLocalProgramsGit
。我不知道是什么原因导致不同的位置。根据需要更改上述PATH
。
我正在寻找如何生成邮寄步骤