Пример #1
0
def _build_html(i) -> str:
    result = tmp.render_tpl('nodered', 'html.tpl', {
        "function": bd.functions[i],
        "module_name": bd.config["program_name"]
    })

    return result
Пример #2
0
def build():
    _build_dep()

    package = tmp.render_tpl('nodejs_uart_client', 'package.tpl',
                             {"module_name": bd.config["program_name"]})

    main_js = tmp.render_tpl('nodejs_uart_client', 'main_js.tpl', {
        "functions": bd.functions,
        "module_name": bd.config["program_name"]
    })

    with open(nodejs_dir + '/%s.js' % (bd.config["program_name"]), "wt") as f:
        f.write(main_js)

    with open(nodejs_dir + '/package.json', "wt") as f:
        f.write(package)
Пример #3
0
def build():
    _build_dep()

    duktape = tmp.render_tpl('duktape', 'duktape.tpl', {
        "functions": bd.functions,
        "header_name": bd.header_name
    })
    with open(
            bd.config["build_path"] +
            '/duktape/%s_duktape.c' % bd.config["program_name"], "wt") as f:
        f.write(duktape)
Пример #4
0
def build():
    _build_dep()

    civetweb = tmp.render_tpl('civetweb', 'civetweb.tpl', {
        "functions": bd.functions,
        "out_list": list(bd.config["out"].keys())
    })
    with open(
            bd.config["build_path"] +
            '/civetweb/%s_civetweb.c' % bd.config["program_name"], "wt") as f:
        f.write(civetweb)
Пример #5
0
def build():
    _build_dep()

    jerryscript = tmp.render_tpl('jerryscript', 'jerryscript.tpl', {
        "functions": bd.functions,
        "header_name": bd.header_name
    })
    with open(
            bd.config["build_path"] +
            '/jerryscript/%s_jerryscript.c' % bd.config["program_name"],
            "wt") as f:
        f.write(jerryscript)
Пример #6
0
def _build_package() -> str:
    nodes = ',\n\t\t\t'.join([
        '"%s": "%s/%s.js"' % (f['name'], f['name'], f['name'])
        for f in bd.functions
    ])

    result = tmp.render_tpl('nodered', 'package.tpl', {
        "nodes": nodes,
        "module_name": bd.config["program_name"]
    })

    return result
Пример #7
0
def build():
    _build_dep()

    out_list = list(bd.config["out"].keys())

    with open(bd.config["out"]["shell"]["target"] + '/shell.c', "rt") as f:
        target_shell = f.read()

    shell = tmp.render_tpl('shell', 'shell.tpl', {
        "target_shell": target_shell,
        "out_list": out_list
    })

    with open(bd.config["build_path"] + '/shell/shell.c', "wt") as f:
        f.write(shell)

    if bd.config["out"]["shell"]["with_app"]:
        bd.config["out"]["shell"]["flags"] = list(
            set(bd.config["out"]["shell"]["flags"] +
                ["-DNO_SSL", "-std=c99", "-DUSE_SSL_DH=1", "-Wall"]))
        bd.config["out"]["shell"]["libs"] = list(
            set(bd.config["out"]["shell"]["libs"] +
                ["-lpthread", "-ldl", "-lcrypto", "-lssl", "-lm"]))

        if 'jerryscript' in out_list:
            bd.config["out"]["shell"]["source"].append(
                'jerryscript/%s_jerryscript.c' % bd.config["program_name"])

            bd.config["out"]["shell"]["include"].append('-I./jerryscript/')

        if 'duktape' in out_list:
            bd.config["out"]["shell"]["source"].append('duktape/duktape.c')
            bd.config["out"]["shell"]["source"].append(
                'duktape/%s_duktape.c' % bd.config["program_name"])

            bd.config["out"]["shell"]["include"].append('-I./duktape/')

        if 'civetweb' in out_list:
            bd.config["out"]["shell"]["source"].append('civetweb/civetweb.c')
            bd.config["out"]["shell"]["source"].append(
                'civetweb/%s_civetweb.c' % bd.config["program_name"])

            bd.config["out"]["shell"]["include"].append('-I./civetweb/')

        bd.config["out"]["shell"]["source"].append('shell/shell.c')

        if not bd.config["header_path"]:
            shutil.copy(bd.config["header"], bd.config["build_path"])
            bd.config["out"]["shell"]["include"].append('-I./')

        makefile = tmp.render_tpl(
            'shell', 'makefile.tpl', {
                "makefile": {
                    "source": ' '.join(bd.config["out"]["shell"]["source"]),
                    "include": ' '.join(bd.config["out"]["shell"]["include"]),
                    "flags": ' '.join(bd.config["out"]["shell"]["flags"]),
                    "libs": ' '.join(bd.config["out"]["shell"]["libs"])
                },
                "program_name": bd.config["program_name"]
            })
        main = tmp.render_tpl('shell', 'main.tpl', {"out_list": out_list})

        with open(bd.config["build_path"] + '/Makefile', "wt") as f:
            f.write(makefile)

        with open(
                bd.config["build_path"] + '/%s.c' % bd.config["program_name"],
                "wt") as f:
            f.write(main)
