Пример #1
0
    def __init__(self, platform, project):
        global project_extension
        global workspace_extension
        
        umake_lib.Targets.__init__(self, platform, project)

        dsw=Workspace()

        projects = []
        makefiles = []
        
        for sumake in project.get_uber_makes():
            makefiles.append(sumake.abs_makefile())

            name = umake_lib.declaw_name(sumake.abs_makefile())
            path = os.path.dirname(sumake.makefile())
            path = os.path.join(path, umake_lib.declaw_name(sumake.abs_makefile()))
            dsw.AddProject(name,path+"."+project_extension)
            for dep in sumake.dependencies():
                dep = umake_lib.declaw_name(dep)
                dsw.AddDependency(name, dep)

        name = os.path.join(self.project.module_directory(),
                            self.project.makefile_name)
        name = umake_lib.declaw_name(name)
        umake_lib.write_file(name+"."+workspace_extension,dsw.generate())
Пример #2
0
    def __init__(self, platform, project):
        umake_lib.Targets.__init__(self, platform, project)

        self.variables = {}

        self.setup_variables()

        name = os.path.join(self.project.module_directory(),
                            self.project.makefile_name)
        name = umake_lib.declaw_name(name)
            
        proj=Project(name,
                     self.project.makefile_name,
                     project.getTargetType(),
                     self.variables)
        self.proj=proj

        self.add_configurations()
            
        for src in project.sources:
            sourcefile = umake_lib.SourceFile(
                platform, src, project.object_dir)
            proj.AddSourceFile(sourcefile)

        cache = globals().get("__umake_win_makefile_header_cache__",
                              {"dir":""})


        if cache["dir"] != os.getcwd():
            cache["dir"]=os.getcwd()
            headers = []
            ## Not very pretty, we add all header files
            ## found in this directory (or any subdir)
            ## to the project.
            potential_headers = [ "." ]
            for h in potential_headers:
                if os.path.isdir(h):
                    for f in os.listdir(h):
                        potential_headers.append(os.path.join(h,f))
                else:
                    if string.lower(os.path.splitext(h)[1]) == ".h":
                        headers.append(h)

            cache["headers"] = headers
            globals()["__umake_win_makefile_header_cache__"] = cache


        proj.AddHeaderFiles(cache["headers"])

        global project_extension
        global workspace_extension
        
        name = os.path.join(self.project.module_directory(),
                            self.project.makefile_name)
        name = umake_lib.declaw_name(name)
        data=proj.generate()

        umake_lib.write_file(name+"."+project_extension,proj.generate())
Пример #3
0
def WritePrefixFile(mprj):
    """Write the prefix header file for projects.  Prefix files on the
    Macintosh are, by default, always included in every source file before
    any other header file.  Therefore, it is a useful place to set up
    #defines, since the Mac doesn't support doing them any other way."""

    line_list = [
        "/* Prefix File Generated by Umake */",
        ]

    ## get all the defines into one list
    line_list.append("/* begin defines */")

    for define in mprj.define_list:
        index = string.find(define, '=')

        ## define without value, just set to true
        if index == -1:
            line_list.append("#define %s 1" % (define))
            continue

        ## define with value
        key = string.strip(define[:index])
        value = string.strip(define[index+1:])
        line_list.append('#define %s %s' % (key, value))

    line_list.append("/* end defines */")

    ## PPC vs. 68k, very legacy...
    line_list = line_list + [
        "#ifdef __POWERPC__",
        "        #define _MACPPC 1",
        "#else",
        "        #define _MAC68K 1",
        "#endif /* __POWERPC__ */",
        ]

    ## included in everything
    for include in mprj.prefix_file_include_list:
        line_list.append("#include <%s>" % (include))

    ## write the file and set creator/type
    data=string.join(line_list,"\n") + "\n"

    umake_lib.write_file(mprj.prefix_file_path, data)

    fsspec = macfs.FSSpec(mprj.prefix_file_path)
    fsspec.SetCreatorType('CWIE', 'TEXT')
Пример #4
0
def WriteResourcePrefixFile(mprj):
    """Write the prefix header file for resource projects."""

    line_list = [
        "/* Resource Prefix File Generated by Umake */",
        "#include <types.r>",
        "#define _MACINTOSH",
        ]


    data=string.join(line_list,"\n") + "\n"

    umake_lib.write_file(mprj.rprefix_file_path, data)

    fsspec = macfs.FSSpec(mprj.rprefix_file_path)
    fsspec.SetCreatorType('CWIE', 'TEXT')
Пример #5
0
    def write_macros(self):
        """Writes all the macros (variables) to the Makefile."""

        umake_lib.debug("Project.write_macros")

        def str_list(list):
            return string.join(list)


        self.writeln("## Generated from %s, do not edit, do not commit to cvs!" % (self.project.umakefile_name ))
        self.writeln("")

        ## print out all command and command flag variables
        ## in the platform command list, taking care not to
        ## print blank lines for commands/command flas which
        ## do not exist
        for current_command in self.platform.command_list:
            command_var = current_command.setup_command_var()
            flags_var = current_command.setup_flags_var()
            if len(command_var):
                self.writeln(command_var)
            if len(flags_var):
                self.writeln(flags_var)

        ## write out env variables for compilers
        for build_rule in self.platform.build_rules.values():
            current_command = build_rule.command
            command_var = current_command.setup_command_var()
            flags_var = current_command.setup_flags_var()
            if len(command_var):
                self.writeln(command_var)
            if len(flags_var):
                self.writeln(flags_var)

        ## LINKER
        if not hasattr(self.platform.link, "linker2"):
            self.writeln(self.platform.link.setup_command_var())
            self.writeln(self.platform.link.setup_flags_var())

        ## SRCS
        self.writeln("SRCS=%s" % (self.compat_quote(self.project.sources)))

        ## COMPILED_OBJS, SOURCE_OBJS, OBJS
        self.writeln("OBJS=%s %s" % (
            self.platform.form_var("COMPILED_OBJS"),
            self.platform.form_var("SOURCE_OBJS")))

        self.writeln("COMPILED_OBJS=%s" % (
            self.compat_quote(self.project.objects)))
        self.writeln('SOURCE_OBJS=%s' % (
            self.compat_quote(self.project.objsrcs)))    

        ## INCLUDES
        self.writeln("INCLUDES=%s" % self.build_quoted_arg_list(
            self.project.includes,
            self.platform.include_arg))

        ## DEFINES
        if self.platform.cc.prefix_include_arg:
            defdir = self.project.output_dir
            shell.mkdir(defdir)
            name = os.path.join(self.project.module_directory(),
                                self.project.makefile_name)
            prefix_file_name = umake_lib.declaw_name(name)+"_ribodefs.h"
            prefix_file_name=os.path.join(defdir, prefix_file_name)
            
            lines=[]

            defs=self.project.defines
            defs.sort()
            for d in defs:
                ind = string.find(d,"=")
                if ind == -1:
                    lines.append("#ifndef %s" % (d))
                    lines.append("#define %s 1" % (d))
                else:
                    lines.append("#ifndef %s" % (d[:ind]))
                    lines.append("#define %s %s" % (d[:ind],d[ind+1:]))
                lines.append("#endif")

            for include in self.project.prefix_file_include_list:
                ## Ugly magic stuff
                if type(include) == types.StringType:
                    if include[0] == '"' or include[0] == '<':
                        lines.append("#include %s" % (include))
                    elif include[0] == '#':
                        lines.append("%s" % (include))
                    else:
                        lines.append("#include <%s>" % (include))
                elif type(include) == types.ListType:
                    lines.extend(include)

            data = string.join(lines,"\n")+"\n"

            umake_lib.write_file(prefix_file_name, data)

            self.writeln("DEFINES=%s%s %s%s" % (
                self.platform.include_arg,
                os.curdir,
                self.platform.cc.prefix_include_arg,
                prefix_file_name))
        else:
            self.writeln("DEFINES=%s" % self.build_quoted_arg_list(
                self.project.defines,
                self.platform.define_arg))

        ## STATIC_LIBS
        static_libs = self.project.libraries + self.project.libraries2 + \
                      self.project.local_libs + self.project.module_libs
        self.writeln("STATIC_LIBS=%s" % (self.compat_quote(static_libs)))

        ## DYNAMIC_LIBS
        self.writeln("DYNAMIC_LIBS=%s %s" % (
            self.compat_quote(self.project.dynamic_libraries),
            self.compat_quote(self.project.sys_libraries,
                              self.platform.sys_lib_arg)))

        self.writeln("")

        ## suffixes
        if len(self.platform.suffix_list):
            self.writeln(".SUFFIXES: %s" % (
                string.join(self.platform.suffix_list)))
            self.writeln("")

        ## default/misc build rules
        for rule in self.platform.build_rules.values():

            ## Add custom INCLUDE/DEFINE variables for each compiler
            ## (Except CC/CXX, which uses INCLUDE/DEFINES)
            if rule.command.make_var not in [ "CC", "CXX" ]:
                if rule.command.define_arg and rule.command.make_var:
                    try:
                        defs = None
                        try:
                            defs = rule.command.defines
                        except AttributeError:
                            pass

                        if defs == None:
                            defs = self.project.defines
                        
                        self.writeln("%sDEFINES=%s" % (
                            rule.command.make_var,
                            self.build_quoted_arg_list(defs,
                                                  rule.command.define_arg)))
                        self.writeln("")
                    except:
                        pass

                if rule.command.include_arg and rule.command.make_var:
                    try:
                        includes = None
                        try:
                            includes = rule.command.includes
                        except AttributeError:
                            pass

                        if includes == None:
                            includes = self.project.includes
                        
                        self.writeln("%sINCLUDES=%s" % (
                            rule.command.make_var,
                            self.build_quoted_arg_list(includes,
                                                  rule.command.include_arg)))
                        self.writeln("")
                    except:
                        pass

            if self.platform.build_rules.get(rule.source_suffix,None) == rule:
                rule_str = "%s%s%s" % (
                    rule.source_suffix, rule.target_suffix,
                    self.platform.make_depend)
                self.writeln(rule_str)

                cmd_str = rule.command.execute(
                    self.platform.make_target, self.platform.make_source)
                self.writeln("\t%s" % (cmd_str))
                self.writeln("")
Пример #6
0
    def write_macros(self):
        """Writes all the macros (variables) to the Makefile."""

        umake_lib.debug("Project.write_macros")

        def str_list(list):
            return string.join(list)

        self.writeln(
            "## Generated from %s, do not edit, do not commit to cvs!" %
            (self.project.umakefile_name))
        self.writeln("")

        ## print out all command and command flag variables
        ## in the platform command list, taking care not to
        ## print blank lines for commands/command flas which
        ## do not exist
        for current_command in self.platform.command_list:
            command_var = current_command.setup_command_var()
            flags_var = current_command.setup_flags_var()
            if len(command_var):
                self.writeln(command_var)
            if len(flags_var):
                self.writeln(flags_var)

        ## write out env variables for compilers
        for build_rule in self.platform.build_rules.values():
            current_command = build_rule.command
            command_var = current_command.setup_command_var()
            flags_var = current_command.setup_flags_var()
            if len(command_var):
                self.writeln(command_var)
            if len(flags_var):
                self.writeln(flags_var)

        ## LINKER
        if not hasattr(self.platform.link, "linker2"):
            self.writeln(self.platform.link.setup_command_var())
            self.writeln(self.platform.link.setup_flags_var())

        ## SRCS
        self.writeln("SRCS=%s" % (self.compat_quote(self.project.sources)))

        ## COMPILED_OBJS, SOURCE_OBJS, OBJS
        self.writeln("OBJS=%s %s" % (self.platform.form_var("COMPILED_OBJS"),
                                     self.platform.form_var("SOURCE_OBJS")))

        self.writeln("COMPILED_OBJS=%s" %
                     (self.compat_quote(self.project.objects)))
        self.writeln('SOURCE_OBJS=%s' %
                     (self.compat_quote(self.project.objsrcs)))

        ## INCLUDES
        self.writeln("INCLUDES=%s" % self.build_quoted_arg_list(
            self.project.includes, self.platform.include_arg))

        ## DEFINES
        if self.platform.cc.prefix_include_arg:
            defdir = self.project.output_dir
            shell.mkdir(defdir)
            name = os.path.join(self.project.module_directory(),
                                self.project.makefile_name)
            prefix_file_name = umake_lib.declaw_name(name) + "_ribodefs.h"
            prefix_file_name = os.path.join(defdir, prefix_file_name)

            lines = []

            defs = self.project.defines
            defs.sort()
            for d in defs:
                ind = string.find(d, "=")
                if ind == -1:
                    lines.append("#ifndef %s" % (d))
                    lines.append("#define %s 1" % (d))
                else:
                    lines.append("#ifndef %s" % (d[:ind]))
                    lines.append("#define %s %s" % (d[:ind], d[ind + 1:]))
                lines.append("#endif")

            for include in self.project.prefix_file_include_list:
                ## Ugly magic stuff
                if type(include) == types.StringType:
                    if include[0] == '"' or include[0] == '<':
                        lines.append("#include %s" % (include))
                    elif include[0] == '#':
                        lines.append("%s" % (include))
                    else:
                        lines.append("#include <%s>" % (include))
                elif type(include) == types.ListType:
                    lines.extend(include)

            data = string.join(lines, "\n") + "\n"

            umake_lib.write_file(prefix_file_name, data)

            self.writeln(
                "DEFINES=%s%s %s%s" %
                (self.platform.include_arg, os.curdir,
                 self.platform.cc.prefix_include_arg, prefix_file_name))
        else:
            self.writeln("DEFINES=%s" % self.build_quoted_arg_list(
                self.project.defines, self.platform.define_arg))

        ## STATIC_LIBS
        static_libs = self.project.libraries + self.project.libraries2 + \
                      self.project.local_libs + self.project.module_libs
        self.writeln("STATIC_LIBS=%s" % (self.compat_quote(static_libs)))

        ## DYNAMIC_LIBS
        self.writeln("DYNAMIC_LIBS=%s %s" %
                     (self.compat_quote(self.project.dynamic_libraries),
                      self.compat_quote(self.project.sys_libraries,
                                        self.platform.sys_lib_arg)))

        self.writeln("")

        ## suffixes
        if len(self.platform.suffix_list):
            self.writeln(".SUFFIXES: %s" %
                         (string.join(self.platform.suffix_list)))
            self.writeln("")

        ## default/misc build rules
        for rule in self.platform.build_rules.values():

            ## Add custom INCLUDE/DEFINE variables for each compiler
            ## (Except CC/CXX, which uses INCLUDE/DEFINES)
            if rule.command.make_var not in ["CC", "CXX"]:
                if rule.command.define_arg and rule.command.make_var:
                    try:
                        defs = None
                        try:
                            defs = rule.command.defines
                        except AttributeError:
                            pass

                        if defs == None:
                            defs = self.project.defines

                        self.writeln("%sDEFINES=%s" %
                                     (rule.command.make_var,
                                      self.build_quoted_arg_list(
                                          defs, rule.command.define_arg)))
                        self.writeln("")
                    except:
                        pass

                if rule.command.include_arg and rule.command.make_var:
                    try:
                        includes = None
                        try:
                            includes = rule.command.includes
                        except AttributeError:
                            pass

                        if includes == None:
                            includes = self.project.includes

                        self.writeln("%sINCLUDES=%s" %
                                     (rule.command.make_var,
                                      self.build_quoted_arg_list(
                                          includes, rule.command.include_arg)))
                        self.writeln("")
                    except:
                        pass

            if self.platform.build_rules.get(rule.source_suffix, None) == rule:
                rule_str = "%s%s%s" % (rule.source_suffix, rule.target_suffix,
                                       self.platform.make_depend)
                self.writeln(rule_str)

                cmd_str = rule.command.execute(self.platform.make_target,
                                               self.platform.make_source)
                self.writeln("\t%s" % (cmd_str))
                self.writeln("")