Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70092378c2 | ||
|
|
f76c1773ae | ||
|
|
997a0ff1e7 | ||
|
|
f0a143a85e | ||
|
|
7b7c6f4794 | ||
|
|
9ad9fd8980 | ||
|
|
6ad1b1ce52 | ||
|
|
4750791a6a | ||
|
|
6894f9b608 | ||
|
|
c23dbfb9f9 | ||
|
|
47fd6af759 | ||
|
|
351399ee9e | ||
|
|
86b5efbd76 | ||
|
|
b0c43ce94f | ||
|
|
c28260a0fa | ||
|
|
b6a92d0825 | ||
|
|
cd0f4e8fc0 | ||
|
|
146487b760 | ||
|
|
197e127035 | ||
|
|
ecfa1b7920 | ||
|
|
093261232c | ||
|
|
fd05f0fbc5 |
@@ -26,6 +26,7 @@ build-*
|
||||
.DS_Store
|
||||
.idea
|
||||
.vscode
|
||||
__pycache__
|
||||
|
||||
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailExtension/bin
|
||||
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailExtension/obj
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "submodules/SourcetrailPythonIndexer"]
|
||||
path = submodules/SourcetrailPythonIndexer
|
||||
url = https://github.com/CoatiSoftware/SourcetrailPythonIndexer.git
|
||||
+44
-6
@@ -482,10 +482,39 @@ else()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
string(REGEX REPLACE "/" "\\\\" BACKSLASHED_CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR})
|
||||
string(REGEX REPLACE "/" "\\\\" BACKSLASHED_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||||
|
||||
|
||||
# Lib Python ---------------------------------------------------------------------
|
||||
|
||||
if (BUILD_PYTHON_LANGUAGE_PACKAGE)
|
||||
|
||||
file (STRINGS "${CMAKE_SOURCE_DIR}/submodules/SourcetrailPythonIndexer/SourcetrailDB/version.txt" VERSION_STRING)
|
||||
|
||||
string(REGEX REPLACE "v([0-9]+)\\..*" "\\1" INTERFACE_VERSION "${VERSION_STRING}")
|
||||
string(REGEX REPLACE "v[0-9]+\\.db([0-9]+)\\..*" "\\1" DATABASE_VERSION "${VERSION_STRING}")
|
||||
string(REGEX REPLACE "v[0-9]+\\.db[0-9]+\\.p([0-9]+).*" "\\1" PATCH_VERSION "${VERSION_STRING}")
|
||||
set(VERSION_STRING_UNDERSCORE "v${INTERFACE_VERSION}_db${DATABASE_VERSION}_p${PATCH_VERSION}")
|
||||
|
||||
message(STATUS "SourcetrailDB Version: ${VERSION_STRING}")
|
||||
message(STATUS "Interface Version: ${INTERFACE_VERSION}")
|
||||
message(STATUS "Database Version: ${DATABASE_VERSION}")
|
||||
message(STATUS "Patch Version: ${PATCH_VERSION}")
|
||||
|
||||
set(LIB_CORE_TARGET_NAME "SourcetrailDB_core_lib")
|
||||
add_subdirectory(
|
||||
"${CMAKE_SOURCE_DIR}/submodules/SourcetrailPythonIndexer/SourcetrailDB/core"
|
||||
"${CMAKE_BINARY_DIR}/SourcetrailPythonIndexer/SourcetrailDB/core")
|
||||
|
||||
set(PYTHON_BINDING_TARGET_NAME "bindings_python")
|
||||
set(PYTHON_BINDING_OUTPUT_DIR "")
|
||||
add_subdirectory(
|
||||
"${CMAKE_SOURCE_DIR}/submodules/SourcetrailPythonIndexer/SourcetrailDB/bindings_python"
|
||||
"${CMAKE_BINARY_DIR}/SourcetrailPythonIndexer/SourcetrailDB/bindings_python")
|
||||
|
||||
|
||||
add_library(${LIB_PYTHON_PROJECT_NAME} ${LIB_PYTHON_FILES})
|
||||
|
||||
create_source_groups(${LIB_PYTHON_FILES})
|
||||
@@ -502,12 +531,24 @@ if (BUILD_PYTHON_LANGUAGE_PACKAGE)
|
||||
#link_directories(${Boost_LIBRARY_DIRS})
|
||||
|
||||
target_link_libraries(${LIB_PYTHON_PROJECT_NAME} ${LIB_UTILITY_PROJECT_NAME} ${LIB_PROJECT_NAME})
|
||||
add_dependencies(${LIB_PYTHON_PROJECT_NAME} _${PYTHON_BINDING_TARGET_NAME})
|
||||
|
||||
string(REGEX REPLACE "\\\\" "/" FORWARDSLASHED_PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_DIR})
|
||||
set(PYTHON_ENVIRONMENT_DIR "${BACKSLASHED_CMAKE_SOURCE_DIR}\\bin\\app\\data\\python\\environment")
|
||||
set(PYTHON_INDEXER_DIR "${BACKSLASHED_CMAKE_SOURCE_DIR}\\bin\\app\\data\\python\\indexer")
|
||||
|
||||
execute_process(
|
||||
COMMAND "cmd.exe" "/k" "rmdir" "/s" "/q" "${PYTHON_ENVIRONMENT_DIR}" & "${PYTHON_INCLUDE_DIR}/../python.exe" "-m" "venv" "--clear" "--copies" "${PYTHON_ENVIRONMENT_DIR}" & "${PYTHON_ENVIRONMENT_DIR}/Scripts/pip" "install" "-r" "${CMAKE_SOURCE_DIR}/submodules/SourcetrailPythonIndexer/requirements.txt" & exit
|
||||
)
|
||||
execute_process(
|
||||
COMMAND "cmd.exe" "/k" "rmdir" "/s" "/q" "${PYTHON_INDEXER_DIR}" & exit
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${LIB_PYTHON_PROJECT_NAME}
|
||||
PRE_BUILD
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/script/download_python_indexer.sh
|
||||
COMMENT "download python indexer"
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/script/update_python_indexer.sh
|
||||
COMMENT "updating python indexer scripts"
|
||||
)
|
||||
|
||||
else()
|
||||
@@ -695,9 +736,6 @@ if (WIN32)
|
||||
TARGET ${APP_PROJECT_NAME}
|
||||
PROPERTY VS_DEBUGGER_WORKING_DIRECTORY
|
||||
"${CMAKE_SOURCE_DIR}/bin/app")
|
||||
|
||||
string(REGEX REPLACE "/" "\\\\" BACKSLASHED_CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR})
|
||||
string(REGEX REPLACE "/" "\\\\" BACKSLASHED_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||||
else ()
|
||||
add_executable(${APP_PROJECT_NAME} ${APP_FILES})
|
||||
endif ()
|
||||
@@ -864,7 +902,7 @@ if (UNIX)
|
||||
COMMAND "${CMAKE_COMMAND}" "-E" "create_symlink" "${CMAKE_SOURCE_DIR}/bin/app/user" "${CMAKE_BINARY_DIR}/app/user"
|
||||
COMMAND "${CMAKE_COMMAND}" "-E" "create_symlink" "${CMAKE_SOURCE_DIR}/bin/test/data" "${CMAKE_BINARY_DIR}/test/data"
|
||||
)
|
||||
elseif(WIN32)
|
||||
elseif (WIN32)
|
||||
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
|
||||
if (EXISTS "${BACKSLASHED_CMAKE_BINARY_DIR}\\${OUTPUTCONFIG}")
|
||||
execute_process(
|
||||
|
||||
+16
-9
@@ -10,16 +10,19 @@ install:
|
||||
- 7z x ninja.zip -oC:\projects\deps\ninja > nul
|
||||
- set PATH=C:\projects\deps\ninja;%PATH%
|
||||
- ninja --version
|
||||
# Install SWIG by Choco
|
||||
- ps: choco install -y --no-progress swig --version 4.0.1
|
||||
|
||||
before_build:
|
||||
- git submodule init
|
||||
- git submodule update
|
||||
- cd submodules/SourcetrailPythonIndexer
|
||||
- git submodule init
|
||||
- git submodule update
|
||||
- cd ../..
|
||||
- mkdir build
|
||||
- cd build
|
||||
- mkdir temp
|
||||
- cd ../
|
||||
- cd script
|
||||
- cmd: "\"C:/Program Files/Git/usr/bin/bash.exe\" download_python_indexer.sh"
|
||||
- cd ../
|
||||
- cd build
|
||||
- mkdir win64
|
||||
- cd win64
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
|
||||
@@ -31,7 +34,11 @@ build_script:
|
||||
- ninja
|
||||
- cd ../../
|
||||
|
||||
test_script:
|
||||
- cd bin/test
|
||||
- ..\..\build\win64\Release\test\Sourcetrail_test.exe
|
||||
- cd ../../
|
||||
artifacts:
|
||||
- path: bin
|
||||
name: bin
|
||||
type: zip
|
||||
- path: build
|
||||
name: build
|
||||
type: zip
|
||||
|
||||
+15
-6
@@ -1,6 +1,15 @@
|
||||
SourceFilePath: "src/a.txt"
|
||||
Custom Command: "echo "Hello World""
|
||||
SourceFilePath: "src/b.txt"
|
||||
Custom Command: "echo "Hello World""
|
||||
SourceFilePath: "src/included/a.txt"
|
||||
Custom Command: "echo "Hello World""
|
||||
IndexerCommandCustom
|
||||
SourceFilePath: "src/a.txt"
|
||||
Custom Command: "echo"
|
||||
Arguments:
|
||||
"Hello World"
|
||||
IndexerCommandCustom
|
||||
SourceFilePath: "src/b.txt"
|
||||
Custom Command: "echo"
|
||||
Arguments:
|
||||
"Hello World"
|
||||
IndexerCommandCustom
|
||||
SourceFilePath: "src/included/a.txt"
|
||||
Custom Command: "echo"
|
||||
Arguments:
|
||||
"Hello World"
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
SOURCETRAIL_PYTHON_INDEXER_VERSION="v1_db25_p5"
|
||||
|
||||
# Determine current platform
|
||||
PLATFORM='unknown'
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
PLATFORM='osx'
|
||||
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
||||
PLATFORM='linux'
|
||||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
|
||||
PLATFORM='windows'
|
||||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
|
||||
PLATFORM='windows'
|
||||
elif [ "$OSTYPE" == "msys" ]; then
|
||||
PLATFORM='windows'
|
||||
fi
|
||||
|
||||
PACKAGE_NAME="SourcetrailPythonIndexer_${SOURCETRAIL_PYTHON_INDEXER_VERSION}-${PLATFORM}"
|
||||
PACKAGE_FILE_NAME="${PACKAGE_NAME}.zip"
|
||||
PACKAGE_URL="https://github.com/CoatiSoftware/SourcetrailPythonIndexer/releases/download/${SOURCETRAIL_PYTHON_INDEXER_VERSION}/${PACKAGE_FILE_NAME}"
|
||||
TEMP_PATH="build/temp"
|
||||
TARGET_PATH="bin/app/data/python"
|
||||
|
||||
|
||||
ABORT="\033[31mAbort:\033[00m"
|
||||
SUCCESS="\033[32mSuccess:\033[00m"
|
||||
INFO="\033[33mInfo:\033[00m"
|
||||
|
||||
if [ $PLATFORM == "windows" ]; then
|
||||
SCRIPT=`realpath $0`
|
||||
if [ "$SCRIPT" == "" ]; then
|
||||
|
||||
ORIGINAL_PATH_TO_SCRIPT="${0}"
|
||||
CLEANED_PATH_TO_SCRIPT="${ORIGINAL_PATH_TO_SCRIPT//\\//}"
|
||||
SCRIPT_DIR=${CLEANED_PATH_TO_SCRIPT%/*}
|
||||
else
|
||||
ORIGINAL_PATH_TO_SCRIPT=`dirname $SCRIPT`
|
||||
SCRIPT_DIR="${ORIGINAL_PATH_TO_SCRIPT//\\//}"
|
||||
fi
|
||||
else
|
||||
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
fi
|
||||
|
||||
echo "This script is running in: $SCRIPT_DIR"
|
||||
|
||||
|
||||
# Enter main directory
|
||||
cd $SCRIPT_DIR/
|
||||
cd ..
|
||||
|
||||
BINARY_PATH="$TARGET_PATH/SourcetrailPythonIndexer"
|
||||
if [ $PLATFORM == "windows" ]; then
|
||||
BINARY_PATH="${BINARY_PATH}.exe"
|
||||
fi
|
||||
|
||||
if [ -e "${BINARY_PATH}" ]; then
|
||||
echo -e $INFO "SourcetrailPythonIndexer already exists, checking version..."
|
||||
|
||||
INSTALLED_VERSION="$(${BINARY_PATH} --version)"
|
||||
INSTALLED_VERSION=${INSTALLED_VERSION#* }
|
||||
INSTALLED_VERSION="${INSTALLED_VERSION//./$'_'}"
|
||||
|
||||
if [ "$INSTALLED_VERSION" == "$SOURCETRAIL_PYTHON_INDEXER_VERSION" ]; then
|
||||
echo -e $INFO "Nothing to update. Target version of SourcetrailPythonIndexer is already installed."
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p $TEMP_PATH
|
||||
|
||||
echo -e $INFO "starting to download $PACKAGE_FILE_NAME"
|
||||
|
||||
if [ $PLATFORM == "linux" ]; then
|
||||
wget -O $TEMP_PATH/$PACKAGE_FILE_NAME $PACKAGE_URL
|
||||
elif [ $PLATFORM == "osx" ]; then
|
||||
wget -O $TEMP_PATH/$PACKAGE_FILE_NAME $PACKAGE_URL
|
||||
elif [ $PLATFORM == "windows" ]; then
|
||||
certutil.exe -urlcache -split -f $PACKAGE_URL $TEMP_PATH/$PACKAGE_FILE_NAME
|
||||
fi
|
||||
|
||||
echo -e $INFO "finished downloading $PACKAGE_FILE_NAME"
|
||||
|
||||
|
||||
if [ $PLATFORM == "linux" ]; then
|
||||
unzip -d $TEMP_PATH $TEMP_PATH/$PACKAGE_FILE_NAME
|
||||
elif [ $PLATFORM == "osx" ]; then
|
||||
unzip -d $TEMP_PATH $TEMP_PATH/$PACKAGE_FILE_NAME
|
||||
elif [ $PLATFORM == "windows" ]; then
|
||||
7z x $TEMP_PATH/$PACKAGE_FILE_NAME -o$TEMP_PATH
|
||||
fi
|
||||
|
||||
|
||||
echo -e $INFO "clearing $TARGET_PATH"
|
||||
rm -rf $TARGET_PATH
|
||||
mkdir -p $TARGET_PATH
|
||||
cp -r $TEMP_PATH/$PACKAGE_NAME/* $TARGET_PATH
|
||||
|
||||
|
||||
echo -e $INFO "clearing temporary data at $TEMP_PATH"
|
||||
rm -rf $TEMP_PATH
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Determine current platform
|
||||
PLATFORM='unknown'
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
PLATFORM='osx'
|
||||
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
||||
PLATFORM='linux'
|
||||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
|
||||
PLATFORM='windows'
|
||||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
|
||||
PLATFORM='windows'
|
||||
elif [ "$OSTYPE" == "msys" ]; then
|
||||
PLATFORM='windows'
|
||||
fi
|
||||
|
||||
INPUT_DIR="submodules/SourcetrailPythonIndexer"
|
||||
OUTPUT_DIR="bin/app/data/python/indexer"
|
||||
|
||||
ABORT="\033[31mAbort:\033[00m"
|
||||
SUCCESS="\033[32mSuccess:\033[00m"
|
||||
INFO="\033[33mInfo:\033[00m"
|
||||
|
||||
if [ $PLATFORM == "windows" ]; then
|
||||
SCRIPT=`realpath $0`
|
||||
if [ "$SCRIPT" == "" ]; then
|
||||
|
||||
ORIGINAL_PATH_TO_SCRIPT="${0}"
|
||||
CLEANED_PATH_TO_SCRIPT="${ORIGINAL_PATH_TO_SCRIPT//\\//}"
|
||||
SCRIPT_DIR=${CLEANED_PATH_TO_SCRIPT%/*}
|
||||
else
|
||||
ORIGINAL_PATH_TO_SCRIPT=`dirname $SCRIPT`
|
||||
SCRIPT_DIR="${ORIGINAL_PATH_TO_SCRIPT//\\//}"
|
||||
fi
|
||||
else
|
||||
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
fi
|
||||
|
||||
echo "This script is running in: $SCRIPT_DIR"
|
||||
|
||||
# Enter main directory
|
||||
cd $SCRIPT_DIR/
|
||||
cd ..
|
||||
|
||||
echo "create $OUTPUT_DIR"
|
||||
if [ $PLATFORM == "windows" ]; then
|
||||
mkdir "$OUTPUT_DIR"
|
||||
dir
|
||||
mkdir bin
|
||||
cd bin
|
||||
mkdir app
|
||||
cd app
|
||||
mkdir data
|
||||
cd data
|
||||
mkdir python
|
||||
cd python
|
||||
dir
|
||||
mkdir indexer
|
||||
cd ../../../../
|
||||
else
|
||||
mkdir -p $OUTPUT_DIR
|
||||
fi
|
||||
|
||||
echo "Copy python indexer files to $OUTPUT_DIR"
|
||||
cp $INPUT_DIR/_version.py $OUTPUT_DIR
|
||||
cp $INPUT_DIR/run.py $OUTPUT_DIR
|
||||
cp $INPUT_DIR/indexer.py $OUTPUT_DIR
|
||||
cp $INPUT_DIR/shallow_indexer.py $OUTPUT_DIR
|
||||
|
||||
echo "Done updating Python indexer"
|
||||
@@ -37,12 +37,22 @@ FilePath ResourcePaths::getJavaPath()
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/java/");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getPythonPath()
|
||||
FilePath ResourcePaths::getPythonEnvironmentFilePath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/python/");
|
||||
return ResourcePaths::getPythonPath().concatenate(L"environment/Scripts/python");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getPythonIndexerFilePath()
|
||||
{
|
||||
return ResourcePaths::getPythonPath().concatenate(L"indexer/run.py");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getCxxCompilerHeaderPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/cxx/include/").getCanonical();
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getPythonPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/python/");
|
||||
}
|
||||
|
||||
@@ -15,8 +15,12 @@ public:
|
||||
static FilePath getGuiPath();
|
||||
static FilePath getLicensePath();
|
||||
static FilePath getJavaPath();
|
||||
static FilePath getPythonPath();
|
||||
static FilePath getPythonEnvironmentFilePath();
|
||||
static FilePath getPythonIndexerFilePath();
|
||||
static FilePath getCxxCompilerHeaderPath();
|
||||
|
||||
private:
|
||||
static FilePath getPythonPath();
|
||||
};
|
||||
|
||||
#endif // RESOURCE_PATHS_H
|
||||
|
||||
@@ -11,7 +11,8 @@ IndexerCommandType IndexerCommandCustom::getStaticIndexerCommandType()
|
||||
}
|
||||
|
||||
IndexerCommandCustom::IndexerCommandCustom(
|
||||
const std::wstring& customCommand,
|
||||
const std::wstring& command,
|
||||
const std::vector<std::wstring>& arguments,
|
||||
const FilePath& projectFilePath,
|
||||
const FilePath& databaseFilePath,
|
||||
const std::wstring& databaseVersion,
|
||||
@@ -19,7 +20,8 @@ IndexerCommandCustom::IndexerCommandCustom(
|
||||
bool runInParallel)
|
||||
: IndexerCommand(sourceFilePath)
|
||||
, m_type(getStaticIndexerCommandType())
|
||||
, m_customCommand(customCommand)
|
||||
, m_command(command)
|
||||
, m_arguments(arguments)
|
||||
, m_projectFilePath(projectFilePath)
|
||||
, m_databaseFilePath(databaseFilePath)
|
||||
, m_databaseVersion(databaseVersion)
|
||||
@@ -29,7 +31,8 @@ IndexerCommandCustom::IndexerCommandCustom(
|
||||
|
||||
IndexerCommandCustom::IndexerCommandCustom(
|
||||
IndexerCommandType type,
|
||||
const std::wstring& customCommand,
|
||||
const std::wstring& command,
|
||||
const std::vector<std::wstring>& arguments,
|
||||
const FilePath& projectFilePath,
|
||||
const FilePath& databaseFilePath,
|
||||
const std::wstring& databaseVersion,
|
||||
@@ -37,7 +40,8 @@ IndexerCommandCustom::IndexerCommandCustom(
|
||||
bool runInParallel)
|
||||
: IndexerCommand(sourceFilePath)
|
||||
, m_type(type)
|
||||
, m_customCommand(customCommand)
|
||||
, m_command(command)
|
||||
, m_arguments(arguments)
|
||||
, m_projectFilePath(projectFilePath)
|
||||
, m_databaseFilePath(databaseFilePath)
|
||||
, m_databaseVersion(databaseVersion)
|
||||
@@ -67,19 +71,19 @@ void IndexerCommandCustom::setDatabaseFilePath(const FilePath& databaseFilePath)
|
||||
m_databaseFilePath = databaseFilePath;
|
||||
}
|
||||
|
||||
std::wstring IndexerCommandCustom::getCustomCommand() const
|
||||
std::wstring IndexerCommandCustom::getCommand() const
|
||||
{
|
||||
std::wstring command = m_customCommand;
|
||||
return replaceVariables(m_command);
|
||||
}
|
||||
|
||||
command = utility::replace(
|
||||
command, L"%{PROJECT_FILE_PATH}", L'\"' + m_projectFilePath.wstr() + L'\"');
|
||||
command = utility::replace(
|
||||
command, L"%{DATABASE_FILE_PATH}", L'\"' + m_databaseFilePath.wstr() + L'\"');
|
||||
command = utility::replace(command, L"%{DATABASE_VERSION}", L'\"' + m_databaseVersion + L'\"');
|
||||
command = utility::replace(
|
||||
command, L"%{SOURCE_FILE_PATH}", L'\"' + getSourceFilePath().wstr() + L'\"');
|
||||
|
||||
return command;
|
||||
std::vector<std::wstring> IndexerCommandCustom::getArguments() const
|
||||
{
|
||||
std::vector<std::wstring> args;
|
||||
for (const std::wstring& argument: m_arguments)
|
||||
{
|
||||
args.push_back(replaceVariables(argument));
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
bool IndexerCommandCustom::getRunInParallel() const
|
||||
@@ -92,7 +96,15 @@ QJsonObject IndexerCommandCustom::doSerialize() const
|
||||
QJsonObject jsonObject = IndexerCommand::doSerialize();
|
||||
|
||||
{
|
||||
jsonObject["custom_command"] = QString::fromStdWString(m_customCommand);
|
||||
jsonObject["command"] = QString::fromStdWString(m_command);
|
||||
}
|
||||
{
|
||||
QJsonArray argumentsArray;
|
||||
for (const std::wstring& argument: m_arguments)
|
||||
{
|
||||
argumentsArray.append(QString::fromStdWString(argument));
|
||||
}
|
||||
jsonObject["arguments"] = argumentsArray;
|
||||
}
|
||||
{
|
||||
jsonObject["run_in_parallel"] = m_runInParallel;
|
||||
@@ -100,3 +112,12 @@ QJsonObject IndexerCommandCustom::doSerialize() const
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
std::wstring IndexerCommandCustom::replaceVariables(std::wstring s) const
|
||||
{
|
||||
s = utility::replace(s, L"%{PROJECT_FILE_PATH}", m_projectFilePath.wstr());
|
||||
s = utility::replace(s, L"%{DATABASE_FILE_PATH}", m_databaseFilePath.wstr());
|
||||
s = utility::replace(s, L"%{DATABASE_VERSION}", m_databaseVersion);
|
||||
s = utility::replace(s, L"%{SOURCE_FILE_PATH}", getSourceFilePath().wstr());
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ public:
|
||||
static IndexerCommandType getStaticIndexerCommandType();
|
||||
|
||||
IndexerCommandCustom(
|
||||
const std::wstring& customCommand,
|
||||
const std::wstring& command,
|
||||
const std::vector<std::wstring>& arguments,
|
||||
const FilePath& projectFilePath,
|
||||
const FilePath& databaseFilePath,
|
||||
const std::wstring& databaseVersion,
|
||||
@@ -21,7 +22,8 @@ public:
|
||||
|
||||
IndexerCommandCustom(
|
||||
IndexerCommandType type,
|
||||
const std::wstring& customCommand,
|
||||
const std::wstring& command,
|
||||
const std::vector<std::wstring>& arguments,
|
||||
const FilePath& projectFilePath,
|
||||
const FilePath& databaseFilePath,
|
||||
const std::wstring& databaseVersion,
|
||||
@@ -34,15 +36,19 @@ public:
|
||||
FilePath getDatabaseFilePath() const;
|
||||
void setDatabaseFilePath(const FilePath& databaseFilePath);
|
||||
|
||||
std::wstring getCustomCommand() const;
|
||||
std::wstring getCommand() const;
|
||||
std::vector<std::wstring> getArguments() const;
|
||||
bool getRunInParallel() const;
|
||||
|
||||
protected:
|
||||
QJsonObject doSerialize() const override;
|
||||
|
||||
private:
|
||||
std::wstring replaceVariables(std::wstring s) const;
|
||||
|
||||
IndexerCommandType m_type;
|
||||
std::wstring m_customCommand;
|
||||
std::wstring m_command;
|
||||
std::vector<std::wstring> m_arguments;
|
||||
FilePath m_projectFilePath;
|
||||
FilePath m_databaseFilePath;
|
||||
std::wstring m_databaseVersion;
|
||||
|
||||
@@ -465,9 +465,12 @@ void TaskExecuteCustomCommands::runIndexerCommand(
|
||||
indexedSourceFileCount + 1, indexedSourceFileCount, m_indexerCommandCount, {sourcePath});
|
||||
MessageIndexingStatus(true, indexedSourceFileCount * 100 / m_indexerCommandCount).dispatch();
|
||||
|
||||
const std::wstring command = indexerCommand->getCustomCommand();
|
||||
const std::wstring command = indexerCommand->getCommand();
|
||||
const std::vector<std::wstring> arguments = indexerCommand->getArguments();
|
||||
|
||||
LOG_INFO("Start processing command \"" + utility::encodeToUtf8(command) + "\"");
|
||||
LOG_INFO(
|
||||
"Start processing command \"" +
|
||||
utility::encodeToUtf8(command + L" " + utility::join(arguments, L" ")) + "\"");
|
||||
|
||||
const ErrorCountInfo previousErrorCount = storage ? storage->getErrorCount()
|
||||
: ErrorCountInfo();
|
||||
@@ -475,7 +478,7 @@ void TaskExecuteCustomCommands::runIndexerCommand(
|
||||
LOG_INFO("Starting to index");
|
||||
std::wstring errorMessage;
|
||||
const int result = utility::executeProcessAndGetExitCode(
|
||||
command, {}, m_projectDirectory, -1, true, &errorMessage);
|
||||
command, arguments, m_projectDirectory, -1, true, &errorMessage);
|
||||
LOG_INFO("Finished indexing");
|
||||
|
||||
if (storage)
|
||||
@@ -508,8 +511,9 @@ void TaskExecuteCustomCommands::runIndexerCommand(
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring statusText = L"command \"" + indexerCommand->getCustomCommand() +
|
||||
L"\" returned";
|
||||
std::wstring statusText = L"command \"" + indexerCommand->getCommand() + L" " +
|
||||
utility::join(arguments, L" ") + L"\" returned";
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
statusText += L" code \"" + std::to_wstring(result) + L"\"";
|
||||
|
||||
@@ -42,7 +42,67 @@ std::set<FilePath> SourceGroupCustomCommand::getAllSourceFilePaths() const
|
||||
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCustomCommand::getIndexerCommands(
|
||||
const RefreshInfo& info) const
|
||||
{
|
||||
std::vector<std::wstring> parts;
|
||||
{
|
||||
const std::wstring customCommand = m_settings->getCustomCommand();
|
||||
|
||||
std::wstring tmp;
|
||||
int quoteCount = 0;
|
||||
bool inQuote = false;
|
||||
// handle quoting. tokens can be surrounded by double quotes
|
||||
// "hello world". three consecutive double quotes represent
|
||||
// the quote character itself.
|
||||
for (int i = 0; i < customCommand.size(); ++i)
|
||||
{
|
||||
if (customCommand.at(i) == L'"')
|
||||
{
|
||||
++quoteCount;
|
||||
if (quoteCount == 3) // third consecutive quote
|
||||
{
|
||||
quoteCount = 0;
|
||||
tmp += customCommand.at(i);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (quoteCount)
|
||||
{
|
||||
if (quoteCount == 1)
|
||||
{
|
||||
inQuote = !inQuote;
|
||||
}
|
||||
quoteCount = 0;
|
||||
}
|
||||
if (!inQuote && customCommand.at(i) == L' ')
|
||||
{
|
||||
if (!tmp.empty())
|
||||
{
|
||||
parts.push_back(tmp);
|
||||
tmp.clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp += customCommand.at(i);
|
||||
}
|
||||
}
|
||||
if (!tmp.empty())
|
||||
{
|
||||
parts.push_back(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (parts.empty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::wstring command = parts.front();
|
||||
std::vector<std::wstring> args;
|
||||
for (size_t i = 1; i < parts.size(); i++)
|
||||
{
|
||||
args.push_back(parts[i]);
|
||||
}
|
||||
|
||||
const bool runInParallel = m_settings->getRunInParallel();
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
@@ -51,7 +111,8 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCustomCommand::getIndexe
|
||||
if (info.filesToIndex.find(sourcePath) != info.filesToIndex.end())
|
||||
{
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCustom>(
|
||||
customCommand,
|
||||
command,
|
||||
args,
|
||||
m_settings->getProjectSettings()->getProjectFilePath(),
|
||||
m_settings->getProjectSettings()->getTempDBFilePath(),
|
||||
std::to_wstring(SqliteIndexStorage::getStorageVersion()),
|
||||
|
||||
@@ -25,8 +25,9 @@ void QtProjectWizardContentSelect::populate(QGridLayout* layout, int& row)
|
||||
std::string pythonIndexerVersion = " ";
|
||||
{
|
||||
std::string str = utility::executeProcess(
|
||||
ResourcePaths::getPythonPath().wstr().append(L"SourcetrailPythonIndexer"),
|
||||
std::vector<std::wstring>{L"--version"},
|
||||
ResourcePaths::getPythonEnvironmentFilePath().wstr(),
|
||||
std::vector<std::wstring> {
|
||||
ResourcePaths::getPythonIndexerFilePath().wstr(), L"--version"},
|
||||
FilePath(),
|
||||
5000)
|
||||
.second;
|
||||
|
||||
+6
-5
@@ -63,13 +63,14 @@ void QtProjectWizardContentPathPythonEnvironment::onTextChanged(const QString& t
|
||||
m_resultLabel->setText("Checking validity of Python environment...");
|
||||
std::thread([=]() {
|
||||
std::pair<int, std::string> out = utility::executeProcess(
|
||||
ResourcePaths::getPythonPath().wstr().append(L"SourcetrailPythonIndexer"),
|
||||
std::vector<std::wstring>{
|
||||
ResourcePaths::getPythonEnvironmentFilePath().wstr(),
|
||||
std::vector<std::wstring> {
|
||||
ResourcePaths::getPythonIndexerFilePath().wstr(),
|
||||
L"check-environment",
|
||||
L"--environment-path " + utility::getExpandedAndAbsolutePath(
|
||||
L"--environment-path " +
|
||||
utility::getExpandedAndAbsolutePath(
|
||||
FilePath(text.toStdWString()), m_settings->getProjectDirectoryPath())
|
||||
.wstr()
|
||||
},
|
||||
.wstr()},
|
||||
FilePath(),
|
||||
5000);
|
||||
m_onQtThread([=]() {
|
||||
|
||||
@@ -20,9 +20,11 @@ std::vector<FilePath> CxxVs15HeaderPathDetector::doGetPaths() const
|
||||
.expandEnvironmentVariables();
|
||||
if (!expandedPaths.empty())
|
||||
{
|
||||
const std::string output =
|
||||
utility::executeProcess(
|
||||
expandedPaths[0].wstr(), std::vector<std::wstring> {L"-latest", L"-property installationPath"}, FilePath(), 10000)
|
||||
const std::string output = utility::executeProcess(
|
||||
expandedPaths[0].wstr(),
|
||||
{L"-latest", L"-property installationPath"},
|
||||
FilePath(),
|
||||
10000)
|
||||
.second;
|
||||
|
||||
const FilePath vsInstallPath(output);
|
||||
|
||||
@@ -14,7 +14,7 @@ std::vector<std::string> getCxxHeaderPaths(const std::string& compilerName)
|
||||
std::string command = compilerName + " -x c++ -v -E /dev/null";
|
||||
std::string clangOutput = utility::executeProcess(
|
||||
utility::decodeFromUtf8(compilerName),
|
||||
std::vector<std::wstring> {L"-x c++", L"-v", L"-E /dev/null"})
|
||||
{L"-x c++", L"-v", L"-E /dev/null"})
|
||||
.second;
|
||||
std::string standardHeaders = utility::substrBetween<std::string>(
|
||||
clangOutput, "#include <...> search starts here:\n", "\nEnd of search list");
|
||||
|
||||
@@ -54,7 +54,7 @@ std::vector<FilePath> JavaPathDetectorLinux::doGetPaths() const
|
||||
|
||||
FilePath JavaPathDetectorLinux::getJavaInPath() const
|
||||
{
|
||||
std::string output = utility::executeProcess(L"which", std::vector<std::wstring>{L"java"}).second;
|
||||
std::string output = utility::executeProcess(L"which", {L"java"}).second;
|
||||
|
||||
if (!output.empty())
|
||||
{
|
||||
@@ -72,7 +72,7 @@ FilePath JavaPathDetectorLinux::getJavaInPath() const
|
||||
|
||||
FilePath JavaPathDetectorLinux::readLink(const FilePath& path) const
|
||||
{
|
||||
FilePath javaPath(utility::executeProcess(L"readlink", std::vector<std::wstring>{L"-f " + path.wstr()}).second);
|
||||
FilePath javaPath(utility::executeProcess(L"readlink", {L"-f " + path.wstr()}).second);
|
||||
if (!javaPath.empty())
|
||||
{
|
||||
return javaPath;
|
||||
@@ -113,7 +113,7 @@ FilePath JavaPathDetectorLinux::getJavaInJavaHome() const
|
||||
|
||||
bool JavaPathDetectorLinux::checkVersion(const FilePath& path) const
|
||||
{
|
||||
std::string output = utility::executeProcess(path.wstr(), std::vector<std::wstring>{L"-version"}).second;
|
||||
std::string output = utility::executeProcess(path.wstr(), {L"-version"}).second;
|
||||
|
||||
return output.find(m_javaVersion) != std::string::npos;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ std::vector<FilePath> JavaPathDetectorMac::doGetPaths() const
|
||||
std::vector<FilePath> paths;
|
||||
FilePath javaPath;
|
||||
|
||||
std::string output = utility::executeProcess(L"/usr/libexec/java_home", std::vector<std::wstring>{}).second;
|
||||
const std::string output = utility::executeProcess(L"/usr/libexec/java_home", {}).second;
|
||||
|
||||
if (!output.empty())
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ MavenPathDetectorUnix::MavenPathDetectorUnix(): PathDetector("Maven for Unix") {
|
||||
|
||||
std::vector<FilePath> MavenPathDetectorUnix::doGetPaths() const
|
||||
{
|
||||
FilePath mavenPath(utility::executeProcess(L"which", std::vector<std::wstring>{L"mvn"}).second);
|
||||
FilePath mavenPath(utility::executeProcess(L"which", {L"mvn"}).second);
|
||||
|
||||
std::vector<FilePath> paths;
|
||||
if (mavenPath.exists())
|
||||
|
||||
@@ -7,9 +7,7 @@ MavenPathDetectorWindows::MavenPathDetectorWindows(): PathDetector("Maven for Wi
|
||||
|
||||
std::vector<FilePath> MavenPathDetectorWindows::doGetPaths() const
|
||||
{
|
||||
FilePath mavenPath(
|
||||
utility::executeProcess(L"cmd", std::vector<std::wstring> {L"\"/c where mvn.cmd && exit\""})
|
||||
.second);
|
||||
FilePath mavenPath(utility::executeProcess(L"cmd", {L"\"/c where mvn.cmd && exit\""}).second);
|
||||
|
||||
std::vector<FilePath> paths;
|
||||
if (mavenPath.exists())
|
||||
|
||||
@@ -208,13 +208,24 @@ int utility::executeProcessAndGetExitCode(
|
||||
*errorMessage = L"An unknown error occurred while executing process.";
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(
|
||||
&process,
|
||||
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
||||
[&finished](int exitCode, QProcess::ExitStatus exitStatus) { finished = true; });
|
||||
[&finished, errorMessage](int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
finished = true;
|
||||
if (errorMessage != nullptr)
|
||||
{
|
||||
switch (exitStatus)
|
||||
{
|
||||
case QProcess::CrashExit:
|
||||
*errorMessage = L"Process crashed.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (!workingDirectory.empty())
|
||||
|
||||
@@ -49,25 +49,27 @@ std::set<FilePath> SourceGroupPythonEmpty::getAllSourceFilePaths() const
|
||||
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupPythonEmpty::getIndexerCommands(
|
||||
const RefreshInfo& info) const
|
||||
{
|
||||
std::wstring args = L"";
|
||||
std::vector<std::wstring> args;
|
||||
args.push_back(L"index");
|
||||
|
||||
args += L" --source-file-path=%{SOURCE_FILE_PATH}";
|
||||
args += L" --database-file-path=%{DATABASE_FILE_PATH}";
|
||||
args.push_back(L"--source-file-path=%{SOURCE_FILE_PATH}");
|
||||
args.push_back(L"--database-file-path=%{DATABASE_FILE_PATH}");
|
||||
|
||||
if (!m_settings->getEnvironmentPath().empty())
|
||||
{
|
||||
args += L" --environment-path=\"" +
|
||||
m_settings->getEnvironmentPathExpandedAndAbsolute().wstr() + L"\"";
|
||||
args.push_back(
|
||||
L"--environment-path=\"" + m_settings->getEnvironmentPathExpandedAndAbsolute().wstr() +
|
||||
L"\"");
|
||||
}
|
||||
|
||||
if (ApplicationSettings::getInstance()->getVerboseIndexerLoggingEnabled())
|
||||
{
|
||||
args += L" --verbose";
|
||||
args.push_back(L"--verbose");
|
||||
}
|
||||
|
||||
if (info.shallow)
|
||||
{
|
||||
args += L" --shallow";
|
||||
args.push_back(L"--shallow");
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
@@ -77,8 +79,9 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupPythonEmpty::getIndexerC
|
||||
{
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCustom>(
|
||||
INDEXER_COMMAND_PYTHON,
|
||||
L"\"" + ResourcePaths::getPythonPath().wstr() +
|
||||
L"SourcetrailPythonIndexer\" index" + args,
|
||||
L"\"" + ResourcePaths::getPythonEnvironmentFilePath().wstr() + L"\" \"" +
|
||||
ResourcePaths::getPythonIndexerFilePath().wstr() + L"\"",
|
||||
args,
|
||||
m_settings->getProjectSettings()->getProjectFilePath(),
|
||||
m_settings->getProjectSettings()->getTempDBFilePath(),
|
||||
std::to_wstring(SqliteIndexStorage::getStorageVersion()),
|
||||
|
||||
@@ -56,16 +56,24 @@ std::shared_ptr<TestStorage> parseCode(std::string code)
|
||||
const std::set<FilePathFilter> includeFilters;
|
||||
const FilePath workingDirectory(L".");
|
||||
|
||||
std::wstring args = L"";
|
||||
args += L" --source-file-path=%{SOURCE_FILE_PATH}";
|
||||
args += L" --database-file-path=%{DATABASE_FILE_PATH}";
|
||||
args += L" --shallow";
|
||||
std::vector<std::wstring> args;
|
||||
args.push_back(FilePath("../app")
|
||||
.getConcatenated(ResourcePaths::getPythonIndexerFilePath())
|
||||
.makeAbsolute()
|
||||
.wstr());
|
||||
args.push_back(L"index");
|
||||
args.push_back(L"--source-file-path=%{SOURCE_FILE_PATH}");
|
||||
args.push_back(L"--database-file-path=%{DATABASE_FILE_PATH}");
|
||||
args.push_back(L"--shallow");
|
||||
|
||||
std::shared_ptr<IndexerCommandCustom> indexerCommand = std::make_shared<IndexerCommandCustom>(
|
||||
INDEXER_COMMAND_PYTHON,
|
||||
L"\"" +
|
||||
FilePath("../app").getConcatenated(ResourcePaths::getPythonPath()).makeAbsolute().wstr() +
|
||||
L"SourcetrailPythonIndexer\" index" + args,
|
||||
|
||||
FilePath("../app")
|
||||
.getConcatenated(ResourcePaths::getPythonEnvironmentFilePath())
|
||||
.makeAbsolute()
|
||||
.wstr(),
|
||||
args,
|
||||
rootPath,
|
||||
tempDbPath,
|
||||
std::to_wstring(SqliteIndexStorage::getStorageVersion()),
|
||||
@@ -74,10 +82,15 @@ std::shared_ptr<TestStorage> parseCode(std::string code)
|
||||
|
||||
std::wstring errorMessage;
|
||||
const int result = utility::executeProcessAndGetExitCode(
|
||||
indexerCommand->getCustomCommand(), {}, rootPath, -1, true, &errorMessage);
|
||||
indexerCommand->getCommand(),
|
||||
indexerCommand->getArguments(),
|
||||
rootPath,
|
||||
-1,
|
||||
true,
|
||||
&errorMessage);
|
||||
|
||||
REQUIRE(result == 0);
|
||||
REQUIRE(errorMessage.empty());
|
||||
REQUIRE(result == 0);
|
||||
}
|
||||
|
||||
std::shared_ptr<TestStorage> testStorage;
|
||||
|
||||
@@ -148,9 +148,15 @@ std::wstring indexerCommandCustomToString(
|
||||
std::shared_ptr<const IndexerCommandCustom> indexerCommand, const FilePath& baseDirectory)
|
||||
{
|
||||
std::wstring result;
|
||||
result += L"SourceFilePath: \"" +
|
||||
result += L"IndexerCommandCustom\n";
|
||||
result += L"\tSourceFilePath: \"" +
|
||||
indexerCommand->getSourceFilePath().getRelativeTo(baseDirectory).wstr() + L"\"\n";
|
||||
result += L"\tCustom Command: \"" + indexerCommand->getCustomCommand() + L"\"\n";
|
||||
result += L"\tCustom Command: \"" + indexerCommand->getCommand() + L"\"\n";
|
||||
result += L"\tArguments:\n";
|
||||
for (const std::wstring& argument: indexerCommand->getArguments())
|
||||
{
|
||||
result += L"\t\t\"" + argument + L"\"\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Submodule
+1
Submodule submodules/SourcetrailPythonIndexer added at 1504d5a689
Reference in New Issue
Block a user