Пример #8
0
def _build_html() -> str:
    result = tmp.render_tpl('express', 'index.tpl',
                            {"functions": bd.functions, "module_name": bd.config["program_name"]})

    return result
Пример #9
0
def _build_run_server_src():
    result = tmp.render_tpl('express', 'run_server.tpl',
                            {"module_name": bd.config["program_name"]})

    return result
Пример #10
0
def _build_package() -> str:
    result = tmp.render_tpl('express', 'package.tpl',
                            {"module_name": bd.config["program_name"]})

    return result
Пример #11
0
def build():
    _build_dep()

    bd.config["out"]["nodejs"]["flags"] = list(
        set(bd.config["out"]["nodejs"]["flags"] +
            ["-DNO_SSL", "-DUSE_SSL_DH=1", "-Wall"]))

    bd.config["out"]["nodejs"]["libs"] = list(
        set(bd.config["out"]["nodejs"]["libs"] +
            ["-lpthread", "-ldl", "-lcrypto", "-lssl", "-lm"]))

    bd.config["out"]["nodejs"]["source"].append(bd.config["program_name"] +
                                                ".cpp")

    main = tmp.render_tpl('nodejs', 'main.tpl', {
        "functions": bd.functions,
        "module_name": bd.config["program_name"]
    })

    binding_gyp = tmp.render_tpl(
        'nodejs', 'binding_gyp.tpl', {
            "module_name":
            bd.config["program_name"],
            "sources":
            ','.join(
                map(lambda f: "'" + f + "'",
                    bd.config["out"]["nodejs"]["source"])),
            "includes":
            ','.join(
                map(
                    lambda f: "'" + f[2:] + "'"
                    if f[:2] == '-I' else "'" + f + "'",
                    bd.config["out"]["nodejs"]["include"])),
            "flags":
            ','.join(
                map(lambda f: "'" + f + "'",
                    bd.config["out"]["nodejs"]["flags"])),
            "libs":
            ','.join(
                map(lambda f: "'" + f + "'",
                    bd.config["out"]["nodejs"]["libs"]))
        })

    package = tmp.render_tpl('nodejs', 'package.tpl',
                             {"module_name": bd.config["program_name"]})

    main_js = tmp.render_tpl('nodejs', 'main_js.tpl', {
        "functions": bd.functions,
        "module_name": bd.config["program_name"]
    })

    with open(nodejs_dir + '/%s.cpp' % (bd.config["program_name"]), "wt") as f:
        f.write(main)

    with open(nodejs_dir + '/%s.js' % (bd.config["program_name"]), "wt") as f:
        f.write(main_js)

    with open(nodejs_dir + '/binding.gyp', "wt") as f:
        f.write(binding_gyp)

    with open(nodejs_dir + '/package.json', "wt") as f:
        f.write(package)