source: UsbWattMeter/trunk/asp_dcre/utils/applyrename@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 7 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

File size: 3.3 KB
Line 
1#! /usr/bin/perl
2#
3# TOPPERS Software
4# Toyohashi Open Platform for Embedded Real-Time Systems
5#
6# Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
7# Toyohashi Univ. of Technology, JAPAN
8# Copyright (C) 2004-2011 by Embedded and Real-Time Systems Laboratory
9# Graduate School of Information Science, Nagoya Univ., JAPAN
10#
11# ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
12# ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
13# •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
14# (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
15# Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
16# ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
17# (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
18# —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
19ƒƒ“ƒgi—˜—p
20# ŽÒƒ}ƒjƒ…
21ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
22# ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
23# (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
24# —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
25# ‚ƁD
26# (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
27ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
28ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
29# ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
30# (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
31# •ñ‚·‚邱‚ƁD
32# (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
33# ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
34# ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
35# —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
36# –Ɛӂ·‚邱‚ƁD
37#
38# –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
39# ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
40# ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
41# ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
42# ‚̐ӔC‚𕉂í‚È‚¢D
43#
44# @(#) $Id: applyrename 332 2007-07-17 12:15:37Z hiro $
45#
46
47#
48# ƒtƒ@ƒCƒ‹‚ɃŠƒl[ƒ€‚ð“K—p‚·‚é
49#
50sub applyrename
51{
52 local($infile) = @_;
53 local($outfile) = $infile.".new";
54 local($line);
55
56 open(INFILE, "< ".$infile) || die;
57 open(OUTFILE, "> ".$outfile) || die;
58
59 while ($line = <INFILE>) {
60 $line =~ s/\b(_?)($syms)\b/$1_kernel_$2/gc;
61 print OUTFILE $line;
62 }
63
64 close(INFILE);
65 close(OUTFILE);
66
67 if (`cmp $infile $outfile`) {
68 rename($infile, $infile.".bak");
69 rename($outfile, $infile);
70 print STDERR "Modified: ",$infile,"\n";
71 }
72 else {
73 unlink($outfile);
74 }
75}
76
77#
78# ƒGƒ‰[ƒ`ƒFƒbƒN
79#
80if ($#ARGV < 1) {
81 die "Usage: appyrename <prefix> <filelist>\n";
82}
83
84#
85# ‰Šú‰»
86#
87@syms = ();
88$name = $ARGV[0];
89
90#
91# ƒVƒ“ƒ{ƒ‹ƒŠƒXƒg‚ð“ǂݍž‚Þ
92#
93$deffile = $name."_rename.def";
94open(INFILE, $deffile) || die "Cannot open $deffile";
95while ($line = <INFILE>) {
96 chomp $line;
97 if ($line =~ /^#(.*)$/) {
98 # do nothing
99 }
100 elsif ($line =~ /^INCLUDE[ \t]+(.*)$/) {
101 # do nothing
102 }
103 elsif ($line ne "") {
104 @syms = (@syms, $line)
105 }
106}
107close(INFILE);
108
109#
110# ³‹K•\Œ»‚ðì‚é
111#
112$syms = join("|", @syms);
113
114#
115# ƒtƒ@ƒCƒ‹‚ɃŠƒl[ƒ€‚ð“K—p‚·‚é
116#
117shift @ARGV;
118foreach $infile (@ARGV) {
119 # ƒtƒ@ƒCƒ‹‚Å‚È‚¯‚ê‚΃XƒLƒbƒv
120 next unless (-f $infile);
121
122 applyrename($infile) if ($infile ne $deffile);
123}
Note: See TracBrowser for help on using the repository browser.