# Path: dependency/Builder.py
# class Builder(object):
#     """
#     base class for splicing the compile command
#     """
#     def __init__(self, obj, compiler, workspace):
#         """
#         init function
#         Args:
#             obj : the cvs path of object file
#             compiler : the path of compiler
#             workspace : the workspace path
#         """
#         self.obj = obj
#         self.obj_dir = os.path.dirname(obj)
#         self.compiler = compiler
#         self.workspace = workspace
#         self.build_cmd = None      # build cmd
#         self.error = "OK"
# 
#     def __str__(self):
#         """
#         """
#         return self.build_cmd
#     
#     def GetBuildCmd(self):
#         """
#         return the build cmd
#         """
#         return self.build_cmd
# 
#     def Error(self):
#         """
#         return the error message
#         """
#         return self.error
# 
# Path: util/Function.py
# DIGITS = [str(x) for x in xrange(0, 10)] 
# ALPHABETS = []
# def CheckName(v):
# def DelFiles(path):
# def MoveFiles(src, dst):
# def Mkdir(target_dir):
# def CalcHash(data, method='MD5'):
# def GetFileHash(path, method='MD5'):
# def RunCommand(cmd, ignore_stderr_when_ok=False):
# def RunCommand_tty(cmd):


import os
import sys
import unittest
from dependency import Builder
from util import Function
\\\n\tbroc_out/a/b/d/output/lib/libutil.a"
        builder = Builder.LibBuilder(obj, dep_objs, dep_libs, compiler, '.')          

        self.assertEqual(right_cmd, builder.GetBuildCmd()) 
    def test_ObjBuilder(self):
        """
        test ObjBuilder
        """
        now_dir = os.getcwd()
        obj = "broc_out/a/b/c/test.o"
        infile = 'a/b/c/test.cpp'
        includes = ['/usr/include', '/usr/local/include', 'a/b/c']
        opts = ['-DBROC', '-DVERSION=1.0.0']
        compiler = '/usr/bin/g++'
        builder = Builder.ObjBuilder(obj, infile, includes, opts, compiler, now_dir)
        right_cmd = "mkdir -p broc_out/a/b/c && /usr/bin/g++ \\\n\t-c \
\\\n\t-DBROC \\\n\t-DVERSION=1.0.0 \\\n\t-I/usr/include \\\n\t-I/usr/local/include \
\\\n\t-Ia/b/c \\\n\t-o \\\n\tbroc_out/a/b/c/test.o \\\n\ta/b/c/test.cpp"
        self.assertEqual(right_cmd, builder.GetBuildCmd())
        builder.CalcHeaderFiles()

    def test_GetHeaderFiles(self):
        """
        test GetHeaderFiles
        """
        now_dir = os.getcwd()
        obj = 'get_header_files.o'
        infile = 'get_header_files.cpp'
        include = ['/usr/include', '/usr/local/include']
        compiler = '/usr/bin/g++'

# Path: dependency/Builder.py
# class Builder(object):
#     """
#     base class for splicing the compile command
#     """
#     def __init__(self, obj, compiler, workspace):
#         """
#         init function
#         Args:
#             obj : the cvs path of object file
#             compiler : the path of compiler
#             workspace : the workspace path
#         """
#         self.obj = obj
#         self.obj_dir = os.path.dirname(obj)
#         self.compiler = compiler
#         self.workspace = workspace
#         self.build_cmd = None      # build cmd
#         self.error = "OK"
# 
#     def __str__(self):
#         """
#         """
#         return self.build_cmd
#     
#     def GetBuildCmd(self):
#         """
#         return the build cmd
#         """
#         return self.build_cmd
# 
#     def Error(self):
#         """
#         return the error message
#         """
#         return self.error
# 
# Path: util/Function.py
# DIGITS = [str(x) for x in xrange(0, 10)] 
# ALPHABETS = []
# def CheckName(v):
# def DelFiles(path):
# def MoveFiles(src, dst):
# def Mkdir(target_dir):
# def CalcHash(data, method='MD5'):
# def GetFileHash(path, method='MD5'):
# def RunCommand(cmd, ignore_stderr_when_ok=False):
# def RunCommand_tty(cmd):


# Path: unittest/test_Builder.py
import os
import sys
import unittest
from dependency import Builder
from util import Function

\\\n\tbroc_out/a/b/d/output/lib/libutil.a"
        builder = Builder.LibBuilder(obj, dep_objs, dep_libs, compiler, '.')          

        self.assertEqual(right_cmd, builder.GetBuildCmd()) 
    def test_ObjBuilder(self):
        """
        test ObjBuilder
        """
        now_dir = os.getcwd()
        obj = "broc_out/a/b/c/test.o"
        infile = 'a/b/c/test.cpp'
        includes = ['/usr/include', '/usr/local/include', 'a/b/c']
        opts = ['-DBROC', '-DVERSION=1.0.0']
        compiler = '/usr/bin/g++'
        builder = Builder.ObjBuilder(obj, infile, includes, opts, compiler, now_dir)
        right_cmd = "mkdir -p broc_out/a/b/c && /usr/bin/g++ \\\n\t-c \
\\\n\t-DBROC \\\n\t-DVERSION=1.0.0 \\\n\t-I/usr/include \\\n\t-I/usr/local/include \
\\\n\t-Ia/b/c \\\n\t-o \\\n\tbroc_out/a/b/c/test.o \\\n\ta/b/c/test.cpp"
        self.assertEqual(right_cmd, builder.GetBuildCmd())
        builder.CalcHeaderFiles()

    def test_GetHeaderFiles(self):
        """
        test GetHeaderFiles
        """
        now_dir = os.getcwd()
        obj = 'get_header_files.o'
        infile = 'get_header_files.cpp'
        include = ['/usr/include', '/usr/local/include']
        compiler = '/usr/bin/g++'

        builder = Builder.ObjBuilder(obj, infile, include, None, compiler, now_dir)