#!/usr/bin/env python import hashlib import subprocess import sys import os from clangParams import parseClangCompileParams from subprocess import Popen from sys import stdout, stderr # #print('Input args is [' + ' '.join(sys.argv[1:]) + ']') #loading old params indexFileLocation = os.path.expanduser('~/.dyci/index/') clangParams = parseClangCompileParams(sys.argv[1:]) className = clangParams['class'] filename = indexFileLocation + hashlib.md5(className).hexdigest() try: with open(filename, "w") as text_file: workingDirectory = os.getcwd() text_file.write('\n'.join(sys.argv[1:] + [workingDirectory])) text_file.close() except: #stderr.write("Couldn't write index file '%s' %s. This is bad:( But compilation will be continued" % (className, className.hash)) pass #faking compile string... #... Since we are clang... #... There's somewere clang-real near us..
# Searching where is Xcode with it's Clang located process = Popen(["xcode-select","-print-path"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) xcodeLocation, err = process.communicate() xcodeLocation = xcodeLocation.rstrip(os.linesep) compileString = [xcodeLocation + '/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-real'] \ + params #Compiling file again runAndFailOnError(compileString) #Compilation was successful... performing linking clangParams = parseClangCompileParams(params) #creating new random name wor the dynamic library libraryName = "dyci%s.dylib" % random.randint(0, 10000000) # {'class':className, # 'object':objectCompilation, # 'arch':arch, # 'isysroot':isysroot, # 'LParams':Lparams, # 'FParams':Fparams, # 'minOSParam':minOSParam #} #Running linker, that will create dynamic library for us linkArgs = \
# Searching where is Xcode with it's Clang located process = Popen(["xcode-select", "-print-path"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) xcodeLocation, err = process.communicate() xcodeLocation = xcodeLocation.rstrip(os.linesep) compileString = [xcodeLocation + '/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-real'] \ + params #Compiling file again runAndFailOnError(compileString) #Compilation was successful... performing linking clangParams = parseClangCompileParams(params) #creating new random name wor the dynamic library libraryName = "dyci%s.dylib" % random.randint(0, 10000000) # {'class':className, # 'object':objectCompilation, # 'arch':arch, # 'isysroot':isysroot, # 'LParams':Lparams, # 'FParams':Fparams, # 'minOSParam':minOSParam #} #Running linker, that will create dynamic library for us linkArgs = \
import hashlib import subprocess import sys import os from clangParams import parseClangCompileParams from subprocess import Popen from sys import stdout, stderr # #print('Input args is [' + ' '.join(sys.argv[1:]) + ']') #loading old params indexFileLocation = os.path.expanduser('~/.dyci/index/') clangParams = parseClangCompileParams(sys.argv[1:]) className = os.path.normpath(clangParams['class']) filename = indexFileLocation + hashlib.md5(className).hexdigest() # Skip clang invocations of analyzer if clangParams['isAnalyzer'] == False: try: with open(filename, "w") as text_file: workingDirectory = os.getcwd() text_file.write('\n'.join(sys.argv[1:] + [workingDirectory])) text_file.close() except: #stderr.write("Couldn't write index file '%s' %s. This is bad:( But compilation will be continued" % (className, className.hash)) pass