Exemplo n.º 1
0
    def process_generated_output(self):
        # This should only ever be executed on the main thread! Node operations cannot happen during run()
        for generated_output in self.generated_output:
            output_path = generated_output['output_path']
            should_add_to_build = generated_output['should_add_to_build']

            # Nodes won't work with absolute paths, so we have to remove the build path from
            # the given output file path. Given path is unicode, make it str to match Node.
            output_path = os.path.relpath(
                str(output_path), start=self.generator.bld.bldnode.abspath())
            with task_node_access_lock:
                output_node = self.generator.bld.bldnode.find_node(output_path)

            if output_node is None:
                raise Errors.WafError(
                    '[ERROR] az_code_gen: Unable to find generated file as node {}'
                    .format(output_path))

            append_to_unique_list(self.outputs, output_node)

            if should_add_to_build:
                # Add to persistent link list
                self.azcg_append_unique('link_inputs', output_node)
                # Perform actual add to link task
                self.add_link_task(output_node)
Exemplo n.º 2
0
def spec_game_projects(ctx, spec_name=None):
    """
    Get and game projects defined for the spec.  Will strip out duplicate entries
    """
    project_settings_map = ctx.get_project_settings_map()

    game_projects = _spec_entry(ctx, 'game_projects', spec_name)
    if game_projects is None:
        return []
    unique_list = list()
    for game_project in game_projects:
        if game_project in project_settings_map:
            append_to_unique_list(unique_list, game_project)

    # Check if this spec has any game->folder map
    global GAME_FOLDER_MAP
    spec_game_folder_map_list = _spec_entry(ctx, 'game_folders', spec_name)
    if spec_game_folder_map_list and len(spec_game_folder_map_list) > 0:
        # If there is an override game folder map in the spec, then validate its uniqueness and add it to the map
        spec_game_folder_map = spec_game_folder_map_list[0]
        for game_name, game_folder in list(spec_game_folder_map.items()):
            if game_name in GAME_FOLDER_MAP:
                current_game_folder = GAME_FOLDER_MAP[game_name]
                if current_game_folder != game_folder:
                    raise Errors.WafError(
                        'Conflicting game name to folder map detected in spec {}'
                        .format(spec_name))
            else:
                GAME_FOLDER_MAP[game_name] = game_folder

    return unique_list
Exemplo n.º 3
0
def get_additional_code_folders_from_spec(ctx):
    spec_list = ctx.get_current_spec_list()
    additional_code_folders = []
    for spec in spec_list:
        spec_additional_folders = ctx.spec_additional_code_folders(spec)
        append_to_unique_list(additional_code_folders, spec_additional_folders)
    return additional_code_folders
Exemplo n.º 4
0
    def post_run(self):
        if hasattr(self, 'cached'):
            # Also add the raw output path
            self.generator.env.append_unique('INCPATHS', get_azcg_output_dir_node(self.generator).abspath())

            # Also add paths we stored from prior builds
            azcg_paths = self.azcg_get('AZCG_INCPATHS', [])
            self.propagate_azcg_incpaths(azcg_paths)

            # link_inputs is a list of nodes that need to be added to the link each time
            for link_node in self.azcg_get('link_inputs', []):
                if not self.add_link_task(link_node):
                    return Task.EXCEPTION

            self.generator.source += self.outputs
        else:
            # Register output files generated by the code gen execution
            self.process_generated_output()

            bld = self.generator.bld
            dep_node = None
            resolved_nodes = []

            # Resolve registered dependencies we got into dependency nodes
            for path in self.registered_dependencies:
                dep_node = self.get_node_from_dependency_path(path)

                if dep_node:
                    if not (dep_node.is_child_of(bld.srcnode) or dep_node.is_child_of(bld.bldnode)):
                        # System library
                        continue

                    if dep_node in self.inputs:
                        # Self-dependency
                        continue

                    if dep_node in self.outputs:
                        # Circular dependency
                        continue

                    append_to_unique_list(resolved_nodes, dep_node)
                else:
                    Logs.error('az_code_gen: Unable to find dependency file as node: {}'.format(path))

            # Add azcg_deps and script nodes as dependencies
            for dep_node in itertools.chain(self.azcg_deps, self.script_nodes):
                append_to_unique_list(resolved_nodes, dep_node)

            bld.node_deps[self.uid()] = resolved_nodes

            # force waf to recompute a full signature for this task (we may have new/deleted dependencies we need it to account for)
            try:
                del self.cache_sig
            except:
                pass

            self.azcg_set('AZCG_OUTPUTS', self.outputs)

        Task.Task.post_run(self)
