{"id":26633535,"url":"https://github.com/vincent-picaud/bazel_and_compilecommands","last_synced_at":"2025-04-10T17:37:55.374Z","repository":{"id":41613557,"uuid":"95450786","full_name":"vincent-picaud/Bazel_and_CompileCommands","owner":"vincent-picaud","description":"Add compile_commands.json to your C++ Bazel Project","archived":false,"fork":false,"pushed_at":"2022-01-01T09:21:29.000Z","size":27,"stargazers_count":149,"open_issues_count":0,"forks_count":32,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T15:15:24.693Z","etag":null,"topics":["bash-script","bazel","compile","cpp"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vincent-picaud.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-26T13:44:52.000Z","updated_at":"2025-02-25T07:11:47.000Z","dependencies_parsed_at":"2022-07-06T03:00:28.657Z","dependency_job_id":null,"html_url":"https://github.com/vincent-picaud/Bazel_and_CompileCommands","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincent-picaud%2FBazel_and_CompileCommands","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincent-picaud%2FBazel_and_CompileCommands/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincent-picaud%2FBazel_and_CompileCommands/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincent-picaud%2FBazel_and_CompileCommands/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vincent-picaud","download_url":"https://codeload.github.com/vincent-picaud/Bazel_and_CompileCommands/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262044,"owners_count":21074237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash-script","bazel","compile","cpp"],"created_at":"2025-03-24T15:15:26.756Z","updated_at":"2025-04-10T17:37:55.335Z","avatar_url":"https://github.com/vincent-picaud.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+BLOG: wordpress\n#+POSTID: 790\n#+CATEGORY: Cpp, CMake, Bazel\n#+DATE: [2017-06-26 Mon 16:16]\n#+OPTIONS: H:3 toc:t num:t \\n:nil ::t |:t ^:nil -:t f:t *:t tex:t d:t tags:not-in-toc\n#+TITLE: Bazel And Compile Commands\n\n* Table of contents                                            :TOC:noexport:\n- [[#caveat--alternatives][Caveat \u0026 Alternatives]]\n- [[#aims][Aims]]\n  - [[#dependencies][Dependencies]]\n  - [[#usage][Usage]]\n- [[#more-details-about-the-shell-scripts][More details about the shell scripts]]\n  - [[#the-setup_compile_commandssh-script][The =setup_compile_commands.sh= script]]\n  - [[#the-create_compile_commandssh-script][The =create_compile_commands.sh= script]]\n- [[#directories-and-files-creation-annex][Directories and files creation (Annex)]]\n  - [[#the-toolsactions-directory][The =tools/actions/= directory]]\n  - [[#the-third_partybazel-directory][The =third_party/bazel= directory]]\n\n* Caveat \u0026 Alternatives\n\nAFAIK this package is still working, however I do not use Bazel\nanymore and I do not intend to upgrade this solution. Here is a list\nof known possible alternatives (alphabetical order) :\n\n- [[https://github.com/grailbio/bazel-compilation-database][github/grailbio/bazel-compilation-database]]\n- [[https://github.com/hedronvision/bazel-compile-commands-extractor][github/hedronvision/bazel-compile-commands-extractor]]\n- [[https://github.com/kythe/kythe/blob/master/tools/cpp/generate_compilation_database.sh][github/kythe/kythe]]\n  \nFeel free to use the one that best fulfils your needs (including my working solution :) )\n\n* Aims\n\n  I generally use [[https://cmake.org/][CMake]] for my C++ developments, but I recently have\n  a look at [[https://bazel.build/][Bazel]] from Google.  I want to use it a little bit to make\n  my opinion. If you are like me and use tools like [[https://clang.llvm.org/docs/ClangTools.html][Clang]], [[https://github.com/Andersbakken/rtags][RTags]], etc.\n  you must generate a =compile_commands.json= file. This is\n  [[https://clang.llvm.org/docs/JSONCompilationDatabase.html#supported-systems][trivial with CMake]], but AFAIK Bazel does not provide such native\n  support.\n\n  I have found this [[https://gist.github.com/bsilver8192/0115ee5d040bb601e3b7][Basics of generating a compile_commands.json file\n  with Bazel]] gist from *bsilver8192*. The comment of *mmlac* was also\n  very useful to understand how to use this gist.\n\n  The aim of this post is to automate the =compile_commands.json= file\n  generation.  Two Shell scripts are used for this purpose.\n\n  These two scripts can be found in this [[https://github.com/vincent-picaud/Bazel_and_CompileCommands][GitHub Repository]] (do not\n  panic, maybe you are already in the right place. This link is only useful\n  when this README.org file is used elsewhere).\n\n** Dependencies\n\n   I am running under Linux, Debian testing distribution. In peculiar I have the following packages installed:\n   - =protobuf-compiler=\n   - =python-protobuf=\n\n** Usage\n\n   The two scripts are:\n\n   - =setup_compile_commands.sh=:\n     used to set up the Bazel project root directory,\n   - =create_compile_commands.sh=: \n     used to generate the =compile_commands.json= file.\n\n   I hope that they will work out of the box, at least for\n   configurations similar to mine.\n\n*** The =setup_compile_commands.sh= script\n \n    The =setup_compile_commands.sh= script must be run only once, it\n    copies and generates all the required files, see\n    [[id:bfca60c5-5d7b-4f87-a223-d714e1b16453][Directories and files creation (Annex)]]\n    for details.\n\n    In a Bazel root directory (where the =WORKSPACE= file is) run:\n\n    #+BEGIN_SRC sh :eval never\nsetup_compile_commands.sh\n    #+END_SRC\n\n    The script should print\n    #+BEGIN_EXAMPLE\nCreate tools/actions/BUILD\nCreate tools/actions/generate_compile_command.py\nCreate tools/actions/generate_compile_commands_json.py\nCreate third_party/bazel/protos/extra_actions_base.proto\nGenerate third_party/bazel/protos/extra_actions_base_pb2.py\nCreate third_party/bazel/BUILD\n    #+END_EXAMPLE\n\n    and generate the following files\n    #+BEGIN_EXAMPLE\n.\n├── third_party\n│   └── bazel\n│       ├── BUILD\n│       └── protos\n│           ├── extra_actions_base_pb2.py\n│           └── extra_actions_base.proto\n└── tools\n    └── actions\n        ├── BUILD\n        ├── generate_compile_command.py\n        └── generate_compile_commands_json.py\n\n5 directories, 6 files\n    #+END_EXAMPLE\n\n*** The =create_compile_commands.sh= script\n\n    After having successfully used the =setup_compile_commands.sh=\n    script it is very easy to generate the =compile_commands.json=\n    file. \n\n Choose a A_BAZEL_TARGET like =...= or =//my:target= and run:\n\n    #+BEGIN_SRC sh :eval never :exports code\ncreate_compile_commands.sh A_BAZEL_TARGET\n    #+END_SRC\n\n    The script should generate your =compile_commands.json= file.\n\n* More details about the shell scripts\n\n** The =setup_compile_commands.sh= script\n \n   The =setup_compile_commands.sh= script is run only once, it copies\n   and generates all the required the files as described in [[https://gist.github.com/bsilver8192/0115ee5d040bb601e3b7][Basics of\n   generating a compile_commands.json file with Bazel]].  \n\n   The main trick to use is:\n\n   #+BEGIN_SRC sh :exports code\n#!/bin/sh\n\nmore \u003e \"a_file.txt\" \u003c\u003c'//MY_CODE_STREAM' \nWhatever you want \n    Whatever you want \n//MY_CODE_STREAM\n   #+END_SRC\n\n   to perform verbatim copies.\n\n   Note that *for usage safety we stop the script if any of the file to be\n   created already exists*.  We also check if the current directory\n   contains the =WORKSPACE= file. Finally, thanks to the =set -e= option\n   any command with a non-zero status stops the script too.\n\n   If you want to overwrite files you can use the \"-f\" option:\n#+BEGIN_SRC sh :eval never :exports code\nsetup_compile_commands.sh -f\n#+END_SRC\n\n   #+BEGIN_SRC sh :exports none :noweb yes :tangle setup_compile_commands.sh :shebang #!/bin/sh :tangle-mode (identity #o555)\nset -e\n\nif [ ! -f \"WORKSPACE\" ]; then\n    echo \"Not in a Bazel root directory (WORKSPACE file does not exist), aborted!\" \n    exit 1\nfi\n\nforce=0\n\nif [ \"$1\" = \"-f\" ]; then\n  force=1\nfi\n\n\u003c\u003csetup_compile_commands.sh\u003e\u003e\n\nexit 0\n   #+END_SRC\n\n\n** The =create_compile_commands.sh= script\n\n   This script generates the =compile_commands.json= file. It invokes\n   the two following commands:\n\n   #+BEGIN_SRC sh :tangle create_compile_commands.sh :shebang #!/bin/sh :tangle-mode (identity #o555) :exports both\nset -e\n\nif [ \"$#\" -lt 1 ]; then\n    echo \"Usage: $(basename $0) BAZEL_BUILD_ARGUMENTS\"\n    exit 1\nfi\n\nbazel build --experimental_action_listener=//tools/actions:generate_compile_commands_listener $*\npython3 ./tools/actions/generate_compile_commands_json.py\nexit 0\n   #+END_SRC\n\nWe added an error message in case the caller did not define a Bazel target ($1=\"\")\n\n* Directories and files creation (Annex)\n  :PROPERTIES:\n  :ID:       bfca60c5-5d7b-4f87-a223-d714e1b16453\n  :END:\n\n  This part lists all the copied or generated files.\n\n** The =tools/actions/= directory\n\n*** The =BUILD= file\n\n    This file is a direct copy of the [[https://gist.github.com/bsilver8192/0115ee5d040bb601e3b7][Basics of generating a compile_commands.json file with Bazel]] gist file.\n\n    #+NAME: tools/actions/BUILD\n    #+BEGIN_SRC text :exports code\npy_binary(\n  name = 'generate_compile_command',\n  srcs = [\n    'generate_compile_command.py',\n  ],\n  deps = [\n    '//third_party/bazel:extra_actions_proto_py',\n  ],\n)\n\naction_listener(\n  name = 'generate_compile_commands_listener',\n  visibility = ['//visibility:public'],\n  mnemonics = [\n    'CppCompile',\n  ],\n  extra_actions = [':generate_compile_commands_action'],\n)\n\nextra_action(\n  name = 'generate_compile_commands_action',\n  tools = [\n    ':generate_compile_command',\n  ],\n  out_templates = [\n    '$(ACTION_ID)_compile_command',\n  ],\n  cmd = '$(location :generate_compile_command) $(EXTRA_ACTION_FILE)' +\n        ' $(output $(ACTION_ID)_compile_command)',\n)\n    #+END_SRC\n\n\n    #+HEADER: :noweb-ref setup_compile_commands.sh\n    #+BEGIN_SRC sh :exports none \ncurrent_file=tools/actions/BUILD\nif [ \"$force\" -eq 1 ] || [ ! -f \"$current_file\" ]; then\n    current_file_dir=\"$(dirname \"$current_file\")\"\n\n    mkdir -p \"$current_file_dir\"\n    echo \"Create $current_file\" 1\u003e\u00262\n    more \u003e \"$current_file\" \u003c\u003c'//MY_CODE_STREAM' \n\u003c\u003ctools/actions/BUILD\u003e\u003e\n//MY_CODE_STREAM\nelse \necho \"File $current_file already exists, aborted! (you can use -f to force overwrite)\" \nexit 1\nfi\n    #+END_SRC\n\n\n*** The =generate_compile_command.py= file\n\n    This file is a direct copy of the [[https://gist.github.com/bsilver8192/0115ee5d040bb601e3b7][Basics of generating a compile_commands.json file with Bazel]] gist file.\n\n    #+NAME: tools/actions/generate_compile_command.py\n    #+BEGIN_SRC python :exports code\n# This is the implementation of a Bazel extra_action which generates\n# _compile_command files for generate_compile_commands.py to consume.\n\nimport sys\n\nimport third_party.bazel.protos.extra_actions_base_pb2 as extra_actions_base_pb2\n\ndef _get_cpp_command(cpp_compile_info):\n  compiler = cpp_compile_info.tool\n  options = ' '.join(cpp_compile_info.compiler_option)\n  source = cpp_compile_info.source_file\n  output = cpp_compile_info.output_file\n  return '%s %s -c %s -o %s' % (compiler, options, source, output), source\n\ndef main(argv):\n  action = extra_actions_base_pb2.ExtraActionInfo()\n  with open(argv[1], 'rb') as f:\n    action.MergeFromString(f.read())\n    command, source_file = _get_cpp_command(\n      action.Extensions[extra_actions_base_pb2.CppCompileInfo.cpp_compile_info])\n  with open(argv[2], 'w') as f:\n    f.write(command)\n    f.write('\\0')\n    f.write(source_file)\n\nif __name__ == '__main__':\n  sys.exit(main(sys.argv))\n    #+END_SRC\n\n    #+HEADER: :noweb-ref setup_compile_commands.sh\n    #+BEGIN_SRC sh :exports none\ncurrent_file=tools/actions/generate_compile_command.py\nif [ \"$force\" -eq 1 ] || [ ! -f \"$current_file\" ]; then\n    current_file_dir=\"$(dirname \"$current_file\")\"\n\n    mkdir -p \"$current_file_dir\"\n    echo \"Create $current_file\" 1\u003e\u00262\n    more \u003e \"$current_file\" \u003c\u003c'//MY_CODE_STREAM' \n\u003c\u003ctools/actions/generate_compile_command.py\u003e\u003e\n//MY_CODE_STREAM\nelse \necho \"File $current_file already exists, aborted! (you can use -f to force overwrite)\" \nexit 1\nfi\n    #+END_SRC\n\n*** The =generate_compile_commands_json.py= file\n\n    This file is a direct copy of the [[https://gist.github.com/bsilver8192/0115ee5d040bb601e3b7][Basics of generating a compile_commands.json file with Bazel]] gist file.\n\n    #+NAME: tools/actions/generate_compile_commands_json.py\n    #+BEGIN_SRC python :exports code\n#!/usr/bin/python3\n\n# This reads the _compile_command files :generate_compile_commands_action\n# generates a outputs a compile_commands.json file at the top of the source\n# tree for things like clang-tidy to read.\n\n# Overall usage directions: run Bazel with\n# --experimental_action_listener=//tools/actions:generate_compile_commands_listener\n# for all the files you want to use clang-tidy with and then run this script.\n# After that, `clang-tidy build_tests/gflags.cc` should work.\n\nimport sys\nimport pathlib\nimport os.path\nimport subprocess\n\n'''\nArgs:\n  path: The pathlib.Path to _compile_command file.\n  command_directory: The directory commands are run from.\nReturns a string to stick in compile_commands.json.\n'''\ndef _get_command(path, command_directory):\n  with path.open('r') as f:\n    contents = f.read().split('\\0')\n    if len(contents) != 2:\n      # Old/incomplete file or something; silently ignore it.\n      return None\n    return '''{\n        \"directory\": \"%s\",\n        \"command\": \"%s\",\n        \"file\": \"%s\"\n      }''' % (command_directory, contents[0].replace('\"', '\\\\\"'), contents[1])\n\n'''\nArgs:\n  path: A directory pathlib.Path to look for _compile_command files under.\n  command_directory: The directory commands are run from.\nYields strings to stick in compile_commands.json.\n'''\ndef _get_compile_commands(path, command_directory):\n  for f in path.iterdir():\n    if f.is_dir():\n      yield from _get_compile_commands(f, command_directory)\n    elif f.name.endswith('_compile_command'):\n      command = _get_command(f, command_directory)\n      if command:\n        yield command\n\ndef main(argv):\n  source_path = os.path.join(os.path.dirname(__file__), '../..')\n  action_outs = os.path.join(source_path,\n                             'bazel-bin/../extra_actions',\n                             'tools/actions/generate_compile_commands_action')\n  command_directory = subprocess.check_output(\n    ('bazel', 'info', 'execution_root'),\n    cwd=source_path).decode('utf-8').rstrip()\n  commands = _get_compile_commands(pathlib.Path(action_outs), command_directory)\n  with open(os.path.join(source_path, 'compile_commands.json'), 'w') as f:\n    f.write('[{}]'.format(','.join(commands)))\n    \nif __name__ == '__main__':\n  sys.exit(main(sys.argv))\n    #+END_SRC\n\n    #+HEADER: :noweb-ref setup_compile_commands.sh\n    #+BEGIN_SRC sh :exports none\ncurrent_file=tools/actions/generate_compile_commands_json.py\nif [ \"$force\" -eq 1 ] || [ ! -f \"$current_file\" ]; then\n    current_file_dir=\"$(dirname \"$current_file\")\"\n\n    mkdir -p \"$current_file_dir\"\n    echo \"Create $current_file\" 1\u003e\u00262\n    more \u003e \"$current_file\" \u003c\u003c'//MY_CODE_STREAM' \n\u003c\u003ctools/actions/generate_compile_commands_json.py\u003e\u003e\n//MY_CODE_STREAM\nelse \necho \"File $current_file already exists, aborted! (you can use -f to force overwrite)\" \nexit 1\nfi\n    #+END_SRC\n\n** The =third_party/bazel= directory\n\n*** The =protos/extra_actions_base_pb2.py= file\n\n    This step requires the =bazel/src/main/protobuf/extra_actions_base.proto= file from the\n    =bazel= source. Its last version can be downloaded using:\n\n    #+BEGIN_SRC sh :eval never :exports code\nwget https://raw.githubusercontent.com/bazelbuild/bazel/master/src/main/protobuf/extra_actions_base.proto\n    #+END_SRC\n\n    This is a temporary file required to generate the =protos/extra_actions_base_pb2.py= file.\n\n    In the current script and in order to be consistent with the\n    previous parts, I do *not* download this file. Instead I directly\n    embed it in the shell script.\n\n    #+NAME: third_party/bazel/protos/extra_actions_base.proto\n    #+BEGIN_SRC protobuf :exports code\n// Copyright 2014 The Bazel Authors. All rights reserved.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//    http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\n// proto definitions for the blaze extra_action feature.\n\nsyntax = \"proto2\";\n\npackage blaze;\n\noption java_multiple_files = true;\noption java_package = \"com.google.devtools.build.lib.actions.extra\";\n\n// A list of extra actions and metadata for the print_action command.\nmessage ExtraActionSummary {\n  repeated DetailedExtraActionInfo action = 1;\n}\n\n// An individual action printed by the print_action command.\nmessage DetailedExtraActionInfo {\n  // If the given action was included in the output due to a request for a\n  // specific file, then this field contains the name of that file so that the\n  // caller can correctly associate the extra action with that file.\n  //\n  // The data in this message is currently not sufficient to run the action on a\n  // production machine, because not all necessary input files are identified,\n  // especially for C++.\n  //\n  // There is no easy way to fix this; we could require that all header files\n  // are declared and then add all of them here (which would be a huge superset\n  // of the files that are actually required), or we could run the include\n  // scanner and add those files here.\n  optional string triggering_file = 1;\n  // The actual action.\n  required ExtraActionInfo action = 2;\n}\n\n// Provides information to an extra_action on the original action it is\n// shadowing.\nmessage ExtraActionInfo {\n  extensions 1000 to max;\n\n  // The label of the ActionOwner of the shadowed action.\n  optional string owner = 1;\n\n  // Only set if the owner is an Aspect.\n  // Corresponds to AspectValue.AspectKey.getAspectClass.getName()\n  // This field is deprecated as there might now be\n  // multiple aspects applied to the same target.\n  // This is the aspect name of the last aspect\n  // in 'aspects' (8) field.\n  optional string aspect_name = 6 [deprecated = true];\n\n  // Only set if the owner is an Aspect.\n  // Corresponds to AspectValue.AspectKey.getParameters()\n  // This field is deprecated as there might now be\n  // multiple aspects applied to the same target.\n  // These are the aspect parameters of the last aspect\n  // in 'aspects' (8) field.\n  map\u003cstring, StringList\u003e aspect_parameters = 7 [deprecated = true];\n  message StringList {\n    option deprecated = true;\n    repeated string value = 1;\n  }\n\n  message AspectDescriptor {\n    // Corresponds to AspectDescriptor.getName()\n    optional string aspect_name = 1;\n    // Corresponds to AspectDescriptor.getParameters()\n    map\u003cstring, StringList\u003e aspect_parameters = 2;\n    message StringList {\n      repeated string value = 1;\n    }\n  }\n\n  // If the owner is an aspect, all aspects applied to the target\n  repeated AspectDescriptor aspects = 8;\n\n  // An id uniquely describing the shadowed action at the ActionOwner level.\n  optional string id = 2;\n\n  // The mnemonic of the shadowed action. Used to distinguish actions with the\n  // same ActionType.\n  optional string mnemonic = 5;\n}\n\nmessage EnvironmentVariable {\n  // It is possible that this name is not a valid variable identifier.\n  required string name = 1;\n  // The value is unescaped and unquoted.\n  required string value = 2;\n}\n\n// Provides access to data that is specific to spawn actions.\n// Usually provided by actions using the \"Spawn\" \u0026 \"Genrule\" Mnemonics.\nmessage SpawnInfo {\n  extend ExtraActionInfo {\n    optional SpawnInfo spawn_info = 1003;\n  }\n\n  repeated string argument = 1;\n  // A list of environment variables and their values. No order is enforced.\n  repeated EnvironmentVariable variable = 2;\n  repeated string input_file = 4;\n  repeated string output_file = 5;\n}\n\n// Provides access to data that is specific to C++ compile actions.\n// Usually provided by actions using the \"CppCompile\" Mnemonic.\nmessage CppCompileInfo {\n  extend ExtraActionInfo {\n    optional CppCompileInfo cpp_compile_info = 1001;\n  }\n\n  optional string tool = 1;\n  repeated string compiler_option = 2;\n  optional string source_file = 3;\n  optional string output_file = 4;\n  // Due to header discovery, this won't include headers unless the build is\n  // actually performed. If set, this field will include the value of\n  // \"source_file\" in addition to the headers.\n  repeated string sources_and_headers = 5;\n  // A list of environment variables and their values. No order is enforced.\n  repeated EnvironmentVariable variable = 6;\n}\n\n// Provides access to data that is specific to C++ link  actions.\n// Usually provided by actions using the \"CppLink\" Mnemonic.\nmessage CppLinkInfo {\n  extend ExtraActionInfo {\n    optional CppLinkInfo cpp_link_info = 1002;\n  }\n\n  repeated string input_file = 1;\n  optional string output_file = 2;\n  optional string interface_output_file = 3;\n  optional string link_target_type = 4;\n  optional string link_staticness = 5;\n  repeated string link_stamp = 6;\n  repeated string build_info_header_artifact = 7;\n  // The list of command line options used for running the linking tool.\n  repeated string link_opt = 8;\n}\n\n// Provides access to data that is specific to java compile actions.\n// Usually provided by actions using the \"Javac\" Mnemonic.\nmessage JavaCompileInfo {\n  extend ExtraActionInfo {\n    optional JavaCompileInfo java_compile_info = 1000;\n  }\n\n  optional string outputjar = 1;\n  repeated string classpath = 2;\n  repeated string sourcepath = 3;\n  repeated string source_file = 4;\n  repeated string javac_opt = 5;\n  repeated string processor = 6;\n  repeated string processorpath = 7;\n  repeated string bootclasspath = 8;\n}\n\n// Provides access to data that is specific to python rules.\n// Usually provided by actions using the \"Python\" Mnemonic.\nmessage PythonInfo {\n  extend ExtraActionInfo {\n    optional PythonInfo python_info = 1005;\n  }\n\n  repeated string source_file = 1;\n  repeated string dep_file = 2;\n}\n    #+END_SRC\n\n    #+HEADER: :noweb-ref setup_compile_commands.sh\n    #+BEGIN_SRC sh :exports none\ncurrent_file=third_party/bazel/protos/extra_actions_base.proto\nif [ \"$force\" -eq 1 ] || [ ! -f \"$current_file\" ]; then\n    current_file_dir=\"$(dirname \"$current_file\")\"\n\n    mkdir -p \"$current_file_dir\"\n    echo \"Create $current_file\" 1\u003e\u00262\n    more \u003e \"$current_file\" \u003c\u003c'//MY_CODE_STREAM' \n\u003c\u003cthird_party/bazel/protos/extra_actions_base.proto\u003e\u003e\n//MY_CODE_STREAM\nelse \necho \"File $current_file already exists, aborted! (you can use -f to force overwrite)\" \nexit 1\nfi\n    #+END_SRC\n\n    The command to generate =extra_actions_base_pb2.py= from the\n    =extra_actions_base.proto= file is:\n\n    #+HEADER: :noweb-ref setup_compile_commands.sh\n    #+BEGIN_SRC sh :noweb yes :exports code\necho \"Generate third_party/bazel/protos/extra_actions_base_pb2.py\" 1\u003e\u00262\nprotoc third_party/bazel/protos/extra_actions_base.proto --python_out=.\n    #+END_SRC\n\n*** The =BUILD= file\n\n    We register this generated file thanks to a simple =BUILD= file:\n\n    #+NAME: third_party/bazel/BUILD\n    #+BEGIN_SRC text :exports code\nlicenses([\"notice\"])\n\npy_library(\n    name = \"extra_actions_proto_py\",\n    srcs = [\"protos/extra_actions_base_pb2.py\"],\n    visibility = [\"//visibility:public\"],\n)\n    #+END_SRC\n\n    #+HEADER: :noweb-ref setup_compile_commands.sh\n    #+BEGIN_SRC sh :exports none\ncurrent_file=third_party/bazel/BUILD\nif [ \"$force\" -eq 1 ] || [ ! -f \"$current_file\" ]; then\n    current_file_dir=\"$(dirname \"$current_file\")\"\n\n    mkdir -p \"$current_file_dir\"\n    echo \"Create $current_file\" 1\u003e\u00262\n    more \u003e \"$current_file\" \u003c\u003c'//MY_CODE_STREAM' \n\u003c\u003cthird_party/bazel/BUILD\u003e\u003e\n//MY_CODE_STREAM\nelse \necho \"File $current_file already exists, aborted! (you can use -f to force overwrite)\" \nexit 1\nfi\n    #+END_SRC\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincent-picaud%2Fbazel_and_compilecommands","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvincent-picaud%2Fbazel_and_compilecommands","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincent-picaud%2Fbazel_and_compilecommands/lists"}