diff options
Diffstat (limited to '')
-rw-r--r-- | src/action.cpp | 8 | ||||
-rw-r--r-- | src/action.h | 2 | ||||
-rw-r--r-- | src/build.cpp | 27 | ||||
-rw-r--r-- | src/build.h | 4 | ||||
-rw-r--r-- | src/main.cpp | 25 | ||||
-rw-r--r-- | src/target.cpp | 4 |
6 files changed, 66 insertions, 4 deletions
diff --git a/src/action.cpp b/src/action.cpp index be11f48..cae4f01 100644 --- a/src/action.cpp +++ b/src/action.cpp | |||
@@ -38,3 +38,11 @@ std::string Action::getWhat() | |||
38 | return (*i).sWhat; | 38 | return (*i).sWhat; |
39 | } | 39 | } |
40 | 40 | ||
41 | void Action::setMode( eAction nAct ) | ||
42 | { | ||
43 | for( CmdList::iterator j = lCmds.begin(); j != lCmds.end(); j++ ) | ||
44 | { | ||
45 | (*j).act = nAct; | ||
46 | } | ||
47 | } | ||
48 | |||
diff --git a/src/action.h b/src/action.h index 0e08192..25badad 100644 --- a/src/action.h +++ b/src/action.h | |||
@@ -50,6 +50,8 @@ public: | |||
50 | { | 50 | { |
51 | return sName; | 51 | return sName; |
52 | } | 52 | } |
53 | |||
54 | void setMode( eAction nAct ); | ||
53 | 55 | ||
54 | private: | 56 | private: |
55 | typedef std::list<Cmd> CmdList; | 57 | typedef std::list<Cmd> CmdList; |
diff --git a/src/build.cpp b/src/build.cpp index 5121d1f..889efa4 100644 --- a/src/build.cpp +++ b/src/build.cpp | |||
@@ -85,10 +85,10 @@ void Build::execAction( const std::string &sWhat ) | |||
85 | sWhat.c_str() | 85 | sWhat.c_str() |
86 | ); | 86 | ); |
87 | Target *pTarget = mTarget[pAct->getWhat()]; | 87 | Target *pTarget = mTarget[pAct->getWhat()]; |
88 | pView->beginCommand( pAct->getAct(), pAct->getWhat() ); | 88 | //pView->beginCommand( pAct->getAct(), pAct->getWhat() ); |
89 | if( !pTarget->wasRun() ) | 89 | if( !pTarget->wasRun() ) |
90 | pTarget->run( pAct->getAct(), *this ); | 90 | pTarget->run( pAct->getAct(), *this ); |
91 | pView->endCommand(); | 91 | //pView->endCommand(); |
92 | } | 92 | } |
93 | 93 | ||
94 | pView->endAction(); | 94 | pView->endAction(); |
@@ -364,3 +364,26 @@ void Build::chainTarget( const std::string &sName ) | |||
364 | (*i).second->run( Action::actCheck, *this ); | 364 | (*i).second->run( Action::actCheck, *this ); |
365 | } | 365 | } |
366 | 366 | ||
367 | void Build::printInfo() | ||
368 | { | ||
369 | printf("---- Build Info ----\n"); | ||
370 | printf("Valid actions: "); | ||
371 | for( ActionMap::iterator i = mAction.begin(); i != mAction.end(); i++ ) | ||
372 | { | ||
373 | if( i != mAction.begin() ) printf(", "); | ||
374 | if( (*i).first == "" ) | ||
375 | printf("*default*"); | ||
376 | else | ||
377 | printf("%s", (*i).first.c_str() ); | ||
378 | } | ||
379 | printf("\n\n"); | ||
380 | } | ||
381 | |||
382 | void Build::setMode( Action::eAction nAct ) | ||
383 | { | ||
384 | for( ActionMap::iterator i = mAction.begin(); i != mAction.end(); i++ ) | ||
385 | { | ||
386 | (*i).second->setMode( nAct ); | ||
387 | } | ||
388 | } | ||
389 | |||
diff --git a/src/build.h b/src/build.h index 6e98405..dd8c11b 100644 --- a/src/build.h +++ b/src/build.h | |||
@@ -76,6 +76,10 @@ public: | |||
76 | 76 | ||
77 | void chainTarget( const std::string &sName ); | 77 | void chainTarget( const std::string &sName ); |
78 | 78 | ||
79 | void printInfo(); | ||
80 | |||
81 | void setMode( Action::eAction nAct ); | ||
82 | |||
79 | private: | 83 | private: |
80 | TargetMap mTarget; | 84 | TargetMap mTarget; |
81 | ReqMap mRequires; | 85 | ReqMap mRequires; |
diff --git a/src/main.cpp b/src/main.cpp index 1576b0c..85886f5 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "paramproc.h" | 5 | #include "paramproc.h" |
6 | #include "staticstring.h" | 6 | #include "staticstring.h" |
7 | #include "build.h" | 7 | #include "build.h" |
8 | #include "action.h" | ||
8 | 9 | ||
9 | class Param : public ParamProc | 10 | class Param : public ParamProc |
10 | { | 11 | { |
@@ -14,17 +15,23 @@ public: | |||
14 | sCache(".build.cache"), | 15 | sCache(".build.cache"), |
15 | bDebug( false ), | 16 | bDebug( false ), |
16 | bPostDebug( false ), | 17 | bPostDebug( false ), |
17 | sView("plain") | 18 | sView("plain"), |
19 | bInfo( false ), | ||
20 | bCleanMode( false ) | ||
18 | { | 21 | { |
19 | addHelpBanner("Build r?\n\n"); | 22 | addHelpBanner("Build r?\n\n"); |
20 | addParam("file", 'f', &sFile, | 23 | addParam("file", 'f', &sFile, |
21 | "Set the input script, default: build.conf"); | 24 | "Set the input script, default: build.conf"); |
25 | addParam("info", 'i', &bInfo, | ||
26 | "Display useful info about the loaded config file.", NULL, "true" ); | ||
27 | addParam("clean", 'c', &bCleanMode, | ||
28 | "Clean instead of checking the given action.", NULL, "true" ); | ||
22 | addParam('p', mkproc(Param::procViewPercent), | 29 | addParam('p', mkproc(Param::procViewPercent), |
23 | "Switch to percent view."); | 30 | "Switch to percent view."); |
24 | addParam('m', mkproc(Param::procViewMake), | 31 | addParam('m', mkproc(Param::procViewMake), |
25 | "Switch to 'make' style view."); | 32 | "Switch to 'make' style view."); |
26 | addParam("cache", &sCache, | 33 | addParam("cache", &sCache, |
27 | "Set an alternative cache file." ); | 34 | "Set an alternative cache file, default: .build.cache" ); |
28 | addParam('d', &bDebug, | 35 | addParam('d', &bDebug, |
29 | "Display debug info instead of building", NULL, "true" ); | 36 | "Display debug info instead of building", NULL, "true" ); |
30 | addParam('D', &bPostDebug, | 37 | addParam('D', &bPostDebug, |
@@ -67,6 +74,8 @@ public: | |||
67 | //Viewer *pViewer; | 74 | //Viewer *pViewer; |
68 | bool bDebug; | 75 | bool bDebug; |
69 | bool bPostDebug; | 76 | bool bPostDebug; |
77 | bool bInfo; | ||
78 | bool bCleanMode; | ||
70 | 79 | ||
71 | private: | 80 | private: |
72 | }; | 81 | }; |
@@ -84,6 +93,15 @@ int main( int argc, char *argv[] ) | |||
84 | pBuild = bld.load( prm.sFile.c_str() ); | 93 | pBuild = bld.load( prm.sFile.c_str() ); |
85 | pBuild->setCache( prm.sCache ); | 94 | pBuild->setCache( prm.sCache ); |
86 | pBuild->setView( prm.sView ); | 95 | pBuild->setView( prm.sView ); |
96 | if( prm.bCleanMode ) | ||
97 | pBuild->setMode( Action::actClean ); | ||
98 | |||
99 | if( prm.bInfo ) | ||
100 | { | ||
101 | pBuild->printInfo(); | ||
102 | delete pBuild; | ||
103 | return 0; | ||
104 | } | ||
87 | if( prm.bDebug ) | 105 | if( prm.bDebug ) |
88 | { | 106 | { |
89 | printf("\n\n----------\nDebug dump\n----------\n"); | 107 | printf("\n\n----------\nDebug dump\n----------\n"); |
@@ -111,9 +129,12 @@ int main( int argc, char *argv[] ) | |||
111 | printf("\n\n----------\nDebug dump\n----------\n"); | 129 | printf("\n\n----------\nDebug dump\n----------\n"); |
112 | pBuild->debugDump(); | 130 | pBuild->debugDump(); |
113 | } | 131 | } |
132 | delete pBuild; | ||
114 | return 1; | 133 | return 1; |
115 | } | 134 | } |
116 | 135 | ||
117 | delete pBuild; | 136 | delete pBuild; |
137 | |||
138 | return 0; | ||
118 | } | 139 | } |
119 | 140 | ||
diff --git a/src/target.cpp b/src/target.cpp index a26f76f..3150c38 100644 --- a/src/target.cpp +++ b/src/target.cpp | |||
@@ -1,4 +1,6 @@ | |||
1 | #include "target.h" | 1 | #include "target.h" |
2 | #include "build.h" | ||
3 | #include "viewer.h" | ||
2 | 4 | ||
3 | Target::Target() : | 5 | Target::Target() : |
4 | bRun( false ) | 6 | bRun( false ) |
@@ -13,6 +15,7 @@ void Target::run( Action::eAction nAct, Build &bld ) | |||
13 | { | 15 | { |
14 | bRun = true; | 16 | bRun = true; |
15 | 17 | ||
18 | bld.getView()->beginCommand( nAct, sName ); | ||
16 | switch( nAct ) | 19 | switch( nAct ) |
17 | { | 20 | { |
18 | case Action::actCheck: | 21 | case Action::actCheck: |
@@ -23,5 +26,6 @@ void Target::run( Action::eAction nAct, Build &bld ) | |||
23 | clean( bld ); | 26 | clean( bld ); |
24 | break; | 27 | break; |
25 | } | 28 | } |
29 | bld.getView()->endCommand(); | ||
26 | } | 30 | } |
27 | 31 | ||