Exemple #1
0
def generate(params):
    proj_path = params["proj_path"]

    # check gluecode folder
    gluecode_modules_path = os.path.join(proj_path, const.DIR_NAME_FILES,
                                         const.DIR_NAME_GLUECODE)

    if not os.path.isdir(gluecode_modules_path):
        log.error("Glue code modules folder not exists: {0}".format(
            gluecode_modules_path))

    # get gluecode modules
    gluecode_config = config.run(proj_path, None, params)
    modules = gluecode_config["modules"]

    if modules:
        log.info("Generating files for all modules...")

        for module in modules:
            log.info('Generating glue code files for "{0}"...'.format(module))

            func_path = "files.gluecode.{0}.generate.run".format(module)
            mod_name, func_name = func_path.rsplit(".", 1)
            mod = importlib.import_module(mod_name)
            func = getattr(mod, func_name)
            func(params)

        log.ok()
    else:
        log.error("No glue code modules to generate")
Exemple #2
0
def generate(params):
    proj_path = params["proj_path"]

    # check modules folder
    modules_path = os.path.join(proj_path, const.DIR_NAME_FILES,
                                const.DIR_NAME_FILES_MODULES)

    if not os.path.isdir(modules_path):
        l.e("Modules folder not exists: {0}".format(modules_path))

    # get gluecode modules
    gluecode_config = config.run(proj_path, None, params)
    modules = gluecode_config["modules"]

    if modules:
        l.i("Generating files for all modules...")

        for m in modules:
            if not os.path.isdir(
                    os.path.join(modules_path, m, const.DIR_NAME_GLUECODE)):
                l.i('Module "{0}" was skipped'.format(m))
                continue

            l.i('Generating glue code files for "{0}"...'.format(m))

            func_path = "files.modules.{0}.gluecode.generate.run".format(m)
            mod_name, func_name = func_path.rsplit(".", 1)
            mod = importlib.import_module(mod_name)
            func = getattr(mod, func_name)
            func(params)

        l.ok()
    else:
        l.e("No modules to generate")
Exemple #3
0
def get_header_dir_list(proj_path, target_name, params):
    result = []
    filter_gen_src = []
    filter_impl_src = []

    # check modules folder
    modules_path = os.path.join(proj_path, const.DIR_NAME_FILES,
                                const.DIR_NAME_FILES_MODULES)

    if os.path.isdir(modules_path):
        gluecode_config = config.run(proj_path, None, params)
        modules = gluecode_config["modules"]

        if modules:
            for m in modules:
                gluecode_dir = os.path.join(
                    modules_path,
                    m,
                    const.DIR_NAME_GLUECODE,
                )

                module_gen_dir = os.path.join(
                    gluecode_dir,
                    "generated-src",
                    "objc",
                )
                module_impl_dir = os.path.join(
                    modules_path,
                    m,
                    "implementation",
                    "objc",
                )

                # generated src
                if m not in filter_gen_src:
                    if os.path.isdir(module_gen_dir):
                        result.append({
                            "type": "dir",
                            "path": module_gen_dir,
                        })

                # implementation
                if m not in filter_impl_src:
                    if os.path.isdir(module_impl_dir):
                        result.append({
                            "type": "dir",
                            "path": module_impl_dir,
                        })

    return result
Exemple #4
0
def run(params):
    proj_path = params["proj_path"]
    gluecode_config = config.run(proj_path, None, params)

    # djinni configurations
    djinni_file = "proj.djinni"

    # cpp configuration
    cpp_namespace = "{0}::net::http".format(
        gluecode_config["cpp_namespace_prefix"], )
    cpp_include_prefix = "{0}/net/http/".format(
        gluecode_config["cpp_include_prefix"], )
    cpp_out = "generated-src/cpp/{0}".format(cpp_include_prefix)

    # objc configuration
    objc_prefix = "{0}".format(gluecode_config["objc_prefix"], )
    objc_out = "generated-src/objc/{0}".format(cpp_include_prefix)
    objc_include_cpp_prefix = "{0}".format(cpp_include_prefix)
    objc_include_prefix = "{0}".format(cpp_include_prefix)

    # java configuration
    java_package = "{0}.net.http".format(
        gluecode_config["java_package_prefix"], )
    java_out = "generated-src/java/{0}".format(java_package.replace(".", "/"))
    java_parcelable = "true"

    # jni configuration
    jni_out = "generated-src/jni/{0}".format(java_package.replace(".", "/"))
    jni_class = "{0}FooBar".format(gluecode_config["jni_class_prefix"], )
    jni_file = "{0}FooBar".format(gluecode_config["jni_file_prefix"], )
    jni_include_cpp_prefix = "{0}".format(cpp_include_prefix)
    jni_include_prefix = "{0}/".format(java_package.replace(".", "/"))
    jni_generate_main = "false"

    # module data
    module_data = {
        "name":
        "http-client",
        "tool_params": [
            "--java-out",
            java_out,
            "--java-package",
            java_package,
            "--ident-java-field",
            "mFooBar",
            "--java-implement-android-os-parcelable",
            java_parcelable,
            "--cpp-out",
            cpp_out,
            "--cpp-namespace",
            cpp_namespace,
            "--cpp-include-prefix",
            cpp_include_prefix,
            "--ident-cpp-field",
            "fooBar",
            "--ident-cpp-method",
            "fooBar",
            "--ident-cpp-file",
            "FooBar",
            "--ident-cpp-local",
            "fooBar",
            "--ident-jni-class",
            jni_class,
            "--ident-jni-file",
            jni_file,
            "--jni-include-cpp-prefix",
            jni_include_cpp_prefix,
            "--jni-include-prefix",
            jni_include_prefix,
            "--jni-out",
            jni_out,
            "--jni-generate-main",
            jni_generate_main,
            "--objc-out",
            objc_out,
            "--objc-type-prefix",
            objc_prefix,
            "--objc-include-prefix",
            objc_include_prefix,
            "--objcpp-include-cpp-prefix",
            objc_include_cpp_prefix,
            "--objcpp-include-prefix",
            objc_include_prefix,
            "--objcpp-out",
            objc_out,
            "--yaml-out",
            "yaml",
            "--idl",
            djinni_file,
        ],
    }

    params["module_data"] = module_data

    gluecode.generate(params)