1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Updated the Windows spawner DLL to build using MinGW gcc.

This commit is contained in:
Doug Schaefer 2004-11-18 16:11:50 +00:00
parent 548574d7fd
commit 8c69def994
5 changed files with 50 additions and 16 deletions

View file

@ -0,0 +1,35 @@
# makefile for libspawner.so
ifeq ($(JAVA_HOME),)
$(warning JAVA_HOME not set in environment)
endif
# Defaults which can be overridden.
OS = win32
ARCH = x86
JDK_INCLUDES= $(JAVA_HOME)/include
JDK_OS_INCLUDES= $(JAVA_HOME)/include/$(OS)
CC=gcc
CPPFLAGS = -I. -I$(JDK_INCLUDES) -I$(JDK_OS_INCLUDES)
CFLAGS += -D_UNICODE -Dwchar_t=short
INSTALL_DIR = ../os/$(OS)/$(ARCH)
LIB_NAME_SPAWNER = spawner.dll
LIB_NAME_FULL_SPAWNER = $(INSTALL_DIR)/spawner.dll
OBJS_SPAWNER=StdAfx.o Win32ProcessEx.o iostream.o raise.o spawner.o
OBJS = $(OBJS_SPAWNER)
all: $(LIB_NAME_FULL_SPAWNER)
rebuild: clean all
$(LIB_NAME_FULL_SPAWNER) : $(OBJS_SPAWNER)
mkdir -p $(INSTALL_DIR)
$(CC) -Wl,--kill-at -g -shared -o $(LIB_NAME_FULL_SPAWNER) $(OBJS_SPAWNER)
clean :
$(RM) $(OBJS_SPAWNER) $(LIB_NAME_FULL_SPAWNER)

View file

@ -19,7 +19,6 @@
#include <process.h>
#include "Spawner.h"
#include "jni.h"
#include "io.h"
@ -150,9 +149,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
// Create pipe names
EnterCriticalSection(&cs);
_stprintf(inPipeName, _T("\\\\.\\pipe\\stdin%08i%010i"), pid, nCounter);
_stprintf(outPipeName, _T("\\\\.\\pipe\\stdout%08i%010i"), pid, nCounter);
_stprintf(errPipeName, _T("\\\\.\\pipe\\stderr%08i%010i"), pid, nCounter);
_stprintf(inPipeName, L"\\\\.\\pipe\\stdin%08i%010i", pid, nCounter);
_stprintf(outPipeName, L"\\\\.\\pipe\\stdout%08i%010i", pid, nCounter);
_stprintf(errPipeName, L"\\\\.\\pipe\\stderr%08i%010i", pid, nCounter);
nLocalCounter = nCounter;
++nCounter;
LeaveCriticalSection(&cs);
@ -192,9 +191,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
}
// Construct starter's command line
_stprintf(eventBreakName, _T("SABreak%p"), pCurProcInfo);
_stprintf(eventWaitName, _T("SAWait%p"), pCurProcInfo);
_stprintf(eventTerminateName, _T("SATerm%p"), pCurProcInfo);
_stprintf(eventBreakName, L"SABreak%p", pCurProcInfo);
_stprintf(eventWaitName, L"SAWait%p", pCurProcInfo);
_stprintf(eventTerminateName, L"SATerm%p", pCurProcInfo);
pCurProcInfo -> eventBreak = CreateEventW(NULL, TRUE, FALSE, eventBreakName);
ResetEvent(pCurProcInfo -> eventBreak);
pCurProcInfo -> eventWait = CreateEventW(NULL, TRUE, FALSE, eventWaitName);
@ -202,7 +201,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
pCurProcInfo -> eventTerminate = CreateEventW(NULL, TRUE, FALSE, eventTerminateName);
ResetEvent(pCurProcInfo -> eventTerminate);
nPos = _stprintf(szCmdLine, _T("%sstarter.exe %i %i %s %s %s "), path, pid, nLocalCounter, eventBreakName, eventWaitName, eventTerminateName);
nPos = _stprintf(szCmdLine, L"%sstarter.exe %i %i %s %s %s ", path, pid, nLocalCounter, eventBreakName, eventWaitName, eventTerminateName);
// Prepare command line
for(i = 0; i < nCmdTokens; ++i)
@ -263,7 +262,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
_stprintf(buffer, _T("%s\n"), str);
OutputDebugStringW(buffer);
#endif
_tcsnccpy(szEnvBlock + nPos, str, len);
_tcsncpy(szEnvBlock + nPos, str, len);
nPos += len;
szEnvBlock[nPos] = _T('\0');
++nPos;
@ -386,7 +385,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
file_handles[0] = (int)stdHandles[0];
file_handles[1] = (int)stdHandles[1];
file_handles[2] = (int)stdHandles[2];
(*env) -> SetIntArrayRegion(env, channels, 0, 3, file_handles);
(*env) -> SetIntArrayRegion(env, channels, 0, 3, (jint *)file_handles);
#ifdef DEBUG_MONITOR
OutputDebugStringW(_T("Process started\n"));
#endif
@ -484,7 +483,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
return 0;
}
}
_tcsnccpy(szEnvBlock + nPos, str, len);
_tcsncpy(szEnvBlock + nPos, str, len);
nPos += len;
szEnvBlock[nPos] = _T('\0');
++nPos;

View file

@ -79,8 +79,8 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_rea
while(len > nBuffOffset)
{
int nNumberOfBytesToRead = min(len - nBuffOffset, BUFF_SIZE);
int nNumberOfBytesRead;
DWORD nNumberOfBytesToRead = min(len - nBuffOffset, BUFF_SIZE);
DWORD nNumberOfBytesRead;
if(0 == ReadFile((HANDLE)fd, tmpBuf, nNumberOfBytesToRead, &nNumberOfBytesRead, &overlapped ))
{
int err = GetLastError();
@ -182,8 +182,8 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_wr
while(len > nBuffOffset)
{
int nNumberOfBytesToWrite = min(len - nBuffOffset, BUFF_SIZE);
int nNumberOfBytesWritten;
DWORD nNumberOfBytesToWrite = min(len - nBuffOffset, BUFF_SIZE);
DWORD nNumberOfBytesWritten;
(*env) -> GetByteArrayRegion(env, buf, nBuffOffset, nNumberOfBytesToWrite, tmpBuf);
if(0 == WriteFile((HANDLE)fd, tmpBuf, nNumberOfBytesToWrite, &nNumberOfBytesWritten, NULL))
{

View file

@ -39,7 +39,7 @@ BOOL APIENTRY DllMain( HANDLE hModule,
if(NULL != p)
*(p + 1) = _T('\0');
else
_tcscat(path, _T("\\"));
_tcscat(path, L"\\");
}
break;
case DLL_THREAD_ATTACH: