Archive for August, 2011

libbash final report

My GSoC project will end in this weekend so this is the final report. This week, I spent most of my time making sure the project is in a good state for future developers.

So far, libbash can generate correct ebuild metadata for 8414 out of 27586 ebuilds. What is blocking us from moving on? We need to be able to parse all the eclasses. But there are still a few problems in the parser grammar. On the other hand, our runtime is not complete. In one word, more time is required. This is the ohloh page for libbash where you can learn some statistics of the code.

I wrote an ebuild for libbash and put it in my overlay. Now you can play with it by

layman -a qiaomuf
emerge libbash

Although libbash is not powerful enough to generate all ebuild metadata, it can do something useful now. As I said before, you can always check what libbash can support from these test scripts. One thing you should notice is that we do not support running external command.

The library is quite easy to use. To give you a taste, here is a code snippet showing how to use it:

#include <algorithm>
#include <iostream>
#include <iterator>

#include <libbash/libbash.h>

int main(int argc, char** argv)
{
  // store variable values and function names
  std::unordered_map<std::string, std::vector<std::string>> variables;
  std::vector<std::string> functions;

  // interpret the script specified by argv[1]
  libbash::interpret(argv[1], variables, functions);

  // do what ever you want with variables and functions
  std::copy(functions.begin(),
            functions.end(),
            std::ostream_iterator<std::string>(std::cout, " "));
  std::cout << std::endl;
}

To get it compiled, run

g++ -std=c++0x $(pkg-config --cflags --libs libbash) test.cpp

The program will interpret the script like bash and store the result in the variable map and function name list. All the variables are treated as arrays. For more information, you can check the API documentation.
(P.S.: The library is not stable so please don’t use it in any serious place)

So what’s next? I think it would be improving the parser grammar, figuring out problems from the output of instruo and implement more runtime. People are welcome to make contributions. I’ll continue making contributions after GSoC.

Last but not least, I’d like to thank Google and Gentoo community for giving me such great experience. Thank Petteri for mentoring me. I enjoyed a wonderful summer with you and learned a lot including C++0x, boost libraries, ANTLR, autotools, Scrum and so on. Thank Donnie, Robin and other people who helped me.

OK, I’m going to get myself prepared and seek a job 😉

2 Comments

libbash weekly report #11

Sorry for the delay this time because I was in Beijing in the last weekend. Finally I can get down to write the report.

Now 8414 ebuilds can be handled. The number is increasing again and it’s not that hard to make progress this time because we have fixed the big issues in the parser grammar. However, running instruo is not that fast any more. It is because we can parse more eclasses so there are more things to handle.

I did more than expected in the last week. Here is the list of what I have done in the last week:

  • Fix code so that our instruo won’t crash anymore(turns out to be a problem related to thread-safety)
  • Get libtool.eclass fully parsed
  • Get perl-module.eclass fully parsed
  • Get distutils.eclass fully parsed
  • Get java-utils-2.eclass fully parsed
  • Get kde4-base.eclass fully parsed
  • Get python.eclass parsed with one exception: double quoted arithmetic expansion

The above eclasses included all the tasks for grammar improvements that I mentioned in the last weekly report.

This week I will:

  • Improve our build system to install something useful
  • Improve our ebuild so that the library can be installed and used properly
  • Review all the documentation
  • Review all the code

2 Comments