@@ -7,148 +7,7 @@ primarily designed for adding import/export annotations to a Windows DLL
77project, but can also be used to add visibility annotations for ELF shared
88library or Mach-O dylib projects.
99
10- ## Building IDS
11-
12- IDS can be built either as an LLVM external project or as a stand-alone project.
13-
14- ### LLVM External Project
15-
16- IDS can be built as a sub-project of LLVM by setting ` LLVM_EXTERNAL_PROJECTS ` .
17- This greatly improves the editing and debugging experience in Visual Studio when
18- navigating to Clang code from the IDS code. Please see [ Getting Started with the
19- LLVM
20- Project] ( https://llvm.org/docs/GettingStarted.html#getting-the-source-code-and-building-llvm )
21- for more info on building LLVM and Clang.
22-
23- The CMake variables ` LLVM_EXTERNAL_PROJECTS ` and ` LLVM_EXTERNAL_IDS_SOURCE_DIR `
24- variables must be set for IDS to build as part of the LLVM build.
25-
26- Testing IDS also requires ` LIT_EXECUTABLE ` and ` FILECHECK_EXECUTABLE ` to specify
27- the locations of ` lit.py ` and ` FileCheck ` , which are located in the LLVM source
28- and LLVM build output directory.
29-
30- ``` bash
31- cmake -G Ninja \
32- -B /home/user/src/llvm-project/build \
33- -S /home/user/src/llvm-project/llvm \
34- -DCMAKE_BUILD_TYPE=Release \
35- -DLLVM_ENABLE_PROJECTS=" llvm;clang" \
36- -DLLVM_EXTERNAL_PROJECTS=" IDS" \
37- -DLLVM_EXTERNAL_IDS_SOURCE_DIR=" /home/user/src/ids" \
38- -DLIT_EXECUTABLE=/home/user/src/llvm-project/llvm/utils/lit/lit.py \
39- -DFILECHECK_EXECUTABLE=/home/user/src/llvm-project/build/bin/FileCheck
40-
41- cmake --build /home/user/src/llvm-project/build --target idt
42- cmake --build /home/user/src/llvm-project/build --target check-ids
43- ```
44-
45- ### Stand-Alone Build
46-
47- To build IDS as a stand-alone project, ` LLVM_DIR ` and ` Clang_DIR ` variables must
48- be provided to specify the locations of local LLVM and Clang libraries. These
49- can refer to locally built LLVM and Clang libraries, or to pre-built LLVM
50- package that includes the Clang development libraries.
51-
52- Testing IDS also requires ` LIT_EXECUTABLE ` and ` FILECHECK_EXECUTABLE ` to specify
53- the locations of ` lit.py ` and ` FileCheck ` , which are not typically included in
54- a pre-built LLVM package.
55-
56- ``` bash
57- cmake -G Ninja \
58- -B /home/user/src/ids/build \
59- -S home/user/src/ids \
60- -DCMAKE_BUILD_TYPE=Release \
61- -DLIT_EXECUTABLE=/home/user/src/llvm-project/llvm/utils/lit/lit.py \
62- -DFILECHECK_EXECUTABLE=/home/user/src/llvm-project/build/bin/FileCheck \
63- -DLLVM_DIR=/home/user/src/llvm-project/build/lib/cmake/llvm \
64- -DClang_DIR=/home/user/src/llvm-project/build/lib/cmake/clang
65-
66- cmake --build S:\i ds\b uild --target idt
67- cmake --build S:\i ds\b uild --target check-ids
68- ```
69-
70- ## Running IDS
71-
72- There are a number of command-line arguments to IDS that dictate its behavior.
73-
74- ``` bash
75- USAGE: idt [options] < source0> [... < sourceN> ]
76-
77- OPTIONS:
78-
79- Generic Options:
80-
81- --help - Display available options (--help-hidden for more)
82- --help-list - Display list of available options (--help-list-hidden for more)
83- --version - Display the version of this program
84-
85- interface definition scanner options:
86-
87- --apply-fixits - Apply suggested changes to decorate interfaces
88- --export-macro=< define> - The macro to decorate interfaces with
89- --extra-arg=< string> - Additional argument to append to the compiler command line
90- --extra-arg-before=< string> - Additional argument to prepend to the compiler command line
91- --ignore=< function-name[,function-name...]> - Ignore one or more functions
92- --include-header=< header> - Header required for export macro
93- --inplace - Apply suggested changes in-place
94- -p < string> - Build path
95- ```
96-
97- At a minimum, the ` --export-macro ` argument must be provided to specify the
98- macro used to annotate public symbols. See [ Export Macro
99- Definitions] ( Docs/ExportMacroDefinitions.md ) for details. Additionally, at
100- least one source file must be specified as a positional argument.
101-
102- While it is possible to specify a number of source files, IDS generally works
103- better when invoked to process one file at a time.
104-
105- ### Windows Example
106-
107- ``` powershell
108- S:\Source\ids\build\bin\idt.exe `
109- -p S:\Source\MyProject\build `
110- --apply-fixits `
111- --inplace `
112- --export-macro=PUBLIC_ABI `
113- --include-header="include/MyAnnotations.h" `
114- --extra-arg="-DPUBLIC_ABI=__declspec(dllexport)" `
115- --extra-arg="-Wno-macro-redefined" `
116- --extra-arg="-fno-delayed-template-parsing" `
117- S:\Source\MyProject\include\ProjectHeader1.h `
118- S:\Source\MyProject\include\ProjectHeader2.h
119- ```
120-
121- ### Linux Example
122-
123- ``` bash
124- /home/user/src/ids/out/bin/idt \
125- -p /home/user/src/MyProject/build \
126- --apply-fixits \
127- --inplace \
128- --export-macro=PUBLIC_ABI \
129- --include-header=" include/MyAnnotations.h" \
130- --extra-arg=" -DLLVM_ABI=[[gnu::visibility(\" default\" )]]" \
131- --extra-arg=" -Wno-macro-redefined" \
132- S:\S ource\M yProject\i nclude\P rojectHeader1.h \
133- S:\S ource\M yProject\i nclude\P rojectHeader2.h
134- ```
135-
136- The arguments in the above examples have the following effects:
137- - ` -p ` refers to the build directory for the project containing a
138- ` compile_commands.json ` file used by IDS to configure build options
139- - ` --apply-fixits ` and ` --inplace ` instruct IDS to modify the source file in
140- place
141- - ` --export-macro ` indicates that the ` PUBLIC_ABI ` macro will be used to
142- annotate public symbols
143- - ` --include-header ` specifies a local header file that will be added as a
144- ` #include ` in the processed source files if needed. This would typically
145- refer to the header file containing the export macro definition.
146- - The first two ` --extra-arg ` arguments ensure that ` PUBLIC_ABI ` is always
147- defined (differently for Windows and Linux), and suppress the warning emitted
148- if it already is. These arguments ensure the ` PUBLIC_ABI ` annotation is not
149- mistakenly added to a symbol that already has it.
150- - The third ` --extra-arg ` argument is Windows-specific and ensures that
151- templates are always expanded while parsing. It is ensures overloaded private
152- methods get properly exported when referenced only from inline templates.
153- - The trailing positional arguments are the names of source files for IDS to
154- scan.
10+ ## Documentation
11+ - [ Building IDS] ( Docs/Building.md )
12+ - [ Running IDS] ( Docs/Running.md )
13+ - [ Export Macro Definitions] ( Docs/ExportMacroDefinitions.md )
0 commit comments