source: CMT/v1r21/mgr/cmt_format_deps.bat

Last change on this file was 488, checked in by rybkin, 15 years ago

See C.L. 383

File size: 1.9 KB
Line 
1
2@echo off
3
4SETLOCAL
5
6if "%1" EQU "-no_stamps" (
7  set no_stamps=yes
8  shift
9)
10if "%1" EQU "/no_stamps" (
11  set no_stamps=yes
12  shift
13)
14if "%1" NEQ "" (
15  set dep=%1
16  shift
17) else (
18  set usage=y
19  goto usage
20)
21if "%1" NEQ "" (
22  set obj=%1
23  shift
24) else (
25  set usage=y
26  goto usage
27)
28if "%1" NEQ "" (
29  set src=%1
30  shift
31) else (
32  set usage=y
33  goto usage
34)
35if exist "%1" (
36  set deps=%1
37  shift
38) else (
39  set usage=y
40  goto usage
41)
42if "%1" NEQ "" (
43  set usage=y
44  goto usage
45)
46
47if not defined CMTMSGPREFIX (
48  set CMTMSGPREFIX=cmt_format_deps.bat
49)
50if defined makecmd (
51  if defined cmtmsg echo "%CMTMSGPREFIX%" "(cmt_format_deps.bat)"
52  @echo on
53)
54
55if "%no_stamps%" EQU "yes" (
56  if exist %dep% del %dep% 
57  if not errorlevel 0 exit /b 1
58  echo %dep% %obj% : %src% \>>%dep%
59  for /F "usebackq tokens=3,*" %%I in (`find "Note: including file:" %deps%`) do @echo "%%J" \>>%dep%
60  if not errorlevel 0 exit /b 1
61  exit /b
62)
63
64  set stamp=%dep%.stamp
65  set stamptmp=%dep%.stamp.tmp
66  set tmp=%dep%.tmp
67
68  type nul >%stamptmp%
69  if exist %tmp% del %tmp%
70  if not errorlevel 0 exit /b 1
71  echo %dep% %obj% : %stamp% %src% \>>%tmp%
72  for /F "usebackq tokens=3,*" %%I in (`find "Note: including file:" %deps%`) do @echo "%%J" \>>%tmp%
73  if not errorlevel 0 exit /b 1
74
75if exist %dep% (
76  echo n|comp %dep% %tmp% >nul 2>&1
77  if errorlevel 0 (
78    if exist %stamp% (
79      del %stamptmp% || exit /b 1
80    ) else (
81      move /y %stamptmp% %stamp% >nul || exit /b 1
82    )
83  ) else (
84    move /y %stamptmp% %stamp% >nul || exit /b 1
85  )
86) else (
87  move /y %stamptmp% %stamp% >nul || exit /b 1
88)
89move /y %tmp% %dep% >nul || exit /b 1
90
91if defined makecmd @echo off
92exit /b
93
94:usage
95if defined usage (
96  echo "Usage: cmt_format_deps.bat [-no_stamps|/no_stamps] DEP OBJ SRC DEPENDENCIES"
97  echo "Create DEP [and its STAMP] containing Make rule with target DEP OBJ"
98  echo "and prerequisites [STAMP] SRC SRC-DEPENDENCIES... based on DEPENDENCIES."
99  exit /b 2
100)
101
102ENDLOCAL
Note: See TracBrowser for help on using the repository browser.