Пример #1
0
def make():
    base.configure_common_apps("../../../build_tools/scripts/base.py")

    with open("template.docx", "rb") as f:
        binary_content = bytearray(open("template.docx", "rb").read())

    text_indent = "    "  # 4 spaces
    len_content = len(binary_content)
    cpp_content = "// [START]"
    cpp_content += "\n" + text_indent
    cpp_content += "int template_binary_len = " + str(len_content) + ";"
    cpp_content += "\n" + text_indent
    cpp_content += "BYTE template_binary[" + str(len_content) + "] = {"
    for byte in binary_content:
        cpp_content += str(byte)
        cpp_content += ","
    cpp_content = cpp_content[0:-1]
    cpp_content += "};"
    cpp_content += "\n" + text_indent
    cpp_content += "// [END]"

    template_path = "./template.h"
    header_content = base.readFile(template_path)
    index_start = header_content.find("// [START]")
    index_end = header_content.find("// [END]") + 8

    header_content_new = header_content[
        0:index_start] + cpp_content + header_content[index_end:]

    base.delete_file(template_path)
    with open(base.get_path(template_path), "w") as file:
        file.write(header_content_new)

    return
Пример #2
0
def make(args=[]):
    try:
        base.configure_common_apps()

        platform = base.host_platform()
        if ("windows" == platform):
            dependence.check_pythonPath()
            dependence.check_gitPath()
            restart_win_rabbit()
        elif ("mac" == platform):
            start_mac_services()
        elif ("linux" == platform):
            start_linux_services()

        branch = base.run_command('git rev-parse --abbrev-ref HEAD')['stdout']

        base.print_info('Build modules')
        base.cmd_in_dir('../../', 'python', [
            'configure.py', '--branch', branch or 'develop', '--develop', '1',
            '--module', 'server', '--update', '1', '--update-light', '1',
            '--clean', '0'
        ] + args)
        base.cmd_in_dir('../../', 'python', ['make.py'])

        run_integration_example()

        base.create_dir('../../../server/App_Data')

        install_module('../../../server/DocService')
        install_module('../../../server/Common')
        install_module('../../../server/FileConverter')

        base.set_env('NODE_ENV', 'development-' + platform)
        base.set_env('NODE_CONFIG_DIR', '../Common/config')

        if ("mac" == platform):
            base.set_env('DYLD_LIBRARY_PATH', '../FileConverter/bin/')
        elif ("linux" == platform):
            base.set_env('LD_LIBRARY_PATH', '../FileConverter/bin/')

        run_module('../../../server/DocService', ['sources/server.js'])
        #    run_module('../../../server/DocService', ['sources/gc.js'])
        run_module('../../../server/FileConverter',
                   ['sources/convertermaster.js'])


#    run_module('../../../server/SpellChecker', ['sources/server.js'])
    except SystemExit:
        input("Ignoring SystemExit. Press Enter to continue...")
        exit(0)
    except KeyboardInterrupt:
        pass
    except:
        input("Unexpected error. " + traceback.format_exc() +
              "Press Enter to continue...")
Пример #3
0
        "./src/hunspell/filemgr.hxx", "FileMgr& operator=(const FileMgr&);",
        "FileMgr& operator=(const FileMgr&);\n" +
        "#ifdef HUNSPELL_WASM_MODULE\nstring_buffer_stream memin;\n#endif"
    )  #custon filemgr support watch filemgr_wrapper_new.cxx
    base.replaceInFile(
        "./src/hunspell/filemgr.hxx", "#include <fstream>",
        "#include <fstream>\n#ifdef HUNSPELL_WASM_MODULE\n#include \"string_buffer_stream.h\"\n#endif\n"
    )
    base.replaceInFile("./src/hunspell/csutil.cxx", "void free_utf_tbl() {",
                       "void free_utf_tbl() { \n return;\n")
    # bug fix, we need to keep this utf table
    # free_utf_tbl doesnt delete anything so we can destroy huspell object
    os.chdir("../")


base.configure_common_apps()

# remove previous version
if base.is_dir("./deploy"):
    base.delete_dir("./deploy")
base.create_dir("./deploy")
base.create_dir("./deploy/spell")

