def FlagsForFile(filename, **kwargs): """This is the main entry point for YCM. Its interface is fixed. Args: filename: (String) Path to source file being edited. Returns: (Dictionary) 'flags': (List of Strings) Command line flags. 'do_cache': (Boolean) True if the result should be cached. """ result = {'flags': ['-std=c++11', '-x', 'c++'], 'do_cache': True} # Headers can't be built, so we get the source file flags instead. if filename.endswith('.h'): filename = filename[:-2] + ".cpp" if not os.path.exists(filename): return result # Force config.h file inclusion, for GLib macros. result['flags'].append("-includeconfig.h") build_path = common.get_build_path(fatal=False) if not build_path: print "Could not find WebKit build path." return result if not ensure_make_trace_file(build_path): print "Could not create make trace file" return result result['flags'].extend(get_compilation_flags_for_file( build_path, filename)) return result
def FlagsForFile(filename, **kwargs): """This is the main entry point for YCM. Its interface is fixed. Args: filename: (String) Path to source file being edited. Returns: (Dictionary) 'flags': (List of Strings) Command line flags. 'do_cache': (Boolean) True if the result should be cached. """ result = {'flags': ['-std=c++11', '-x', 'c++'], 'do_cache': True} # Headers can't be built, so we get the source file flags instead. if filename.endswith('.h'): filename = filename[:-2] + ".cpp" if not os.path.exists(filename): return result # Force config.h file inclusion, for GLib macros. result['flags'].append("-includeconfig.h") build_path = common.get_build_path(fatal=False) if not build_path: print "Could not find WebKit build path." return result if not ensure_make_trace_file(build_path): print "Could not create make trace file" return result result['flags'].extend(get_compilation_flags_for_file(build_path, filename)) return result
def initialize(): global dictionary_lib src = """ typedef struct { wchar_t lemma[80]; int nFeatures; wchar_t **features; } MorphologyWrapper; void createDictionary(const char* i_language); size_t getGramInfo(const wchar_t* i_token, const char * i_language); size_t getParadigmForLemma(const wchar_t* i_lemma, const char* i_language); const MorphologyWrapper* requestGetGramInfoReturnValue(size_t i_index); const size_t requestGetParadigmForLemmaSize(size_t i_index); const MorphologyWrapper* requestGetParadigmForLemmaReturnValueMorphology(size_t i_paradigm_index, size_t i_element_index); const wchar_t* requestGetParadigmForLemmaReturnValueWordform(size_t i_paradigm_index, size_t i_element_index); void cleanGetGramInfoReturnValue(); size_t synthesizeTokenFromLemma(const wchar_t* i_lemma, const wchar_t ** i_grammarFeatures, size_t i_numberOfFeatures, const char* i_language); const wchar_t* requestSynthesizeTokenFromLemmaReturnValue(size_t i_index); void cleanSynthesizeTokenFromLemmaReturnValue(); void cleanGetParadigmForLemmaReturnValue(); """ # Parse global ffi ffi = cffi.FFI() ffi.cdef(src) # Loadself.features = {} full_path = os.path.join(common.get_build_path(), 'libdictionary.so') dictionary_lib = ffi.dlopen(full_path)
def initialize(): global tagset_converter_lib src = """ void createConverter(); size_t convert(const wchar_t ** i_markers, size_t i_numberOfFeatures); void removeConverter(); const wchar_t* requestConvertReturnValue(size_t i_index); """ # Parse global ffi ffi = cffi.FFI() ffi.cdef(src) # Loadself.features = {} full_path = os.path.join(common.get_build_path(), 'libtagset-converter.so') tagset_converter_lib = ffi.dlopen(full_path)
def get_build_path(): webkitbuild_path = os.path.join(common.get_build_path(fatal=False), '..') if not os.path.exists(webkitbuild_path): return None release_build_path = os.path.join(webkitbuild_path, 'Release') debug_build_path = os.path.join(webkitbuild_path, 'Debug') try: release_mtime = os.path.getmtime(os.path.join(release_build_path, 'compile_commands.json')) except os.error: release_mtime = 0 try: debug_mtime = os.path.getmtime(os.path.join(debug_build_path, 'compile_commands.json')) except os.error: debug_mtime = 0 return release_build_path if release_mtime >= debug_mtime else debug_build_path
def get_build_path(): webkitbuild_path = os.path.join(common.get_build_path(fatal=False), '..') if not os.path.exists(webkitbuild_path): return None release_build_path = os.path.join(webkitbuild_path, 'Release') debug_build_path = os.path.join(webkitbuild_path, 'Debug') try: release_mtime = os.path.getmtime( os.path.join(release_build_path, 'compile_commands.json')) except os.error: release_mtime = 0 try: debug_mtime = os.path.getmtime( os.path.join(debug_build_path, 'compile_commands.json')) except os.error: debug_mtime = 0 return release_build_path if release_mtime >= debug_mtime else debug_build_path