예제 #1
0
def run_task_publish():
    f.debug("Publishing...")

    current_dir = os.getcwd()
    publish_dir = os.path.join(current_dir, "build", "linux", "publish")
    node_dir = os.path.join(current_dir, "build", "linux", "x64", "release",
                            "node")
    template_dir = os.path.join(current_dir, "extras", "wasm", "template")

    # copy generated files
    f.remove_dir(publish_dir)
    f.copy_dir(node_dir, publish_dir)

    # copy template files
    f.copy_file(
        os.path.join(template_dir, "README.md"),
        os.path.join(publish_dir, "README.md"),
    )

    # finish
    f.debug("Published")
예제 #2
0
파일: wasm.py 프로젝트: kewlbear/pdfium-lib
def run_task_publish_to_web():
    f.debug("Publishing...")

    current_dir = os.getcwd()
    publish_dir = os.path.join(current_dir, "build", "linux", "publish")
    node_dir = os.path.join(current_dir, "build", "linux", "x64", "release",
                            "node")
    template_dir = os.path.join(current_dir, "extras", "wasm", "template")

    # copy generated files
    f.remove_dir(publish_dir)
    f.copy_dir(node_dir, publish_dir)

    # copy template files
    f.copy_file(
        os.path.join(template_dir, "README.md"),
        os.path.join(publish_dir, "README.md"),
    )

    # clone gh-pages branch
    command = "git init ."
    check_call(command, cwd=publish_dir, shell=True)

    command = "git add ."
    check_call(command, cwd=publish_dir, shell=True)

    command = 'git commit -m "new version published"'
    check_call(command, cwd=publish_dir, shell=True)

    command = 'git push "[email protected]:pdfviewer/pdfviewer.github.io.git" master:master --force'
    check_call(command, cwd=publish_dir, shell=True)

    # finish
    f.debug("Test on browser with: https://pdfviewer.github.io/")

    f.debug("Published")
예제 #3
0
파일: wasm.py 프로젝트: kewlbear/pdfium-lib
def run_task_publish():
    f.debug("Publishing...")

    current_dir = os.getcwd()
    publish_dir = os.path.join(current_dir, "build", "linux", "publish")
    node_dir = os.path.join(current_dir, "build", "linux", "x64", "release",
                            "node")
    template_dir = os.path.join(current_dir, "extras", "wasm", "template")

    # copy generated files
    f.remove_dir(publish_dir)
    f.copy_dir(node_dir, publish_dir)

    # copy template files
    f.copy_file(
        os.path.join(template_dir, "README.md"),
        os.path.join(publish_dir, "README.md"),
    )

    # finish
    f.debug(
        "Test on browser with: https://paulo-coutinho.github.io/pdfium-lib/")

    f.debug("Published")
예제 #4
0
파일: wasm.py 프로젝트: kewlbear/pdfium-lib
def run_task_generate():
    f.debug("Generating...")

    current_dir = os.getcwd()

    for config in c.configurations_wasm:
        for target in c.targets_wasm:
            # paths
            utils_dir = os.path.join(current_dir, "extras", "wasm", "utils")
            template_dir = os.path.join(current_dir, "extras", "wasm",
                                        "template")

            relative_dir = os.path.join(
                "build",
                target["target_os"],
                target["target_cpu"],
            )

            root_dir = os.path.join(current_dir, relative_dir)
            main_dir = os.path.join(root_dir, config)
            lib_dir = os.path.join(main_dir, "lib")
            include_dir = os.path.join(main_dir, "include")
            gen_dir = os.path.join(root_dir, "gen")
            node_dir = os.path.join(main_dir, "node")
            http_dir = os.path.join(relative_dir, config, "node")

            f.remove_dir(gen_dir)
            f.create_dir(gen_dir)

            # doxygen
            f.debug("Doxygen...")

            doxygen_file = os.path.join(
                current_dir,
                "extras",
                "wasm",
                "doxygen",
                "Doxyfile",
            )

            command = " ".join([
                "doxygen",
                doxygen_file,
            ])
            check_call(command, cwd=include_dir, shell=True)

            # copy xml files
            f.debug("Copying xml files...")

            xml_dir = os.path.join(include_dir, "xml")
            f.copy_dir(xml_dir, os.path.join(gen_dir, "xml"))
            f.remove_dir(xml_dir)

            # copy utils files
            f.debug("Copying utils files...")

            f.copy_dir(utils_dir, os.path.join(gen_dir, "utils"))

            # prepare files
            f.debug("Preparing files...")

            rsp_file = os.path.join(gen_dir, "utils", "pdfium.rsp")
            f.replace_in_file(rsp_file, "{LIB_DIR}", lib_dir)
            f.replace_in_file(rsp_file, "{INCLUDE_DIR}", include_dir)

            # node modules
            f.debug("Installing node modules...")

            gen_utils_dir = os.path.join(
                gen_dir,
                "utils",
            )

            command = " ".join([
                "npm",
                "install",
            ])
            check_call(command, cwd=gen_utils_dir, shell=True)

            # generate
            f.debug("Compiling with emscripten...")

            gen_out_dir = os.path.join(
                gen_dir,
                "out",
            )

            f.remove_dir(gen_out_dir)
            f.create_dir(gen_out_dir)

            html_file = os.path.join(
                gen_out_dir,
                "pdfium.html",
            )

            command = " ".join([
                "em++",
                "-o",
                html_file,
                "-s",
                'EXPORTED_FUNCTIONS="$(node function-names ../xml/index.xml)"',
                "-s",
                'EXTRA_EXPORTED_RUNTIME_METHODS=\'["ccall", "cwrap"]\'',
                "custom.cpp",
                "@pdfium.rsp",
                "-O3",
                "-std=c++11",
                "-Wall",
                "--no-entry",
            ])
            check_call(command, cwd=gen_utils_dir, shell=True)

            # copy files
            f.debug("Copying compiled files...")

            f.remove_dir(node_dir)
            f.copy_dir(gen_out_dir, node_dir)

            # copy template files
            f.debug("Copying template files...")

            f.copy_file(
                os.path.join(template_dir, "index.html"),
                os.path.join(node_dir, "index.html"),
            )

            # test
            f.debug(
                "Test on browser with: python -m http.server --directory {0}".
                format(http_dir))

    f.debug("Generated")