Exemplo n.º 5
0
def load_test_settings(ctx):
    """
    Setup all compiler and linker settings shared over all dedicated configurations
    """
    # Setup defines
    append_to_unique_list(
        ctx.env['DEFINES'],
        [
            'AZ_TESTS_ENABLED',
            'AZCORE_ENABLE_MEMORY_TRACKING'  # Enable memory tracking for all unit tests
        ])
def initialize_lumberyard(ctx):
    """
    Setup all platform, compiler and configuration agnostic settings
    """
    v = ctx.env

    if conf.is_option_true('enable_memory_tracking'):
        append_to_unique_list(v['DEFINES'], 'AZCORE_ENABLE_MEMORY_TRACKING')

    # To allow pragma comment (lib, 'SDKs/...) uniformly, pass Code to the libpath
    append_to_unique_list(v['LIBPATH'], conf.CreateRootRelativePath('Code'))
    return True
Exemplo n.º 7
0
def load_cryengine_common_settings(conf):
    """
    Setup all platform, compiler and configuration agnostic settings
    """
    v = conf.env

    if conf.is_option_true('enable_memory_tracking'):
        append_to_unique_list(v['DEFINES'], 'AZCORE_ENABLE_MEMORY_TRACKING')

    # To allow pragma comment (lib, 'SDKs/...) uniformly, pass Code to the libpath
    append_to_unique_list(v['LIBPATH'], conf.CreateRootRelativePath('Code'))

    # Set the product sku define, default is 'default'
    v['DEFINES'] += ['PRODUCT_SKU_' + Options.options.product_sku]
Exemplo n.º 8
0
    def merge_kw_key(self, target, kw_key, source_section, merge_kw):

        if not kw_key in source_section:
            return

        elif not kw_key in merge_kw:
            merge_kw[kw_key] = source_section[kw_key]  # TODO: deep copy?

        else:
            if not self.merge_kw_key_type(
                    target, kw_key, str, source_section,
                    merge_kw) and not self.merge_kw_key_type(
                        target, kw_key, bool, source_section, merge_kw):
                # Everything else is meant to be a list of string
                target_list = merge_kw.setdefault(kw_key, [])
                append_to_unique_list(target_list, source_section[kw_key])
Exemplo n.º 9
0
def spec_restricted_launchers(ctx, spec_name=None):
    """ For a given spec, See if we are restricting particular launchers for the spec"""
    if spec_name is None and len(ctx.options.project_spec) == 0:
        specs_to_restrict = [
            spec for spec in ctx.loaded_specs()
            if not ctx.spec_disable_games(spec)
        ]
        restricted_launcher_list = []
        for spec in specs_to_restrict:
            spec_restrict_launchers = _spec_entry(ctx, 'restricted_launchers',
                                                  spec)
            append_to_unique_list(restricted_launcher_list,
                                  spec_restrict_launchers)
        return restricted_launcher_list
    else:
        additional_launcher_projects = _spec_entry(ctx, 'restricted_launchers',
                                                   spec_name)
    return additional_launcher_projects
Exemplo n.º 10
0
def spec_additional_launchers(ctx, spec_name=None):
    """ For a given spec, add any additional custom launchers"""
    if spec_name is None and len(ctx.options.project_spec) == 0:
        specs_to_include = [
            spec for spec in ctx.loaded_specs()
            if not ctx.spec_disable_games(spec)
        ]
        additional_launcher_for_all_specs = []
        for spec in specs_to_include:
            spec_additional_launchers = _spec_entry(ctx,
                                                    'additional_launchers',
                                                    spec)
            append_to_unique_list(additional_launcher_for_all_specs,
                                  spec_additional_launchers)
        return additional_launcher_for_all_specs
    else:
        additional_launcher_projects = _spec_entry(ctx, 'additional_launchers',
                                                   spec_name)
    return additional_launcher_projects
