Beispiel #1
0
 def Action(self):
     """
     init builder
     """
     Source.Action(self)
     self.CalcObjectName()
     options = ['-DBROC']
     options.extend(self.cppflags + self.cxxflags)
     self.builder = Builder.ObjBuilder(self.outfile,
                                       self.infile, self.includes, options,
                                       self.env.CXX(), self.env.Workspace())
Beispiel #2
0
 def Action(self):
     """
     parse compile options, and join all options as a string object       
     """
     Source.Action(self)
     self.CalcObjectName()
     options = ['-DBROC']
     options.extend(self.cppflags + self.cflags)
     self.builder = Builder.ObjBuilder(self.outfile,
                                       self.infile, self.includes, options,
                                       self.env.CC(), self.env.Workspace())
Beispiel #3
0
    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)
        right_header_cmd = "/usr/bin/g++ \\\n\t-MM -MG\\\n\t-I/usr/include \
\\\n\t-I/usr/local/include \\\n\tget_header_files.cpp"

        self.assertEqual(right_header_cmd, builder.GetHeaderCmd())
        with open('hello.h', 'wb') as f:
            f.write("#include <stdio.h>\n\
void hello()\n\
{\n\
    print(\"hello - hello\");\n\
}\n")
        with open('world.h', 'wb') as f:
            f.write("#include <stdio.h>\n\
void world()\n\
{\n\
    print(\"hello - world\");\n\
}\n")
        with open('get_header_files.cpp', 'wb') as f:
            f.write("#include <stdio.h>\n\
#include <pthread.h>\n\
#include \"hello.h\"\n\
#include \"world.h\"\n\
int main()\n\
{\n\
    hello();\n\
    world();\n\
    return 0;\n\
}\n")
        ret = builder.CalcHeaderFiles()
        self.assertEqual(True, ret['ret'])
        self.assertEqual(sorted(["hello.h", 'world.h']),
                         sorted(builder.GetHeaderFiles()))

        Function.DelFiles('get_header_files.cpp')
        Function.DelFiles('hello.h')
        Function.DelFiles('world.h')
Beispiel #4
0
    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()