Set up llvm lit test with bazel
Lit is an important tool in llvm project to do text-based tests. This post records how to use lit in a bazel project. Most of the code are pulled from Tensorflow. I did some modification to make it more convinent to use them in a new project. For Setting up project based on llvm, please see my previous post: https://anissl93.github.io/posts/proj_llvm_bazel/, The full code is in build_llvm_with_bazel, and the bazel helpers here bazel_tools...
Setup a project depending on llvm using bazel
Create your repo, such as "BuildWithLLVM" To add a local repo, copy following files to BuildWithLLVM llvm-project/utils/bazel/WORKSPACE .bazelrc .bazelversion .bazelignore Add workspace name to the start of WORKSPACE file workspace(name = "build_with_llvm") Change path in WORKSPACE new_local_repository( name = "llvm-raw", build_file_content = "# empty", # change path pointing to your llvm-project path = "/path/to/llvm-project", ) Test the build bazel build --config=generic_gcc @llvm-project//llvm:all Build something depending on llvm Add a c++ source file main....