From 7280e10e8bfa507953d8c823abd502db98c514fa Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Wed, 8 Oct 2014 14:29:34 +0200 Subject: some fixes on Windows --- include/luaglue/LuaGlueExportable.hpp | 26 ++++++++++++ include/luaglue/LuaVM.hpp | 16 +++---- include/util/StringUtils.hpp | 4 +- include/util/win32/errormsg.hpp | 2 +- include/util/win32/stringutils.hpp | 2 +- lua/src/luaconf.h | 2 +- makefiles/nmake/platform.mk | 7 ++++ src/crawl/Makefile.W32 | 9 ++-- src/libluaglue/Makefile.W32 | 8 ++-- src/libutil/Makefile.W32 | 2 +- src/libutil/win32/errormsg.cpp | 2 +- src/libutil/win32/stringutils.cpp | 2 +- src/modules/fetcher/winhttp/Makefile.W32 | 1 + src/modules/processor/robotstxt/Makefile.W32 | 4 +- src/modules/processor/sitemap/Makefile.W32 | 5 ++- src/modules/urlnormalizer/googleurl/Makefile.W32 | 9 +++- tests/modules/Makefile.W32 | 1 + tests/modules/testmod3/Makefile.W32 | 1 + tests/modules/testmod4/Makefile.W32 | 1 + tests/tolua/Makefile.W32 | 44 ++++++++++++++++++++ tests/tolua/exec_test | 8 ++++ tests/tolua/exec_test.cmd | 21 ++++++++++ tests/tolua/libtest1/Makefile.W32 | 53 ++++++++++++++++++++++++ tests/url/Makefile.W32 | 8 ++++ 24 files changed, 213 insertions(+), 25 deletions(-) create mode 100644 include/luaglue/LuaGlueExportable.hpp create mode 100644 tests/tolua/Makefile.W32 create mode 100644 tests/tolua/exec_test create mode 100644 tests/tolua/exec_test.cmd create mode 100644 tests/tolua/libtest1/Makefile.W32 diff --git a/include/luaglue/LuaGlueExportable.hpp b/include/luaglue/LuaGlueExportable.hpp new file mode 100644 index 0000000..134e3f0 --- /dev/null +++ b/include/luaglue/LuaGlueExportable.hpp @@ -0,0 +1,26 @@ +#ifndef __LUAGLUE_EXPORTABLE_H +#define __LUAGLUE_EXPORTABLE_H + +#ifndef _WIN32 + +#define LUAGLUE_DLL_VISIBLE + +#else + +#ifdef SHARED + +#ifdef BUILDING_LUAGLUE +#define LUAGLUE_DLL_VISIBLE __declspec(dllexport) +#else +#define LUAGLUE_DLL_VISIBLE __declspec(dllimport) +#endif + +#else + +#define LUAGLUE_DLL_VISIBLE + +#endif // BUILDING_LUAGLUE + +#endif // _WIN32 + +#endif diff --git a/include/luaglue/LuaVM.hpp b/include/luaglue/LuaVM.hpp index baa5bca..bd2fd21 100755 --- a/include/luaglue/LuaVM.hpp +++ b/include/luaglue/LuaVM.hpp @@ -1,6 +1,8 @@ #ifndef __LUA_VM_H #define __LUA_VM_H +#include "LuaGlueExportable.hpp" + #include "lua.hpp" #include @@ -8,15 +10,15 @@ class LuaVM { public: - LuaVM( ); - ~LuaVM( ); + LUAGLUE_DLL_VISIBLE LuaVM( ); + LUAGLUE_DLL_VISIBLE ~LuaVM( ); - void loadSource( const char *sourceFilename ); - void executeMain( ); - void dumpState( ); - void fullGarbageCollect( ); + LUAGLUE_DLL_VISIBLE void loadSource( const char *sourceFilename ); + LUAGLUE_DLL_VISIBLE void executeMain( ); + LUAGLUE_DLL_VISIBLE void dumpState( ); + LUAGLUE_DLL_VISIBLE void fullGarbageCollect( ); - lua_State *handle( ); + LUAGLUE_DLL_VISIBLE lua_State *handle( ); private: void initialize( ); diff --git a/include/util/StringUtils.hpp b/include/util/StringUtils.hpp index c6b9f87..d0c832e 100644 --- a/include/util/StringUtils.hpp +++ b/include/util/StringUtils.hpp @@ -3,6 +3,8 @@ #include -bool stringicasecmp( const std::string &s1, const std::string &s2 ); +#include "util/UtilExportable.hpp" + +UTIL_DLL_VISIBLE bool stringicasecmp( const std::string &s1, const std::string &s2 ); #endif diff --git a/include/util/win32/errormsg.hpp b/include/util/win32/errormsg.hpp index 93ce3b7..7bdc582 100755 --- a/include/util/win32/errormsg.hpp +++ b/include/util/win32/errormsg.hpp @@ -3,7 +3,7 @@ #include -#include "UtilExportable.hpp" +#include "util/UtilExportable.hpp" UTIL_DLL_VISIBLE std::string getLastError( ); diff --git a/include/util/win32/stringutils.hpp b/include/util/win32/stringutils.hpp index 8f293dd..976c5cf 100755 --- a/include/util/win32/stringutils.hpp +++ b/include/util/win32/stringutils.hpp @@ -3,7 +3,7 @@ #include -#include "UtilExportable.hpp" +#include "util/UtilExportable.hpp" UTIL_DLL_VISIBLE std::wstring s2ws( const std::string &s ); diff --git a/lua/src/luaconf.h b/lua/src/luaconf.h index 837790c..3f650d6 100644 --- a/lua/src/luaconf.h +++ b/lua/src/luaconf.h @@ -140,7 +140,7 @@ ** the libraries, you may want to use the following definition (define ** LUA_BUILD_AS_DLL to get it). */ -#if defined(LUA_BUILD_AS_DLL) || defined(BUILD_SHARED) /* { */ +#if defined(LUA_BUILD_AS_DLL) || defined(SHARED) /* { */ #if defined(LUA_CORE) || defined(LUA_LIB) /* { */ #define LUA_API __declspec(dllexport) diff --git a/makefiles/nmake/platform.mk b/makefiles/nmake/platform.mk index 3a04b36..ea15202 100755 --- a/makefiles/nmake/platform.mk +++ b/makefiles/nmake/platform.mk @@ -25,3 +25,10 @@ SETUPBLD = "$(WIX_DIR)\bin\setupbld.exe" ################ XSLTPROC = $(LIBXSLT_DIR)\bin\xsltproc.exe + +# ICU +##### + +!IFDEF WITH_ICU +ICU_DIR=C:\develop\icu4c-52_1-src\icu +!ENDIF diff --git a/src/crawl/Makefile.W32 b/src/crawl/Makefile.W32 index 6ab255c..237d189 100755 --- a/src/crawl/Makefile.W32 +++ b/src/crawl/Makefile.W32 @@ -10,19 +10,22 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ + /I$(TOPDIR)\include \ /I$(TOPDIR)\include\logger \ /I$(TOPDIR)\include\module \ /I$(TOPDIR)\include\util \ /I$(TOPDIR)\include\crawler \ - /I$(TOPDIR)\include\luaglue - + /I$(TOPDIR)\include\luaglue \ + /I$(TOPDIR)\lua\src + INCLUDE_LDFLAGS = \ INCLUDE_LIBS = \ $(TOPDIR)\src\libutil\util.lib \ $(TOPDIR)\src\liblogger\logger.lib \ $(TOPDIR)\src\libcrawler\crawler.lib \ - $(TOPDIR)\src\libluaglue\luaglue.lib + $(TOPDIR)\src\libluaglue\luaglue.lib \ + $(TOPDIR)\lua\src\lua52.lib CPP_OBJS = \ diff --git a/src/libluaglue/Makefile.W32 b/src/libluaglue/Makefile.W32 index 605835e..8b34ea8 100755 --- a/src/libluaglue/Makefile.W32 +++ b/src/libluaglue/Makefile.W32 @@ -6,16 +6,18 @@ SUBDIRS = INCLUDE_CXXFLAGS = \ /D_WIN32_WINNT=0x504 \ - /DBUILDING_UTIL + /DBUILDING_LUAGLUE INCLUDE_DIRS = \ /I. \ - /I$(TOPDIR)\include\util + /I$(TOPDIR)\include\luaglue \ + /I$(TOPDIR)\lua\src INCLUDE_LDFLAGS = \ INCLUDE_LIBS = \ - + $(TOPDIR)\lua\src\lua52.lib + CPP_OBJS = \ LuaVM.obj diff --git a/src/libutil/Makefile.W32 b/src/libutil/Makefile.W32 index c4c8f83..dafcd1d 100755 --- a/src/libutil/Makefile.W32 +++ b/src/libutil/Makefile.W32 @@ -10,7 +10,7 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ - /I$(TOPDIR)\include\util + /I$(TOPDIR)\include INCLUDE_LDFLAGS = \ diff --git a/src/libutil/win32/errormsg.cpp b/src/libutil/win32/errormsg.cpp index c0a65d8..1939aa6 100755 --- a/src/libutil/win32/errormsg.cpp +++ b/src/libutil/win32/errormsg.cpp @@ -1,4 +1,4 @@ -#include "win32/errormsg.hpp" +#include "util/win32/errormsg.hpp" using namespace std; diff --git a/src/libutil/win32/stringutils.cpp b/src/libutil/win32/stringutils.cpp index 607735c..b6eab62 100755 --- a/src/libutil/win32/stringutils.cpp +++ b/src/libutil/win32/stringutils.cpp @@ -1,4 +1,4 @@ -#include "win32/stringutils.hpp" +#include "util/win32/stringutils.hpp" using namespace std; diff --git a/src/modules/fetcher/winhttp/Makefile.W32 b/src/modules/fetcher/winhttp/Makefile.W32 index b996b5d..ab00db5 100755 --- a/src/modules/fetcher/winhttp/Makefile.W32 +++ b/src/modules/fetcher/winhttp/Makefile.W32 @@ -10,6 +10,7 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ /I$(TOPDIR)\src \ + /I$(TOPDIR)\include \ /I$(TOPDIR)\include\module \ /I$(TOPDIR)\include\util \ /I$(TOPDIR)\include\logger \ diff --git a/src/modules/processor/robotstxt/Makefile.W32 b/src/modules/processor/robotstxt/Makefile.W32 index ebf1e22..fb39242 100755 --- a/src/modules/processor/robotstxt/Makefile.W32 +++ b/src/modules/processor/robotstxt/Makefile.W32 @@ -10,11 +10,11 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ /I$(TOPDIR)\src \ + /I$(TOPDIR)\include \ /I$(TOPDIR)\include\module \ /I$(TOPDIR)\include\util \ /I$(TOPDIR)\include\logger \ - /I$(TOPDIR)\include\crawler \ - /I$(TOPDIR)\streamhtmlparser + /I$(TOPDIR)\include\crawler INCLUDE_LDFLAGS = \ diff --git a/src/modules/processor/sitemap/Makefile.W32 b/src/modules/processor/sitemap/Makefile.W32 index 115b4c8..1f30297 100755 --- a/src/modules/processor/sitemap/Makefile.W32 +++ b/src/modules/processor/sitemap/Makefile.W32 @@ -13,7 +13,8 @@ INCLUDE_DIRS = \ /I$(TOPDIR)\include\module \ /I$(TOPDIR)\include\util \ /I$(TOPDIR)\include\logger \ - /I$(TOPDIR)\include\crawler + /I$(TOPDIR)\include\crawler \ + /I$(TOPDIR)\textwolf\include INCLUDE_LDFLAGS = \ @@ -31,7 +32,7 @@ CPP_OBJS = \ SitemapProcessor.obj SHARED_CPP_OBJS = \ - HTMLLinkExtractProcessor.dllobj + SitemapProcessor.dllobj !INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk diff --git a/src/modules/urlnormalizer/googleurl/Makefile.W32 b/src/modules/urlnormalizer/googleurl/Makefile.W32 index a906404..fb0a76b 100755 --- a/src/modules/urlnormalizer/googleurl/Makefile.W32 +++ b/src/modules/urlnormalizer/googleurl/Makefile.W32 @@ -19,8 +19,15 @@ INCLUDE_LDFLAGS = \ INCLUDE_LIBS = \ $(TOPDIR)\googleurl\googleurl.lib \ - $(TOPDIR)\src\libcrawler\crawler.lib \ + $(TOPDIR)\src\libcrawler\crawler.lib + +!IFDEF DEBUG +INCLUDE_LIBS = $(INCLUDE_LIBS) \ + "$(ICU_DIR)\lib\icuucd.lib" +!ELSE +INCLUDE_LIBS = $(INCLUDE_LIBS) \ "$(ICU_DIR)\lib\icuuc.lib" +!ENDIF DYNAMIC_MODULE = \ mod_urlnormalizer_googleurl.dll diff --git a/tests/modules/Makefile.W32 b/tests/modules/Makefile.W32 index 5705031..307e8a4 100755 --- a/tests/modules/Makefile.W32 +++ b/tests/modules/Makefile.W32 @@ -10,6 +10,7 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ /I$(TOPDIR)\src \ + /I$(TOPDIR)\include \ /I$(TOPDIR)\include\module \ /I$(TOPDIR)\include\util \ /I$(TOPDIR)\include\crawler \ diff --git a/tests/modules/testmod3/Makefile.W32 b/tests/modules/testmod3/Makefile.W32 index 44d289d..f8fc46c 100755 --- a/tests/modules/testmod3/Makefile.W32 +++ b/tests/modules/testmod3/Makefile.W32 @@ -10,6 +10,7 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ /I$(TOPDIR)\src \ + /I$(TOPDIR)\include \ /I$(TOPDIR)\include\module \ /I$(TOPDIR)\include\util \ /I$(TOPDIR)\include\crawler \ diff --git a/tests/modules/testmod4/Makefile.W32 b/tests/modules/testmod4/Makefile.W32 index 6bf7af1..c688308 100755 --- a/tests/modules/testmod4/Makefile.W32 +++ b/tests/modules/testmod4/Makefile.W32 @@ -10,6 +10,7 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ /I$(TOPDIR)\src \ + /I$(TOPDIR)\include \ /I$(TOPDIR)\include\module \ /I$(TOPDIR)\include\util \ /I$(TOPDIR)\include\crawler \ diff --git a/tests/tolua/Makefile.W32 b/tests/tolua/Makefile.W32 new file mode 100644 index 0000000..aedc3e2 --- /dev/null +++ b/tests/tolua/Makefile.W32 @@ -0,0 +1,44 @@ +TOPDIR = ..\.. + +SUBDIRS = libtest1 + +!INCLUDE $(TOPDIR)\makefiles\nmake\platform.mk + +INCLUDE_CXXFLAGS = \ + /D_WIN32_WINNT=0x504 /DSHARED + +INCLUDE_DIRS = \ + /I. \ + /I$(TOPDIR)\src \ + /I$(TOPDIR)\include \ + /I$(TOPDIR)\include\module \ + /I$(TOPDIR)\include\util \ + /I$(TOPDIR)\include\logger \ + /I$(TOPDIR)\include\crawler \ + /I$(TOPDIR)\include\luaglue \ + /I$(TOPDIR)\lua\src + +INCLUDE_LDFLAGS = \ + +INCLUDE_LIBS = \ + $(TOPDIR)\src\libutil\util.lib \ + $(TOPDIR)\src\libcrawler\crawler.lib \ + $(TOPDIR)\src\liblogger\logger.lib \ + $(TOPDIR)\src\libluaglue\luaglue.lib + +TEST_CPP_BINS = \ + test1.exe + +OBJS = + +!INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk + +test1.exe: test1.obj + +local_clean: + @-erase -f *.RES *.DIFF *.ERR 2>NUL + +local_distclean: + +local_test: + @-exec_test test1 "ToLua binding in module" diff --git a/tests/tolua/exec_test b/tests/tolua/exec_test new file mode 100644 index 0000000..5b29fc8 --- /dev/null +++ b/tests/tolua/exec_test @@ -0,0 +1,8 @@ +#!/bin/sh + +BINARY=$1 +TITLE=$2 + +printf "$BINARY: $TITLE .. " +LD_LIBRARY_PATH=../../src:../../src/liblogger:../../src/libcrawler:../../src/libluaglue:libcommon ./$BINARY >$BINARY.RES 2>&1 +diff $BINARY.MUST $BINARY.RES > $BINARY.DIFF && printf "OK\n" || printf "ERROR\n" diff --git a/tests/tolua/exec_test.cmd b/tests/tolua/exec_test.cmd new file mode 100644 index 0000000..49d6168 --- /dev/null +++ b/tests/tolua/exec_test.cmd @@ -0,0 +1,21 @@ +@echo off + +set BINARY=%1 +set TITLE=%2 + +copy libcommon\common.dll . >NUL +copy ..\..\src\libcrawler\crawler.dll . >NUL +copy ..\..\src\liblogger\logger.dll . >NUL +copy ..\..\src\libutil\util.dll . >NUL +copy ..\..\src\libluaglue\luaglue.dll . >NUL +copy ..\..\lua\src\lua52.dll . >NUL +%BINARY% >%BINARY%.OUT 2>%BINARY%.ERR +..\..\utils\win32\dos2unix <%BINARY%.OUT >%BINARY%.RES +erase /q %BINARY%.OUT +echo n | comp %BINARY%.MUST %BINARY%.RES > %BINARY%.DIFF 2>NUL +if ERRORLEVEL 1 GOTO FAIL +echo %BINARY%: %TITLE%.. OK +goto END +:FAIL +echo %BINARY%: %TITLE% .. ERROR +:END diff --git a/tests/tolua/libtest1/Makefile.W32 b/tests/tolua/libtest1/Makefile.W32 new file mode 100644 index 0000000..407d9ae --- /dev/null +++ b/tests/tolua/libtest1/Makefile.W32 @@ -0,0 +1,53 @@ +TOPDIR = ..\..\.. + +SUBDIRS = + +!INCLUDE $(TOPDIR)\makefiles\nmake\platform.mk + +INCLUDE_CXXFLAGS = \ + /D_WIN32_WINNT=0x504 + +INCLUDE_DIRS = \ + /I. \ + /I$(TOPDIR)\src \ + /I$(TOPDIR)\include \ + /I$(TOPDIR)\include\module \ + /I$(TOPDIR)\include\util \ + /I$(TOPDIR)\include\luaglue \ + /I.. + +INCLUDE_LDFLAGS = \ + +INCLUDE_LIBS = \ + $(TOPDIR)\src\libutil\util.lib \ + $(TOPDIR)\src\libluaglue\luaglue.lib + +DYNAMIC_MODULE = \ + mod_test.dll + +STATIC_LIB = \ + libtest.lib + +CPP_OBJS = \ + TestMod.obj \ + TestModLua.obj + +SHARED_CPP_OBJS = \ + TestMod.dllobj \ + TestModLua.dllobj + +!INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk + +$(STATIC_LIB): $(CPP_OBJS) + $(LINK) /lib /nologo /out:$@ $(STATIC_LDFLAGS) $? + +$(DYNAMIC_MODULE): $(SHARED_CPP_OBJS) + $(LINK) /dll /nologo /out:$@ $(LDFLAGS) $(LIBS) $? + +local_all: $(STATIC_LIB) $(DYNAMIC_MODULE) + +local_clean: + +local_distclean: + +local_test: diff --git a/tests/url/Makefile.W32 b/tests/url/Makefile.W32 index d71853c..93e6494 100755 --- a/tests/url/Makefile.W32 +++ b/tests/url/Makefile.W32 @@ -11,6 +11,7 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ /I$(TOPDIR)\src \ + /I$(TOPDIR)\include \ /I$(TOPDIR)\include\module \ /I$(TOPDIR)\include\util \ /I$(TOPDIR)\include\crawler \ @@ -25,7 +26,14 @@ INCLUDE_LIBS = \ $(TOPDIR)\src\modules\urlnormalizer\simpleurl\simpleurlnormalizer.lib \ $(TOPDIR)\src\modules\urlnormalizer\googleurl\googleurlnormalizer.lib \ $(TOPDIR)\googleurl\googleurl.lib \ + +!IFDEF DEBUG +INCLUDE_LIBS = $(INCLUDE_LIBS) \ + "$(ICU_DIR)\lib\icuucd.lib" +!ELSE +INCLUDE_LIBS = $(INCLUDE_LIBS) \ "$(ICU_DIR)\lib\icuuc.lib" +!ENDIF TEST_CPP_BINS = \ test1.exe -- cgit v1.2.3-54-g00ecf