Ejemplo n.º 1
0
    def build_for_automation(self):

        arg_dict = {'target' : self.target,
                'configuration' : self.configuration,
                'sdk' : 'iphonesimulator',
                }


        build_command = utils.create_build_command(['build'], self.preprocessor_defs, **arg_dict)

        print build_command
        
        ret_val = os.system(build_command)

        os.environ['IMAT'] = os.environ['IMAT_HOME'] + "/imat"

        if ret_val == 0:

            regx = re.compile(".*xcodeproj$")
            projfolder = filter(regx.match, os.listdir("."))

            if len(projfolder) == 1:
                pbxfile = "/".join([projfolder[0], "project.pbxproj"])
            else:
                raise Exception("No pbx file found in %s" % projfolder)

            conf_dict = utils.build_settings_dict(pbxfile, self.target, self.configuration)
            test_bundle_path = "%s/build/%s-%s/%s.%s" % (os.getcwd(), arg_dict['configuration'], arg_dict['sdk'], arg_dict['target'], conf_dict['WRAPPER_EXTENSION'])


        self.app_path = test_bundle_path
Ejemplo n.º 2
0
def main():

    target, config = command_line_args()

    arg_dict = {
            'configuration' : config,
            'target' : target,
            'sdk' : 'iphonesimulator'
            }

    build_command = utils.create_build_command(['clean', 'build'], **arg_dict)
    print build_command

    ret_val = os.system(build_command)

    if ret_val != 0:
        sys.exit(ret_val)
Ejemplo n.º 3
0
def run_unit_tests(target, configuration):

    os.system("killall \"iPhone Simulator\"")

    launcher_path = "/usr/local/bin/ios-sim"
    arg_dict = {'target' : target,
            'configuration' : configuration,
            'sdk' : 'iphonesimulator' }
    build_command = utils.create_build_command(['clean', 'build'], **arg_dict)

    ret_val = os.system(build_command)

    if ret_val == 0:

        regx = re.compile(".*xcodeproj$")
        projfolder = filter(regx.match, os.listdir("."))

        if len(projfolder) == 1:
            pbxfile = "/".join([projfolder[0], "project.pbxproj"])
        else:
            raise Exception("No pbx file found in %s" % projfolder)

        conf_dict = utils.build_settings_dict(pbxfile, target, configuration)

        e = conf_dict

        test_bundle_path = "%s/build/%s-%s/%s.%s" % (os.getcwd(), arg_dict['configuration'], arg_dict['sdk'], arg_dict['target'], e['WRAPPER_EXTENSION'])

        r = {}
        r['DYLD_INSERT_LIBRARIES'] = "/../../Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection"
        r['XCInjectBundle'] = test_bundle_path
        r['XCInjectBundleInto'] = e['TEST_HOST']

        env_args = "".join(["--setenv %s=\"%s\" " % (x, r[x]) for x in r.keys()])
        app_test_host = os.path.dirname(e['TEST_HOST'])
        test_command = "%s launch \"%s\" %s --args -SenTest All %s" % (launcher_path, app_test_host, env_args, test_bundle_path)
        output_descriptor, temp_output_path = tempfile.mkstemp()


        split_command = shlex.split(str(test_command))
        temp_file = open(temp_output_path, "w") 
        test_results = subprocess.Popen(split_command, stdout=temp_file, stderr=subprocess.STDOUT)
        test_results.wait()
        test_results_text = open(temp_output_path, "r")
        subprocess.check_output("%s/ocunit2junit.rb" % os.environ['COMMON_SCRIPTS_HOME'], stdin=test_results_text)
Ejemplo n.º 4
0
def main():
    arg_dict = command_line_controller()

    print os.system("xcodebuild -showsdks")
    print os.system("whereis xcodebuild")
    print os.listdir("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs")


    if arg_dict['scheme'] == None or arg_dict['configuration'] == None:
        raise Exception("You must specify at least a scheme and a configuration to build through the command line or by setting the DIST_scheme and DIST_CONFIGURATION environment variables")

    if arg_dict['sdk'] == None:
        sdk = "iphoneos6.0"

    regx = re.compile(".*xcodeproj$")

    projfolder = filter(regx.match, os.listdir("."))

    if len(projfolder) == 1:
        pbxfile = "/".join([projfolder[0], "project.pbxproj"])
        info_plist_path = utils.get_plist_path_from_pbxfile(pbxfile, arg_dict['scheme'], arg_dict['actions'][0], arg_dict['configuration'])

        plist_dict = biplist.readPlist(info_plist_path)
        resource_root = os.path.dirname(os.path.abspath(info_plist_path))

        print "xxxxXXXXxxx"
        print plist_dict
        print resource_root


        if arg_dict['version'] != None and arg_dict['version'] != "":
            version = plutil.increment_development_version(info_plist_path, arg_dict['version'])
            version = plutil.increment_release_version(info_plist_path, arg_dict['version'])
        if arg_dict['bundle_id'] != None and arg_dict['version'] != "":
            plutil.change_bundle_id(info_plist_path, arg_dict['bundle_id'])
        del(arg_dict['bundle_id'])

        def brand_icons(icon_list):
            try:
                for icon in icon_list:
                    icon_path = "%s/%s" % (resource_root, icon)
                    print icon_path
                    utils.brand_icon(icon_path, version, os.getenv("GIT_BRANCH"))
            except:
                pass


        if "CFBundleIconFiles" in plist_dict.keys():
            brand_icons(plist_dict['CFBundleIconFiles'])

        if "CFBundleIcons" in plist_dict.keys():
            primary_icons = plist_dict['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFiles']
            brand_icons(primary_icons)



    if (arg_dict['xcconfig'] is not None):

        current_date = datetime.now() 
        expiry_date = current_date + timedelta(30)

        template_vars = {'kill_day' : expiry_date.month, 'kill_year' : expiry_date.year, 'kill_month' : expiry_date.month }
        temp_config_path = utils.format_file_with_vars(arg_dict['xcconfig'], template_vars)
        arg_dict['xcconfig'] = temp_config_path
    else:
        del(arg_dict['xcconfig'])

    if "version" in arg_dict.keys():
        del(arg_dict['version'])

    command_append_string = ""

    if arg_dict['additional_vars'] != None and arg_dict['additional_vars'] != "":
        command_append_string = arg_dict['additional_vars']

    if "additional_vars" in arg_dict.keys():
        del(arg_dict['additional_vars'])
        
    actions_string = arg_dict['actions']
    del(arg_dict['actions'])


    build_command = utils.create_build_command(actions_string, **arg_dict)
    build_command += " " + command_append_string
    print build_command
      
    retval = os.system(build_command)
    if retval != 0:
        sys.exit(-1)