Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test on Windows Self-Hosted Runner

on:
workflow_dispatch:

jobs:
test:
name: Run Python and Echo Lines
runs-on: [self-hosted, windows-runner]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Echo multiple lines
run: |
echo Line 1: Hello from the runner
echo Line 2: This is a test
echo Line 3: Echoing multiple lines
shell: cmd

- name: Run Python script
run: |
import sys
print("Python is working!")
print("Version:", sys.version)
shell: python
16 changes: 8 additions & 8 deletions check-clang.pri
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# Clang installation.
#

REQUIRED_CLANG_VERSION = 3.8
REQUIRED_CLANG_VERSION = 5.0.0

equals(CLANG_DIR, "") {
warning("The CLANG_DIR qmake variable is unset.")
warning("Add CLANG_DIR=<path-to-clang-root> to the qmake command-line.")
warning("The provided path should point to a" $$REQUIRED_CLANG_VERSION \
"Clang installation.")
warning("(In the QtCreator IDE, add the setting in the Projects mode.)")
error("check-clang.pri: CLANG_DIR is unset. Aborting.")
# warning("The CLANG_DIR qmake variable is unset.")
# warning("Add CLANG_DIR=<path-to-clang-root> to the qmake command-line.")
# warning("The provided path should point to a" $$REQUIRED_CLANG_VERSION \
# "Clang installation.")
# warning("(In the QtCreator IDE, add the setting in the Projects mode.)")
# error("check-clang.pri: CLANG_DIR is unset. Aborting.")
}

