[Ttssh2-commit] [4728] svnrev を実行するとき、リビジョンを調べるディレクトリと出力ファイル名を引数で渡すようにした

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 11月 18日 (金) 18:10:09 JST


Revision: 4728
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4728
Author:   maya
Date:     2011-11-18 18:10:09 +0900 (Fri, 18 Nov 2011)

Log Message:
-----------
svnrev を実行するとき、リビジョンを調べるディレクトリと出力ファイル名を引数で渡すようにした

Modified Paths:
--------------
    trunk/teraterm/svnrev/svnrev.cpp
    trunk/teraterm/ttpdlg/ttpdlg.vcproj


-------------- next part --------------
Modified: trunk/teraterm/svnrev/svnrev.cpp
===================================================================
--- trunk/teraterm/svnrev/svnrev.cpp	2011-11-16 14:28:02 UTC (rev 4727)
+++ trunk/teraterm/svnrev/svnrev.cpp	2011-11-18 09:10:09 UTC (rev 4728)
@@ -18,7 +18,10 @@
 	int revision = -1;
 
 	filename = path;
-	filename += "\\.svn\\entries"; // [top of source tree]\.svn\entries
+	if (filename.Right(1) != "\\") {
+		filename += "\\";
+	}
+	filename += ".svn\\entries"; // [top of source tree]\.svn\entries
 
 	ret = csf.Open(filename, CFile::modeRead);
 	if (ret == FALSE) {
@@ -46,16 +49,20 @@
 	return revision;
 }
 
-BOOL write_svn_revesion(char *path, int revision) {
+BOOL write_svn_revesion(char *filename, int revision) {
 	BOOL ret;
 	CStdioFile csf;
-	CString cs, filename;
+	CString cs;
 	int file_revision = -1;
 	
-	filename = path;
-	filename += "\\teraterm\\ttpdlg\\svnversion.h";
+	// print to stdout
+	if (strcmp(filename, "-") == 0) {
+		CStdioFile csf (stdout);
+		cs.Format("#define SVNVERSION %d\n", revision);
+		csf.WriteString(cs);
+		return TRUE;
+	}
 
-
 	// read current file
 	ret = csf.Open(filename, CFile::modeRead);
 	if (ret == TRUE) {
@@ -97,30 +104,19 @@
 
 int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 {
-	int nRetCode = 0;
 	int revision = -1;
-	char path[MAX_PATH * 2];
-	int i, len;
+	char *input, *output;
 
-	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) {
-		return 1;
+	if (argc != 3) {
+		printf("USAGE: %s path output\n", argv[0]);
+		return -1;
 	}
 
-	GetModuleFileName(::GetModuleHandle(NULL), path, sizeof(path));
-	len = (int)strlen(path);
-	for (i=len; i>=0; i--) {
-		if (path[i] == '\\') {
-			break;
-		}
-		path[i] = '\0';
-	}
-	SetCurrentDirectory(path); // teraterm\debug or teraterm\release
-	SetCurrentDirectory("..\\..\\"); // top of source tree
-	GetCurrentDirectory(sizeof(path), path);
+	input = argv[1];
+	output = argv[2];
+	revision = get_svn_revision(input);
 
-	revision = get_svn_revision(path);
-
-	if (!write_svn_revesion(path, revision)) {
+	if (!write_svn_revesion(output, revision)) {
 		return 1;
 	}
 

Modified: trunk/teraterm/ttpdlg/ttpdlg.vcproj
===================================================================
--- trunk/teraterm/ttpdlg/ttpdlg.vcproj	2011-11-16 14:28:02 UTC (rev 4727)
+++ trunk/teraterm/ttpdlg/ttpdlg.vcproj	2011-11-18 09:10:09 UTC (rev 4728)
@@ -25,7 +25,7 @@
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="$(OutDir)\svnrev.exe"
+				CommandLine="$(OutDir)\svnrev.exe $(SolutionDir)..\ $(ProjectDir)svnversion.h"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -126,7 +126,7 @@
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="$(OutDir)\svnrev.exe"
+				CommandLine="$(OutDir)\svnrev.exe $(SolutionDir)..\ $(ProjectDir)svnversion.h"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"



Ttssh2-commit メーリングリストの案内
Back to archive index