Exemplo n.º 1
0
def _load_specs(ctx):
    """ Helper function to find all specs stored in _WAF_/specs/*.json """
    if hasattr(ctx, 'loaded_specs_dict'):
        return

    ctx.loaded_specs_dict = {}
    spec_file_folder = ctx.root.make_node(
        Context.launch_dir).make_node('/_WAF_/specs')
    spec_files = spec_file_folder.ant_glob('**/*.json')

    for file in spec_files:
        try:
            spec = ctx.parse_json_file(file)
            spec_name = str(file).split('.')[0]
            ctx.loaded_specs_dict[spec_name] = spec
        except Exception as e:
            ctx.cry_file_error(str(e), file.abspath())

    # For any enabled game project, see if it has a WAFSpec subfolder as well
    enabled_game_projects_list = split_comma_delimited_string(
        ctx.options.enabled_game_projects, True)
    for project in enabled_game_projects_list:
        game_project_spec = ctx.path.make_node(project).make_node(
            'WAFSpec').make_node('{}.json'.format(project))
        if os.path.exists(game_project_spec.abspath()):
            try:
                spec = ctx.parse_json_file(game_project_spec)
                if project in ctx.loaded_specs_dict:
                    Logs.warn(
                        "[WARN] Game project WAF spec '{}' in game project folder '{}' collides with a spec in _WAF_/specs.  "
                        "Overriding the _WAF_/specs version with the one in the game project"
                        .format(project, project))
                ctx.loaded_specs_dict[project] = spec
            except Exception as e:
                ctx.cry_file_error(str(e), game_project_spec.abspath())
Exemplo n.º 2
0
    def _collect_override_game_projects(check_spec_list):

        default_enabled_game_projects = split_comma_delimited_string(
            ctx.options.enabled_game_projects, True)

        project_settings_map = ctx.get_project_settings_map()

        game_project_set = set()
        for check_spec in check_spec_list:
            game_projects_for_spec = ctx.spec_game_projects(check_spec)
            if len(game_projects_for_spec) > 0:
                for game_project_for_spec in game_projects_for_spec:
                    if game_project_for_spec not in project_settings_map:
                        Logs.warn(
                            "[WARN] Game project '{}' defined in spec {} is not a valid game project.  Will ignore."
                            .format(game_project, check_spec))
                    else:
                        Logs.debug(
                            "lumberyard: Adding game project '{}' from spec '{}'"
                            .format(game_project_for_spec, check_spec))
                        game_project_set.add(game_project_for_spec)

        for default_enabled_game_project in default_enabled_game_projects:
            if default_enabled_game_project not in game_project_set:
                if default_enabled_game_project not in project_settings_map:
                    ctx.fatal("[ERROR] Game project '{}' is invalid".format(
                        default_enabled_game_project))
                else:
                    game_project_set.add(default_enabled_game_project)

        return list(game_project_set)
Exemplo n.º 3
0
def add_game_projects_to_specs(self):
    """Add game projects to specs that have them defined"""

    specs_to_include = self.loaded_specs()

    available_launchers = self.get_available_launchers()

    for spec_name in specs_to_include:

        # Get the defined game project per spec and only add game projects
        # to specs that have them defined
        game_projects = self.spec_game_projects(spec_name)

        if len(game_projects) == 0 and not self.spec_disable_games(spec_name):
            # Handle the legacy situation where the game projects is set in the enabled_game_projects in user_settings.options
            game_projects = split_comma_delimited_string(
                self.options.enabled_game_projects, True)

        # Skip if there are no game projects for this spec
        if len(game_projects) == 0:
            continue

        # Add both the game modules for the project (legacy) and all the launchers
        spec_dict = self.loaded_specs_dict[spec_name]
        if 'modules' not in spec_dict:
            spec_dict['modules'] = []
        if 'projects' not in spec_dict:
            spec_dict['projects'] = []
        spec_list = spec_dict['modules']
        spec_proj = spec_dict['projects']

        for project in game_projects:
            spec_proj.append(project)

            # Add any additional modules from the project's project.json configuration
            for module in project_modules(self, project):
                if not module in spec_list:
                    spec_list.append(module)
                    Logs.debug(
                        "lumberyard: Added module to spec list: %s for %s" %
                        (module, spec_name))

            # if we have game projects, also allow the building of the launcher from templates:
            for available_launcher_spec in available_launchers:
                if available_launcher_spec not in spec_dict:
                    spec_dict[available_launcher_spec] = []
                spec_list_to_append_to = spec_dict[available_launcher_spec]
                available_spec_list = available_launchers[
                    available_launcher_spec]
                for module in available_spec_list:
                    launcher_name = project + module
                    Logs.debug(
                        "lumberyard: Added launcher %s for %s (to %s spec in in %s sub_spec)"
                        % (launcher_name, project, spec_name,
                           available_launcher_spec))
                    spec_list_to_append_to.append(launcher_name)
