Skip to content
Browse files

fix MSVC build regression

  • Loading branch information...
1 parent 36aa743 commit f79f32085972bbc7000994ea515d3b7983082503 @dicej dicej committed Dec 5, 2012
Showing with 37 additions and 16 deletions.
  1. +22 −8 makefile
  2. +5 −3 src/embed.cpp
  3. +1 −1 src/embed.h
  4. +9 −4 src/embedded-loader.cpp
View
30 makefile
@@ -568,7 +568,10 @@ as := $(cc)
ld := $(cc)
build-ld := $(build-cc)
+static = -static
+
ifdef msvc
+ static =
no-error =
windows-path = $(native-path)
windows-java-home := $(shell $(windows-path) "$(JAVA_HOME)")
@@ -591,7 +594,7 @@ ifdef msvc
shared = -dll
lflags = -nologo -LIBPATH:"$(zlib)/lib" -DEFAULTLIB:ws2_32 \
- -DEFAULTLIB:zlib -MANIFEST -debug
+ -DEFAULTLIB:zlib -DEFAULTLIB:user32 -MANIFEST -debug
output = -Fo$(1)
ifeq ($(mode),debug)
@@ -1021,12 +1024,18 @@ endif
ifdef embed
$(embed): $(embed-objects) $(embed-loader-o)
@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
@echo "compiling $(@)"
@mkdir -p $(dir $(@))
- $(cxx) -D_UNICODE -DUNICODE -c $(<) -o $(@)
+ $(cxx) $(cflags) -c $(<) $(call output,$(@))
$(embed-loader-o): $(embed-loader) $(converter)
@mkdir -p $(dir $(@))
@@ -1036,17 +1045,22 @@ $(embed-loader-o): $(embed-loader) $(converter)
$(embed-loader): $(embed-loader-objects) $(static-library)
@mkdir -p $(dir $(@))
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) -d $(addsuffix .def,$(basename $(@))) -e $(addsuffix .exp,$(basename $(@)))
- $(cxx) $(addsuffix .exp,$(basename $(@))) $(dir $(@))/*.o -L../win32/lib -lmingwthrd -lm -lz -lws2_32 -liphlpapi \
- -mwindows -mconsole -static -o $(@)
- strip --strip-all $(@)
+ $(ld) $(addsuffix .exp,$(basename $(@))) $(dir $(@))/*.o \
+ $(lflags) $(bootimage-lflags) -o $(@)
+endif
+ $(strip) $(strip-all) $(@)
$(build-embed-loader)/%.o: $(src)/%.cpp
@echo "compiling $(@)"
@mkdir -p $(dir $(@))
- $(cxx) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 \
- -D_JNI_IMPLEMENTATION_ -c $(<) -o $(@)
+ $(cxx) $(cflags) -c $(<) $(call output,$(@))
endif
$(build)/%.o: $(lzma)/C/%.c
View
8 src/embed.cpp
@@ -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)
{
- for(int i = 0; i < strings.size(); i += 16)
+ for(unsigned i = 0; i < strings.size(); i += 16)
{
std::vector<wchar_t> stringSection;
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;
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);
}
@@ -113,6 +113,7 @@ int wmain(int argc, wchar_t* argv[])
return 0;
}
+#ifndef _MSC_VER
extern "C" int _CRT_glob;
extern "C" void __wgetmainargs(int*, wchar_t***, wchar_t***, int, int*);
@@ -123,3 +124,4 @@ int main()
__wgetmainargs(&argc, &argv, &enpv, _CRT_glob, &si);
return wmain(argc, argv);
}
+#endif
View
2 src/embed.h
@@ -12,6 +12,6 @@
#define EMBED_H
#define RESID_MAIN_CLASS 100
-#define RESID_BOOT_JAR "BOOT.JAR"
+#define RESID_BOOT_JAR L"BOOT.JAR"
#endif
View
13 src/embedded-loader.cpp
@@ -15,20 +15,25 @@
#include "embed.h"
#include "jni.h"
-
#if (defined __MINGW32__) || (defined _MSC_VER)
# define EXPORT __declspec(dllexport)
+# ifdef _MSC_VER
+# define not !
+# endif
#else
# define EXPORT __attribute__ ((visibility("default"))) \
__attribute__ ((used))
#endif
extern "C" {
+ // since we aren't linking against libstdc++, we must implement this
+ // ourselves:
+ void __cxa_pure_virtual(void) { abort(); }
EXPORT const uint8_t*
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))
{
@@ -44,7 +49,7 @@ 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))
{
@@ -61,7 +66,7 @@ main(int ac, const char** av)
vmArgs.nOptions = 1;
vmArgs.ignoreUnrecognized = JNI_TRUE;
- JavaVMOption options[vmArgs.nOptions];
+ JavaVMOption options[1];
vmArgs.options = options;
options[0].optionString = const_cast<char*>("-Xbootclasspath:[bootJar]");

0 comments on commit f79f320

Please sign in to comment.
Something went wrong with that request. Please try again.