diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-08-21 05:54:52 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-08-21 05:54:52 +0000 |
commit | 4887f62bea708f24e03b3f926f2698c60a94c807 (patch) | |
tree | 77271e92cf517cbc2846897f7482c9df5efee124 | |
parent | df5286fe3bca619beb4771da1ffa8ace9613e9e5 (diff) | |
download | build-4887f62bea708f24e03b3f926f2698c60a94c807.tar.gz build-4887f62bea708f24e03b3f926f2698c60a94c807.tar.bz2 build-4887f62bea708f24e03b3f926f2698c60a94c807.tar.xz build-4887f62bea708f24e03b3f926f2698c60a94c807.zip |
Getting there, it compiles, now for the fun sophisticated pieces where the
builder itself tells the lexer which tokens are functions, and which are target
types.
-rw-r--r-- | congo | 3 | ||||
-rw-r--r-- | src/build.l | 1 | ||||
-rw-r--r-- | src/build.y | 4 | ||||
-rw-r--r-- | src/builder.cpp | 30 | ||||
-rw-r--r-- | src/builder.h | 31 | ||||
-rw-r--r-- | src/main.cpp | 52 | ||||
-rw-r--r-- | src/viewer.cpp | 9 | ||||
-rw-r--r-- | src/viewer.h | 17 |
8 files changed, 117 insertions, 30 deletions
@@ -31,6 +31,9 @@ server action: check congod | |||
31 | create file congod from files in src/congod, src/shared using rule exe | 31 | create file congod from files in src/congod, src/shared using rule exe |
32 | create file congo from files in src/congo, src/shared using rule exe | 32 | create file congo from files in src/congo, src/shared using rule exe |
33 | 33 | ||
34 | create files "modules/db{name}.so" from directories in src/congod/db ... | ||
35 | from files in "src/congod/db/{name}" using rule lib | ||
36 | |||
34 | # | 37 | # |
35 | # After all of that, some targets or list items may have their own additional | 38 | # After all of that, some targets or list items may have their own additional |
36 | # dependancies, depending on the rule that built them. You can define these | 39 | # dependancies, depending on the rule that built them. You can define these |
diff --git a/src/build.l b/src/build.l index b174681..9a15719 100644 --- a/src/build.l +++ b/src/build.l | |||
@@ -31,6 +31,7 @@ std::string strbuf; | |||
31 | "produces" return TOK_PRODUCES; | 31 | "produces" return TOK_PRODUCES; |
32 | "check" return TOK_CHECK; | 32 | "check" return TOK_CHECK; |
33 | "clean" return TOK_CLEAN; | 33 | "clean" return TOK_CLEAN; |
34 | "target" return TOK_TARGET; | ||
34 | 35 | ||
35 | \n+ { | 36 | \n+ { |
36 | yylloc->last_line += yyleng; | 37 | yylloc->last_line += yyleng; |
diff --git a/src/build.y b/src/build.y index a624418..d852c4c 100644 --- a/src/build.y +++ b/src/build.y | |||
@@ -2,10 +2,6 @@ | |||
2 | %{ | 2 | %{ |
3 | # include <string> | 3 | # include <string> |
4 | # include "builder.h" | 4 | # include "builder.h" |
5 | # include "action.h" | ||
6 | # include "command.h" | ||
7 | # include "rule.h" | ||
8 | # include "filetarget.h" | ||
9 | # include "build.tab.h" | 5 | # include "build.tab.h" |
10 | void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ); | 6 | void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ); |
11 | %} | 7 | %} |
diff --git a/src/builder.cpp b/src/builder.cpp new file mode 100644 index 0000000..1ecbf05 --- /dev/null +++ b/src/builder.cpp | |||
@@ -0,0 +1,30 @@ | |||
1 | #include "builder.h" | ||
2 | |||
3 | Builder::Builder() | ||
4 | { | ||
5 | } | ||
6 | |||
7 | Builder::~Builder() | ||
8 | { | ||
9 | } | ||
10 | |||
11 | void yyparse( Builder &bld ); | ||
12 | |||
13 | void Builder::load( const std::string &sFile ) | ||
14 | { | ||
15 | file = sFile; | ||
16 | scanBegin(); | ||
17 | yyparse( *this ); | ||
18 | scanEnd(); | ||
19 | } | ||
20 | |||
21 | void Builder::error( YYLTYPE *locp, const char *msg ) | ||
22 | { | ||
23 | printf("%s\n", msg ); | ||
24 | } | ||
25 | |||
26 | void Builder::error( const std::string &msg ) | ||
27 | { | ||
28 | printf("%s\n", msg.c_str() ); | ||
29 | } | ||
30 | |||
diff --git a/src/builder.h b/src/builder.h new file mode 100644 index 0000000..9c146ea --- /dev/null +++ b/src/builder.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef BUILDER_H | ||
2 | #define BUILDER_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | #include <string> | ||
6 | #include "build.tab.h" | ||
7 | |||
8 | class Builder; | ||
9 | |||
10 | #define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, Builder &bld ) | ||
11 | YY_DECL; | ||
12 | |||
13 | class Builder | ||
14 | { | ||
15 | public: | ||
16 | Builder(); | ||
17 | virtual ~Builder(); | ||
18 | |||
19 | void error( YYLTYPE *locp, const char *msg ); | ||
20 | void error( const std::string &msg ); | ||
21 | |||
22 | void load( const std::string &sFile ); | ||
23 | |||
24 | private: | ||
25 | std::string file; | ||
26 | void scanBegin(); | ||
27 | void scanEnd(); | ||
28 | |||
29 | }; | ||
30 | |||
31 | #endif | ||
diff --git a/src/main.cpp b/src/main.cpp index 2b4baa5..9168df7 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | #include "builder.h" | 1 | #include "builder.h" |
2 | #include "viewerplain.h" | 2 | //#include "viewerplain.h" |
3 | #include "viewerpercent.h" | 3 | //#include "viewerpercent.h" |
4 | #include "viewermake.h" | 4 | //#include "viewermake.h" |
5 | #include "paramproc.h" | 5 | #include "paramproc.h" |
6 | #include "staticstring.h" | 6 | #include "staticstring.h" |
7 | 7 | ||
@@ -26,12 +26,12 @@ public: | |||
26 | "Print out a debug dump of the read build.conf", "true" ); | 26 | "Print out a debug dump of the read build.conf", "true" ); |
27 | addParam("help", mkproc(ParamProc::help), | 27 | addParam("help", mkproc(ParamProc::help), |
28 | "This help"); | 28 | "This help"); |
29 | pViewer = new ViewerPlain; | 29 | //pViewer = new ViewerPlain; |
30 | } | 30 | } |
31 | 31 | ||
32 | virtual ~Param() | 32 | virtual ~Param() |
33 | { | 33 | { |
34 | delete pViewer; | 34 | //delete pViewer; |
35 | } | 35 | } |
36 | 36 | ||
37 | virtual int cmdParam( int argc, char *argv[] ) | 37 | virtual int cmdParam( int argc, char *argv[] ) |
@@ -47,20 +47,20 @@ public: | |||
47 | 47 | ||
48 | int procViewPercent( int argc, char *argv[] ) | 48 | int procViewPercent( int argc, char *argv[] ) |
49 | { | 49 | { |
50 | delete pViewer; | 50 | //delete pViewer; |
51 | pViewer = new ViewerPercent; | 51 | //pViewer = new ViewerPercent; |
52 | } | 52 | } |
53 | 53 | ||
54 | int procViewMake( int argc, char *argv[] ) | 54 | int procViewMake( int argc, char *argv[] ) |
55 | { | 55 | { |
56 | delete pViewer; | 56 | //delete pViewer; |
57 | pViewer = new ViewerMake; | 57 | //pViewer = new ViewerMake; |
58 | } | 58 | } |
59 | 59 | ||
60 | std::string sCache; | 60 | std::string sCache; |
61 | std::string sFile; | 61 | std::string sFile; |
62 | StaticString sAction; | 62 | StaticString sAction; |
63 | Viewer *pViewer; | 63 | //Viewer *pViewer; |
64 | bool bDebug; | 64 | bool bDebug; |
65 | 65 | ||
66 | private: | 66 | private: |
@@ -71,31 +71,31 @@ int main( int argc, char *argv[] ) | |||
71 | Param prm; | 71 | Param prm; |
72 | prm.process( argc, argv ); | 72 | prm.process( argc, argv ); |
73 | 73 | ||
74 | Builder bld( *prm.pViewer ); | 74 | Builder bld;//*prm.pViewer ); |
75 | 75 | ||
76 | bld.setCache( prm.sCache ); | 76 | //bld.setCache( prm.sCache ); |
77 | try | 77 | //try |
78 | { | 78 | //{ |
79 | bld.load( prm.sFile.c_str() ); | 79 | bld.load( prm.sFile.c_str() ); |
80 | } | 80 | //} |
81 | catch( BuildException &e ) | 81 | //catch( BuildException &e ) |
82 | { | 82 | //{ |
83 | fputs( e.what(), stderr ); | 83 | // fputs( e.what(), stderr ); |
84 | fputs( "\n", stderr ); | 84 | // fputs( "\n", stderr ); |
85 | return 1; | 85 | // return 1; |
86 | } | 86 | //} |
87 | 87 | ||
88 | if( prm.bDebug ) | 88 | if( prm.bDebug ) |
89 | { | 89 | { |
90 | printf("\n\n----------\nDebug dump\n----------\n"); | 90 | printf("\n\n----------\nDebug dump\n----------\n"); |
91 | bld.debug(); | 91 | //bld.debug(); |
92 | } | 92 | } |
93 | else | 93 | else |
94 | { | 94 | { |
95 | if( prm.sAction > 0 ) | 95 | //if( prm.sAction > 0 ) |
96 | bld.build( prm.sAction ); | 96 | // bld.build( prm.sAction ); |
97 | else | 97 | //else |
98 | bld.build(); | 98 | // bld.build(); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
diff --git a/src/viewer.cpp b/src/viewer.cpp new file mode 100644 index 0000000..93b2ac1 --- /dev/null +++ b/src/viewer.cpp | |||
@@ -0,0 +1,9 @@ | |||
1 | #include "viewer.h" | ||
2 | |||
3 | Viewer::Viewer() | ||
4 | { | ||
5 | } | ||
6 | |||
7 | Viewer::~Viewer() | ||
8 | { | ||
9 | } | ||
diff --git a/src/viewer.h b/src/viewer.h new file mode 100644 index 0000000..04f4ea7 --- /dev/null +++ b/src/viewer.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef VIEWER_H | ||
2 | #define VIEWER_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | |||
6 | |||
7 | class Viewer | ||
8 | { | ||
9 | public: | ||
10 | Viewer(); | ||
11 | virtual ~Viewer(); | ||
12 | |||
13 | private: | ||
14 | |||
15 | }; | ||
16 | |||
17 | #endif | ||