[ttssh2-commit] [9764] svnrev_perl/ を buildtools/svnrev/ へ移動

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 2月 21日 (月) 01:16:29 JST


Revision: 9764
          https://osdn.net/projects/ttssh2/scm/svn/commits/9764
Author:   zmatsuo
Date:     2022-02-21 01:16:28 +0900 (Mon, 21 Feb 2022)
Log Message:
-----------
svnrev_perl/ を buildtools/svnrev/ へ移動

ttssh2-dev 257

Modified Paths:
--------------
    trunk/CMakeLists.txt
    trunk/ci_scripts/build_appveyor.bat
    trunk/ci_scripts/build_appveyor.cmake
    trunk/doc/en/html/reference/develop.html
    trunk/doc/en/html/reference/develop.txt
    trunk/doc/ja/html/reference/develop.html
    trunk/doc/ja/html/reference/develop.txt
    trunk/installer/build.bat
    trunk/teraterm/teraterm/ttermpro.v16.vcxproj
    trunk/teraterm/teraterm/ttermpro.v8.vcproj

Added Paths:
-----------
    trunk/buildtools/svnrev/
    trunk/buildtools/svnrev/.gitignore
    trunk/buildtools/svnrev/readme.md
    trunk/buildtools/svnrev/svnrev.bat
    trunk/buildtools/svnrev/svnrev.pl
    trunk/buildtools/svnrev/svnversion.default.h
    trunk/buildtools/svnrev/toolinfo_sample.txt

Removed Paths:
-------------
    trunk/svnrev_perl/.gitignore
    trunk/svnrev_perl/readme.md
    trunk/svnrev_perl/svnrev.bat
    trunk/svnrev_perl/svnrev.pl
    trunk/svnrev_perl/svnversion.default.h
    trunk/svnrev_perl/toolinfo_sample.txt

-------------- next part --------------
Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/CMakeLists.txt	2022-02-20 16:16:28 UTC (rev 9764)
@@ -138,7 +138,7 @@
   file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/teraterm/ttpdlg)
   execute_process(
     COMMAND ${PERL} svnrev.pl --svn "${Subversion_SVN_EXECUTABLE}" --git "${GIT_EXECUTABLE}" --root ${CMAKE_SOURCE_DIR} --header ${CMAKE_BINARY_DIR}/teraterm/ttpdlg/svnversion.h --cmake ${CMAKE_BINARY_DIR}/build_config.cmake
-    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/svnrev_perl
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/buildtools/svnrev
     RESULT_VARIABLE rv
     )
   if(NOT rv STREQUAL "0")

Copied: trunk/buildtools/svnrev/.gitignore (from rev 9763, trunk/svnrev_perl/.gitignore)
===================================================================
--- trunk/buildtools/svnrev/.gitignore	                        (rev 0)
+++ trunk/buildtools/svnrev/.gitignore	2022-02-20 16:16:28 UTC (rev 9764)
@@ -0,0 +1 @@
+sourcetree_info.bat

Copied: trunk/buildtools/svnrev/readme.md (from rev 9763, trunk/svnrev_perl/readme.md)
===================================================================
--- trunk/buildtools/svnrev/readme.md	                        (rev 0)
+++ trunk/buildtools/svnrev/readme.md	2022-02-20 16:16:28 UTC (rev 9764)
@@ -0,0 +1,59 @@
+# svnrev
+
+- ソースツリーのsvn(又は git)の情報をヘッダファイル等に書き出すためのツール
+  - ソース用のヘッダフィル
+    - 例 `../teraterm/ttpdlg/svnversion.h`
+  - CI用のbatファイル
+    - 例 `sourcetree_info.bat`
+  - cmake用ファイル
+    - 例 buildフォルダの `build_config.cmake`
+
+## 準備
+
+- perl を実行できるようにしておく
+  - perl が実行できるよう環境変数 PATH を設定する
+  - または、../buildtools/libs/perl があれば使用する
+    - ../buildtools/getperl.bat をダブルクリックすると
+      strawberry perl が buildtools/perl に展開される
+  - または、いくつかのメジャーなperlを探して見つければ使用する
+  - perl が見つからない場合は svnversion.default.h が使用される
+- svn(又は git)をインストールしておく
+  - Windows用svnの例
+    - Subversion for Windows
+      - http://sourceforge.net/projects/win32svn/
+    - TortoiseSVN の command line client tools
+      - https://tortoisesvn.net/
+  - Windows用gitの例
+    - git
+      - https://git-scm.com/
+  - 標準的なインストールフォルダから自動的に実行ファイルを探す
+  - 見つからない場合は環境変数 PATH にあるプログラムを実行する
+  - toolinfo.txt にツールのパスを書いておくと優先して使用される
+  - ツールが実行できない場合もヘッダファイルは作成される
+
+# ヘッダの作成方法
+
+- Visual Studioを利用している場合
+  - 自動的に生成される
+  - ttermpro プロジェクトのビルド前のイベントでsvnrev.batが呼び出される
+- Windows の場合
+  - svnrev.bat をダブルクリックでヘッダが作成される
+- cmake の場合
+  - ビルド用のファイルをジェネレート時に自動で生成される
+  - build フォルダの build_config.cmake を削除してビルドすると再生成される
+- コマンドラインで直接実行する場合
+  - `perl svnrev.pl --root ../.. --header ../../teraterm/ttpdlg/svnversion.h`
+
+## svnrev.pl のオプション
+
+- --root
+  - プロジェクトファイルのパス
+  - '.svn/' 又は '.git/' の存在するパス
+- --header
+  - ヘッダファイルのパス
+- --svn
+  - svnコマンドのパス
+- --git
+  - gitコマンドのパス
+
+オプションが toolinfo.txt より優先される