예제 #5
0
def run_task_generate():
    f.debug("Generating...")

    current_dir = os.getcwd()

    for config in c.configurations_wasm:
        for target in c.targets_wasm:
            # paths
            utils_dir = os.path.join(current_dir, "extras", "wasm", "utils")
            template_dir = os.path.join(current_dir, "extras", "wasm",
                                        "template")

            relative_dir = os.path.join(
                "build",
                target["target_os"],
                target["target_cpu"],
            )

            root_dir = os.path.join(current_dir, relative_dir)
            main_dir = os.path.join(root_dir, config)
            lib_dir = os.path.join(main_dir, "lib")
            include_dir = os.path.join(main_dir, "include")
            gen_dir = os.path.join(root_dir, "gen")
            node_dir = os.path.join(main_dir, "node")
            http_dir = os.path.join(relative_dir, config, "node")
            lib_file_out = os.path.join(lib_dir, "libpdfium.a")

            f.remove_dir(gen_dir)
            f.create_dir(gen_dir)

            # doxygen
            f.debug("Doxygen...")

            doxygen_file = os.path.join(
                current_dir,
                "extras",
                "wasm",
                "doxygen",
                "Doxyfile",
            )

            command = " ".join([
                "doxygen",
                doxygen_file,
            ])
            check_call(command, cwd=include_dir, shell=True)

            # copy xml files
            f.debug("Copying xml files...")

            xml_dir = os.path.join(include_dir, "xml")
            f.copy_dir(xml_dir, os.path.join(gen_dir, "xml"))
            f.remove_dir(xml_dir)

            # copy utils files
            f.debug("Copying utils files...")
            f.copy_dir(utils_dir, os.path.join(gen_dir, "utils"))

            # node modules
            f.debug("Installing node modules...")

            gen_utils_dir = os.path.join(
                gen_dir,
                "utils",
            )

            command = " ".join([
                "npm",
                "install",
            ])
            check_call(command, cwd=gen_utils_dir, shell=True)

            # generate
            f.debug("Compiling with emscripten...")

            gen_out_dir = os.path.join(
                gen_dir,
                "out",
            )

            f.remove_dir(gen_out_dir)
            f.create_dir(gen_out_dir)

            html_file = os.path.join(
                gen_out_dir,
                "pdfium.html",
            )

            command = " ".join([
                "em++",
                "{0}".format("-g" if config == "debug" else "-O3"),
                "-o",
                html_file,
                "-s",
                'EXPORTED_FUNCTIONS="$(node function-names ../xml/index.xml)"',
                "-s",
                'EXPORTED_RUNTIME_METHODS=\'["ccall", "cwrap"]\'',
                "custom.cpp",
                lib_file_out,
                "-I{0}".format(include_dir),
                "-s",
                "DEMANGLE_SUPPORT=1",
                "-s",
                "USE_ZLIB=1",
                "-s",
                "USE_LIBJPEG=1",
                "-s",
                "WASM=1",
                "-s",
                "ASSERTIONS=1",
                "-s",
                "ALLOW_MEMORY_GROWTH=1",
                "-std=c++11",
                "-Wall",
                "--no-entry",
            ])
            check_call(command, cwd=gen_utils_dir, shell=True)

            # copy files
            f.debug("Copying compiled files...")

            f.remove_dir(node_dir)
            f.copy_dir(gen_out_dir, node_dir)

            # copy template files
            f.debug("Copying template files...")

            f.copy_file(
                os.path.join(template_dir, "index.html"),
                os.path.join(node_dir, "index.html"),
            )

            # change template tags
            f.debug("Replacing template tags...")

            f.replace_in_file(
                os.path.join(node_dir, "index.html"),
                "{pdfium-branch}",
                c.pdfium_git_branch,
            )

            f.replace_in_file(
                os.path.join(node_dir, "index.html"),
                "{pdfium-commit}",
                c.pdfium_git_commit,
            )

            # test
            f.debug(
                "Test on browser with: python -m http.server --directory {0}".
                format(http_dir))

    f.debug("Generated")