mirror of
https://github.com/geohot/qira
synced 2025-03-13 18:43:19 +03:00
next version should ship with CDA
This commit is contained in:
parent
532af41de4
commit
a6e66f5a48
@ -73,6 +73,12 @@ echo "copying pin"
|
||||
mkdir -p distrib/qira/pin
|
||||
cp -av pin/makefile pin/pin_build.sh pin/qirapin.cpp distrib/qira/pin/
|
||||
|
||||
echo "copying cda"
|
||||
mkdir -p distrib/qira/cda distrib/qira/cda/clang
|
||||
cp -av cda/*.py distrib/qira/cda/
|
||||
cp -av cda/clang/*.py distrib/qira/cda/clang/
|
||||
cp -Rav cda/static distrib/qira/cda/
|
||||
|
||||
# package up the python, hopefully this includes pymongo driver
|
||||
# hmm, it doesn't, user will need to install
|
||||
#cd bin
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env python2.7
|
||||
import os
|
||||
import sys
|
||||
import cda_config
|
||||
|
||||
basedir = os.path.dirname(os.path.realpath(__file__))
|
||||
#sys.path.append(basedir+"/clang/llvm/tools/clang/bindings/python")
|
||||
import clang.cindex as ci
|
||||
#ci.Config.set_library_file(basedir+"/clang/build/Release+Asserts/lib/libclang.so")
|
||||
ci.Config.set_library_file(basedir+"/libclang.so")
|
||||
ci.Config.set_library_file(cda_config.LIBCLANG_PATH)
|
||||
|
||||
import pickle
|
||||
from clang.cindex import CursorKind
|
||||
@ -122,9 +122,8 @@ def parse_file(filename, args=[]):
|
||||
|
||||
def parse_files(files, args=[]):
|
||||
args.append("-I")
|
||||
#args.append(basedir+"/clang-latest/build/Release+Asserts/lib/clang/3.4.2/include")
|
||||
# for unbuilt clang
|
||||
args.append(basedir+"/include")
|
||||
args.append(cda_config.CLANG_INCLUDES)
|
||||
for fn in files:
|
||||
print "CDA: caching",fn
|
||||
try:
|
||||
|
7
cda/cda_config.py
Normal file
7
cda/cda_config.py
Normal file
@ -0,0 +1,7 @@
|
||||
#ci.Config.set_library_file(basedir+"/clang/build/Release+Asserts/lib/libclang.so")
|
||||
#ci.Config.set_library_file(basedir+"/libclang.so")
|
||||
LIBCLANG_PATH = '/usr/lib/x86_64-linux-gnu/libclang.so.1'
|
||||
#args.append(basedir+"/clang-latest/build/Release+Asserts/lib/clang/3.4.2/include")
|
||||
#args.append(basedir+"/include")
|
||||
CLANG_INCLUDES = '/usr/lib/llvm-3.4/lib/clang/3.4/include'
|
||||
|
@ -8,6 +8,8 @@ PIP="pip"
|
||||
if [ $(which apt-get) ]; then
|
||||
echo "installing apt packages"
|
||||
sudo apt-get install build-essential python-dev python-pip debootstrap
|
||||
echo "installing cda packages"
|
||||
sudo apt-get install codesearch clang
|
||||
elif [ $(which pacman) ]; then
|
||||
echo "installing pip"
|
||||
sudo pacman -S base-devel python2-pip
|
||||
|
@ -41,7 +41,7 @@ if __name__ == '__main__':
|
||||
raise Exception("--web-host must be a valid IPv4/IPv6 address")
|
||||
|
||||
# handle arguments
|
||||
if sys.argv[0] == "cda":
|
||||
if sys.argv[0][-3:] == "cda":
|
||||
print "*** called as cda, not running QIRA"
|
||||
args.cda_only = True
|
||||
|
||||
|
@ -261,10 +261,15 @@ class Program:
|
||||
return raw.encode("hex")
|
||||
|
||||
def research(self, re):
|
||||
csearch = qira_config.BASEDIR + "/cda/codesearch-latest/csearch"
|
||||
out = subprocess.Popen([csearch, "-n", "--", re], stdout=subprocess.PIPE, env={"CSEARCHINDEX": self.cindexname})
|
||||
dat = out.communicate()
|
||||
return dat[0].split("\n")[:-1]
|
||||
try:
|
||||
#csearch = qira_config.BASEDIR + "/cda/codesearch-latest/csearch"
|
||||
csearch = "/usr/bin/csearch"
|
||||
out = subprocess.Popen([csearch, "-n", "--", re], stdout=subprocess.PIPE, env={"CSEARCHINDEX": self.cindexname})
|
||||
dat = out.communicate()
|
||||
return dat[0].split("\n")[:-1]
|
||||
except:
|
||||
print "ERROR: csearch not found"
|
||||
return []
|
||||
|
||||
def getdwarf(self):
|
||||
if not qira_config.WITH_DWARF:
|
||||
@ -325,11 +330,17 @@ class Program:
|
||||
|
||||
(files, self.dwarves, self.rdwarves, dirs) = cachewrap("/tmp/qira_dwarfcaches", self.proghash, parse_dwarf)
|
||||
|
||||
cindex = qira_config.BASEDIR + "/cda/codesearch-latest/cindex"
|
||||
self.cindexname = get_cachename("/tmp/qira_cindexcaches", self.proghash)
|
||||
if not os.path.isfile(self.cindexname):
|
||||
if os.fork() == 0:
|
||||
os.execve(cindex, [cindex,"--"]+files, {"CSEARCHINDEX": self.cindexname})
|
||||
try:
|
||||
#cindex = qira_config.BASEDIR + "/cda/codesearch-latest/cindex"
|
||||
cindex = "/usr/bin/cindex"
|
||||
os.execve(cindex, [cindex,"--"]+files, {"CSEARCHINDEX": self.cindexname})
|
||||
except:
|
||||
print "ERROR: cindex not found"
|
||||
exit(0)
|
||||
|
||||
# no need to wait
|
||||
|
||||
# cda
|
||||
|
Loading…
x
Reference in New Issue
Block a user