1 |
My GSoC project will end in this weekend so this is the final report. |
2 |
This week, I spent most of my time making sure the project is in a good |
3 |
state for future developers. |
4 |
|
5 |
So far, libbash can generate correct ebuild metadata for 8414 out of |
6 |
27586 ebuilds. What is blocking us from moving on? We need to be able to |
7 |
parse all the eclasses. But there are still a few problems in the parser |
8 |
grammar. On the other hand, our runtime is not complete. In one word, |
9 |
more time is required. This is the ohloh page for libbash[1] where you |
10 |
can learn some statistics of the code. |
11 |
|
12 |
I wrote an ebuild for libbash and put it in my overlay. Now you can play |
13 |
with it by |
14 |
layman -a qiaomuf |
15 |
emerge libbash |
16 |
|
17 |
Although libbash is not powerful enough to generate all ebuild metadata, |
18 |
it can do something useful now. As I said before, you can always check |
19 |
what libbash can support from these test scripts[2]. One thing you |
20 |
should notice is that we do not support running external command. |
21 |
|
22 |
The library is quite easy to use. To give you a taste, here is a code |
23 |
snippet showing how to use it: |
24 |
#include <algorithm> |
25 |
#include <iostream> |
26 |
#include <iterator> |
27 |
|
28 |
#include <libbash/libbash.h> |
29 |
|
30 |
int main(int argc, char** argv) |
31 |
{ |
32 |
// store variable values and function names |
33 |
|
34 |
std::unordered_map<std::string, std::vector<std::string>> variables; |
35 |
std::vector<std::string> functions; |
36 |
|
37 |
// interpret the script specified by argv[1] |
38 |
libbash::interpret(argv[1], variables, functions); |
39 |
|
40 |
// do what ever you want with variables and functions |
41 |
std::copy(functions.begin(), functions.end(), |
42 |
std::ostream_iterator<std::string>(std::cout, " ")); |
43 |
std::cout << std::endl; |
44 |
} |
45 |
|
46 |
|
47 |
To get it compiled, run |
48 |
g++ -std=c++0x $(pkg-config --cflags --libs libbash) test.cpp |
49 |
|
50 |
The program will interpret the script like bash and store the result in |
51 |
the variable map and function name list. All the variables are treated |
52 |
as arrays. For more information, you can check the API documentation. |
53 |
(P.S.: The library is not stable so please don’t use it in any serious |
54 |
place) |
55 |
|
56 |
So what’s next? I think it would be improving the parser grammar, |
57 |
figuring out problems from the output of instruo and implement more |
58 |
runtime. People are welcome to make contributions. I’ll continue making |
59 |
contributions after GSoC. |
60 |
|
61 |
Last but not least, I’d like to thank Google and Gentoo community for |
62 |
giving me such great experience. Thank Petteri for mentoring me. I |
63 |
enjoyed a wonderful summer with you and learned a lot including C++0x, |
64 |
boost libraries, ANTLR, autotools, Scrum and so on. Thank Donnie, Robin |
65 |
and other people who helped me. |
66 |
|
67 |
OK, I’m going to get myself prepared and seek a job ;) |
68 |
|
69 |
[1] https://www.ohloh.net/p/gentoo_libbash |
70 |
[2] |
71 |
http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=tree;f=scripts;hb=HEAD |
72 |
|
73 |
-- |
74 |
Best wishes, |
75 |
Mu Qiao |
76 |
GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5 3ACC 30B3 0DE4 17B1 57E9 |