defineTest(checkClangRequire) {
Expand All @@ -31,7 +31,7 @@ CLANG_LIBS = \
clangTooling clangParse clangSema clangAnalysis \
clangEdit clangAST clangLex clangBasic \
LLVMMC LLVMMCParser LLVMObject LLVMAsmParser LLVMCore LLVMProfileData LLVMSupport \
LLVMOption LLVMBitWriter LLVMBitReader
LLVMOption LLVMBitWriter LLVMBitReader LLVMDemangle
for(CLANG_LIB, CLANG_LIBS) {
checkClangRequire($${CLANG_DIR}/lib/lib$${CLANG_LIB}.a)
}
32 changes: 28 additions & 4 deletions clang-indexer/DaemonPool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace indexer {

///////////////////////////////////////////////////////////////////////////////
// Daemon

/**
* @brief Constructor of Daemon class
*/
Daemon::Daemon()
{
std::string program =
Expand All @@ -22,13 +24,23 @@ Daemon::Daemon()
args.push_back("--daemon");
m_process = new Process(program, args);
}

/**
* @brief Destructor of Daemon class
*/
Daemon::~Daemon()
{
fprintf(m_process->stdoutFile(), "\n");
delete m_process;
}

/**
* @brief Function sends cmd arguments to child process by writing to stdin file child reads
* and then expects output from child process in stdout file,
* after reciving "DONE 0" from child, function destroys child process and exits
* @param workingDirectory
* @param args
* @return
*/
int Daemon::run(
const std::string &workingDirectory,
const std::vector<std::string> &args)
Expand Down Expand Up @@ -61,16 +73,25 @@ int Daemon::run(
///////////////////////////////////////////////////////////////////////////////
// DaemonPool

/**
* @brief DaemonPool::DaemonPool constructor
*/
DaemonPool::DaemonPool()
{
}
/**
* @brief DaemonPool::~DaemonPool destructor
*/

DaemonPool::~DaemonPool()
{
for (Daemon *daemon : m_daemons)
delete daemon;
}

/**
* @brief If daemon list is empty create new daemon, else return last daemon inside list
* @return
*/
Daemon *DaemonPool::get()
{
LockGuard<Mutex> lock(m_mutex);
Expand All @@ -82,7 +103,10 @@ Daemon *DaemonPool::get()
return new Daemon();
}
}

/**
* @brief Removes last daemon from list
* @param daemon
*/
void DaemonPool::release(Daemon *daemon)
{
LockGuard<Mutex> lock(m_mutex);
Expand Down
2 changes: 1 addition & 1 deletion clang-indexer/IndexerContext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ IndexerFileContext &IndexerContext::fileContext(clang::FileID fileID)
const clang::FileEntry *pFE =
m_sourceManager.getFileEntryForID(fileID);
if (pFE != NULL) {
char *filename = portableRealPath(pFE->getName());
char *filename = portableRealPath(pFE->getName().data());
if (filename != NULL) {
pathSymbolName += filename;
free(filename);
Expand Down
2 changes: 1 addition & 1 deletion clang-indexer/IndexerPPCallbacks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void IndexerPPCallbacks::InclusionDirective(
auto it = m_includePathMap.find(file);
if (it == m_includePathMap.end()) {
std::string symbol = "@";
char *path = portableRealPath(file->getName());
char *path = portableRealPath(file->getName().data());
if (path != NULL) {
symbol += path;
free(path);
Expand Down
21 changes: 16 additions & 5 deletions clang-indexer/Mutex.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#include "Mutex.h"

#include <cassert>

/**
* @class Mutex
* @brief Does mutex locking of process on a shared resource, using criticalSection objects
*/
namespace indexer {

/**
* @brief Mutex::Mutex constructor
*/
Mutex::Mutex()
{
#if INDEXER_MUTEX_USE_PTHREADS
Expand All @@ -13,7 +18,9 @@ Mutex::Mutex()
InitializeCriticalSection(&mutex);
#endif
}

/**
* @brief Mutex::~Mutex destructor
*/
Mutex::~Mutex()
{
#if INDEXER_MUTEX_USE_PTHREADS
Expand All @@ -23,7 +30,9 @@ Mutex::~Mutex()
DeleteCriticalSection(&mutex);
#endif
}

/**
* @brief Locks the shared object
*/
void Mutex::lock()
{
#if INDEXER_MUTEX_USE_PTHREADS
Expand All @@ -37,7 +46,9 @@ void Mutex::lock()
#error "Not implemented"
#endif
}

/**
* @brief Unlocks the shared object
*/
void Mutex::unlock()
{
#if INDEXER_MUTEX_USE_PTHREADS
Expand Down
2 changes: 1 addition & 1 deletion clang-indexer/NameGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void NameGenerator::VisitDeclContext(clang::DeclContext *context)
const clang::FileEntry *fileEntry =
sourceManager.getFileEntryForID(fileID);
if (fileEntry != NULL) {
m_out << const_basename(fileEntry->getName());
m_out << const_basename(fileEntry->getName().data());
if (m_needOffsetPrefix)
m_out << '@' << sourceManager.getFileOffset(sloc);
m_out << '/';
Expand Down
58 changes: 43 additions & 15 deletions clang-indexer/Process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#if defined(_WIN32)
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>
#ifndef NOMINMAX
#define NOMINMAX 1
#endif
Expand Down Expand Up @@ -168,29 +172,53 @@ Process::Process(
// seems to. CreateProcess seems to decide that the standard handles must
// be inherited no matter what.
BOOL success;
std::string cmdLine = makeCommandLine(programPath, args);
std::string cmdLine = makeCommandLine(programPath, args);


//child process handles
HANDLE hStdinRead = NULL;
HANDLE hStdinWrite = NULL;
HANDLE hStdoutRead = NULL;
HANDLE hStdoutWrite = NULL;

// set the inheritHandle flag so pipe handles are inherited
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;

//create pipe for the child process STDOUT
success = CreatePipe(&hStdoutRead, &hStdoutWrite, &saAttr, 0);
assert(success);
// Ensure the read handle to the pipe for STDOUT is not inherited.
success = SetHandleInformation(hStdoutRead, HANDLE_FLAG_INHERIT, 0);
assert(success);

//create pipe for the child process STDIN
success = CreatePipe(&hStdinRead, &hStdinWrite, &saAttr, 0);
assert(success);
// Ensure the write handle to the pipe for STDIN is not inherited.
success = SetHandleInformation(hStdinWrite, HANDLE_FLAG_INHERIT, 0);
assert(success);

// create child process
STARTUPINFOA sui;
PROCESS_INFORMATION pi;

memset(&sui, 0, sizeof(sui));
memset(&pi, 0, sizeof(pi));
sui.dwFlags = STARTF_USESTDHANDLES;
HANDLE hStdinRead;
HANDLE hStdinWrite;
HANDLE hStdoutRead;
HANDLE hStdoutWrite;
success = CreatePipe(&hStdinRead, &hStdinWrite, NULL, 0);
assert(success);
success = CreatePipe(&hStdoutRead, &hStdoutWrite, NULL, 0);
assert(success);

sui.cb = sizeof(sui);
sui.hStdInput = hStdinRead;
sui.hStdOutput = hStdoutWrite;
sui.hStdError = GetStdHandle(STD_ERROR_HANDLE);
sui.hStdError = hStdoutWrite;
sui.dwFlags |= STARTF_USESTDHANDLES;

BOOL ret = CreateProcessA(
programPath.c_str(),
&cmdLine[0],
NULL, NULL,
/*bInheritHandles=*/FALSE,
/*bInheritHandles=*/TRUE,
/*dwCreationFlags=*/0,
/*lpEnvironment=*/NULL,
/*lpCurrentDirectory=*/NULL,
Expand All @@ -199,13 +227,13 @@ Process::Process(
fprintf(stderr, "sw-clang-indexer: Error starting daemon process\n");
exit(1);
}

m_p->hproc = pi.hProcess;
CloseHandle(pi.hThread);
CloseHandle(hStdinRead);
CloseHandle(hStdoutWrite);
// Calling close() on these file descriptors will call CloseHandle().
// (i.e. Ownership of the HANDLE is transferred. See the _open_osfhandle
// MSDN page.)

//open files for stdin and stdout
int stdinFd = _open_osfhandle(reinterpret_cast<intptr_t>(hStdinWrite),
_O_TEXT | _O_RDWR);
int stdoutFd = _open_osfhandle(reinterpret_cast<intptr_t>(hStdoutRead),
Expand Down
Loading