diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-12-21 18:59:32 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-12-21 18:59:32 +0000 |
commit | 8ebc3f17961ef6a0cf708cc6bdca948d77817ee0 (patch) | |
tree | bab53e5e249dc4eab4904a5a4519b372245eee53 | |
parent | 0bcd7aeb48055e74203332851ce51ea55335d135 (diff) | |
download | build-8ebc3f17961ef6a0cf708cc6bdca948d77817ee0.tar.gz build-8ebc3f17961ef6a0cf708cc6bdca948d77817ee0.tar.bz2 build-8ebc3f17961ef6a0cf708cc6bdca948d77817ee0.tar.xz build-8ebc3f17961ef6a0cf708cc6bdca948d77817ee0.zip |
Wow, it's much more general now, I like that.
Diffstat (limited to '')
-rw-r--r-- | default.bld | 16 | ||||
-rw-r--r-- | share/autoinclude/general-rules.bld | 80 | ||||
-rw-r--r-- | src/action.cpp | 25 | ||||
-rw-r--r-- | src/action.h | 1 | ||||
-rw-r--r-- | src/context.cpp | 4 |
5 files changed, 103 insertions, 23 deletions
diff --git a/default.bld b/default.bld index de31b78..19b66bf 100644 --- a/default.bld +++ b/default.bld | |||
@@ -5,6 +5,8 @@ | |||
5 | 5 | ||
6 | CXXFLAGS += "-ggdb -W -Wall"; | 6 | CXXFLAGS += "-ggdb -W -Wall"; |
7 | 7 | ||
8 | CC = CXX; // We actually want to use c++ to compile our c files. | ||
9 | |||
8 | action "default" | 10 | action "default" |
9 | { | 11 | { |
10 | build: "build"; | 12 | build: "build"; |
@@ -49,6 +51,7 @@ target "build" | |||
49 | rule "exe"; | 51 | rule "exe"; |
50 | LDFLAGS += "-Llibbu++ -lbu++ -ldl"; | 52 | LDFLAGS += "-Llibbu++ -lbu++ -ldl"; |
51 | CXXFLAGS += "-Ilibbu++"; | 53 | CXXFLAGS += "-Ilibbu++"; |
54 | CFLAGS = CXXFLAGS; | ||
52 | tag "tools"; | 55 | tag "tools"; |
53 | } | 56 | } |
54 | 57 | ||
@@ -74,19 +77,6 @@ target "build-r$(svnversion "-n").tar.bz2" | |||
74 | tag "pkg"; | 77 | tag "pkg"; |
75 | } | 78 | } |
76 | 79 | ||
77 | // We want to override the c rule, and just use c++ for it | ||
78 | rule "c" | ||
79 | { | ||
80 | input "*.c"; | ||
81 | output replace(".c", ".o"); | ||
82 | tag "auto-source"; | ||
83 | requires getMakeDeps("g++ ${CXXFLAGS} -M ${INPUT}"); | ||
84 | profile "build" | ||
85 | { | ||
86 | execute("g++ ${CXXFLAGS} -c -o ${OUTPUT} ${INPUT}"); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | rule "tarball" | 80 | rule "tarball" |
91 | { | 81 | { |
92 | input matches("*.cpp", "*.h", "*.c", "*.y", "*.l", "*.conf", "Doxyfile", | 82 | input matches("*.cpp", "*.h", "*.c", "*.y", "*.l", "*.conf", "Doxyfile", |
diff --git a/share/autoinclude/general-rules.bld b/share/autoinclude/general-rules.bld index 16217e0..46720c6 100644 --- a/share/autoinclude/general-rules.bld +++ b/share/autoinclude/general-rules.bld | |||
@@ -1,10 +1,68 @@ | |||
1 | // | ||
2 | // Really, variables here should default to something that's platform dependant, | ||
3 | // but for now, we use linux, I'll default them to gnu/linux | ||
4 | // | ||
5 | |||
6 | |||
7 | if CXX == null then | ||
8 | { | ||
9 | CXX = "g++"; | ||
10 | } | ||
11 | |||
12 | if AR == null then | ||
13 | { | ||
14 | AR = "ar"; | ||
15 | } | ||
16 | |||
17 | if CC == null then | ||
18 | { | ||
19 | CC = "cc"; | ||
20 | } | ||
21 | |||
22 | if BISON == null then | ||
23 | { | ||
24 | BISON = "bison"; | ||
25 | } | ||
26 | |||
27 | if FLEX == null then | ||
28 | { | ||
29 | FLEX = "flex"; | ||
30 | } | ||
31 | |||
32 | function cppToObj() | ||
33 | { | ||
34 | if OBJ_DIR == null then | ||
35 | { | ||
36 | DIR = INPUT.dirName(); | ||
37 | } | ||
38 | else | ||
39 | { | ||
40 | DIR = OBJ_DIR; | ||
41 | } | ||
42 | |||
43 | return DIR + "/" + INPUT.fileName().replace(".cpp", ".o"); | ||
44 | } | ||
45 | |||
46 | function cToObj() | ||
47 | { | ||
48 | if OBJ_DIR == null then | ||
49 | { | ||
50 | DIR = INPUT.dirName(); | ||
51 | } | ||
52 | else | ||
53 | { | ||
54 | DIR = OBJ_DIR; | ||
55 | } | ||
56 | |||
57 | return DIR + "/" + INPUT.fileName().replace(".c", ".o"); | ||
58 | } | ||
1 | 59 | ||
2 | rule "exe" | 60 | rule "exe" |
3 | { | 61 | { |
4 | input "*.o"; | 62 | input "*.o"; |
5 | profile "build" | 63 | profile "build" |
6 | { | 64 | { |
7 | execute("g++ -o ${OUTPUT} ${INPUT} ${LDFLAGS}"); | 65 | execute("${CXX} -o ${OUTPUT} ${INPUT} ${LDFLAGS}"); |
8 | } | 66 | } |
9 | } | 67 | } |
10 | 68 | ||
@@ -13,18 +71,19 @@ rule "lib" | |||
13 | input "*.o"; | 71 | input "*.o"; |
14 | profile "build" | 72 | profile "build" |
15 | { | 73 | { |
16 | execute("ar cr ${OUTPUT} ${INPUT}"); | 74 | execute("${AR} cr ${OUTPUT} ${INPUT}"); |
17 | } | 75 | } |
18 | } | 76 | } |
19 | 77 | ||
20 | rule "cpp" | 78 | rule "cpp" |
21 | { | 79 | { |
22 | input "*.cpp"; | 80 | input "*.cpp"; |
23 | output replace(".cpp", ".o"); | 81 | output cppToObj(); |
24 | requires getMakeDeps("g++ ${CXXFLAGS} -M ${INPUT}"); | 82 | // output replace(".cpp", ".o"); |
83 | requires getMakeDeps("${CXX} ${CXXFLAGS} -M ${INPUT}"); | ||
25 | profile "build" | 84 | profile "build" |
26 | { | 85 | { |
27 | execute("g++ ${CXXFLAGS} -c -o ${OUTPUT} ${INPUT}", "g++"); | 86 | execute("${CXX} ${CXXFLAGS} -c -o ${OUTPUT} ${INPUT}", "g++"); |
28 | } | 87 | } |
29 | } | 88 | } |
30 | 89 | ||
@@ -32,11 +91,12 @@ rule "cpp" | |||
32 | rule "c" | 91 | rule "c" |
33 | { | 92 | { |
34 | input "*.c"; | 93 | input "*.c"; |
35 | output replace(".c", ".o"); | 94 | output cToObj(); |
36 | requires getMakeDeps("gcc ${CXXFLAGS} -M ${INPUT}"); | 95 | // output replace(".c", ".o"); |
96 | requires getMakeDeps("${CC} ${CFLAGS} -M ${INPUT}"); | ||
37 | profile "build" | 97 | profile "build" |
38 | { | 98 | { |
39 | execute("gcc ${CFLAGS} -c -o ${OUTPUT} ${INPUT}"); | 99 | execute("${CC} ${CFLAGS} -c -o ${OUTPUT} ${INPUT}"); |
40 | } | 100 | } |
41 | } | 101 | } |
42 | 102 | ||
@@ -47,7 +107,7 @@ rule "bison" | |||
47 | profile "build" | 107 | profile "build" |
48 | { | 108 | { |
49 | BASE = INPUT.replace(".y", ""); | 109 | BASE = INPUT.replace(".y", ""); |
50 | execute("bison -b${BASE} ${INPUT}"); | 110 | execute("${BISON} -b${BASE} ${INPUT}"); |
51 | // if you add a -v bison will produce a .output file | 111 | // if you add a -v bison will produce a .output file |
52 | } | 112 | } |
53 | } | 113 | } |
@@ -59,6 +119,6 @@ rule "flex" | |||
59 | output replace(".l", ".yy.h"); | 119 | output replace(".l", ".yy.h"); |
60 | profile "build" | 120 | profile "build" |
61 | { | 121 | { |
62 | execute("flex ${FLEXFLAGS} ${INPUT}"); | 122 | execute("${FLEX} ${FLEXFLAGS} ${INPUT}"); |
63 | } | 123 | } |
64 | } | 124 | } |
diff --git a/src/action.cpp b/src/action.cpp index 23c24cd..8b10641 100644 --- a/src/action.cpp +++ b/src/action.cpp | |||
@@ -80,6 +80,31 @@ Action *Action::genDefaultClean() | |||
80 | return pRet; | 80 | return pRet; |
81 | } | 81 | } |
82 | 82 | ||
83 | Action *Action::genDefaultCleanAll() | ||
84 | { | ||
85 | Ast *pAst = new Ast(); | ||
86 | pAst->addNode( AstNode::typeActionDef ); | ||
87 | pAst->openBranch(); | ||
88 | pAst->addNode( AstNode::typeString, "clean-all" ); | ||
89 | pAst->openBranch(); | ||
90 | pAst->addNode( AstNode::typeProcessTarget ); | ||
91 | pAst->openBranch(); | ||
92 | pAst->addNode( AstNode::typeString, "clean" ); | ||
93 | pAst->openBranch(); | ||
94 | pAst->addNode( AstNode::typeFunction ); | ||
95 | pAst->openBranch(); | ||
96 | pAst->addNode( AstNode::typeString, "targets" ); | ||
97 | pAst->closeNode(); | ||
98 | pAst->closeNode(); | ||
99 | pAst->closeNode(); | ||
100 | Action *pRet = new Action( | ||
101 | dynamic_cast<const AstBranch *>( *pAst->getNodeBegin() ) | ||
102 | ); | ||
103 | pRet->pAst = pAst; | ||
104 | |||
105 | return pRet; | ||
106 | } | ||
107 | |||
83 | Action *Action::genDefaultDefault() | 108 | Action *Action::genDefaultDefault() |
84 | { | 109 | { |
85 | Ast *pAst = new Ast(); | 110 | Ast *pAst = new Ast(); |
diff --git a/src/action.h b/src/action.h index 520f2f1..7f60095 100644 --- a/src/action.h +++ b/src/action.h | |||
@@ -15,6 +15,7 @@ public: | |||
15 | 15 | ||
16 | static Action *genDefaultAll(); | 16 | static Action *genDefaultAll(); |
17 | static Action *genDefaultClean(); | 17 | static Action *genDefaultClean(); |
18 | static Action *genDefaultCleanAll(); | ||
18 | static Action *genDefaultDefault(); | 19 | static Action *genDefaultDefault(); |
19 | 20 | ||
20 | private: | 21 | private: |
diff --git a/src/context.cpp b/src/context.cpp index c257a75..bc48def 100644 --- a/src/context.cpp +++ b/src/context.cpp | |||
@@ -438,6 +438,10 @@ void Context::genDefaultActions() | |||
438 | { | 438 | { |
439 | addAction( Action::genDefaultClean() ); | 439 | addAction( Action::genDefaultClean() ); |
440 | } | 440 | } |
441 | if( !hAction.has("clean-all") ) | ||
442 | { | ||
443 | addAction( Action::genDefaultCleanAll() ); | ||
444 | } | ||
441 | if( !hAction.has("default") ) | 445 | if( !hAction.has("default") ) |
442 | { | 446 | { |
443 | addAction( Action::genDefaultDefault() ); | 447 | addAction( Action::genDefaultDefault() ); |