diff --git a/build.md b/build.md index 5642ccc9ce..fb329e422c 100644 --- a/build.md +++ b/build.md @@ -21,6 +21,7 @@ - [開発者向けの情報](#開発者向けの情報) - [githash.h の更新のスキップ](#githashh-の更新のスキップ) - [Powershell によるZIPファイルの圧縮、解凍、内容確認の強制](#powershell-によるzipファイルの圧縮解凍内容確認の強制) + - [MinGW-w64 ビルド](#MinGW-w64-ビルド) @@ -140,3 +141,32 @@ build-sln.bat x64 Release build-sln.bat x64 Debug ``` +### MinGW w64 ビルド + +生成されるバイナリは正しく動作しないが、MinGWでのビルドも可能。 + + +MinGW64のビルド環境 + +* [pleiades 4.6 Neon](http://mergedoc.osdn.jp/) +* [MSYS2+MinGW-w64](https://gist.github.com/Hamayama/eb4b4824ada3ac71beee0c9bb5fa546d) +* [MinGW-w64](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/) + +cpu | thread モデル | 例外モデル | コメント +---- | ---- | ---- | ---- +x86_64 | win32 | seh | windows向け。外部DLL不要 +x86_64 | posix | seh | 標準。pthreadのDLLが必要 +x86_64 | win32 | sjlj | 外部DLL不要 +x86_64 | posix | sjlj | pthreadのDLLが必要 + +標準的なMinGWセットアップでビルドしたバイナリは ```libwinpthread-1.dll``` に依存することに注意。 + + +コマンド実行例 + +``` +path=D:\eclipse4.6\eclipse\mingw\bin;%path% +cd sakura_core +mingw32-make githash stdafx sakura_rc.o +mingw32-make -j4 +``` diff --git a/sakura/mingw32-del.bat b/sakura/mingw32-del.bat new file mode 100644 index 0000000000..6119c11a04 --- /dev/null +++ b/sakura/mingw32-del.bat @@ -0,0 +1,26 @@ +@echo off + +SETLOCAL + +:�����œn���ꂽ�t�@�C���Q���擾 +set OUTFILES=%* +:�p�X��؂��u�� +set OUTFILES=%OUTFILES:/=\% + + +:del_file +:1�t�@�C������del�R�}���h�ɓn���č폜 +for /F "tokens=1,*" %%f in ("%OUTFILES%") DO ( + if exist %%f del /F /Q %%f + set OUTFILES=%%g +) + +:����ԍ폜�ł�����I�� +if "%OUTFILES%" == "" goto :EOF +goto :del_file + + +:END + +ENDLOCAL +exit /b diff --git a/sakura_core/Makefile b/sakura_core/Makefile index 6f0a3d20f6..a3ba83cfb6 100644 --- a/sakura_core/Makefile +++ b/sakura_core/Makefile @@ -20,19 +20,20 @@ endif CC= $(PREFIX)gcc CXX= $(PREFIX)g++ RC= $(RCPREFIX)windres -SUBWCREV= SubWCRev.exe +RM= cmd /c $(CURDIR)/../sakura/mingw32-del.bat DEFINES= \ -DWIN32 \ -DWINVER=0x500 \ -D_WIN32_WINNT=0x500 \ -D_WIN32_IE=0x501 \ + -DMINGW_HAS_SECURE_API=1 \ -DNOMINMAX \ -D_UNICODE \ -DUNICODE \ -DNDEBUG CFLAGS= -O2 \ - -finput-charset=cp932 -fexec-charset=cp932 \ + -finput-charset=utf-8 -fexec-charset=cp932 \ -I. \ $(DEFINES) $(MYCFLAGS) CXXFLAGS= $(CFLAGS) $(MYCXXFLAGS) @@ -416,47 +417,46 @@ _os/CDropTarget.o \ _os/COsVersionInfo.o \ sakura_rc.o \ +GENERATED_FILES= \ +Funccode_define.h \ +Funccode_enum.h \ +githash.h \ + RCTOOLDIR=../btool RCTOOL=$(RCTOOLDIR)/mrc2grc.exe HEADERMAKETOOLDIR= ../HeaderMake HEADERMAKE= $(HEADERMAKETOOLDIR)/HeaderMake.exe -all: $(RCTOOL) $(HEADERMAKE) $(exe) +all: $(exe) -$(exe): Funccode_define.h Funccode_enum.h svnrev stdafx $(OBJS) +$(exe): githash $(OBJS) $(CXX) -o $@ $(OBJS) $(LIBS) -Funccode_define.h: Funccode_x.hsrc +Funccode_define.h: $(HEADERMAKE) Funccode_x.hsrc $(HEADERMAKE) -in=../sakura_core/Funccode_x.hsrc -out=../sakura_core/Funccode_define.h -mode=define -Funccode_enum.h: Funccode_x.hsrc +Funccode_enum.h: $(HEADERMAKE) Funccode_x.hsrc $(HEADERMAKE) -in=../sakura_core/Funccode_x.hsrc -out=../sakura_core/Funccode_enum.h -mode=enum -enum=EFunctionCode -svnrev: - cp svnrev_unknown.h svnrev.h - -$(SUBWCREV) ".\\" ".\svnrev_template.h" ".\svnrev.h" +githash: + cmd /c $(CURDIR)/../sakura/githash.bat ..\\sakura_core -stdafx: +stdafx: Funccode_enum.h StdAfx.h $(CXX) $(CXXFLAGS) -c StdAfx.h -.cpp.o: +.cpp.o: stdafx $(CXX) $(CXXFLAGS) -o $@ -c $< -$(RCTOOL): $(RCTOOLDIR)/mrc2grc.cpp - $(CXX) $(CXXFLAGS) $(RCTOOLDIR)/mrc2grc.cpp -o $@ -static-libgcc - $(HEADERMAKE): $(HEADERMAKETOOLDIR)/HeaderMake.cpp $(CXX) $(CXXFLAGS) $(HEADERMAKETOOLDIR)/HeaderMake.cpp -o $@ -static-libgcc -.rc.o: - $(RCTOOL) $< sakura_grc.rc - $(RC) --language=0411 $(DEFINES) sakura_grc.rc -o $@ - $(RM) sakura_grc.rc +sakura_rc.o: Funccode_define.h githash sakura_rc.rc + $(RC) -c utf-8 --language=0411 $(DEFINES) sakura_rc.rc -o $@ clean: - $(RM) $(exe) $(OBJS) $(RCTOOL) $(HEADERMAKE) StdAfx.h.gch + $(RM) $(exe) $(OBJS) $(HEADERMAKE) StdAfx.h.gch $(GENERATED_FILES) -depend: svnrev +depend: githash $(CXX) -E -MM -w $(DEFINES) $(CXXFLAGS) *.cpp */*.cpp */*/*.cpp > depend.mak .SUFFIXES: .cpp .o .rc diff --git a/sakura_core/StdAfx.h b/sakura_core/StdAfx.h index 22db244345..d31c288e4d 100644 --- a/sakura_core/StdAfx.h +++ b/sakura_core/StdAfx.h @@ -34,12 +34,6 @@ #endif #endif -#ifdef __MINGW32__ -#include <_mingw.h> -#ifdef MINGW_HAS_SECURE_API -#undef MINGW_HAS_SECURE_API -#endif // MINGW_HAS_SECURE_API -#endif // __MINGW32__ //グローバル #include "_main/global.h" diff --git a/sakura_core/io/CFileLoad.cpp b/sakura_core/io/CFileLoad.cpp index 095d9614b5..fb9c51d19b 100644 --- a/sakura_core/io/CFileLoad.cpp +++ b/sakura_core/io/CFileLoad.cpp @@ -656,7 +656,7 @@ const char* CFileLoad::GetNextLineCharCode( if( pData[i] == '\x0d' || pData[i] == '\x25' ){ char szEof[3] = { (pData[i] == '\x25' ? '\x0a' : '\x0d'), - (pData[i+1]== '\x25' ? '\x0a' : + (pData[i+1]== '\x25' ? '\x0a' : (char) (pData[i+1] == '\x0a' ? 0 : // EBCDIC の"\x0aがLFにならないように細工する (i + 1 < nDataLen ? pData[i+1] : 0))), 0 diff --git a/sakura_core/io/CZipFile.cpp b/sakura_core/io/CZipFile.cpp index 87084786df..590dbd1a88 100644 --- a/sakura_core/io/CZipFile.cpp +++ b/sakura_core/io/CZipFile.cpp @@ -28,18 +28,6 @@ #include "StdAfx.h" #include #include "CZipFile.h" -#ifdef __MINGW32__ -//uuid(D8F015C0-C278-11CE-A49E-444553540000); -const GUID IID_IShellDispatch = -{ - 0xD8F015C0, 0xc278, 0x11ce, { 0xa4, 0x9e, 0x44, 0x45, 0x53, 0x54 } -}; -// 13709620-C279-11CE-A49E-444553540000 -const GUID CLSID_Shell = -{ - 0x13709620, 0xc279, 0x11ce, { 0xa4, 0x9e, 0x44, 0x45, 0x53, 0x54 } -}; -#endif // コンストラクタ diff --git a/sakura_core/macro/CMacroFactory.cpp b/sakura_core/macro/CMacroFactory.cpp index a7643dcaaa..0cfe030240 100644 --- a/sakura_core/macro/CMacroFactory.cpp +++ b/sakura_core/macro/CMacroFactory.cpp @@ -89,7 +89,7 @@ bool CMacroFactory::RegisterCreator( Creator f ) bool CMacroFactory::Unregister( Creator f ) { // Creator Listからの削除 - auto& c_it = m_mMacroCreators.begin(); + auto c_it = m_mMacroCreators.begin(); while( c_it != m_mMacroCreators.end() ){ if( *c_it == f ){ // いきなり削除するとiteratorが無効になるので, diff --git a/sakura_core/mem/CNativeA.cpp b/sakura_core/mem/CNativeA.cpp index f6b7490f1a..eb6a9225f4 100644 --- a/sakura_core/mem/CNativeA.cpp +++ b/sakura_core/mem/CNativeA.cpp @@ -73,9 +73,8 @@ void CNativeA::AppendStringF(const char* pszData, ...) va_end(v); if (len == -1) { - char cbuf[128]; - sprintf_s(cbuf, _countof(cbuf), "AppendStringF error. errno = %d", e); - throw std::exception(cbuf); + DEBUG_TRACE(L"AppendStringF error. errno = %d", e); + throw std::exception(); } // 追加 diff --git a/sakura_core/mem/CNativeW.cpp b/sakura_core/mem/CNativeW.cpp index eb798d4125..651438fb0c 100644 --- a/sakura_core/mem/CNativeW.cpp +++ b/sakura_core/mem/CNativeW.cpp @@ -97,9 +97,8 @@ void CNativeW::AppendStringF(const wchar_t* pszData, ...) va_end(v); if (len == -1) { - char cbuf[128]; - sprintf_s(cbuf, _countof(cbuf), "AppendStringF error. errno = %d", e); - throw std::exception(cbuf); + DEBUG_TRACE(L"AppendStringF error. errno = %d", e); + throw std::exception(); } // 追加 diff --git a/sakura_core/util/string_ex.cpp b/sakura_core/util/string_ex.cpp index b05a6ce8f8..ac060424b3 100644 --- a/sakura_core/util/string_ex.cpp +++ b/sakura_core/util/string_ex.cpp @@ -222,7 +222,9 @@ const char* stristr_j( const char* s1, const char* s2 ) // 互換 // // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // -#if (defined(_MSC_VER) && _MSC_VER<1400) || defined(__MINGW32__) //VS2005より前なら +#if (defined(_MSC_VER) && _MSC_VER<1400) \ +|| (defined(__MINGW32__) && defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) //VS2005より前なら + errno_t wcscat_s(wchar_t* szDst, size_t nDstCount, const wchar_t* szSrc) { // 本物は _set_invalid_parameter_handler で設定されたハンドラが起動します diff --git a/sakura_core/util/string_ex.h b/sakura_core/util/string_ex.h index b272bd6456..f72166af66 100644 --- a/sakura_core/util/string_ex.h +++ b/sakura_core/util/string_ex.h @@ -144,7 +144,8 @@ int my_strnicmp( const char *s1, const char *s2, size_t n ); // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // // VS2005以降の安全版文字列関数 -#if (defined(_MSC_VER) && _MSC_VER<1400) || defined(__MINGW32__) //VS2005より前なら +#if (defined(_MSC_VER) && _MSC_VER<1400) \ + || (defined(__MINGW32__) && defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) //VS2005より前なら typedef int errno_t; #define _TRUNCATE ((size_t)-1) errno_t strcpy_s(char *dest, size_t num, const char *src);