Copied: trunk/buildtools/svnrev/svnrev.bat (from rev 9763, trunk/svnrev_perl/svnrev.bat)
===================================================================
--- trunk/buildtools/svnrev/svnrev.bat	                        (rev 0)
+++ trunk/buildtools/svnrev/svnrev.bat	2022-02-20 16:16:28 UTC (rev 9764)
@@ -0,0 +1,49 @@
+ @ echo off
+setlocal
+cd /d %~dp0
+set BAT=%~n0%~x0
+
+set SVNVERSION_H=../../teraterm/ttpdlg/svnversion.h
+set SVNVERSION_H_DOS=..\..\teraterm\ttpdlg\svnversion.h
+set DO_NOT_RUN_SVNREV=do_not_run_svnrev.txt
+
+if NOT EXIST %SVNVERSION_H% goto env_perl
+if NOT EXIST %DO_NOT_RUN_SVNREV% goto env_perl
+ @ echo %BAT%: Find %DO_NOT_RUN_SVNREV%, Do not run svnrev.pl
+goto finish
+
+:env_perl
+if NOT "%PERL%" == "" goto found_perl
+
+:search_perl
+set PERL=perl.exe
+where %PERL% > nul 2>&1
+if %errorlevel% == 0 goto found_perl
+set PERL=%~dp0..\buildtools\perl\perl\bin\perl.exe
+if exist %PERL% goto found_perl
+set PERL=C:\Strawberry\perl\bin\perl.exe
+if exist %PERL% goto found_perl
+set PERL=C:\Perl64\bin\perl.exe
+if exist %PERL% goto found_perl
+set PERL=C:\Perl\bin\perl.exe
+if exist %PERL% goto found_perl
+set PERL=C:\cygwin64\usr\bin\perl.exe
+if exist %PERL% goto found_perl
+set PERL=C:\cygwin\usr\bin\perl.exe
+if exist %PERL% goto found_perl
+goto no_perl
+
+:no_perl
+ @ echo %BAT%: perl not found
+ @ echo %BAT%: default svnversion.h is used
+if exist sourcetree_info.bat del sourcetree_info.bat
+type svnversion.default.h > %SVNVERSION_H_DOS%
+goto finish
+
+:found_perl
+ @ echo %BAT%: perl=%PERL%
+%PERL% svnrev.pl --root ../.. --header %SVNVERSION_H%
+goto finish
+
+
+:finish

