diff --git a/build.pro b/build.pro index ef0e0a5f..8705c660 100644 --- a/build.pro +++ b/build.pro @@ -32,7 +32,13 @@ core_windows { CONFIG += core_and_multimedia } core_linux { - CONFIG += core_and_multimedia + !core_freebsd { + CONFIG += core_and_multimedia + } +} +core_freebsd { + CONFIG += no_desktop_apps + CONFIG += no_use_htmlfileinternal } core_mac { CONFIG += no_desktop_apps diff --git a/make.py b/make.py index 7635f70d..f34bb572 100755 --- a/make.py +++ b/make.py @@ -14,6 +14,7 @@ import deploy import make_common import develop +import os # parse configuration config.parse() @@ -56,6 +57,16 @@ repositories = base.get_repositories() base.update_repositories(repositories) + # Apply patches if available + patchdir = base_dir + '/patches/' + base.host_platform() + if os.path.exists(patchdir) : + for root, dirs, files in os.walk(patchdir) : + for filename in files : + tmpdir = base_dir + '/../' + filename.split('.', 1)[0] + print('Patching directory %s' % tmpdir) + base.cmd("patch", ["-N", "-d", tmpdir, "-i", patchdir + "/" + filename]) + + base.configure_common_apps() # developing... @@ -67,7 +78,8 @@ exit(0) # core 3rdParty -make_common.make() +if base.host_platform() != 'freebsd' : + make_common.make() # build updmodule for desktop (only for windows version) if ("windows" == base.host_platform()) and (config.check_option("module", "desktop")): diff --git a/scripts/build_server.py b/scripts/build_server.py index b084f8a9..4740642c 100644 --- a/scripts/build_server.py +++ b/scripts/build_server.py @@ -41,30 +41,36 @@ def make(): if(base.is_exist(custom_public_key)): base.copy_file(custom_public_key, server_build_dir + '/Common/sources') + pkgBin = "pkg" pkg_target = "node10" if ("linux" == base.host_platform()): pkg_target += "-linux" + if ("freebsd" == base.host_platform()): + pkg_target += "-freebsd" + pkgBin = "/usr/local/bin/" + pkgBin + pkg_target = "node12" + if ("windows" == base.host_platform()): pkg_target += "-win" - base.cmd_in_dir(server_build_dir + "/DocService", "pkg", [".", "-t", pkg_target, "--options", "max_old_space_size=4096", "-o", "docservice"]) - base.cmd_in_dir(server_build_dir + "/FileConverter", "pkg", [".", "-t", pkg_target, "-o", "converter"]) - base.cmd_in_dir(server_build_dir + "/Metrics", "pkg", [".", "-t", pkg_target, "-o", "metrics"]) - base.cmd_in_dir(server_build_dir + "/SpellChecker", "pkg", [".", "-t", pkg_target, "-o", "spellchecker"]) + base.cmd_in_dir(server_build_dir + "/DocService", pkgBin, [".", "-t", pkg_target, "--options", "max_old_space_size=4096", "-o", "docservice"]) + base.cmd_in_dir(server_build_dir + "/FileConverter", pkgBin, [".", "-t", pkg_target, "-o", "converter"]) + base.cmd_in_dir(server_build_dir + "/Metrics", pkgBin, [".", "-t", pkg_target, "-o", "metrics"]) + base.cmd_in_dir(server_build_dir + "/SpellChecker", pkgBin, [".", "-t", pkg_target, "-o", "spellchecker"]) example_dir = base.get_script_dir() + "/../../document-server-integration/web/documentserver-example/nodejs" base.delete_dir(example_dir + "/node_modules") base.cmd_in_dir(example_dir, "npm", ["install"]) sync_rpc_lib_dir = example_dir + "/node_modules/sync-rpc/lib" patch_file = base.get_script_dir() + "/../tools/linux/sync-rpc.patch" - if ("linux" == base.host_platform()): + if ("linux" == base.host_platform() or "freebsd" == base.host_platform()): base.cmd_in_dir(sync_rpc_lib_dir, "patch", ["-N", "-i", patch_file]) if ("windows" == base.host_platform()): patch_exe_dir = base.git_dir() + "/usr/bin" base.cmd_in_dir(patch_exe_dir, "patch.exe", ["-N", "-d", sync_rpc_lib_dir, "-i", patch_file]) - base.cmd_in_dir(example_dir, "pkg", [".", "-t", pkg_target, "-o", "example"]) + base.cmd_in_dir(example_dir, pkgBin, [".", "-t", pkg_target, "-o", "example"]) def build_server_develop(): server_dir = base.get_script_dir() + "/../../server" diff --git a/scripts/core_common/make_common.py b/scripts/core_common/make_common.py index 64e68ce4..3bbd9518 100644 --- a/scripts/core_common/make_common.py +++ b/scripts/core_common/make_common.py @@ -16,11 +16,12 @@ import hunspell def make(): - boost.make() - cef.make() - icu.make() - openssl.make() - v8.make() + if base.host_platform() != 'freebsd' : + boost.make() + cef.make() + icu.make() + openssl.make() + v8.make() html2.make() hunspell.make(False) return diff --git a/scripts/deploy_server.py b/scripts/deploy_server.py index 779370f5..2cdca43e 100644 --- a/scripts/deploy_server.py +++ b/scripts/deploy_server.py @@ -96,7 +96,7 @@ def make(): base.copy_file(core_dir + "/Common/3dParty/icu/" + platform + "/build/icudt58.dll", converter_dir + "/icudt58.dll") base.copy_file(core_dir + "/Common/3dParty/icu/" + platform + "/build/icuuc58.dll", converter_dir + "/icuuc58.dll") - if (0 == platform.find("linux")): + if (0 == platform.find("linux") and 0 != platform.find('freebsd')): base.copy_file(core_dir + "/Common/3dParty/icu/" + platform + "/build/libicudata.so.58", converter_dir + "/libicudata.so.58") base.copy_file(core_dir + "/Common/3dParty/icu/" + platform + "/build/libicuuc.so.58", converter_dir + "/libicuuc.so.58") @@ -111,6 +111,7 @@ def make(): # builder base.copy_exe(core_build_dir + "/bin/" + platform_postfix, converter_dir, "docbuilder") + # XXX warning under FreeBSD base.copy_dir(git_dir + "/DocumentBuilder/empty", converter_dir + "/empty") # js diff --git a/tools/freebsd/automate.py b/tools/freebsd/automate.py new file mode 100755 index 00000000..7f2c3cd3 --- /dev/null +++ b/tools/freebsd/automate.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python +# +# Before calling this script: +# - be sure that "git" (or "git-lite"), "sudo" "npm-node10" and # "python27" +# are installed: +# # pkg install git-lite sudo python27 npm-node10 +# - /usr/bin/python is a symlink to /usr/local/bin/python2.7: +# # ln -s /usr/local/bin/python2.7 /usr/bin/python +# - CC and CXX environment variables are respectively set to clang and clang++ +# # export CC=clang +# # export CXX=clang++ + +import sys +sys.path.append('../../scripts') +import base +import os +import subprocess + +def get_branch_name(directory): + cur_dir = os.getcwd() + os.chdir(directory) + # detect build_tools branch + #command = "git branch --show-current" + command = "git symbolic-ref --short -q HEAD" + popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + current_branch = "master" + try: + stdout, stderr = popen.communicate() + popen.wait() + current_branch = stdout.strip().decode("utf-8") + finally: + popen.stdout.close() + popen.stderr.close() + os.chdir(cur_dir) + return current_branch + +def install_deps(): + # dependencies + packages = ["git-lite", + "bash", + "png", + "jpeg", + "p7zip", + "qt5-qmake", + "boost-libs", + "openjdk8", + "subversion"] + + base.cmd("sudo", ["pkg", "install"] + packages) + base.set_env('QT_SELECT', 'qt5') + + # nodejs + if not base.is_file("./node_js_setup_10.x"): + base.cmd("sudo", ["touch", "./node_js_setup_10.x"]) + base.cmd("sudo", ["npm", "install", "-g", "npm"]) + base.cmd("sudo", ["npm", "install", "-g", "grunt-cli"]) + base.cmd("sudo", ["npm", "install", "-g", "pkg"]) + return + +if not base.is_file("./node_js_setup_10.x"): + print("install dependencies...") + install_deps() + +if not base.is_dir("./qt"): + base.cmd("mkdir", ["qt",]) + base.cmd("ln", ["-s", "/usr/local/lib/qt5", "qt/gcc_64"]) + +# Apply a patch on the node_gyp cache in case of npm-node10 use.. +base.cmd("bash", ["patch_nodegyp.sh",]) + +branch = get_branch_name("../..") + +array_args = sys.argv[1:] +array_modules = [] + +config = {} +for arg in array_args: + if (0 == arg.find("--")): + indexEq = arg.find("=") + if (-1 != indexEq): + config[arg[2:indexEq]] = arg[indexEq + 1:] + else: + # XXX Currently only server has been checked for compilation under FreeBSD + if arg != 'server': + print("module %s not supported yet under FreeBSD" % arg) + array_modules.append(arg) + +if ("branch" in config): + branch = config["branch"] + +print("---------------------------------------------") +print("build branch: " + branch) +print("---------------------------------------------") + +modules = " ".join(array_modules) +# XXX Currently only server has been checked for compilation under FreeBSD +if "" == modules: + modules = "server" + +print("---------------------------------------------") +print("build modules: " + modules) +print("---------------------------------------------") + +build_tools_params = ["--branch", branch, + "--module", modules, + "--update", "1", + "--platform", "linux_64", + "--qt-dir", os.getcwd() + "/qt"] + +base.cmd_in_dir("../..", "./configure.py", build_tools_params) +base.cmd_in_dir("../..", "./make.py") + + + diff --git a/tools/freebsd/patch_nodegyp.sh b/tools/freebsd/patch_nodegyp.sh new file mode 100755 index 00000000..5077e3ba --- /dev/null +++ b/tools/freebsd/patch_nodegyp.sh @@ -0,0 +1,37 @@ +#!/usr/local/bin/bash + +echo "Trying to find whether current node version is buggy under FreeBSD" +CURDIR=`pwd` +TEMP=`mktemp -d` +cd $TEMP +npm install statsd >& out.log +grep -q "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" out.log +if [ $? -eq 0 ]; then + cd ~/.cache/node-gyp/10.*/include/node + patch -s -N -p1 <