Add your tool into LLVM project - I mean source code.

来源:互联网 发布:mac更新后重启黑屏 编辑:程序博客网 时间:2024/04/30 05:21

1. create testTool folder under <source root>/tools/

$ cd <clang source root>/tools$ mkdir testTool & cd testTools

2. create CMakeList.cmake file and copy below code into it & save

$ vi CMakeList.cmake
add_llvm_tool(testTool)

3. create LLVMBuild.txt file to describe your tool

$ vi LLVMBuild.txt
[component_0]type = Toolname = testToolparent = Toolsrequired_libraries =)

This is an empty tool project, so we do not need any libraries. If you need, you can do as below:

required_libraries = AsmPrinter DebugInfoDWARF MC Object Support all-targets

4. create main.cpp file and copy below code into it & save

$ vi main.cpp
#include <cstdio>int main() {printf("Hello LLVM, I am your new tool, my name is testTool!");}

5. done!

$ cd <where you want to build>$ cmake -G Ninja -DCMAKE_INSTALL_PREFIX=<where you want to install>$ ninja testTool
0 0
原创粉丝点击