Copied: trunk/buildtools/svnrev/svnrev.pl (from rev 9763, trunk/svnrev_perl/svnrev.pl)
===================================================================
--- trunk/buildtools/svnrev/svnrev.pl	                        (rev 0)
+++ trunk/buildtools/svnrev/svnrev.pl	2022-02-20 16:16:28 UTC (rev 9764)
@@ -0,0 +1,302 @@
+use strict;
+use warnings;
+use utf8;
+use Getopt::Long 'GetOptions';
+use POSIX 'strftime';
+
+binmode STDOUT, ':encoding(utf8)';
+
+my $version = "5.0";
+my $svn = "svn";
+my $git = "git";
+my $out_header = "svnversion.h";
+my $out_bat = "sourcetree_info.bat";
+my $out_cmake = "";
+my $source_root = "..";
+my $date = strftime "%Y%m%d", localtime;
+my $time = strftime "%H%M%S", localtime;
+my $verbose = 0;
+my $script_name = $0;
+my $header = "This file was generated by buildtools/svnrev/svnrev.pl";
+my %svninfo = (
+	name => '',
+	release => 0,
+	Revision => ''
+	);
+
+sub read_toolinfo {
+	my $info = "toolinfo.txt";
+	if (!-f $info) {
+		return;
+	}
+	open(my $FD, "<:utf8:crlf", $info);
+	while (my $l = <$FD>) {
+		chomp $l;
+		$l =~ s/^\x{FEFF}//;	# remove BOM
+		if ($l =~ /^#/) {
+			next;
+		}
+		if ($l =~ /^svn=\s*(.*)$/) {
+			$svn = $1;
+		}
+		if ($l =~ /^git=\s*(.*)$/) {
+			$git = $1;
+		}
+	}
+	close($FD);
+}
+
+sub search_svn {
+	my @test_list = (
+		"C:/Program Files (x86)/Subversion/bin/svn.exe",
+		"C:/Program Files/Subversion/bin/svn.exe",
+		"C:/Program Files/TortoiseSVN/bin/svn.exe",
+		"C:/cygwin64/bin/svn.exe",
+		"C:/cygwin/bin/svn.exe",
+		"/usr/bin/svn.exe"	# msys, cygwin
+		);
+	for (my $i = 0; $i < @test_list; $i++) {
+		my $test = $test_list[$i];
+		if (-e $test) {
+			$svn = $test;
+			return;
+		}
+	}
+}
+
+sub search_git {
+	my @test_list = (
+		"C:/Program Files/Git/bin/git.exe",
+		"C:/cygwin64/bin/git.exe",
+		"C:/cygwin/bin/git.exe",
+		"/usr/bin/git.exe"	# msys, cygwin
+		);
+	for (my $i = 0; $i < @test_list; $i++) {
+		my $test = $test_list[$i];
+		if (-e $test) {
+			$git = $test;
+			return;
+		}
+	}
+}
+
+sub dump_info()
+{
+	my %info = @_;
+
+	print "SVNREVISION $info{'Revision'}\n";
+	print "RELEASE $info{'release'}\n";
+	print "BRANCH_NAME $info{'name'}\n";
+}
+
+sub write_info_header
+{
+	my ($out_header, %svninfo) = @_;
+	my $revision = $svninfo{'Revision'};
+
+	open(my $FD, ">$out_header") || die "error $out_header";
+	print $FD "/* $header */\n";
+	print $FD "/* #define TT_VERSION_STR \"$version\" check teraterm/common/tt-version.h */\n";
+	if (defined $revision) {
+		print $FD "#define SVNVERSION $revision\n";
+	} else {
+		print $FD "#undef SVNVERSION\n";
+	}
+	if ($svninfo{'release'}) {
+		print $FD "#define TERATERM_RELEASE 1\n";
+	} else {
+		print $FD "#undef TERATERM_RELEASE\n";
+	}
+	print $FD "#define BRANCH_NAME \"$svninfo{'name'}\"\n";
+	close($FD);
+}
+
+sub write_info_bat
+{
+	my ($out_header, %svninfo) = @_;
+	my $revision = $svninfo{'Revision'};
+
+	open(my $FD, ">$out_bat") || die "error $out_bat";
+	print $FD "\@rem $header\n";
+	print $FD "set VERSION=$version\n";
+	if (defined $revision) {
+		print $FD "set SVNVERSION=$revision\n";
+	} else {
+		print $FD "set SVNVERSION=unknown\n";
+	}
+	print $FD "set RELEASE=$svninfo{'release'}\n";
+	print $FD "set DATE=$date\n";
+	print $FD "set TIME=$time\n";
+	close($FD);
+}
+
+sub write_info_cmake
+{
+	my ($out_header, %svninfo) = @_;
+	my $revision = $svninfo{'Revision'};
+
+	open(my $FD, ">$out_cmake") || die "error $out_cmake";
+	print $FD "# $header\n";
+	print $FD "set(VERSION \"$version\")\n";
+	if (defined $revision) {
+		print $FD "set(SVNVERSION \"$revision\")\n";
+	} else {
+		print $FD "#set(SVNVERSION \"0000\")\n";
+	}
+	print $FD "set(RELEASE $svninfo{'release'})\n";
+	print $FD "set(DATE \"$date\")\n";
+	print $FD "set(TIME \"$time\")\n";
+	close($FD);
+}
+
+sub read_revision_from_header()
+{
+	my ($out_header) = @_;
+
+	# ヘッダーファイルがない場合
+	if (! -f $out_header) {
+		return '';
+	}
+
+	open FH, '<', $out_header || die "error open $out_header";
+	while (<FH>) {
+		if (/#define SVNVERSION (\d+)/) {
+			close FH;
+			return $1;
+		}
+	}
+	close FH;
+
+	# パターンマッチしない場合
+	return '';
+}
+
+&search_svn();
+&search_git();
+&read_toolinfo();
+
+GetOptions(
+	'root=s' => \$source_root,
+	'svn=s' => \$svn,
+	'git=s' => \$git,
+	'header=s' => \$out_header,
+	'bat=s' => \$out_bat,
+	'cmake=s' => \$out_cmake,
+	'verbose' => \$verbose
+);
+
+$git =~ s/"//g;
+$git =~ s/\\/\//g;
+$svn =~ s/"//g;
+$svn =~ s/\\/\//g;
+
+if ($verbose != 0) {
+	print "root=$source_root\n";
+	print "svn=\"$svn\"\n";
+	print "git=\"$git\"\n";
+	print "header=\"$out_header\"\n";
+	print "bat=\"$out_bat\"\n";
+	print "cmake=\"$out_cmake\"\n";
+}
+
+if (-d "$source_root/.svn" && $svn ne "") {
+	# svn infoを実行、出力をすべて取り込む
+	if (!open(my $FD, "-|", "\"$svn\" info --xml $source_root 2>&1")) {
+		# svn が実行できない
+		print "$script_name: '$svn' can not execute\n";
+	}
+	else {
+		# 出力をすべて取り込む
+		my $text = do { local $/; <$FD> };
+		close($FD);
+
+		# xmlパーサがインストールされていない環境もあるので
+		# パターンマッチで実装
+		if ($text =~ /<commit([^>]+)>/) {
+			my $commit = $1;
+			if ($commit =~ /revision=\"(\d+)\"/) {
+				$svninfo{'Revision'} = $1;
+			}
+		}
+		if ($text =~ /<relative-url>(.+)<\/relative-url>/) {
+			my $url = $1;
+			my $name = $url;
+			$name =~ s/^\^\/(.*)$/$1/; # "\/" を削除する
+			$svninfo{'name'} = $name;
+			my $release = 0;
+			if ($url =~ /tags\/(teraterm-(\d+)_(\d+))/) {
+				# パス名からリリースと判定
+				my $tag = $1;
+				my $version = "$2.$3";
+				$release = 1;
+			}
+			$svninfo{'release'} = $release;
+		}
+	}
+}
+elsif(-d "$source_root/.git" && $git ne "") {
+	my $branch = `\"$git\" rev-parse --abbrev-ref HEAD`;
+	if ($branch eq '') {
+		# git が実行できない
+		print "$script_name: \"$git\" can not execute\n";
+	}
+	else {
+		$branch =~ s/[\r\n]$//g;
+		$svninfo{'name'} = $branch;
+
+		if (-d "$source_root/.git/svn") {
+			# use git svn log
+			my $revision = `\"$git\" svn log --oneline -1`;
+			$revision =~ s/^r(\d+).*$/$1/;
+			$svninfo{'Revision'} = $1;
+		}
+		else {
+			$svninfo{'Revision'} = undef;
+		}
+
+		my $release = 0;
+		if ($branch =~ /tags\/(teraterm-(\d+)_(\d+))/) {
+			# リリースと判定
+			my $tag = $1;
+			my $version = "$2.$3";
+			$release = 1;
+		}
+		$svninfo{'release'} = $release;
+	}
+}
+else {
+	# do not use VCS
+}
+
+if ($verbose != 0) {
+	&dump_info(%svninfo);
+}
+
+# read revision from out header file
+my $header_revision = &read_revision_from_header($out_header);
+if ($verbose != 0) {
+	print "Revision of header is '$header_revision'\n";
+}
+
+# output for source(C,C++) header
+if (! -f $out_header ||
+    $header_revision ne $svninfo{'Revision'}) {
+	if ($verbose != 0) {
+		print "write '$out_header'\n";
+	}
+	write_info_header($out_header, %svninfo);
+}
+
+# output for bat file
+if ($verbose != 0) {
+	print "write '$out_bat'\n";
+}
+write_info_bat($out_bat, %svninfo);
+
+# output for cmake
+if ($out_cmake ne "") {
+	if ($verbose != 0) {
+		print "write '$out_cmake'\n";
+	}
+	write_info_cmake($out_cmake, %svninfo);
+}

