Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding FreeBSD support for server version #353

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion build.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion make.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import deploy
import make_common
import develop
import os

# parse configuration
config.parse()
Expand Down Expand Up @@ -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...
Expand All @@ -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")):
Expand Down
18 changes: 12 additions & 6 deletions scripts/build_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 6 additions & 5 deletions scripts/core_common/make_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion scripts/deploy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
Expand Down
114 changes: 114 additions & 0 deletions tools/freebsd/automate.py
Original file line number Diff line number Diff line change
@@ -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")



37 changes: 37 additions & 0 deletions tools/freebsd/patch_nodegyp.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
diff -p a/common.gypi b/common.gypi
*** a/common.gypi 2021-07-19 15:26:27.407830000 +0200
--- b/common.gypi 2021-07-19 15:27:03.047869000 +0200
***************
*** 512,526 ****
'libraries': [ '-lelf' ],
}],
['OS=="freebsd"', {
- 'conditions': [
- ['"0" < llvm_version < "4.0"', {
- # Use this flag because on FreeBSD std::pairs copy constructor is non-trivial.
- # Doesn't apply to llvm 4.0 (FreeBSD 11.1) or later.
- # Refs: https://lists.freebsd.org/pipermail/freebsd-toolchain/2016-March/002094.html
- # Refs: https://svnweb.freebsd.org/ports/head/www/node/Makefile?revision=444555&view=markup
- 'cflags': [ '-D_LIBCPP_TRIVIAL_PAIR_COPY_CTOR=1' ],
- }],
- ],
'ldflags': [
'-Wl,--export-dynamic',
],
--- 512,517 ----
EOF
echo "Patching bugged ~/.cache/node-gyp/10.*/include/node/common.gypi file"
fi
cd $CURDIR
rm -rf $TEMP