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 ;)

About these ads
  1. #1 by Mike Gilbert on August 6, 2011 - 11:58 pm

    Thanks for the interesting blog series. Most of it was a bit over my head, but interesting.

  2. #2 by joc on April 27, 2012 - 3:53 am

    excellent points altogether, you simply received a new reader. What would you suggest about your post that you just made a few days in the past? Any certain?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: