예제 #1
0
def make_makefile(platform, project):
    ## FIX pncrt madness
    if project.getTargetType() in [ 'dll' , 'exe' ]:
        fix_pncrt(project)

    ## Create Applescript
    mprj = ProjectToMacCWProjectData(platform, project)
    applescript_path = macfs.FSSpec(project.makefile_name).as_pathname()
    ASMakefile(mprj).script.CompileAndSave(applescript_path)

    ## Create Uber XML file
    generate_uberxml(platform, project, mprj)

    ## Create an applescript stub file for reading the Uber XML file
    # this needs better handling/reporting of build errors
    script = ascript.CreateAppleScript()
    script.Append(
        'tell application %s' % (os.environ["BUILD_SW"]),
        '  with timeout of 99999 seconds',
        '    try',
        '      make new (project document) as "%s" with data ("%s")' % (
        macpath.join(os.getcwd(),project.makefile_name+"_uber.prj"),
        macpath.join(os.getcwd(),project.makefile_name+"_uber.xml")),
        '      set cwErrorList to Make Project with ExternalEditor',
        '      Close Project',
        '    on error errText number errnum',
        '      return errText & return',
        '    end try',
        '  end timeout',
        'end tell')
    uber_ascript = macfs.FSSpec(project.makefile_name+"_uber").as_pathname()
    script.CompileAndSave(uber_ascript)

    ## Pretend like everything went well
    return None
예제 #2
0
def Initialize(platform, project):
    if project.module_dir == '' or project.module_dir == ':':
        project.module_dir = project.target_name   

    if platform.name == 'mac':
        project.src_root_path = os.environ['SOURCE_ROOT']

    if (project.build_choices.count('release') > 0):
        debug_release = 'release'
    else:
        debug_release = 'debug'

    project.target_dir = os.path.join(project.src_root_path, debug_release)

    if platform.name == 'mac':
        global g_rzt_apple_script
        g_rzt_apple_script = ascript.CreateAppleScript('on all()')
        g_rzt_apple_script.Append(
            'verify path "%s"' % (project.target_dir))

    # Copy pncrt*.dll which is needed for pnpkg.exe on win32
    if platform.name == 'win32':
        if project.IsDefined("HELIX_CONFIG_RN_CRT"):
            project.writeln('\t' + platform.mkdir.execute(project.target_dir))

            pncrt_path = os.path.join(os.pardir, 'pncrt')
            if (project.build_choices.count('release') > 0):
                pncrt_path = os.path.join(pncrt_path, 'pncrt.dll')
            else:
                pncrt_path = os.path.join(pncrt_path, 'pncrtd.dll')
            project.writeln('\t' + platform.copy.cmd + ' ' +  pncrt_path + ' ' + project.target_dir)

        pnpkg_path = os.path.join(os.pardir, 'pnpkg', project.output_dir)
        project.writeln('\t' + platform.copy.cmd + ' ' +  pnpkg_path + ' ' + project.target_dir)
예제 #3
0
    def make(self, arg=''):
        old_dir = os.getcwd()
        status = 0
        result = ''

        path = macfs.FSSpec('Makefile').as_pathname()

        ## ALL
        if arg == '':
            script = ascript.CreateAppleScript(
                'set errtext to ""',
                'set scriptobj to (load script file "%s")' % (path),
                'tell scriptobj', '  with timeout of 99999 seconds', '    run',
                '    set errtext to the result', '  end timeout', 'end tell',
                'return errtext')

            result = script.CompileAndExecute()

        else:
            self.error('unsupported MAKE argument')

        ## so that it doesn't equal None
        if result == None:
            result = ''

        ## process output from AppleScript
        result = string.translate(result, string.maketrans('\r', '\n'))
        result = string.strip(result)
        result = string.replace(result, "\n\n", "\n")

        ## strip off the stupid quotes
        if len(result) >= 1:
            if result[0] == '"' and result[-1] == '"':
                result = string.strip(result[1:-1])

        outmsg.verbose(result)

        ## Scan the output for error messages
        for line in string.split(result, "\n"):
            if not line:  ## empty line
                continue

            words = string.split(line)
            if words[1] == "Warning":  ## Warning
                continue

            ## Anything else is an error
            status = 1
            self.error('failed make')

        os.chdir(old_dir)
        return status, result
예제 #4
0
def build_uberproject(uber_xml_path, uber_project_path, script_path):

    outmsg.send("Creating %s" % (os.path.basename(script_path)))

    script = ascript.CreateAppleScript()

    # this needs better handling/reporting of build errors
    script.Append(
        'tell application %s' % (os.environ["BUILD_SW"]),
        '  with timeout of 99999 seconds', '    try',
        '      make new (project document) as "%s" with data ("%s")' %
        (uber_project_path, uber_xml_path),
        '      set cwErrorList to Make Project with ExternalEditor',
        '      Close Project', '    on error errText number errnum',
        '      return errText & return', '    end try', '  end timeout',
        'end tell')
    script.CompileAndSave(script_path)

    if 0:  # set to 1 to actually make the uber project
        script.CompileAndExecute()
예제 #5
0
    def __init__(self, mprj):
        self.mprj = mprj
        ## start the script and define subroutines
        script = ascript.CreateAppleScript()
        self.script = script
        all =  []
        self.all = all

        for sumake in mprj.project.submakes:
            m_path = macpath.normpath(macpath.join(os.getcwd(), sumake.makefile()))
            all.extend( [
                'set scriptobj to (load script file "%s")' % (m_path),
                'tell scriptobj',
                '  set myerrors to myerrors & return & all()',
                'end tell' ] )

        script.Extend(mprj.project.pre_target_buff)

        self.Clean()


        if mprj.project.getTargetType() != "":

            WritePrefixFile(mprj)
            WriteResourcePrefixFile(mprj)    
            WriteExportFile(mprj)

            self.VerifyPath()
            self.ExtractCWErrors()    

            if len(mprj.weak_link_list):
                self.SetWeakLink()

            if len(mprj.post_build_script):
                self.PostBuildScript()

            if mprj.rtarget:
                self.DefineResourceProject()

            ## FIXME, only do this for if asked to 'clean' build
            all.extend( [
                '  --clean out old project and data by default',
                '  Clean()' ])

            ## write the "all" function, like "make all" in a Makefile
            all.extend( [
                '  --make the output directory, and target directory',
                '  verifypath("%s")' % (mprj.output_dir_path),
                '  verifypath("%s")' % (mprj.target_dir_path) ] )

            if mprj.rtarget:
                all.extend( [
                    '--build the windows resource dll',
                    'myerrors = myerrors & return & ResourceProject()' ] )


            self.RunProject()

            ## for DLL target types, we make a alias to the dll with a .lib
            ## extention so developers can do implicit linking to DLL's the
            ## same way they do on Windows
            ##
            ## Note: when Windows compiles a DLL, it creates a companion .LIB
            ##       library with the same name; you link to the DLL by linking
            ##       in the stub .LIB
            absolute_output_dir = os.path.join(os.getcwd(), mprj.output_dir)
            absolute_output_path = os.path.join(absolute_output_dir, mprj.output_name)

            if mprj.target_type == "dll":

                if mprj.project.opt_target_name:
                    alias_name= mprj.project.opt_target_name
                else:
                    alias_name= mprj.target_name

                alias_name = "%s.LIB" % (string.upper(alias_name))
                absolute_alias_path = os.path.join(absolute_output_dir, alias_name)

                all.extend( [
                    'tell application "Finder"',
                    '  try',
                    '    if (file "%s") exists then' % (absolute_alias_path),
                    '    else',
                    '      make new alias file to (file "%s") at (folder "%s") '\
                    '       with properties {name:"%s"}' % (
                            absolute_output_path, absolute_output_dir, alias_name),
                    '    end if',
                    '   on error',
                    '  end try',
                    'end tell' ])

            if len(mprj.post_build_script):
                all.extend( [
                    '--execute the custom subroutine',
                    'DoPostBuild()' ])

            ## copy the built target and finish off the script
            all.extend( [
                '-- Copy results to common output folder',
                'tell application "Finder"',
                '  if (file "%s") exists then' % (absolute_output_path),
                '      Duplicate file "%s" to folder "%s" with replacing' % (
                    absolute_output_path, mprj.target_dir_path),
                '  end if',
                'end tell' ])

        if len(all):
            script.Append('on all()',
                          'set myerrors to ""')
            script.Extend(all)
            script.Append(
                'return myerrors',
                'end all',
                '-- run the "all()" function',
                'return all()')


        script.Extend(mprj.project.post_target_buff)

        ## for DRM signing
        if mprj.project.getTargetType() == "dll" and \
               mprj.project.BuildOption("drmsign") and \
               mprj.project.CheckDRMSign():
            import shell
            shell.mkdir(os.path.dirname(absolute_output_path))
            open(absolute_output_path+"--drmsign","w").write("signme!")
예제 #6
0
def generate_ubersyms(build_list, uberxml_output_name, uber_dir):

    sym_folder_name = uberxml_output_name + " xSYMs"
    old_dir = os.getcwd()

    # make a list of the module names we're building; we'll exclude
    # any dependencies that are not in the list

    modules_built_id_list = [x.name for x in build_list]

    # look for sym files in the debug directory of each module

    sym_file_paths = []
    outmsg.send("Looking for sym files in %s" %
                (string.join(modules_built_id_list, ", ")))
    for module_name in modules_built_id_list:

        module_dir = os.path.join(old_dir, module_name)
        module_debug_dir = os.path.join(module_dir, "debug")
        if os.path.isdir(module_debug_dir):
            os.chdir(module_debug_dir)

            # find all sym files, and add the paths to those files to our sym_file_paths list
            sym_file_names = glob.glob("*.xSYM")
            sym_file_paths = sym_file_paths + [
                os.path.join(module_debug_dir, x) for x in sym_file_names
            ]

    if len(sym_file_paths) < 1:
        outmsg.send("No xSYM files found")
        os.chdir(old_dir)
        return

    # now make a folder containing aliases to the found sym files
    if not os.path.isdir(uber_dir):
        os.mkdir(uber_dir)

    syms_dir = os.path.join(uber_dir, sym_folder_name)
    if not os.path.isdir(syms_dir):
        os.mkdir(syms_dir)

    os.chdir(syms_dir)

    script = ascript.CreateAppleScript()

    for alias_target_path in sym_file_paths:

        (target_dir, target_name) = os.path.split(alias_target_path)
        alias_full_path = os.path.join(syms_dir, target_name)

        script.Append(
            'tell application "Finder"', '  try',
            '    if not (file "%s" exists) then' % (alias_full_path),
            '       make new alias file to (file "%s") at (folder "%s") with properties {name:"%s"}'
            % (alias_target_path, syms_dir, target_name), '    end if',
            '   on error', '  end try', 'end tell')

    script_path = os.path.join(syms_dir, "Make Symfile Aliases Script")
    script.CompileAndExecute()

    os.chdir(old_dir)
예제 #7
0
    def update(self,
               tag,
               module_list,
               az=None,
               timestamp=None,
               nonrecursive=0,
               dir=None):

        ### FIXME:
        ### test this!

        if dir:
            odir = os.getcwd()
            try:
                os.chdir(dir)
                ret = self.checkout(tag, module_list, az, timestamp,
                                    nonrecursive)
            finally:
                os.chdir(odir)

            return ret

        if az:
            odir = os.getcwd()
            shell.mkdir("cvs_temp")
            os.chdir("cvs_temp")
            self.checkout(tag, module_list, None, timestamp, nonrecursive)
            os.chdir(odir)
            for m in module_list:
                shell.cp(os.path.join(odir, "cvs_temp", m),
                         os.path.join(odir, az))

            shell.rm("cvs_temp")
            return

        if nonrecursive:
            e = err.Error()
            e.Set("Nonrecursive not supported by MacCVS")
            raise err.error, e

        session_name = self.cvs_session_path[1:-1]
        session_name = os.path.basename(session_name)

        script = ascript.CreateAppleScript(
            'tell application %s' % (self.cvs_path), '  activate',
            '  open alias %s' % (self.cvs_session_path),
            '  set thesession to session named "%s"' % (session_name),
            '  set local root of thesession to alias "%s"' % (os.getcwd()),
            '  with timeout of 99999 seconds')

        for module in module_list:
            cmd = 'check out thesession module "%s"' % (module)
            if tag:
                cmd = cmd + ' revision "%s"' % (tag)

            if timestamp:
                cmd = cmd + ' date "%s"' % (timestamp)

            script.Append(cmd)

        script.Append('  end timeout', '  quit', 'end tell')

        if self.script_save_path == '':
            result = script.CompileAndExecute()
        else:
            script.CompileAndSave(self.script_save_path)

            launch_script = ascript.CreateAppleScript(
                'set scriptobj to (load script file "%s")' %
                (self.script_save_path), 'tell scriptobj', '  run', 'end tell')

            result = launch_script.CompileAndExecute()

        if result and result != '':
            outmsg.error('cvs checkout error %s' % (result))