mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
fix MSVC build regression
This commit is contained in:
parent
36aa74316a
commit
f79f320859
30
makefile
30
makefile
@ -568,7 +568,10 @@ as := $(cc)
|
|||||||
ld := $(cc)
|
ld := $(cc)
|
||||||
build-ld := $(build-cc)
|
build-ld := $(build-cc)
|
||||||
|
|
||||||
|
static = -static
|
||||||
|
|
||||||
ifdef msvc
|
ifdef msvc
|
||||||
|
static =
|
||||||
no-error =
|
no-error =
|
||||||
windows-path = $(native-path)
|
windows-path = $(native-path)
|
||||||
windows-java-home := $(shell $(windows-path) "$(JAVA_HOME)")
|
windows-java-home := $(shell $(windows-path) "$(JAVA_HOME)")
|
||||||
@ -591,7 +594,7 @@ ifdef msvc
|
|||||||
|
|
||||||
shared = -dll
|
shared = -dll
|
||||||
lflags = -nologo -LIBPATH:"$(zlib)/lib" -DEFAULTLIB:ws2_32 \
|
lflags = -nologo -LIBPATH:"$(zlib)/lib" -DEFAULTLIB:ws2_32 \
|
||||||
-DEFAULTLIB:zlib -MANIFEST -debug
|
-DEFAULTLIB:zlib -DEFAULTLIB:user32 -MANIFEST -debug
|
||||||
output = -Fo$(1)
|
output = -Fo$(1)
|
||||||
|
|
||||||
ifeq ($(mode),debug)
|
ifeq ($(mode),debug)
|
||||||
@ -1021,12 +1024,18 @@ endif
|
|||||||
ifdef embed
|
ifdef embed
|
||||||
$(embed): $(embed-objects) $(embed-loader-o)
|
$(embed): $(embed-objects) $(embed-loader-o)
|
||||||
@echo "building $(embed)"
|
@echo "building $(embed)"
|
||||||
$(cxx) $(^) -mwindows -mconsole -static -o $(@)
|
ifdef msvc
|
||||||
|
$(ld) $(lflags) $(^) -out:$(@) -PDB:$(@).pdb \
|
||||||
|
-IMPLIB:$(@).lib -MANIFESTFILE:$(@).manifest
|
||||||
|
$(mt) -manifest $(@).manifest -outputresource:"$(@);1"
|
||||||
|
else
|
||||||
|
$(cxx) $(^) $(lflags) $(static) $(call output,$(@))
|
||||||
|
endif
|
||||||
|
|
||||||
$(build-embed)/%.o: $(src)/%.cpp
|
$(build-embed)/%.o: $(src)/%.cpp
|
||||||
@echo "compiling $(@)"
|
@echo "compiling $(@)"
|
||||||
@mkdir -p $(dir $(@))
|
@mkdir -p $(dir $(@))
|
||||||
$(cxx) -D_UNICODE -DUNICODE -c $(<) -o $(@)
|
$(cxx) $(cflags) -c $(<) $(call output,$(@))
|
||||||
|
|
||||||
$(embed-loader-o): $(embed-loader) $(converter)
|
$(embed-loader-o): $(embed-loader) $(converter)
|
||||||
@mkdir -p $(dir $(@))
|
@mkdir -p $(dir $(@))
|
||||||
@ -1036,17 +1045,22 @@ $(embed-loader-o): $(embed-loader) $(converter)
|
|||||||
$(embed-loader): $(embed-loader-objects) $(static-library)
|
$(embed-loader): $(embed-loader-objects) $(static-library)
|
||||||
@mkdir -p $(dir $(@))
|
@mkdir -p $(dir $(@))
|
||||||
cd $(dir $(@)) && $(ar) x ../../../$(static-library)
|
cd $(dir $(@)) && $(ar) x ../../../$(static-library)
|
||||||
|
ifdef msvc
|
||||||
|
$(ld) $(lflags) $(dir $(@))/*.o -out:$(@) -PDB:$(@).pdb \
|
||||||
|
-IMPLIB:$(@).lib -MANIFESTFILE:$(@).manifest
|
||||||
|
$(mt) -manifest $(@).manifest -outputresource:"$(@);1"
|
||||||
|
else
|
||||||
$(dlltool) -z $(addsuffix .def,$(basename $(@))) $(dir $(@))/*.o
|
$(dlltool) -z $(addsuffix .def,$(basename $(@))) $(dir $(@))/*.o
|
||||||
$(dlltool) -d $(addsuffix .def,$(basename $(@))) -e $(addsuffix .exp,$(basename $(@)))
|
$(dlltool) -d $(addsuffix .def,$(basename $(@))) -e $(addsuffix .exp,$(basename $(@)))
|
||||||
$(cxx) $(addsuffix .exp,$(basename $(@))) $(dir $(@))/*.o -L../win32/lib -lmingwthrd -lm -lz -lws2_32 -liphlpapi \
|
$(ld) $(addsuffix .exp,$(basename $(@))) $(dir $(@))/*.o \
|
||||||
-mwindows -mconsole -static -o $(@)
|
$(lflags) $(bootimage-lflags) -o $(@)
|
||||||
strip --strip-all $(@)
|
endif
|
||||||
|
$(strip) $(strip-all) $(@)
|
||||||
|
|
||||||
$(build-embed-loader)/%.o: $(src)/%.cpp
|
$(build-embed-loader)/%.o: $(src)/%.cpp
|
||||||
@echo "compiling $(@)"
|
@echo "compiling $(@)"
|
||||||
@mkdir -p $(dir $(@))
|
@mkdir -p $(dir $(@))
|
||||||
$(cxx) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 \
|
$(cxx) $(cflags) -c $(<) $(call output,$(@))
|
||||||
-D_JNI_IMPLEMENTATION_ -c $(<) -o $(@)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(build)/%.o: $(lzma)/C/%.c
|
$(build)/%.o: $(lzma)/C/%.c
|
||||||
|
@ -74,12 +74,12 @@ bool mkStringSection(std::vector<wchar_t>* stringSection, const std::vector<std:
|
|||||||
|
|
||||||
void writeStringResources(HANDLE hDest, const std::vector<std::wstring>& strings)
|
void writeStringResources(HANDLE hDest, const std::vector<std::wstring>& strings)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < strings.size(); i += 16)
|
for(unsigned i = 0; i < strings.size(); i += 16)
|
||||||
{
|
{
|
||||||
std::vector<wchar_t> stringSection;
|
std::vector<wchar_t> stringSection;
|
||||||
|
|
||||||
if(mkStringSection(&stringSection, strings, i, std::min<int>(i + 15, strings.size() - 1)))
|
if(mkStringSection(&stringSection, strings, i, std::min<int>(i + 15, strings.size() - 1)))
|
||||||
UpdateResourceW(hDest, RT_STRING, MAKEINTRESOURCE((i >> 4) + 1), LANG_NEUTRAL, &stringSection.at(0), sizeof(wchar_t) * stringSection.size());
|
UpdateResourceW(hDest, reinterpret_cast<LPCWSTR>(RT_STRING), reinterpret_cast<LPCWSTR>(MAKEINTRESOURCE((i >> 4) + 1)), LANG_NEUTRAL, &stringSection.at(0), sizeof(wchar_t) * stringSection.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ int wmain(int argc, wchar_t* argv[])
|
|||||||
|
|
||||||
std::vector<char> jarFile;
|
std::vector<char> jarFile;
|
||||||
readFile(&jarFile, classesName);
|
readFile(&jarFile, classesName);
|
||||||
UpdateResourceW(hDest, RT_RCDATA, _T(RESID_BOOT_JAR), LANG_NEUTRAL, &jarFile.at(0), jarFile.size());
|
UpdateResourceW(hDest, reinterpret_cast<LPCWSTR>(RT_RCDATA), RESID_BOOT_JAR, LANG_NEUTRAL, &jarFile.at(0), jarFile.size());
|
||||||
|
|
||||||
EndUpdateResource(hDest, FALSE);
|
EndUpdateResource(hDest, FALSE);
|
||||||
}
|
}
|
||||||
@ -113,6 +113,7 @@ int wmain(int argc, wchar_t* argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
extern "C" int _CRT_glob;
|
extern "C" int _CRT_glob;
|
||||||
extern "C" void __wgetmainargs(int*, wchar_t***, wchar_t***, int, int*);
|
extern "C" void __wgetmainargs(int*, wchar_t***, wchar_t***, int, int*);
|
||||||
|
|
||||||
@ -123,3 +124,4 @@ int main()
|
|||||||
__wgetmainargs(&argc, &argv, &enpv, _CRT_glob, &si);
|
__wgetmainargs(&argc, &argv, &enpv, _CRT_glob, &si);
|
||||||
return wmain(argc, argv);
|
return wmain(argc, argv);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -12,6 +12,6 @@
|
|||||||
#define EMBED_H
|
#define EMBED_H
|
||||||
|
|
||||||
#define RESID_MAIN_CLASS 100
|
#define RESID_MAIN_CLASS 100
|
||||||
#define RESID_BOOT_JAR "BOOT.JAR"
|
#define RESID_BOOT_JAR L"BOOT.JAR"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,20 +15,25 @@
|
|||||||
#include "embed.h"
|
#include "embed.h"
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
|
|
||||||
|
|
||||||
#if (defined __MINGW32__) || (defined _MSC_VER)
|
#if (defined __MINGW32__) || (defined _MSC_VER)
|
||||||
# define EXPORT __declspec(dllexport)
|
# define EXPORT __declspec(dllexport)
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# define not !
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
# define EXPORT __attribute__ ((visibility("default"))) \
|
# define EXPORT __attribute__ ((visibility("default"))) \
|
||||||
__attribute__ ((used))
|
__attribute__ ((used))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
// since we aren't linking against libstdc++, we must implement this
|
||||||
|
// ourselves:
|
||||||
|
void __cxa_pure_virtual(void) { abort(); }
|
||||||
|
|
||||||
EXPORT const uint8_t*
|
EXPORT const uint8_t*
|
||||||
bootJar(unsigned* size)
|
bootJar(unsigned* size)
|
||||||
{
|
{
|
||||||
if(HRSRC hResInfo = FindResource(NULL, _T(RESID_BOOT_JAR), RT_RCDATA))
|
if(HRSRC hResInfo = FindResourceW(NULL, RESID_BOOT_JAR, reinterpret_cast<LPCWSTR>(RT_RCDATA)))
|
||||||
{
|
{
|
||||||
if(HGLOBAL hRes = LoadResource(NULL, hResInfo))
|
if(HGLOBAL hRes = LoadResource(NULL, hResInfo))
|
||||||
{
|
{
|
||||||
@ -44,7 +49,7 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
static bool getMainClass(char* pName, int maxLen)
|
static void getMainClass(char* pName, int maxLen)
|
||||||
{
|
{
|
||||||
if(0 == LoadString(NULL, RESID_MAIN_CLASS, pName, maxLen))
|
if(0 == LoadString(NULL, RESID_MAIN_CLASS, pName, maxLen))
|
||||||
{
|
{
|
||||||
@ -61,7 +66,7 @@ main(int ac, const char** av)
|
|||||||
vmArgs.nOptions = 1;
|
vmArgs.nOptions = 1;
|
||||||
vmArgs.ignoreUnrecognized = JNI_TRUE;
|
vmArgs.ignoreUnrecognized = JNI_TRUE;
|
||||||
|
|
||||||
JavaVMOption options[vmArgs.nOptions];
|
JavaVMOption options[1];
|
||||||
vmArgs.options = options;
|
vmArgs.options = options;
|
||||||
|
|
||||||
options[0].optionString = const_cast<char*>("-Xbootclasspath:[bootJar]");
|
options[0].optionString = const_cast<char*>("-Xbootclasspath:[bootJar]");
|
||||||
|
Loading…
Reference in New Issue
Block a user