This repository has been archived by the owner on Jun 5, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97aa37f
commit 5a307f4
Showing
6 changed files
with
1,880 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
CONFIG := Release | ||
CONFIG := Debug | ||
LLVM_DIR ?= /PATH/TO/LLVM/ | ||
|
||
EXENAME := ./clang-extract.$(CONFIG) | ||
|
||
CXXFLAGS := -I$(LLVM_DIR)/include -I$(LLVM_DIR)/tools/clang/include \ | ||
-DNDEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS \ | ||
-pedantic -fomit-frame-pointer -fno-exceptions -fno-rtti -fPIC -fno-strict-aliasing \ | ||
-W -Wall -Woverloaded-virtual -Wcast-qual -Wno-long-long -Wno-unused-parameter -Wwrite-strings \ | ||
-Wno-variadic-macros -Wno-reorder -Wno-trigraphs -Wno-unknown-pragmas -Wno-unused | ||
LDFLAGS := -L$(LLVM_DIR)/$(CONFIG)/lib | ||
LIBS := -lclangFrontend -lclangSerialization -lclangParse -lclangSema -lclangAnalysis -lclangAST \ | ||
-lclangLex -lclangBasic -lLLVMMC -lLLVMCore -lLLVMSupport -lpthread -ldl -lm | ||
|
||
ifeq ($(CONFIG),"Debug") | ||
CXXFLAGS += -DDEBUG -g | ||
endif | ||
ifeq ($(CONFIG),"Release") | ||
CXXFLAGS += -O3 | ||
endif | ||
|
||
SRCS := extract.cpp main.cpp | ||
$(EXENAME) : $(SRCS) extract.h Makefile | ||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(SRCS) $(LIBS) | ||
|
||
test : test1.h #$(EXENAME) | ||
$(EXENAME) -I . test1.h -o test.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
Clang-extract uses clang to parse your header files and then prints out a description of what it parsed. | ||
|
||
This project was described in a talk a GDC 2012 http://www.gdcvault.com/play/1015586/ (subscription required) | ||
It was funded by Havok and is used as the basis of its reflection system. | ||
|
||
|
||
Building: | ||
* Either in your environment or in the Makefile, set LLVM_DIR to the folder containing a prebuilt LLVM and Clang. | ||
* make | ||
|
||
|
||
Test: | ||
To run clang-extract on a small test: | ||
* make test | ||
|
||
You'll notice the output format is actually python code so you can parse it with thus | ||
def parse(text): | ||
output = # your output structure | ||
def Method(id, recordid, typeid, name, static): | ||
# code here for a method, modifids output | ||
# more local function definitions here | ||
exec text in locals() | ||
return output | ||
|
||
|
||
Invoking: | ||
Run clang-extract --help to see command line options. | ||
|
||
|
||
Notes: | ||
clang-extract internally creates a file which includes all the input files specified on the command line. | ||
You may need to add "-I ." to find the input files. | ||
The -A option is useful to pass through annotations which are stored in the output file. |
Oops, something went wrong.