Copied: trunk/buildtools/svnrev/svnversion.default.h (from rev 9763, trunk/svnrev_perl/svnversion.default.h)
===================================================================
--- trunk/buildtools/svnrev/svnversion.default.h	                        (rev 0)
+++ trunk/buildtools/svnrev/svnversion.default.h	2022-02-20 16:16:28 UTC (rev 9764)
@@ -0,0 +1,4 @@
+/* default svnversion.h */
+#define SVNVERSION 0000
+#undef TERATERM_RELEASE
+#define BRANCH_NAME "unknown"

Copied: trunk/buildtools/svnrev/toolinfo_sample.txt (from rev 9763, trunk/svnrev_perl/toolinfo_sample.txt)
===================================================================
--- trunk/buildtools/svnrev/toolinfo_sample.txt	                        (rev 0)
+++ trunk/buildtools/svnrev/toolinfo_sample.txt	2022-02-20 16:16:28 UTC (rev 9764)
@@ -0,0 +1,4 @@
+# tool info
+#
+svn="C:\Program Files\TortoiseSVN\bin\svn.exe"
+git="C:\Program Files\Git\bin\git.exe"

Modified: trunk/ci_scripts/build_appveyor.bat
===================================================================
--- trunk/ci_scripts/build_appveyor.bat	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/ci_scripts/build_appveyor.bat	2022-02-20 16:16:28 UTC (rev 9764)
@@ -1,8 +1,8 @@
 if exist teraterm\ttpdlg\svnversion.h del teraterm\ttpdlg\svnversion.h
-if exist svnrev_perl\sourcetree_info.bat del svnrev_perl\sourcetree_info.bat
+if exist buildtools\svnrev\sourcetree_info.bat del buildtools\svnrev\sourcetree_info.bat
 call ci_scripts\install.bat
-call svnrev_perl\svnrev.bat
-call svnrev_perl\sourcetree_info.bat
+call buildtools\svnrev\svnrev.bat
+call buildtools\svnrev\sourcetree_info.bat
 if exist c:\cygwin64\setup-x86_64.exe (
   c:\cygwin64\setup-x86_64.exe --quiet-mode --packages cmake --packages cygwin32-gcc-g++ --packages cygwin32-gcc-core
 )

Modified: trunk/ci_scripts/build_appveyor.cmake
===================================================================
--- trunk/ci_scripts/build_appveyor.cmake	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/ci_scripts/build_appveyor.cmake	2022-02-20 16:16:28 UTC (rev 9764)
@@ -17,8 +17,8 @@
 # svn revision
 file(MAKE_DIRECTORY ${BUILD_DIR}/teraterm/ttpdlg)
 execute_process(
-  COMMAND perl ${CMAKE_CURRENT_LIST_DIR}/../svnrev_perl/svnrev.pl -v --root "${CMAKE_CURRENT_LIST_DIR}/.." --header ${BUILD_DIR}/teraterm/ttpdlg/svnversion.h --cmake ${BUILD_DIR}/build_config.cmake
-  WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../svnrev_perl
+  COMMAND perl ${CMAKE_CURRENT_LIST_DIR}/../buildtools/svnrev/svnrev.pl -v --root "${CMAKE_CURRENT_LIST_DIR}/.." --header ${BUILD_DIR}/teraterm/ttpdlg/svnversion.h --cmake ${BUILD_DIR}/build_config.cmake
+  WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../buildtools/svnrev
   )
 
 

