From a3da0edf1edb197a7fe8e2a05b7ce648dc43bbf9 Mon Sep 17 00:00:00 2001 From: mlangkabel Date: Mon, 3 Dec 2018 12:10:46 +0100 Subject: [PATCH] add support for appveyor builds (32 bit windows only) --- README.md | 4 +- appveyor.yml | 59 ++++++++++++++++++++++++++++ bindings_python/CMakeLists.txt | 27 +++++++++---- resources_swig/src/sourcetraildb.cpp | 58 +++++++++++++-------------- 4 files changed, 110 insertions(+), 38 deletions(-) create mode 100644 appveyor.yml diff --git a/README.md b/README.md index 73f3a92..9e8ba75 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # SourcetrailDBWriter +[![Build status](https://ci.appveyor.com/api/projects/status/gbblx1l790vm952c/branch/master?svg=true)](https://ci.appveyor.com/project/mlangkabel/sourcetraildb/branch/master) + + TODO: write short description here with code example and sourcetrail screenshorts of resulting graph @@ -30,7 +33,6 @@ TODO: write short description here with code example and sourcetrail screenshort * rename NodeType::NODE_SYMBOL to UNKNOWN * versioning in package name: lalala_v1_db21_c684 -* add own license info as license file to repo * add license info to source files * add 3rd party license references * debug vs release (may need to disable something in cmake) diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..7ec4029 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,59 @@ +version: 0.0.0.{build} +image: Visual Studio 2017 + +# TODO use "Visual Studio 15 2017 Win64" for 64 bit builds + +artifacts: + - path: artifacts_core + name: sourcetraildb_core_windows_32bit_$(appveyor_build_version) + type: Zip + - path: artifacts_bindings_python + name: sourcetrailbd_python_windows_32bit_$(appveyor_build_version) + type: Zip + +install: + - ps: | + # Install SWIG by Choco + choco install -y --no-progress swig + +before_build: + # Setup core project + - cd core + - mkdir build + - cd build + - mkdir 32bit + - cd 32bit + - cmake -G "Visual Studio 15 2017" ../.. + - cd ../../.. + # Setup bindings_python project + - cd bindings_python + - mkdir build + - cd build + - mkdir 32bit + - cd 32bit + - cmake -G "Visual Studio 15 2017" ../.. -DPYTHON_INCLUDE_DIRS="C:/Python37/include" -DPYTHON_LIBRARIES="C:/Python37/libs/python37.lib" + - cd ../../.. + +build_script: + - cd core/build/32bit + - msbuild /p:configuration=Release /v:m ALL_BUILD.vcxproj + - cd ../../.. + - cd bindings_python/build/32bit + - msbuild /p:configuration=Release /v:m ALL_BUILD.vcxproj + - cd ../../.. + +after_build: + - mkdir artifacts_core + - cd artifacts_core + - mkdir lib + - mkdir include + - cd .. + - ps: | + copy core/build/32bit/release/sourcetraildb.lib artifacts_core/lib/ + copy core/build/32bit/include/version.h artifacts_core/include/ + copy core/include/* artifacts_core/include/ + - mkdir artifacts_bindings_python + - ps: | + copy bindings_python/build/32bit/release/_sourcetraildb.pyd artifacts_bindings_python/ + copy bindings_python/build/32bit/release/sourcetraildb.py artifacts_bindings_python/ + - echo All done! diff --git a/bindings_python/CMakeLists.txt b/bindings_python/CMakeLists.txt index 4ee5a6f..fa6eec5 100644 --- a/bindings_python/CMakeLists.txt +++ b/bindings_python/CMakeLists.txt @@ -45,6 +45,21 @@ message(STATUS "Found Python include dirs: ${PYTHON_INCLUDE_DIRS}") message(STATUS "Found Python libraries: ${PYTHON_LIBRARIES}") +# --- Find Core --- + +if (NOT EXISTS "${CORE_INCLUDE_DIRS}") + message(STATUS "Core include dir \"${CORE_INCLUDE_DIRS}\" does not exist, trying to find Core automatically.") + set(CORE_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/../core/include" CACHE FILEPATH "path to core include directory") + message(STATUS "Set Core include dir to \"${CORE_INCLUDE_DIRS}\".") +endif () + +if (NOT EXISTS "${CORE_LIBRARIES}") + message(STATUS "Core library \"${CORE_LIBRARIES}\" does not exist, trying to find Core automatically.") + set(CORE_LIBRARIES "${CMAKE_SOURCE_DIR}/../core/build/${ARCH}bit/Release/sourcetraildb.lib" CACHE FILEPATH "path to core library directory") + message(STATUS "Set Core library to \"${CORE_LIBRARIES}\".") +endif () + + # --- Setup Paths --- set(RESOURCES_SWIG_DIR "${CMAKE_SOURCE_DIR}/../resources_swig") @@ -53,9 +68,6 @@ set(GENERATED_SRC_DIR "${CMAKE_BINARY_DIR}/src") set(SWIG_INTERFACE_FILE "${RESOURCES_SWIG_DIR}/interface/${PACKAGE_NAME}.i") set(GENERATED_WRAPPER_FILE "${GENERATED_SRC_DIR}/${PACKAGE_NAME}_wrap.cxx") -set(CORE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../core/include" CACHE FILEPATH "path to core include directory") -set(CORE_DEBUG_LIBRARY "${CMAKE_SOURCE_DIR}/../core/build/${ARCH}bit/Debug/sourcetraildb.lib" CACHE FILEPATH "path to core library directory") -set(CORE_RELEASE_LIBRARY "${CMAKE_SOURCE_DIR}/../core/build/${ARCH}bit/Release/sourcetraildb.lib" CACHE FILEPATH "path to core library directory") if (WIN32) file(WRITE ${GENERATED_WRAPPER_FILE} "") @@ -80,18 +92,17 @@ set_target_properties(${LIB_NAME} PROPERTIES SUFFIX ".pyd") add_custom_command( TARGET ${LIB_NAME} PRE_BUILD - COMMAND if not exist \"${GENERATED_SRC_DIR}\" mkdir \"${GENERATED_SRC_DIR}\" \n $ENV{SWIG_DIR}/swig.exe -c++ -python -I${RESOURCES_SWIG_DIR}/include -o ${GENERATED_WRAPPER_FILE} -outdir ${CMAKE_BINARY_DIR}/$(CONFIGURATION) ${SWIG_INTERFACE_FILE} + COMMAND if not exist \"${GENERATED_SRC_DIR}\" mkdir \"${GENERATED_SRC_DIR}\" \n swig -c++ -python -I${RESOURCES_SWIG_DIR}/include -o ${GENERATED_WRAPPER_FILE} -outdir ${CMAKE_BINARY_DIR}/$(CONFIGURATION) ${SWIG_INTERFACE_FILE} COMMENT "Generating wrapper code file." ) target_include_directories(${LIB_NAME} PUBLIC "${RESOURCES_SWIG_DIR}/include" - "${CORE_INCLUDE_DIR}" + "${CORE_INCLUDE_DIRS}" ${PYTHON_INCLUDE_DIRS} ) -message("CORE_RELEASE_LIBRARY: ${CORE_RELEASE_LIBRARY}") +message("CORE_RELEASE_LIBRARY: ${CORE_LIBRARIES}") target_link_libraries(${LIB_NAME} ${PYTHON_LIBRARIES}) -target_link_libraries(${LIB_NAME} debug "${CORE_DEBUG_LIBRARY}" ) -target_link_libraries(${LIB_NAME} optimized "${CORE_RELEASE_LIBRARY}" ) +target_link_libraries(${LIB_NAME} ${CORE_LIBRARIES}) diff --git a/resources_swig/src/sourcetraildb.cpp b/resources_swig/src/sourcetraildb.cpp index a20daec..cbb9c6e 100644 --- a/resources_swig/src/sourcetraildb.cpp +++ b/resources_swig/src/sourcetraildb.cpp @@ -5,9 +5,9 @@ #include "SymbolKind.h" #include "SourceLocation.h" #include "SourceRange.h" +#include "SourcetrailDBWriter.h" #include "ReferenceKind.h" -#include "SrctrldbWriter.h" namespace { @@ -71,71 +71,71 @@ namespace } } -sourcetrail::SrctrldbWriter srctrldbWriter; +sourcetrail::SourcetrailDBWriter dbWriter; int getSupportedDatabaseVersion() { - return srctrldbWriter.getSupportedDatabaseVersion(); + return dbWriter.getSupportedDatabaseVersion(); } std::string getLastError() { - return srctrldbWriter.getLastError(); + return dbWriter.getLastError(); } void clearLastError() { - srctrldbWriter.clearLastError(); + dbWriter.clearLastError(); } bool openProject(std::string projectDirectory, std::string projectName) { - return srctrldbWriter.openProject(projectDirectory, projectName); + return dbWriter.openProject(projectDirectory, projectName); } bool closeProject() { - return srctrldbWriter.closeProject(); + return dbWriter.closeProject(); } bool clearProject() { - return srctrldbWriter.clearProject(); + return dbWriter.clearProject(); } bool isEmpty() { - return srctrldbWriter.isEmpty(); + return dbWriter.isEmpty(); } bool isCompatible() { - return srctrldbWriter.isCompatible(); + return dbWriter.isCompatible(); } int getLoadedDatabaseVersion() { - return srctrldbWriter.getLoadedDatabaseVersion(); + return dbWriter.getLoadedDatabaseVersion(); } bool beginTransaction() { - return srctrldbWriter.beginTransaction(); + return dbWriter.beginTransaction(); } bool commitTransaction() { - return srctrldbWriter.commitTransaction(); + return dbWriter.commitTransaction(); } bool rollbackTransaction() { - return srctrldbWriter.rollbackTransaction(); + return dbWriter.rollbackTransaction(); } bool optimizeDatabaseMemory() { - return srctrldbWriter.optimizeDatabaseMemory(); + return dbWriter.optimizeDatabaseMemory(); } int recordSymbol(std::string serializedNameHierarchy) @@ -144,68 +144,68 @@ int recordSymbol(std::string serializedNameHierarchy) if (nameHierarchy.nameElements.empty()) { // TODO: handle this case! - //srctrldbWriter.setLastError("Unable to deserialize name hierarchy \"" + serializedNameHierarchy + "\"."); + //dbWriter.setLastError("Unable to deserialize name hierarchy \"" + serializedNameHierarchy + "\"."); return 0; } - return srctrldbWriter.recordSymbol(nameHierarchy); + return dbWriter.recordSymbol(nameHierarchy); } bool recordSymbolDefinitionKind(int symbolId, DefinitionKind symbolDefinitionKind) { - return srctrldbWriter.recordSymbolDefinitionKind(symbolId, convertDefinitionKind(symbolDefinitionKind)); + return dbWriter.recordSymbolDefinitionKind(symbolId, convertDefinitionKind(symbolDefinitionKind)); } bool recordSymbolKind(int symbolId, SymbolKind symbolKind) { - return srctrldbWriter.recordSymbolKind(symbolId, convertSymbolKind(symbolKind)); + return dbWriter.recordSymbolKind(symbolId, convertSymbolKind(symbolKind)); } bool recordSymbolLocation(int symbolId, std::string filePath, int startLine, int startColumn, int endLine, int endColumn) { - return srctrldbWriter.recordSymbolLocation(symbolId, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); + return dbWriter.recordSymbolLocation(symbolId, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); } bool recordSymbolScopeLocation(int symbolId, std::string filePath, int startLine, int startColumn, int endLine, int endColumn) { - return srctrldbWriter.recordSymbolScopeLocation(symbolId, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); + return dbWriter.recordSymbolScopeLocation(symbolId, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); } bool recordSymbolSignatureLocation(int symbolId, std::string filePath, int startLine, int startColumn, int endLine, int endColumn) { - return srctrldbWriter.recordSymbolSignatureLocation(symbolId, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); + return dbWriter.recordSymbolSignatureLocation(symbolId, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); } int recordReference(int contextSymbolId, int referencedSymbolId, ReferenceKind referenceKind) { - return srctrldbWriter.recordReference(contextSymbolId, referencedSymbolId, convertReferenceKind(referenceKind)); + return dbWriter.recordReference(contextSymbolId, referencedSymbolId, convertReferenceKind(referenceKind)); } bool recordReferenceLocation(int referenceId, std::string filePath, int startLine, int startColumn, int endLine, int endColumn) { - return srctrldbWriter.recordReferenceLocation(referenceId, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); + return dbWriter.recordReferenceLocation(referenceId, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); } int recordFile(std::string filePath) { - return srctrldbWriter.recordFile(filePath); + return dbWriter.recordFile(filePath); } int recordLocalSymbol(std::string name) { - return srctrldbWriter.recordLocalSymbol(name); + return dbWriter.recordLocalSymbol(name); } bool recordLocalSymbolLocation(int localSymbolId, std::string filePath, int startLine, int startColumn, int endLine, int endColumn) { - return srctrldbWriter.recordLocalSymbolLocation(localSymbolId, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); + return dbWriter.recordLocalSymbolLocation(localSymbolId, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); } bool recordCommentLocation(std::string filePath, int startLine, int startColumn, int endLine, int endColumn) { - return srctrldbWriter.recordCommentLocation(sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); + return dbWriter.recordCommentLocation(sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); } bool recordError(std::string message, bool fatal, std::string filePath, int startLine, int startColumn, int endLine, int endColumn) { - return srctrldbWriter.recordError(message, fatal, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); + return dbWriter.recordError(message, fatal, sourcetrail::SourceRange({ filePath, startLine, startColumn, endLine, endColumn })); }