# fetch emsdk
command_prefix = "" if ("windows" == base.host_platform()) else "./"
if not base.is_dir("emsdk"):
    base.cmd("git", ["clone", "https://github.com/emscripten-core/emsdk.git"])
    os.chdir("emsdk")
    base.cmd(command_prefix + "emsdk", ["install", "latest"])
    base.cmd(command_prefix + "emsdk", ["activate", "latest"])
    os.chdir("../")
Пример #4
0
def make(build_js = True):

  old_cur_dir = os.getcwd()
  #fetch libhunspell
  print("[fetch & build]: hunspell")
  base_dir = base.get_script_dir() + "/../../core/Common/3dParty/hunspell"
  os.chdir(base_dir)
  if not base.is_dir("hunspell"):
      last_stable_commit = "8a2fdfe5a6bb1cbafc04b0c8486abcefd17ad903"
      repo_path = "https://github.com/hunspell/hunspell.git"
      base.cmd("git", ["clone", repo_path])
      os.chdir("hunspell")
      base.cmd("git", ["checkout", last_stable_commit])
      base.replaceInFile("./src/hunspell/filemgr.hxx", "FileMgr& operator=(const FileMgr&);", "FileMgr& operator=(const FileMgr&); \n" 
          +" #ifdef HUNSPELL_WASM_MODULE \n char* memory;size_t index;size_t size; \n #endif") #custon filemgr support watch filemgr_wrapper_new.cxx
      os.chdir("../")

  if not build_js:
    os.chdir(old_cur_dir)
    return
  base.configure_common_apps()

  # remove previous version
  if base.is_dir("./deploy"):
    base.delete_dir("./deploy")
  base.create_dir("./deploy")
  base.create_dir("./deploy/spell")

  # fetch emsdk
  command_prefix = "" if ("windows" == base.host_platform()) else "./"
  if not base.is_dir("emsdk"):
    base.cmd("git", ["clone", "https://github.com/emscripten-core/emsdk.git"])
    os.chdir("emsdk")
    base.cmd(command_prefix + "emsdk", ["install", "latest"])
    base.cmd(command_prefix + "emsdk", ["activate", "latest"])
    os.chdir("../")

  # compile
  compiler_flags = ["-o spell.js",
                    "-O3",
                    "-fno-exceptions",
                    "-fno-rtti",
                    "-s WASM=1",
                    "-s ALLOW_MEMORY_GROWTH=1",
                    "-s FILESYSTEM=0",
                    "-s ENVIRONMENT='web,worker'"]

  exported_functions = ["_malloc",
                        "_free",
                        "_Spellchecker_Malloc",
                        "_Spellchecker_Free",
                        "_Spellchecker_Create",
                        "_Spellchecker_Destroy",
                        "_Spellchecker_AddDictionary",
                        "_Spellchecker_RemoveDicrionary",
                        "_Spellchecker_Load",
                        "_Spellchecker_Spell",
                        "_Spellchecker_Suggest",
                        "_Spellchecker_RemoveEngine",
                        "_Spellchecker_TotalAllocatedMemory"]

  version_hunspell = 17
  libhunspell_src_path = "./hunspell/src/hunspell"

  input_sources = ["affentry.cxx",
                  "affixmgr.cxx",
                  "csutil.cxx",
                  "dictmgr.cxx",
                  "hashmgr.cxx",
                  "hunspell.cxx",
                  "hunzip.cxx",
                  "phonet.cxx",
                  "replist.cxx",
                  "suggestmgr.cxx"]

  sources = []
  for item in input_sources:
    if base.is_file(libhunspell_src_path + "/" + item):
      sources.append(libhunspell_src_path + "/" + item)

  if (13 == version_hunspell):
    sources.append("./wasm/src/filemgr_wrapper.cxx")
  else:
    sources.append("./wasm/src/filemgr_wrapper_new.cxx")

  sources.append("./wasm/src/base.cpp")

  compiler_flags.append("-I" + libhunspell_src_path)
  compiler_flags.append("-DWIN32 -DNDEBUG -DHUNSPELL_STATIC -DBUILDING_LIBHUNSPELL -DHUNSPELL_WASM_MODULE")

  # arguments
  arguments = ""
  for item in compiler_flags:
    arguments += (item + " ")

  arguments += "-s EXPORTED_FUNCTIONS=\"["
  for item in exported_functions:
    arguments += ("'" + item + "',")
  arguments = arguments[:-1]
  arguments += "]\" "

  for item in sources:
    arguments += (item + " ")


  # command
  windows_bat = []
  if (base.host_platform() == "windows"):
    windows_bat.append("call emsdk/emsdk_env.bat")
    windows_bat.append("call emcc " + arguments)  
  else:
    windows_bat.append("#!/bin/bash")
    windows_bat.append("source ./emsdk/emsdk_env.sh")
    windows_bat.append("emcc " + arguments)  
  base.run_as_bat(windows_bat)

  # finalize
  base.replaceInFile("./spell.js", "__ATPOSTRUN__=[];", "__ATPOSTRUN__=[function(){self.onEngineInit();}];")
  base.replaceInFile("./spell.js", "function getBinaryPromise(){", "function getBinaryPromise2(){")

  spell_js_content = base.readFile("./spell.js")
  engine_base_js_content = base.readFile("./wasm/js/spell.js")
  engine_js_content = engine_base_js_content.replace("//module", spell_js_content)

  # write new version
  base.writeFile("./deploy/spell/spell.js", engine_js_content)
  base.copy_file("spell.wasm", "./deploy/spell/spell.wasm")

  # ie asm version
  arguments = arguments.replace("WASM=1", "WASM=0")

  # command
  windows_bat = []
  if (base.host_platform() == "windows"):
    windows_bat.append("call emsdk/emsdk_env.bat")
    windows_bat.append("call emcc " + arguments)  
  else:
    windows_bat.append("#!/bin/bash")
    windows_bat.append("source ./emsdk/emsdk_env.sh")
    windows_bat.append("emcc " + arguments)  
  base.run_as_bat(windows_bat)

  # finalize
  base.replaceInFile("./spell.js", "__ATPOSTRUN__=[];", "__ATPOSTRUN__=[function(){self.onEngineInit();}];")
  base.replaceInFile("./spell.js", "function getBinaryPromise(){", "function getBinaryPromise2(){")

  spell_js_content = base.readFile("./spell.js")
  engine_base_js_content = base.readFile("./wasm/js/spell.js")
  engine_base_js_polyfill = base.readFile("./wasm/js/polyfill.js")
  engine_js_content = engine_base_js_polyfill + "\n\n" + engine_base_js_content.replace("//module", spell_js_content)

  # write new version
  base.writeFile("./deploy/spell/spell_ie.js", engine_js_content)
  base.copy_file("spell.js.mem", "./deploy/spell/spell.js.mem")

  base.copy_file("./wasm/js/code.js", "./deploy/spell.js")
  base.copy_file("./wasm/js/index.html", "./deploy/index.html")

  base.delete_file("spell.js")
  base.delete_file("spell.js.mem")
  os.chdir(old_cur_dir)
Пример #5
0
import sys
sys.path.append('./../../../../../build_tools/scripts')
import base
import os

if ("linux" == base.host_platform()):
    if not base.is_dir("./build"):
        base.bash("./build")

if ("mac" == base.host_platform()):
    if not base.is_file("./build.zip"):
        base.bash("./run_docker")
    if not base.is_dir("./build"):
        base.configure_common_apps(
            "./../../../../../build_tools/scripts/base.py")
        base.extract("./build.zip", "./")
    if not base.is_dir("v8"):
        if not base.is_dir("depot_tools"):
            base.cmd("git", [
                "clone",
                "https://chromium.googlesource.com/chromium/tools/depot_tools.git"
            ])
        old_cur = os.getcwd()
        os.environ[
            "PATH"] = old_cur + "/depot_tools" + os.pathsep + os.environ["PATH"]
        base.cmd("./depot_tools/fetch", ["v8"], True)
        os.chdir(old_cur + "/v8")
        base.cmd("git", ["checkout", "-b", "6.0", "branch-heads/6.0"], True)
        os.chdir(old_cur)
        base.cmd("gclient", ["sync"])