Modified: trunk/doc/en/html/reference/develop.html
===================================================================
--- trunk/doc/en/html/reference/develop.html	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/doc/en/html/reference/develop.html	2022-02-20 16:16:28 UTC (rev 9764)
@@ -143,8 +143,8 @@
       </li>
       <li>Subversion for Windows (<a href="http://sourceforge.net/projects/win32svn/">http://sourceforge.net/projects/win32svn/</a>)<br />
           \x83\x8A\x83r\x83W\x83\x87\x83\x93\x94ԍ\x86\x8E擾\x8E\x9E\x82Ɏg\x97p\x82\xB5\x82܂\xB7<br />
-          svnrev_perl/toolinfo.txt \x82\xC9 svn.exe \x82̃t\x83\x8B\x83p\x83X\x82\xF0\x8BL\x8Fq\x82\xA2\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B<br />
-          \x8Fڂ\xB5\x82\xAD\x82\xCD svnrev_perl/readme.md \x82\xF0\x8EQ\x8FƂ\xAD\x82\xBE\x82\xB3\x82\xA2
+          buildtools/svnrev/toolinfo.txt \x82\xC9 svn.exe \x82̃t\x83\x8B\x83p\x83X\x82\xF0\x8BL\x8Fq\x82\xA2\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B<br />
+          \x8Fڂ\xB5\x82\xAD\x82\xCD buildtools/svnrev/readme.md \x82\xF0\x8EQ\x8FƂ\xAD\x82\xBE\x82\xB3\x82\xA2
       </li>
 -->
     </ul>

Modified: trunk/doc/en/html/reference/develop.txt
===================================================================
--- trunk/doc/en/html/reference/develop.txt	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/doc/en/html/reference/develop.txt	2022-02-20 16:16:28 UTC (rev 9764)
@@ -70,8 +70,8 @@
     - \x83\x8A\x83r\x83W\x83\x87\x83\x93\x94ԍ\x86\x8E擾 (perl\x82\xAA\x82Ȃ\xA2\x8Fꍇ\x83\x8A\x83r\x83W\x83\x87\x83\x93\x94ԍ\x86\x82\xF0\x8E擾\x82\xB9\x82\xB8\x82Ƀr\x83\x8B\x83h\x82\xB5\x82܂\xB7)
   Subversion for Windows (http://sourceforge.net/projects/win32svn/)
     \x83\x8A\x83r\x83W\x83\x87\x83\x93\x94ԍ\x86\x8E擾\x8E\x9E\x82Ɏg\x97p\x82\xB5\x82܂\xB7
-    svnrev_perl/toolinfo.txt \x82\xC9 svn.exe \x82̃t\x83\x8B\x83p\x83X\x82\xF0\x8BL\x8Fq\x82\xA2\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B
-    \x8Fڂ\xB5\x82\xAD\x82\xCD svnrev_perl/readme.md \x82\xF0\x8EQ\x8FƂ\xAD\x82\xBE\x82\xB3\x82\xA2
+    buildtools/svnrev/toolinfo.txt \x82\xC9 svn.exe \x82̃t\x83\x8B\x83p\x83X\x82\xF0\x8BL\x8Fq\x82\xA2\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B
+    \x8Fڂ\xB5\x82\xAD\x82\xCD buildtools/svnrev/readme.md \x82\xF0\x8EQ\x8FƂ\xAD\x82\xBE\x82\xB3\x82\xA2
 ------
 
 

Modified: trunk/doc/ja/html/reference/develop.html
===================================================================
--- trunk/doc/ja/html/reference/develop.html	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/doc/ja/html/reference/develop.html	2022-02-20 16:16:28 UTC (rev 9764)
@@ -143,8 +143,8 @@
       </li>
       <li>Subversion for Windows (<a href="http://sourceforge.net/projects/win32svn/">http://sourceforge.net/projects/win32svn/</a>)<br />
           \x83\x8A\x83r\x83W\x83\x87\x83\x93\x94ԍ\x86\x8E擾\x8E\x9E\x82Ɏg\x97p\x82\xB5\x82܂\xB7<br />
-          svnrev_perl/toolinfo.txt \x82\xC9 svn.exe \x82̃t\x83\x8B\x83p\x83X\x82\xF0\x8BL\x8Fq\x82\xA2\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B<br />
-          \x8Fڂ\xB5\x82\xAD\x82\xCD svnrev_perl/readme.md \x82\xF0\x8EQ\x8FƂ\xAD\x82\xBE\x82\xB3\x82\xA2
+          buildtools/svnrev/toolinfo.txt \x82\xC9 svn.exe \x82̃t\x83\x8B\x83p\x83X\x82\xF0\x8BL\x8Fq\x82\xA2\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B<br />
+          \x8Fڂ\xB5\x82\xAD\x82\xCD buildtools/svnrev/readme.md \x82\xF0\x8EQ\x8FƂ\xAD\x82\xBE\x82\xB3\x82\xA2
       </li>
     </ul>
   </li>

Modified: trunk/doc/ja/html/reference/develop.txt
===================================================================
--- trunk/doc/ja/html/reference/develop.txt	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/doc/ja/html/reference/develop.txt	2022-02-20 16:16:28 UTC (rev 9764)
@@ -64,8 +64,8 @@
     - \x83\x8A\x83r\x83W\x83\x87\x83\x93\x94ԍ\x86\x8E擾 (perl\x82\xAA\x82Ȃ\xA2\x8Fꍇ\x83\x8A\x83r\x83W\x83\x87\x83\x93\x94ԍ\x86\x82\xF0\x8E擾\x82\xB9\x82\xB8\x82Ƀr\x83\x8B\x83h\x82\xB5\x82܂\xB7)
   Subversion for Windows (http://sourceforge.net/projects/win32svn/)
     \x83\x8A\x83r\x83W\x83\x87\x83\x93\x94ԍ\x86\x8E擾\x8E\x9E\x82Ɏg\x97p\x82\xB5\x82܂\xB7
-    svnrev_perl/toolinfo.txt \x82\xC9 svn.exe \x82̃t\x83\x8B\x83p\x83X\x82\xF0\x8BL\x8Fq\x82\xA2\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B
-    \x8Fڂ\xB5\x82\xAD\x82\xCD svnrev_perl/readme.md \x82\xF0\x8EQ\x8FƂ\xAD\x82\xBE\x82\xB3\x82\xA2
+    buildtools/svnrev/toolinfo.txt \x82\xC9 svn.exe \x82̃t\x83\x8B\x83p\x83X\x82\xF0\x8BL\x8Fq\x82\xA2\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B
+    \x8Fڂ\xB5\x82\xAD\x82\xCD buildtools/svnrev/readme.md \x82\xF0\x8EQ\x8FƂ\xAD\x82\xBE\x82\xB3\x82\xA2
 
 
 \x81\xA1 \x83\x89\x83C\x83u\x83\x89\x83\x8A

Modified: trunk/installer/build.bat
===================================================================
--- trunk/installer/build.bat	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/installer/build.bat	2022-02-20 16:16:28 UTC (rev 9764)
@@ -195,13 +195,13 @@
 popd
 
 
-rem "rebuild"\x82\xF0\x8Ew\x92肵\x82Ȃ\xA2\x8Fꍇ\x81Asvnversion.h \x82\xF0\x8DX\x90V\x82\xB7\x82\xE9\x81B
+rem svnversion.h \x82\xAA\x91\xB6\x8D݂\xB5\x82Ȃ\xA2 or "rebuild"\x8E\x9E\x81Asvnversion.h \x82\xF0\x8DX\x90V\x82\xB7\x82\xE9
 if not exist ..\teraterm\ttpdlg\svnversion.h goto create_svnversion_h
 if not "%BUILD%" == "rebuild" goto build
 
 del ..\teraterm\ttpdlg\svnversion.h
 :create_svnversion_h
-call ..\svnrev_perl\svnrev.bat
+call ..\buildtools\svnrev\svnrev.bat
 
 :build
 devenv /%BUILD% release %TERATERMSLN%

Deleted: trunk/svnrev_perl/.gitignore
===================================================================
--- trunk/svnrev_perl/.gitignore	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/svnrev_perl/.gitignore	2022-02-20 16:16:28 UTC (rev 9764)
@@ -1 +0,0 @@
-sourcetree_info.bat

Deleted: trunk/svnrev_perl/readme.md
===================================================================
--- trunk/svnrev_perl/readme.md	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/svnrev_perl/readme.md	2022-02-20 16:16:28 UTC (rev 9764)
@@ -1,58 +0,0 @@
-# svnrev
-
-- ソースツリーのsvn(又は git)の情報をヘッダファイル等に書き出すためのツール
-  - ソース用のヘッダフィル
-    - 例 `../teraterm/ttpdlg/svnversion.h`
-  - CI用のbatファイル
-    - 例 `sourcetree_info.bat`
-  - cmake用ファイル
-    - 例 buildフォルダの `build_config.cmake`
-
-## 準備
-
-- perl を実行できるようにしておく
-  - perl が実行できるよう環境変数 PATH を設定する
-  - または、../buildtools/libs/perl があれば使用する
-    - ../buildtools/getperl.bat をダブルクリックすると
-      strawberry perl が buildtools/perl に展開される
-  - または、いくつかのメジャーなperlを探して見つければ使用する
-  - perl が見つからない場合は svnversion.default.h が使用される
-- svn(又は git)をインストールしておく
-  - Windows用svnの例
-    - Subversion for Windows
-      - http://sourceforge.net/projects/win32svn/
-    - TortoiseSVN の command line client tools
-      - https://tortoisesvn.net/
-  - Windows用gitの例
-    - git
-      - https://git-scm.com/
-  - 標準的なインストールフォルダから自動的に実行ファイルを探す
-  - 見つからない場合は環境変数 PATH にあるプログラムを実行する
-  - toolinfo.txt にツールのパスを書いておくと優先して使用される
-  - ツールが実行できない場合もヘッダファイルは作成される
-
-# ヘッダの作成方法
-
-- Visual Studioを利用している場合
-  - svnrev_perl プロジェクトから自動的に生成される
-- Windows の場合
-  - svnrev.bat をダブルクリックでヘッダが作成される
-- cmake の場合
-  - ビルド用のファイルをジェネレート時に自動で生成される
-  - build フォルダの build_config.cmake を削除してビルドすると再生成される
-- コマンドラインで直接実行する場合
-  - `perl svnrev.pl --root .. --header ../teraterm/ttpdlg/svnversion.h`
-
-## svnrev.pl のオプション
-
-- --root
-  - プロジェクトファイルのパス
-  - '.svn/' 又は '.git/' の存在するパス
-- --header
-  - ヘッダファイルのパス
-- --svn
-  - svnコマンドのパス
-- --git
-  - gitコマンドのパス
-
-オプションが toolinfo.txt より優先される

Deleted: trunk/svnrev_perl/svnrev.bat
===================================================================
--- trunk/svnrev_perl/svnrev.bat	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/svnrev_perl/svnrev.bat	2022-02-20 16:16:28 UTC (rev 9764)
@@ -1,49 +0,0 @@
- @ echo off
-setlocal
-cd /d %~dp0
-set BAT=%~n0%~x0
-
-set SVNVERSION_H=../teraterm/ttpdlg/svnversion.h
-set SVNVERSION_H_DOS=..\teraterm\ttpdlg\svnversion.h
-set DO_NOT_RUN_SVNREV=do_not_run_svnrev.txt
-
-if NOT EXIST %SVNVERSION_H% goto env_perl
-if NOT EXIST %DO_NOT_RUN_SVNREV% goto env_perl
- @ echo %BAT%: Find %DO_NOT_RUN_SVNREV%, Do not run svnrev.pl
-goto finish
-
-:env_perl
-if NOT "%PERL%" == "" goto found_perl
-
-:search_perl
-set PERL=perl.exe
-where %PERL% > nul 2>&1
-if %errorlevel% == 0 goto found_perl
-set PERL=%~dp0..\buildtools\perl\perl\bin\perl.exe
-if exist %PERL% goto found_perl
-set PERL=C:\Strawberry\perl\bin\perl.exe
-if exist %PERL% goto found_perl
-set PERL=C:\Perl64\bin\perl.exe
-if exist %PERL% goto found_perl
-set PERL=C:\Perl\bin\perl.exe
-if exist %PERL% goto found_perl
-set PERL=C:\cygwin64\usr\bin\perl.exe
-if exist %PERL% goto found_perl
-set PERL=C:\cygwin\usr\bin\perl.exe
-if exist %PERL% goto found_perl
-goto no_perl
-
-:no_perl
- @ echo %BAT%: perl not found
- @ echo %BAT%: default svnversion.h is used
-if exist sourcetree_info.bat del sourcetree_info.bat
-type svnversion.default.h > %SVNVERSION_H_DOS%
-goto finish
-
-:found_perl
- @ echo %BAT%: perl=%PERL%
-%PERL% svnrev.pl --root .. --header %SVNVERSION_H%
-goto finish
-
-
-:finish

Deleted: trunk/svnrev_perl/svnrev.pl
===================================================================
--- trunk/svnrev_perl/svnrev.pl	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/svnrev_perl/svnrev.pl	2022-02-20 16:16:28 UTC (rev 9764)
@@ -1,302 +0,0 @@
-use strict;
-use warnings;
-use utf8;
-use Getopt::Long 'GetOptions';
-use POSIX 'strftime';
-
-binmode STDOUT, ':encoding(utf8)';
-
-my $version = "5.0";
-my $svn = "svn";
-my $git = "git";
-my $out_header = "svnversion.h";
-my $out_bat = "sourcetree_info.bat";
-my $out_cmake = "";
-my $source_root = "..";
-my $date = strftime "%Y%m%d", localtime;
-my $time = strftime "%H%M%S", localtime;
-my $verbose = 0;
-my $script_name = $0;
-my $header = "This file was generated by svnrev_perl/svnrev.pl";
-my %svninfo = (
-	name => '',
-	release => 0,
-	Revision => ''
-	);
-
-sub read_toolinfo {
-	my $info = "toolinfo.txt";
-	if (!-f $info) {
-		return;
-	}
-	open(my $FD, "<:utf8:crlf", $info);
-	while (my $l = <$FD>) {
-		chomp $l;
-		$l =~ s/^\x{FEFF}//;	# remove BOM
-		if ($l =~ /^#/) {
-			next;
-		}
-		if ($l =~ /^svn=\s*(.*)$/) {
-			$svn = $1;
-		}
-		if ($l =~ /^git=\s*(.*)$/) {
-			$git = $1;
-		}
-	}
-	close($FD);
-}
-
-sub search_svn {
-	my @test_list = (
-		"C:/Program Files (x86)/Subversion/bin/svn.exe",
-		"C:/Program Files/Subversion/bin/svn.exe",
-		"C:/Program Files/TortoiseSVN/bin/svn.exe",
-		"C:/cygwin64/bin/svn.exe",
-		"C:/cygwin/bin/svn.exe",
-		"/usr/bin/svn.exe"	# msys, cygwin
-		);
-	for (my $i = 0; $i < @test_list; $i++) {
-		my $test = $test_list[$i];
-		if (-e $test) {
-			$svn = $test;
-			return;
-		}
-	}
-}
-
-sub search_git {
-	my @test_list = (
-		"C:/Program Files/Git/bin/git.exe",
-		"C:/cygwin64/bin/git.exe",
-		"C:/cygwin/bin/git.exe",
-		"/usr/bin/git.exe"	# msys, cygwin
-		);
-	for (my $i = 0; $i < @test_list; $i++) {
-		my $test = $test_list[$i];
-		if (-e $test) {
-			$git = $test;
-			return;
-		}
-	}
-}
-
-sub dump_info()
-{
-	my %info = @_;
-
-	print "SVNREVISION $info{'Revision'}\n";
-	print "RELEASE $info{'release'}\n";
-	print "BRANCH_NAME $info{'name'}\n";
-}
-
-sub write_info_header
-{
-	my ($out_header, %svninfo) = @_;
-	my $revision = $svninfo{'Revision'};
-
-	open(my $FD, ">$out_header") || die "error $out_header";
-	print $FD "/* $header */\n";
-	print $FD "/* #define TT_VERSION_STR \"$version\" check teraterm/common/tt-version.h */\n";
-	if (defined $revision) {
-		print $FD "#define SVNVERSION $revision\n";
-	} else {
-		print $FD "#undef SVNVERSION\n";
-	}
-	if ($svninfo{'release'}) {
-		print $FD "#define TERATERM_RELEASE 1\n";
-	} else {
-		print $FD "#undef TERATERM_RELEASE\n";
-	}
-	print $FD "#define BRANCH_NAME \"$svninfo{'name'}\"\n";
-	close($FD);
-}
-
-sub write_info_bat
-{
-	my ($out_header, %svninfo) = @_;
-	my $revision = $svninfo{'Revision'};
-
-	open(my $FD, ">$out_bat") || die "error $out_bat";
-	print $FD "\@rem $header\n";
-	print $FD "set VERSION=$version\n";
-	if (defined $revision) {
-		print $FD "set SVNVERSION=$revision\n";
-	} else {
-		print $FD "set SVNVERSION=unknown\n";
-	}
-	print $FD "set RELEASE=$svninfo{'release'}\n";
-	print $FD "set DATE=$date\n";
-	print $FD "set TIME=$time\n";
-	close($FD);
-}
-
-sub write_info_cmake
-{
-	my ($out_header, %svninfo) = @_;
-	my $revision = $svninfo{'Revision'};
-
-	open(my $FD, ">$out_cmake") || die "error $out_cmake";
-	print $FD "# $header\n";
-	print $FD "set(VERSION \"$version\")\n";
-	if (defined $revision) {
-		print $FD "set(SVNVERSION \"$revision\")\n";
-	} else {
-		print $FD "#set(SVNVERSION \"0000\")\n";
-	}
-	print $FD "set(RELEASE $svninfo{'release'})\n";
-	print $FD "set(DATE \"$date\")\n";
-	print $FD "set(TIME \"$time\")\n";
-	close($FD);
-}
-
-sub read_revision_from_header()
-{
-	my ($out_header) = @_;
-
-	# ヘッダーファイルがない場合
-	if (! -f $out_header) {
-		return '';
-	}
-
-	open FH, '<', $out_header || die "error open $out_header";
-	while (<FH>) {
-		if (/#define SVNVERSION (\d+)/) {
-			close FH;
-			return $1;
-		}
-	}
-	close FH;
-
-	# パターンマッチしない場合
-	return '';
-}
-
-&search_svn();
-&search_git();
-&read_toolinfo();
-
-GetOptions(
-	'root=s' => \$source_root,
-	'svn=s' => \$svn,
-	'git=s' => \$git,
-	'header=s' => \$out_header,
-	'bat=s' => \$out_bat,
-	'cmake=s' => \$out_cmake,
-	'verbose' => \$verbose
-);
-
-$git =~ s/"//g;
-$git =~ s/\\/\//g;
-$svn =~ s/"//g;
-$svn =~ s/\\/\//g;
-
-if ($verbose != 0) {
-	print "root=$source_root\n";
-	print "svn=\"$svn\"\n";
-	print "git=\"$git\"\n";
-	print "header=\"$out_header\"\n";
-	print "bat=\"$out_bat\"\n";
-	print "cmake=\"$out_cmake\"\n";
-}
-
-if (-d "$source_root/.svn" && $svn ne "") {
-	# svn infoを実行、出力をすべて取り込む
-	if (!open(my $FD, "-|", "\"$svn\" info --xml $source_root 2>&1")) {
-		# svn が実行できない
-		print "$script_name: '$svn' can not execute\n";
-	}
-	else {
-		# 出力をすべて取り込む
-		my $text = do { local $/; <$FD> };
-		close($FD);
-
-		# xmlパーサがインストールされていない環境もあるので
-		# パターンマッチで実装
-		if ($text =~ /<commit([^>]+)>/) {
-			my $commit = $1;
-			if ($commit =~ /revision=\"(\d+)\"/) {
-				$svninfo{'Revision'} = $1;
-			}
-		}
-		if ($text =~ /<relative-url>(.+)<\/relative-url>/) {
-			my $url = $1;
-			my $name = $url;
-			$name =~ s/^\^\/(.*)$/$1/; # "\/" を削除する
-			$svninfo{'name'} = $name;
-			my $release = 0;
-			if ($url =~ /tags\/(teraterm-(\d+)_(\d+))/) {
-				# パス名からリリースと判定
-				my $tag = $1;
-				my $version = "$2.$3";
-				$release = 1;
-			}
-			$svninfo{'release'} = $release;
-		}
-	}
-}
-elsif(-d "$source_root/.git" && $git ne "") {
-	my $branch = `\"$git\" rev-parse --abbrev-ref HEAD`;
-	if ($branch eq '') {
-		# git が実行できない
-		print "$script_name: \"$git\" can not execute\n";
-	}
-	else {
-		$branch =~ s/[\r\n]$//g;
-		$svninfo{'name'} = $branch;
-
-		if (-d "$source_root/.git/svn") {
-			# use git svn log
-			my $revision = `\"$git\" svn log --oneline -1`;
-			$revision =~ s/^r(\d+).*$/$1/;
-			$svninfo{'Revision'} = $1;
-		}
-		else {
-			$svninfo{'Revision'} = undef;
-		}
-
-		my $release = 0;
-		if ($branch =~ /tags\/(teraterm-(\d+)_(\d+))/) {
-			# リリースと判定
-			my $tag = $1;
-			my $version = "$2.$3";
-			$release = 1;
-		}
-		$svninfo{'release'} = $release;
-	}
-}
-else {
-	# do not use VCS
-}
-
-if ($verbose != 0) {
-	&dump_info(%svninfo);
-}
-
-# read revision from out header file
-my $header_revision = &read_revision_from_header($out_header);
-if ($verbose != 0) {
-	print "Revision of header is '$header_revision'\n";
-}
-
-# output for source(C,C++) header
-if (! -f $out_header ||
-    $header_revision ne $svninfo{'Revision'}) {
-	if ($verbose != 0) {
-		print "write '$out_header'\n";
-	}
-	write_info_header($out_header, %svninfo);
-}
-
-# output for bat file
-if ($verbose != 0) {
-	print "write '$out_bat'\n";
-}
-write_info_bat($out_bat, %svninfo);
-
-# output for cmake
-if ($out_cmake ne "") {
-	if ($verbose != 0) {
-		print "write '$out_cmake'\n";
-	}
-	write_info_cmake($out_cmake, %svninfo);
-}

Deleted: trunk/svnrev_perl/svnversion.default.h
===================================================================
--- trunk/svnrev_perl/svnversion.default.h	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/svnrev_perl/svnversion.default.h	2022-02-20 16:16:28 UTC (rev 9764)
@@ -1,4 +0,0 @@
-/* default svnversion.h */
-#define SVNVERSION 0000
-#undef TERATERM_RELEASE
-#define BRANCH_NAME "unknown"

Deleted: trunk/svnrev_perl/toolinfo_sample.txt
===================================================================
--- trunk/svnrev_perl/toolinfo_sample.txt	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/svnrev_perl/toolinfo_sample.txt	2022-02-20 16:16:28 UTC (rev 9764)
@@ -1,4 +0,0 @@
-# tool info
-#
-svn="C:\Program Files\TortoiseSVN\bin\svn.exe"
-git="C:\Program Files\Git\bin\git.exe"

Modified: trunk/teraterm/teraterm/ttermpro.v16.vcxproj
===================================================================
--- trunk/teraterm/teraterm/ttermpro.v16.vcxproj	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/teraterm/teraterm/ttermpro.v16.vcxproj	2022-02-20 16:16:28 UTC (rev 9764)
@@ -93,7 +93,7 @@
       <AdditionalManifestFiles>.\teraterm.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
     </Manifest>
     <PreBuildEvent>
-      <Command>$(SolutionDir)..\svnrev_perl\svnrev.bat</Command>
+      <Command>$(SolutionDir)..\buildtools\svnrev\svnrev.bat</Command>
     </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -137,7 +137,7 @@
       <AdditionalManifestFiles>.\teraterm.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
     </Manifest>
     <PreBuildEvent>
-      <Command>$(SolutionDir)..\svnrev_perl\svnrev.bat</Command>
+      <Command>$(SolutionDir)..\buildtools\svnrev\svnrev.bat</Command>
     </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>

Modified: trunk/teraterm/teraterm/ttermpro.v8.vcproj
===================================================================
--- trunk/teraterm/teraterm/ttermpro.v8.vcproj	2022-02-20 16:06:48 UTC (rev 9763)
+++ trunk/teraterm/teraterm/ttermpro.v8.vcproj	2022-02-20 16:16:28 UTC (rev 9764)
@@ -25,7 +25,7 @@
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="$(SolutionDir)..\svnrev_perl\svnrev.bat"
+				CommandLine="$(SolutionDir)..\buildtools\svnrev\svnrev.bat"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -119,7 +119,7 @@
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
-				CommandLine="$(SolutionDir)..\svnrev_perl\svnrev.bat"
+				CommandLine="$(SolutionDir)..\buildtools\svnrev\svnrev.bat"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"


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