Exemplo n.º 11
0
def load_android_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all android configurations
    """

    env = conf.env
    ndk_root = env['ANDROID_NDK_HOME']

    defines = []

    if env['ANDROID_NDK_REV_MAJOR'] < 19:
        defines += [
            '__ANDROID_API__={}'.format(env['ANDROID_NDK_PLATFORM_NUMBER']),
        ]

    append_to_unique_list(env['DEFINES'], defines)

    # Pattern to transform outputs
    env['cprogram_PATTERN'] = env['cxxprogram_PATTERN'] = '%s'
    env['cshlib_PATTERN'] = env['cxxshlib_PATTERN'] = 'lib%s.so'
    env['cstlib_PATTERN'] = env['cxxstlib_PATTERN'] = 'lib%s.a'

    env['RPATH_ST'] = '-Wl,-rpath,%s'
    env['SONAME_ST'] = '-Wl,-soname,%s'  # sets the DT_SONAME field in the shared object, used for ELF object loading

    # frameworks aren't supported on Android, disable it
    env['FRAMEWORK'] = []
    env['FRAMEWORK_ST'] = ''
    env['FRAMEWORKPATH'] = []
    env['FRAMEWORKPATH_ST'] = ''

    # java settings
    env['JAVA_VERSION'] = '1.7'
    env['CLASSPATH'] = []

    platform = os.path.join(env['ANDROID_SDK_HOME'], 'platforms',
                            env['ANDROID_SDK_VERSION'])
    android_jar = os.path.join(platform, 'android.jar')

    env['JAVACFLAGS'] = [
        '-encoding',
        'UTF-8',
        '-bootclasspath',
        android_jar,
        '-target',
        env['JAVA_VERSION'],
    ]

    # android interface processing
    env['AIDL_PREPROC_ST'] = '-p%s'
    env['AIDL_PREPROCESSES'] = [os.path.join(platform, 'framework.aidl')]

    # aapt settings
    env['AAPT_ASSETS_ST'] = ['-A']
    env['AAPT_ASSETS'] = []

    env['AAPT_RESOURCE_ST'] = ['-S']
    env['AAPT_RESOURCES'] = []

    env['AAPT_INLC_ST'] = ['-I']
    env['AAPT_INCLUDES'] = [android_jar]

    env['AAPT_PACKAGE_FLAGS'] = ['--auto-add-overlay']

    # apk packaging settings
    env['ANDROID_MANIFEST'] = ''
    env['ANDROID_DEBUG_MODE'] = ''

    # manifest merger settings
    tools_path = os.path.join(env['ANDROID_SDK_HOME'], 'tools', 'lib')
    tools_contents = os.listdir(tools_path)
    tools_jars = [
        entry for entry in tools_contents if entry.lower().endswith('.jar')
    ]

    manifest_merger_lib_names = [
        # entry point for the merger
        'manifest-merger',

        # dependent libs
        'sdk-common',
        'common'
    ]

    manifest_merger_libs = []
    for jar in tools_jars:
        if any(lib_name for lib_name in manifest_merger_lib_names
               if jar.lower().startswith(lib_name)):
            manifest_merger_libs.append(jar)

    if len(manifest_merger_libs) < len(manifest_merger_lib_names):
        conf.fatal(
            '[ERROR] Failed to find the required file(s) for the Manifest Merger.  Please use the Android SDK Manager to update to the latest SDK Tools version and run the configure command again.'
        )

    env['MANIFEST_MERGER_CLASSPATH'] = os.pathsep.join([
        os.path.join(tools_path, jar_file) for jar_file in manifest_merger_libs
    ])

    # zipalign settings
    env['ZIPALIGN_SIZE'] = '4'  # alignment in bytes, e.g. '4' provides 32-bit alignment (has to be a string)

    # jarsigner settings
    env['KEYSTORE_ALIAS'] = conf.get_android_env_keystore_alias()
    env['KEYSTORE'] = conf.get_android_env_keystore_path()