Exemplo n.º 4
0
def get_enabled_game_project_list(self):
    """Utility function which returns the current game projects."""

    # Get either the current spec being built (build) or all the specs for the solution generation (configure/msvs)
    current_spec = getattr(self.options, 'project_spec', '')
    if len(current_spec)==0:
        spec_string_list = getattr(self.options, 'specs_to_include_in_project_generation', '').strip()
        if len(spec_string_list) == 0:
            self.fatal("[ERROR] Missing/Invalid specs ('specs_to_include_in_project_generation') in user_settings.options")
        spec_list = [spec.strip() for spec in spec_string_list.split(',')]
        if len(spec_list) == 0:
            self.fatal("[ERROR] Empty spec list ('specs_to_include_in_project_generation') in user_settings.options")
    else:
        spec_list = [current_spec]

    # Vet the list and make sure all of the specs are valid specs
    for spec in spec_list:
        if not self.is_valid_spec_name(spec):
            self.fatal("[ERROR] Invalid spec '{}'.  Make sure it exists in the specs folder and is a valid spec file.".format(spec))

    # Build up the list of project names
    ordered_unique_list = list()
    for spec in spec_list:
        # Get the projects defined for the particular spec
        projects_for_spec = self.spec_game_projects(spec)

        # If there are no games defined for the spec, and it is not marked with 'disable_game_projects',
        # use the legacy method of getting the enabled game project
        if len(projects_for_spec) == 0 and not self.spec_disable_games(spec):
            projects_for_spec = split_comma_delimited_string(self.options.enabled_game_projects, True)

        # Build up the list
        for project_for_spec in projects_for_spec:
            if len(project_for_spec) > 0:
                append_to_unique_list(ordered_unique_list, project_for_spec)

    # Make sure that the game that is set bootstrap.cfg is specified as an enabled game project, otherwise produce a warning if we
    # have specified at least one game project during build commands
    if len(ordered_unique_list) > 0 and self.cmd.startswith('build_'):
        bootstrap_game = self.get_bootstrap_game()
        bootstrap_game_enabled = False
        for enabled_game in ordered_unique_list:
            if enabled_game == bootstrap_game:
                bootstrap_game_enabled = True
        if not bootstrap_game_enabled:
            if len(ordered_unique_list) > 1:
                self.warn_once("Game project '{}' configured in bootstrap.cfg is not an enabled game for this build.  "
                               "In order to run or debug for the any of the enabled games '{}', one of them needs to be set in bootstrap.cfg under the "
                               "'sys_game_folder' entry accordingly".format(bootstrap_game, ','.join(ordered_unique_list)))
            else:
                self.warn_once("Game project '{}' configured in bootstrap.cfg is the enabled game for this build.  "
                               "In order to run or debug for the game '{}', they need to be set in bootstrap.cfg under the "
                               "'sys_game_folder' entry accordingly".format(bootstrap_game, ordered_unique_list[0]))

    return ordered_unique_list
Exemplo n.º 5
0
def test_SplitCommaDelimitedString_ValidInputPermutations_Success(input_param, expected, enforce_uniqueness):
    result = split_comma_delimited_string(input_str=input_param,
                                          enforce_uniqueness=enforce_uniqueness)
    assert result == expected