Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protobuf项目生成的compiler_commands不包含对应的pb.h文件 #1065

Closed
songouyang opened this issue Nov 24, 2020 · 2 comments
Closed

Comments

@songouyang
Copy link

描述问题

使用文档用的protobuf工程例子,然后生成对应的compiler_commands.json文件。由于编译命令中没有指定pb的include目录,IDE使用compiler_commands.json无法做出代码提示。不知道这是否符合预期。

compile_commands.json
[
  {
    "directory": "/Users/name/repos/xmake/hello",
    "arguments": [
      "/usr/local/bin/ccache",
      "/usr/local/opt/llvm/bin/clang++",
      "-c",
      "-Qunused-arguments",
      "-arch",
      "x86_64",
      "-std=c++11",
      "-I/Users/name/.xmake/packages/p/protobuf-cpp/3.12.3/d639b7d6e3244216b403b39df5101abf/include",
      "-I/usr/local/include",
      "-I/usr/include",
      "-o",
      "build/.objs/hello/macosx/x86_64/release/src/main.cpp.o",
      "src/main.cpp"
    ],
    "file": "src/main.cpp"
  }
]
xmake.lua
add_requires("protobuf-cpp")

target("hello")
    set_kind("binary")
    set_languages("c++11")
    add_packages("protobuf-cpp")
    add_files("src/*.cpp")
    add_files("src/*.proto", {rules = "protobuf.cpp"})
src/main.cpp
#include <iostream>
#include <string>
#include "request.pb.h"


using namespace std;

int main(int argc, char** argv)
{
  return 0;
}
src/request.proto
syntax = "proto3";

message SearchRequest {
  string query = 1;
  int32 page_number = 2;
  int32 result_per_page = 3;
}

期待的结果

希望include地址可以把pb生成的代码路径加入

错误信息

image

相关环境

请提供编译和运行环境信息,下面是一些必须填写的基础信息,便于我们针对性排查问题:

  • xmake版本:xmake v2.3.8+202011150524
  • xmake运行平台:MacOS
  • xmake目标平台:MacOS
@waruqi
Copy link
Member

waruqi commented Nov 24, 2020

pb.h的自动生成是在 protobuf 规则的 on_build_file() 脚本里面直接处理的,而 compile_commands 里面目前不支持导出所有的 on_xxx() 脚本内部的各种命令,因此目前是不支持导出pb.h 路径到 compile_commands 的。

这块后期要支持,理论上也是可以,但是要花点时间,可以先在这备着吧,在之后的版本中,如果有时间我会考虑下的。

@waruqi waruqi added this to the todo milestone Nov 24, 2020
@waruqi waruqi modified the milestones: todo, v2.5.2 Feb 19, 2021
@waruqi
Copy link
Member

waruqi commented Feb 19, 2021

我在 generator 分支上改进过了,应该支持了,可以更新下试试

xmake update -s github:xmake-io/xmake#generator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants