Skip to content
Browse files

Issues #204 and #192 wip

  • Loading branch information...
1 parent 8172c7a commit 364f48e9941e8acdfb659c3bb671e9ab96039b74 @quarnster committed Feb 17, 2013
View
9 internals/clang/cindex.py
@@ -79,17 +79,18 @@ def get_cindex_library():
# CIndex library. It could be on path or elsewhere, or versioned, etc.
import platform
name = platform.system()
+ import os
+ path = os.path.dirname(os.path.abspath(__file__))
+
if name == 'Darwin':
return cdll.LoadLibrary('libclang.dylib')
elif name == 'Windows':
if isWin64:
- return cdll.LoadLibrary("libclang_x64.dll")
- return cdll.LoadLibrary('libclang.dll')
+ return cdll.LoadLibrary("%s/../libclang_x64.dll" % path)
+ return cdll.LoadLibrary('%s/../libclang.dll' % path)
else:
try:
# Try loading with absolute path first
- import os
- path = os.path.dirname(os.path.abspath(__file__))
return cdll.LoadLibrary('%s/../libclang.so' % path)
except:
try:
View
9 internals/translationunitcache.py
@@ -55,12 +55,11 @@ def get_cache_library():
return cdll.LoadLibrary('%s/libcache.dylib' % scriptpath)
elif name == 'Windows':
if cindex.isWin64:
- return cdll.LoadLibrary("libcache_x64.dll")
- return cdll.LoadLibrary('libcache.dll')
+ return cdll.LoadLibrary("%s/libcache_x64.dll" % scriptpath)
+ return cdll.LoadLibrary('%s/libcache.dll' % scriptpath)
else:
try:
# Try loading with absolute path first
-
return cdll.LoadLibrary('%s/libcache.so' % scriptpath)
except:
try:
@@ -799,10 +798,10 @@ def worker(self):
for dirpath, dirnames, filenames in os.walk(folder):
for filename in filenames:
full_path = os.path.join(dirpath, filename)
- ok = not "./src/build" in full_path
+ ok = not "./src/build" in full_path and not "\\src\\build" in full_path
if not ok:
full_path = os.path.abspath(full_path)
- ok = not "SublimeClang" in full_path
+ ok = not "SublimeClang" in full_path and not "Y:\\src\\build" in full_path
if ok and self.impre.search(filename) != None:
score = 1000
for i in range(min(len(filename), len(name))):
View
14 src/CMakeLists.txt
@@ -6,7 +6,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(MSVC)
set(LIBPREFIX lib)
endif()
- if(CMAKE_CL_64)
+ if(CMAKE_CL_64 OR CMAKE_SIZEOF_VOID_P EQUAL 8)
set(LIBSUFFIX _x64)
endif()
@@ -33,7 +33,7 @@ include_directories(
)
set(CLANG_VERSION 3.2 CACHE STRING "Clang version to use")
-set(LLVM_TARGETS_TO_BUILD "X86")
+set(LLVM_TARGETS_TO_BUILD "X86" CACHE STRING "LLVM targets to build")
if(NOT DEFINED BUILD_LIBCLANG)
set(BUILD_LIBCLANG False)
@@ -145,11 +145,11 @@ if(BUILD_LIBCLANG)
execute_process(COMMAND ${CMAKE_COMMAND} -E rename clang-${CLANG_VERSION}.src llvm/tools/clang WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
endif()
- if(NOT EXISTS ${PROJECT_BINARY_DIR}/native)
- # TODO
+ if(NOT EXISTS ${PROJECT_BINARY_DIR}/native AND CMAKE_CROSSCOMPILING)
execute_process(COMMAND ln -s ${PROJECT_BINARY_DIR}/../build2/llvm_out native WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
endif()
add_subdirectory(${PROJECT_BINARY_DIR}/llvm ${PROJECT_BINARY_DIR}/llvm_out EXCLUDE_FROM_ALL)
+ set_target_properties(libclang PROPERTIES OUTPUT_NAME "${LIBPREFIX}clang${LIBSUFFIX}")
string(REPLACE "\\" "" COPY_TARGET ${COPY_TARGET})
@@ -161,8 +161,8 @@ if(BUILD_LIBCLANG)
add_dependencies(${TARGETLIB} copy)
endif()
-# TODO
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND NOT DEFINED WIN_RELEASE)
+# TODO
# if(MSVC)
# #set(MYPATTERN "[ \t\r\n]+([0-9]+)[ \t]+([0-9A-F]+)[ \t]+([0-9A-F]+)[ \t]+([a-zA-Z0-9_]+)")
# #execute_process(COMMAND dumpbin /exports ${PROJECT_SOURCE_DIR}/../libclang${LIBSUFFIX}.dll OUTPUT_VARIABLE libclangdump)
@@ -184,7 +184,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND NOT DEFINED WIN_RELEASE)
# add_dependencies(${TARGETLIB} linklib)
# endif()
add_custom_target(copy2 ALL
- COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:cache> ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${TARGETLIB}> ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
DEPENDS ${TARGETLIB}
VERBATIM
@@ -194,7 +194,7 @@ endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_custom_command(TARGET ${TARGETLIB}
POST_BUILD
- COMMAND install_name_tool -change $<TARGET_FILE:libclang> libclang.dylib $<TARGET_FILE:cache>
+ COMMAND install_name_tool -change $<TARGET_FILE:libclang> libclang.dylib $<TARGET_FILE:${TARGETLIB}>
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/../../internals/
VERBATIM
)
View
16 src/mingw32-toolchain.cmake
@@ -0,0 +1,16 @@
+set(CMAKE_SYSTEM_NAME Windows)
+
+set(CMAKE_C_COMPILER /Developer/mingw32/bin/i686-w64-mingw32-gcc)
+set(CMAKE_CXX_COMPILER /Developer/mingw32/bin/i686-w64-mingw32-g++)
+set(CMAKE_RC_COMPILER /Developer/mingw32/bin/i686-w64-mingw32-windres)
+
+
+set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++")
+
+set(CMAKE_FIND_ROOT_PATH /Developer/mingw32/mingw)
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+set(CMAKE_CROSSCOMPILING True)
View
16 src/mingw64-toolchain.cmake
@@ -0,0 +1,16 @@
+set(CMAKE_SYSTEM_NAME Windows)
+
+set(CMAKE_C_COMPILER /Developer/mingw64/bin/x86_64-w64-mingw32-gcc)
+set(CMAKE_CXX_COMPILER /Developer/mingw64/bin/x86_64-w64-mingw32-g++)
+set(CMAKE_RC_COMPILER /Developer/mingw64/bin/x86_64-w64-mingw32-windres)
+
+
+set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++")
+
+set(CMAKE_FIND_ROOT_PATH /Developer/mingw64/mingw)
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+set(CMAKE_CROSSCOMPILING True)
View
BIN unittests/gold.txt.gz
Binary file not shown.
View
151 unittests/unittest.py
@@ -20,7 +20,22 @@
thisrun = time.time()
scriptpath = os.path.dirname(os.path.abspath(__file__))
-opts = ["-I%s/../clang/include" % scriptpath, "-I%s/../src" % scriptpath]
+opts = [
+ "-I%s/../internals/clang/include" % scriptpath,
+ "-I%s/../src" % scriptpath,
+ "-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/",
+ "-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1",
+ "-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/",
+ "-Wno-deprecated-declarations",
+ "-std=c++11",
+ "-isystem", "C:\\MinGW\\lib\\gcc\\mingw32\\4.7.0\\include",
+ "-isystem", "C:\\MinGW\\lib\\gcc\\mingw32\\4.7.0\\include\\c++",
+ "-isystem", "C:\\MinGW\\lib\\gcc\\mingw32\\4.7.0\\include\\c++\\mingw32",
+ "-isystem", "C:\\MinGW\\include",
+ "-isystem", "/usr/include",
+ "-isystem", "/usr/include/c++/*",
+ "-Wall"
+]
golden = {}
testsAdded = False
@@ -240,7 +255,7 @@ def add_completion_test(currtest, platformspecific=False, noneok=False):
else:
data += currtest
- if currtest.startswith(currfile_data):
+ if currtest.startswith(currfile_data) or disableplatformspecific:
# This is pretty much what we've already tested for the clangcomplete operation
return
data += " "
@@ -732,71 +747,73 @@ def check_correct(a, b):
# ---------------------------------------------------------
- opts = [
- "-isysroot",
- "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/",
- "-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks",
- "-ICocoa"]
- tu = get_tu("unittests/8.mm")
- add_completion_test(" ", True)
- add_completion_test("[Hello ")
- add_completion_test("Hello * h; [h ")
- add_completion_test("World * w; [w ")
- add_completion_test("World * w; [[w world] ")
- add_completion_test("World * w; [[w blah] ")
- add_completion_test("World2 * w; [[w world2] ")
- add_completion_test("World2 * w; [[[w world2] world] ")
- add_completion_test("World2 * w; w.")
- add_completion_test("World2 * w; w.world2.")
- add_completion_test("World2 * w; w.world2.world.")
- add_completion_test("""@implementation World2
- - (World*) world2
- {
- [self """)
- add_completion_test("""@implementation World2
- - (World*) world2
- {
- self.""")
-
- add_completion_test("World3 *w; w.")
- add_completion_test("World3 *w; [w ")
- add_completion_test("World3 *w; w->")
- add_completion_test("World *w; w.")
- add_completion_test("World *w; w->")
- add_completion_test("World *w; w.world.")
- add_completion_test("World *w; w.world->")
- add_completion_test("World *w; w->worldVar.")
- add_completion_test("World *w; w->worldVar->")
-
- data = read_file("unittests/8.mm")
- add_completion_test(data[:data.rfind(".")+1])
- add_completion_test("""@implementation World3
- - (void) something
- {
- """, True)
-
- add_completion_test("""@implementation World4
- - (void) myworld
- {
- """, True)
- add_completion_test("World4 *w; w.")
- add_completion_test("World4 *w; w->")
- add_completion_test("World4 *w; [w ")
-
- add_completion_test("World5 *w; [w ")
-
- # ---------------------------------------------------------
-
-
- tu = get_tu("unittests/9.mm")
- add_completion_test("[NSString ", True, True)
- add_completion_test("NSString *s; [s ", True, True)
-
- add_completion_test("[NSMutableData ", True, True)
- add_completion_test("NSMutableData *s; [s ", True, True)
-
- add_completion_test("Test t; [t.", True, True)
- add_completion_test("Test t; [t.context ", True, True)
+ if platform.system() == "Darwin":
+
+ opts = [
+ "-isysroot",
+ "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/",
+ "-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks",
+ "-ICocoa"]
+ tu = get_tu("unittests/8.mm")
+ add_completion_test(" ", True)
+ add_completion_test("[Hello ")
+ add_completion_test("Hello * h; [h ")
+ add_completion_test("World * w; [w ")
+ add_completion_test("World * w; [[w world] ")
+ add_completion_test("World * w; [[w blah] ")
+ add_completion_test("World2 * w; [[w world2] ")
+ add_completion_test("World2 * w; [[[w world2] world] ")
+ add_completion_test("World2 * w; w.")
+ add_completion_test("World2 * w; w.world2.")
+ add_completion_test("World2 * w; w.world2.world.")
+ add_completion_test("""@implementation World2
+ - (World*) world2
+ {
+ [self """)
+ add_completion_test("""@implementation World2
+ - (World*) world2
+ {
+ self.""")
+
+ add_completion_test("World3 *w; w.")
+ add_completion_test("World3 *w; [w ")
+ add_completion_test("World3 *w; w->")
+ add_completion_test("World *w; w.")
+ add_completion_test("World *w; w->")
+ add_completion_test("World *w; w.world.")
+ add_completion_test("World *w; w.world->")
+ add_completion_test("World *w; w->worldVar.")
+ add_completion_test("World *w; w->worldVar->")
+
+ data = read_file("unittests/8.mm")
+ add_completion_test(data[:data.rfind(".")+1])
+ add_completion_test("""@implementation World3
+ - (void) something
+ {
+ """, True)
+
+ add_completion_test("""@implementation World4
+ - (void) myworld
+ {
+ """, True)
+ add_completion_test("World4 *w; w.")
+ add_completion_test("World4 *w; w->")
+ add_completion_test("World4 *w; [w ")
+
+ add_completion_test("World5 *w; [w ")
+
+ # ---------------------------------------------------------
+
+
+ tu = get_tu("unittests/9.mm")
+ add_completion_test("[NSString ", True, True)
+ add_completion_test("NSString *s; [s ", True, True)
+
+ add_completion_test("[NSMutableData ", True, True)
+ add_completion_test("NSMutableData *s; [s ", True, True)
+
+ add_completion_test("Test t; [t.", True, True)
+ add_completion_test("Test t; [t.context ", True, True)
# ---------------------------------------------------------

0 comments on commit 364f48e

Please sign in to comment.
Something went wrong with that request. Please try again.