• R/O
  • SSH
  • HTTPS

ttssh2: コミット


コミットメタ情報

リビジョン5665 (tree)
日時2014-09-20 00:05:02
作者(del#1144)

ログメッセージ

インストーラはインストールされている Cygwin が 32bit か 64bit か判定して、適切な cygterm.exe をコピーする

32bit 版の cygterm.exe もフォルダを作ってインストールする
{app} に cygterm.exe がないときだけ、cygwin1.dll を探して判定して適切な cygterm.exe をコピーする
アンインストール時には {app}\cygterm.exe を必ず削除する

64bit Cygwin でコンパイルした cyglaunch.exe の同梱をやめた

cyglaunch.exe は単体で動くので、32bit 版バイナリでも 64bit の cygterm.exe を起動できるため

変更サマリ

差分

--- trunk/installer/build.bat (revision 5664)
+++ trunk/installer/build.bat (revision 5665)
@@ -28,3 +28,8 @@
2828 if "%BUILD%" == "rebuild" make clean
2929 make
3030 popd
31+
32+rem cygtool をコンパイル
33+pushd cygtool
34+nmake -f cygtool.mak
35+popd
--- trunk/installer/cygtool/cygtool.c (nonexistent)
+++ trunk/installer/cygtool/cygtool.c (revision 5665)
@@ -0,0 +1,224 @@
1+#pragma comment(lib, "version.lib")
2+
3+#include <windows.h>
4+#include <stdio.h>
5+
6+#include "compat_w95.h"
7+
8+int __stdcall FindCygwinPath(char *CygwinDirectory, char *Dir, int Dirlen)
9+{
10+ char c, *envptr, *p, *p2;
11+
12+ envptr = getenv("PATH");
13+ if (envptr == NULL) {
14+ return 0;
15+ }
16+#ifdef EXE
17+ printf(" PATH => %s\n", envptr);
18+#endif
19+ if ((p = strstr(envptr, "cygwin\\bin")) != NULL) {
20+ goto found_path;
21+ }
22+ if ((p = strstr(envptr, "cygwin64\\bin")) != NULL) {
23+ goto found_path;
24+ }
25+
26+ _snprintf_s(Dir, Dirlen, _TRUNCATE, "%s\\bin", CygwinDirectory);
27+ if (GetFileAttributes(Dir) != -1) { // open success
28+ goto found_dll;
29+ }
30+
31+ _snprintf_s(Dir, Dirlen, _TRUNCATE, "C:\\cygwin\\bin");
32+ for (c = 'C' ; c <= 'Z' ; c++) {
33+ Dir[0] = c;
34+ if (GetFileAttributes(Dir) != -1) { // open success
35+ goto found_dll;
36+ }
37+ }
38+ _snprintf_s(Dir, Dirlen, _TRUNCATE, "C:\\cygwin64\\bin");
39+ for (c = 'C' ; c <= 'Z' ; c++) {
40+ Dir[0] = c;
41+ if (GetFileAttributes(Dir) != -1) { // open success
42+ goto found_dll;
43+ }
44+ }
45+
46+ return 0;
47+
48+found_dll:;
49+ Dir[strlen(Dir)-4] = '\0'; // delete "\\bin"
50+ return 1;
51+
52+found_path:;
53+ if ((p2 = strchr(p, ';')) == NULL) {
54+ p2 += strlen(p);
55+ }
56+ else {
57+ p2--;
58+ }
59+ while (envptr < p) {
60+ p--;
61+ if (*p == ';') {
62+ p++;
63+ break;
64+ }
65+ }
66+ strncpy_s(Dir, Dirlen, p, _TRUNCATE);
67+ if (p2 - p < Dirlen-1) {
68+ Dir[p2 - p + 1] = '\0';
69+ }
70+ Dir[strlen(Dir)-4] = '\0'; // delete "\\bin"
71+ return 1;
72+}
73+
74+int __stdcall CygwinMachine(char *file)
75+{
76+ FILE *fp;
77+ unsigned char buf[4];
78+ long e_lfanew;
79+ WORD Machine;
80+
81+ if ((fp = fopen(file, "rb")) == NULL) {
82+ return IMAGE_FILE_MACHINE_UNKNOWN;
83+ }
84+
85+ // IMAGE_DOS_HEADER
86+ if (fseek(fp, 0x3c, SEEK_SET) != 0) {
87+ fclose(fp);
88+ return IMAGE_FILE_MACHINE_UNKNOWN;
89+ }
90+ if (fread(buf, sizeof(char), 4, fp) < 4) {
91+ fclose(fp);
92+ return IMAGE_FILE_MACHINE_UNKNOWN;
93+ }
94+ e_lfanew = buf[0] + (buf[1] << 8) + (buf[1] << 16) + (buf[1] << 24);
95+#ifdef EXE
96+ printf(" e_lfanew => x%08x\n", e_lfanew);
97+#endif
98+
99+ // IMAGE_NT_HEADERS32
100+ // DWORD Signature;
101+ // IMAGE_FILE_HEADER FileHeader;
102+ if (fseek(fp, e_lfanew + 4, SEEK_SET) != 0) {
103+ fclose(fp);
104+ return IMAGE_FILE_MACHINE_UNKNOWN;
105+ }
106+ if (fread(buf, sizeof(char), 2, fp) < 2) {
107+ fclose(fp);
108+ return IMAGE_FILE_MACHINE_UNKNOWN;
109+ }
110+ Machine = buf[0] + (buf[1] << 8);
111+
112+ fclose(fp);
113+
114+ return Machine;
115+}
116+
117+int __stdcall CygwinVersion(char *dll, int *major, int *minor)
118+{
119+ DWORD dwSize;
120+ DWORD dwHandle;
121+ DWORD dwLen;
122+ LPVOID lpBuf;
123+ UINT uLen;
124+ VS_FIXEDFILEINFO *pFileInfo;
125+
126+ dwSize = GetFileVersionInfoSize(dll, &dwHandle);
127+ if (dwSize == 0) {
128+ return 0;
129+ }
130+
131+ lpBuf = malloc(dwSize);
132+ if (!GetFileVersionInfo(dll, dwHandle, dwSize, lpBuf)) {
133+ free(lpBuf);
134+ return 0;
135+ }
136+
137+ if (!VerQueryValue(lpBuf, "\\", (LPVOID*)&pFileInfo, &uLen)) {
138+ free(lpBuf);
139+ return 0;
140+ }
141+
142+ *major = HIWORD(pFileInfo->dwFileVersionMS);
143+ *minor = LOWORD(pFileInfo->dwFileVersionMS);
144+
145+ free(lpBuf);
146+
147+ return 1;
148+}
149+
150+#ifdef EXE
151+int main(void)
152+{
153+ char file[MAX_PATH];
154+ char version[MAX_PATH];
155+ int file_len = sizeof(file);
156+ int version_major, version_minor;
157+ int res;
158+
159+ printf("FindCygwinPath()\n");
160+ res = FindCygwinPath("C:\\cygwin", file, file_len);
161+ printf(" result => %d\n", res);
162+ if (!res) {
163+ printf("\n");
164+ return -1;
165+ }
166+ printf(" Cygwin directory => %s\n", file);
167+ printf("\n");
168+
169+ printf("CygwinMachine()\n");
170+ strncat_s(file, sizeof(file), "\\bin\\cygwin1.dll", _TRUNCATE);
171+ printf(" Cygwin DLL => %s\n", file);
172+ res = CygwinMachine(file);
173+ printf(" Machine => x%04x", res);
174+ switch (res) {
175+ case IMAGE_FILE_MACHINE_I386:
176+ printf(" = %s\n", "IMAGE_FILE_MACHINE_I386");
177+ break;
178+ case IMAGE_FILE_MACHINE_AMD64:
179+ printf(" = %s\n", "IMAGE_FILE_MACHINE_AMD64");
180+ break;
181+ default:
182+ printf("\n");
183+ return -1;
184+ break;
185+ }
186+ printf("\n");
187+
188+ printf("CygwinVersion()\n");
189+ printf(" Cygwin DLL => %s\n", file);
190+ res = CygwinVersion(file, &version_major, &version_minor);
191+ printf(" result => %d\n", res);
192+ if (!res) {
193+ printf("\n");
194+ return -1;
195+ }
196+ printf(" version_major => %d\n", version_major);
197+ printf(" version_minor => %d\n", version_minor);
198+ printf("\n");
199+
200+ return 0;
201+}
202+#else
203+BOOL WINAPI DllMain(HANDLE hInstance,
204+ ULONG ul_reason_for_call,
205+ LPVOID lpReserved)
206+{
207+ switch( ul_reason_for_call ) {
208+ case DLL_THREAD_ATTACH:
209+ /* do thread initialization */
210+ break;
211+ case DLL_THREAD_DETACH:
212+ /* do thread cleanup */
213+ break;
214+ case DLL_PROCESS_ATTACH:
215+ /* do process initialization */
216+ DoCover_IsDebuggerPresent();
217+ break;
218+ case DLL_PROCESS_DETACH:
219+ /* do process cleanup */
220+ break;
221+ }
222+ return TRUE;
223+}
224+#endif
--- trunk/installer/makearchive.bat (revision 5664)
+++ trunk/installer/makearchive.bat (revision 5665)
@@ -47,9 +47,11 @@
4747 copy /y ..\cygterm\cygterm.cfg %dst%
4848 copy /y ..\cygterm\cyglaunch.exe %dst%
4949 copy /y "..\cygterm\cygterm+.tar.gz" %dst%
50+copy /y "..\cygterm\cygterm.exe" %dst%
51+mkdir "%dst%\cygterm+-i686"
52+copy /y "..\cygterm\cygterm.exe" "%dst%\cygterm+-i686"
5053 mkdir "%dst%\cygterm+-x86_64"
5154 copy /y "..\cygterm\cygterm+-x86_64\cygterm.exe" "%dst%\cygterm+-x86_64"
52-copy /y "..\cygterm\cygterm+-x86_64\cyglaunch.exe" "%dst%\cygterm+-x86_64"
5355 copy /y ..\ttpmenu\Release\ttpmenu.exe %dst%
5456 copy /y ..\TTProxy\Release\TTXProxy.dll %dst%
5557 copy /y ..\TTXKanjiMenu\Release\ttxkanjimenu.dll %dst%
旧リポジトリブラウザで表示