Skip to content

Commit

Permalink
Merge branch release/v8.0.0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
papacarlo committed Jan 30, 2024
2 parents a2639af + 2a8c5ea commit f801e77
Show file tree
Hide file tree
Showing 20 changed files with 269 additions and 170 deletions.
4 changes: 2 additions & 2 deletions defaults
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sdkjs-plugin="photoeditor, macros, ocr, translator, thesaurus, youtube, highlightcode, drawio, zotero"
sdkjs-plugin-server="speech, zotero, mendeley, speechrecognition"
sdkjs-plugin="photoeditor, macros, ocr, translator, thesaurus, youtube, highlightcode, zotero"
sdkjs-plugin-server="speech, zotero, mendeley, speechrecognition, drawio"
sdkjs-addons="sdkjs-forms"
57 changes: 40 additions & 17 deletions scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,34 @@ def copy_exe(src, dst, name):
copy_file(src + "/" + name + exe_ext, dst + "/" + name + exe_ext)
return

def readFileCommon(path):
file_data = ""
try:
with open(get_path(path), "r") as file:
file_data = file.read()
except Exception as e:
with open(get_path(path), "r", encoding="utf-8") as file:
file_data = file.read()
return file_data

def writeFileCommon(path, data):
file_data = ""
try:
with open(get_path(path), "w") as file:
file.write(data)
except Exception as e:
with open(get_path(path), "w", encoding="utf-8") as file:
file.write(data)
return

def replaceInFile(path, text, textReplace):
if not is_file(path):
print("[replaceInFile] file not exist: " + path)
return
filedata = ""
with open(get_path(path), "r") as file:
filedata = file.read()
filedata = readFileCommon(path)
filedata = filedata.replace(text, textReplace)
delete_file(path)
with open(get_path(path), "w") as file:
file.write(filedata)
writeFileCommon(path, filedata)
return
def replaceInFileUtf8(path, text, textReplace):
if not is_file(path):
Expand All @@ -320,28 +337,21 @@ def replaceInFileRE(path, pattern, textReplace):
if not is_file(path):
print("[replaceInFile] file not exist: " + path)
return
filedata = ""
with open(get_path(path), "r") as file:
filedata = file.read()
filedata = readFileCommon(path)
filedata = re.sub(pattern, textReplace, filedata)
delete_file(path)
with open(get_path(path), "w") as file:
file.write(filedata)
writeFileCommon(path, filedata)
return

def readFile(path):
if not is_file(path):
return ""
filedata = ""
with open(get_path(path), "r") as file:
filedata = file.read()
return filedata
return readFileCommon(path)

def writeFile(path, data):
if is_file(path):
delete_file(path)
with open(get_path(path), "w") as file:
file.write(data)
writeFileCommon(path, data)
return

# system cmd methods ------------------------------------
Expand Down Expand Up @@ -1291,9 +1301,11 @@ def copy_marketplace_plugin(dst_dir, is_name_as_guid=False, is_desktop_local=Fal
delete_dir(dst_dir_path + "/store/plugin-dev")
return

def copy_sdkjs_plugins(dst_dir, is_name_as_guid=False, is_desktop_local=False):
def copy_sdkjs_plugins(dst_dir, is_name_as_guid=False, is_desktop_local=False, isXp=False):
plugins_dir = __file__script__path__ + "/../../onlyoffice.github.io/sdkjs-plugins/content"
plugins_list_config = config.option("sdkjs-plugin")
if isXp:
plugins_list_config="photoeditor, macros, drawio, highlightcode, doc2md"
if ("" == plugins_list_config):
return
plugins_list = plugins_list_config.rsplit(", ")
Expand Down Expand Up @@ -1649,3 +1661,14 @@ def copy_dictionaries(src, dst, is_hyphen = True, is_spell = True):
delete_file(dst + "/uk_UA/th_uk_UA.idx")

return

def check_module_version(actual_version, clear_func):
module_file = "./module.version"
current_module_version = readFile(module_file)
if (actual_version == current_module_version):
return
if is_file(module_file):
delete_file(module_file)
writeFile(module_file, actual_version)
clear_func()
return
34 changes: 23 additions & 11 deletions scripts/build_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,37 @@ def make():

build_interface(base_dir + "/../desktop-apps/common/loginpage/build")
base.copy_file(base_dir + "/../desktop-apps/common/loginpage/deploy/index.html", out_dir + "/desktop/index.html")

base.copy_file(base_dir + "/../desktop-apps/common/loginpage/deploy/noconnect.html", out_dir + "/desktop/noconnect.html")

# mobile
if config.check_option("module", "mobile"):
build_sdk_native(base_dir + "/../sdkjs/build", False)
base.create_dir(out_dir + "/mobile")
base.create_dir(out_dir + "/mobile/sdkjs")
vendor_dir_src = base_dir + "/../web-apps/vendor/"
sdk_dir_src = base_dir + "/../sdkjs/deploy/sdkjs/"

prefix_js = [
vendor_dir_src + "xregexp/xregexp-all-min.js",
vendor_dir_src + "underscore/underscore-min.js",
base_dir + "/../sdkjs/common/Native/native.js",
base_dir + "/../sdkjs-native/common/common.js",
base_dir + "/../sdkjs/common/Native/jquery_native.js"
]

postfix_js = [
base_dir + "/../sdkjs/common/libfont/engine/fonts_native.js",
base_dir + "/../sdkjs/common/Charts/ChartStyles.js"
]

base.join_scripts([vendor_dir_src + "xregexp/xregexp-all-min.js",
vendor_dir_src + "underscore/underscore-min.js",
base_dir + "/../sdkjs/common/Native/native.js",
base_dir + "/../sdkjs/common/Native/Wrappers/common.js",
base_dir + "/../sdkjs/common/Native/jquery_native.js"],
out_dir + "/mobile/sdkjs/banners.js")
base.join_scripts(prefix_js, out_dir + "/mobile/sdkjs/banners.js")

base.create_dir(out_dir + "/mobile/sdkjs/word")
base.join_scripts([out_dir + "/mobile/sdkjs/banners.js", sdk_dir_src + "word/sdk-all-min.js", sdk_dir_src + "word/sdk-all.js"], out_dir + "/mobile/sdkjs/word/script.bin")
base.join_scripts([out_dir + "/mobile/sdkjs/banners.js", sdk_dir_src + "word/sdk-all-min.js", sdk_dir_src + "word/sdk-all.js"] + postfix_js, out_dir + "/mobile/sdkjs/word/script.bin")
base.create_dir(out_dir + "/mobile/sdkjs/cell")
base.join_scripts([out_dir + "/mobile/sdkjs/banners.js", sdk_dir_src + "cell/sdk-all-min.js", sdk_dir_src + "cell/sdk-all.js"], out_dir + "/mobile/sdkjs/cell/script.bin")
base.join_scripts([out_dir + "/mobile/sdkjs/banners.js", sdk_dir_src + "cell/sdk-all-min.js", sdk_dir_src + "cell/sdk-all.js"] + postfix_js, out_dir + "/mobile/sdkjs/cell/script.bin")
base.create_dir(out_dir + "/mobile/sdkjs/slide")
base.join_scripts([out_dir + "/mobile/sdkjs/banners.js", sdk_dir_src + "slide/sdk-all-min.js", sdk_dir_src + "slide/sdk-all.js"], out_dir + "/mobile/sdkjs/slide/script.bin")
base.join_scripts([out_dir + "/mobile/sdkjs/banners.js", sdk_dir_src + "slide/sdk-all-min.js", sdk_dir_src + "slide/sdk-all.js"] + postfix_js, out_dir + "/mobile/sdkjs/slide/script.bin")

base.delete_file(out_dir + "/mobile/sdkjs/banners.js")
return
Expand Down Expand Up @@ -132,7 +141,10 @@ def build_sdk_builder(directory):
def build_sdk_native(directory, minimize=True):
#_run_npm_cli(directory)
_run_npm(directory)
_run_grunt(directory, get_build_param(minimize) + ["--mobile=true"] + base.sdkjs_addons_param())
addons = base.sdkjs_addons_param()
if not config.check_option("sdkjs-addons", "sdkjs-native"):
addons.append("--addon=sdkjs-native")
_run_grunt(directory, get_build_param(minimize) + ["--mobile=true"] + addons)
return

def build_js_develop(root_dir):
Expand Down
37 changes: 26 additions & 11 deletions scripts/build_js_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
parser.add_option("--write-version",
action="store_true", dest="write_version", default=False,
help="Create version file of build")
parser.add_option("--minimize",
action="store", type="string", dest="minimize", default="0",
help="Is minimized version")
(options, args) = parser.parse_args(arguments)

def write_version_files(output_dir):
Expand All @@ -32,7 +35,11 @@ def write_version_files(output_dir):
# parse configuration
config.parse()
config.parse_defaults()
config.extend_option("jsminimize", "0")

isMinimize = False
if ("1" == options.minimize or "true" == options.minimize):
isMinimize = True
config.set_option("jsminimize", "disable")

branding = config.option("branding-name")
if ("" == branding):
Expand All @@ -46,23 +53,31 @@ def write_version_files(output_dir):

base.create_dir(out_dir)

build_js.build_sdk_native(base_dir + "/../sdkjs/build")
build_js.build_sdk_native(base_dir + "/../sdkjs/build", isMinimize)
vendor_dir_src = base_dir + "/../web-apps/vendor/"
sdk_dir_src = base_dir + "/../sdkjs/deploy/sdkjs/"

base.join_scripts([vendor_dir_src + "xregexp/xregexp-all-min.js",
vendor_dir_src + "underscore/underscore-min.js",
base_dir + "/../sdkjs/common/Native/native.js",
base_dir + "/../sdkjs/common/Native/Wrappers/common.js",
base_dir + "/../sdkjs/common/Native/jquery_native.js"],
out_dir + "/banners.js")
prefix_js = [
vendor_dir_src + "xregexp/xregexp-all-min.js",
vendor_dir_src + "underscore/underscore-min.js",
base_dir + "/../sdkjs/common/Native/native.js",
base_dir + "/../sdkjs-native/common/common.js",
base_dir + "/../sdkjs/common/Native/jquery_native.js"
]

postfix_js = [
base_dir + "/../sdkjs/common/libfont/engine/fonts_native.js",
base_dir + "/../sdkjs/common/Charts/ChartStyles.js"
]

base.join_scripts(prefix_js, out_dir + "/banners.js")

base.create_dir(out_dir + "/word")
base.join_scripts([out_dir + "/banners.js", sdk_dir_src + "word/sdk-all-min.js", sdk_dir_src + "word/sdk-all.js"], out_dir + "/word/script.bin")
base.join_scripts([out_dir + "/banners.js", sdk_dir_src + "word/sdk-all-min.js", sdk_dir_src + "word/sdk-all.js"] + postfix_js, out_dir + "/word/script.bin")
base.create_dir(out_dir + "/cell")
base.join_scripts([out_dir + "/banners.js", sdk_dir_src + "cell/sdk-all-min.js", sdk_dir_src + "cell/sdk-all.js"], out_dir + "/cell/script.bin")
base.join_scripts([out_dir + "/banners.js", sdk_dir_src + "cell/sdk-all-min.js", sdk_dir_src + "cell/sdk-all.js"] + postfix_js, out_dir + "/cell/script.bin")
base.create_dir(out_dir + "/slide")
base.join_scripts([out_dir + "/banners.js", sdk_dir_src + "slide/sdk-all-min.js", sdk_dir_src + "slide/sdk-all.js"], out_dir + "/slide/script.bin")
base.join_scripts([out_dir + "/banners.js", sdk_dir_src + "slide/sdk-all-min.js", sdk_dir_src + "slide/sdk-all.js"] + postfix_js, out_dir + "/slide/script.bin")

base.delete_file(out_dir + "/banners.js")

Expand Down
33 changes: 20 additions & 13 deletions scripts/build_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def make():
if("" != config.option("branding")):
branding_dir = git_dir + '/' + config.option("branding") + '/server'

base.cmd_in_dir(server_dir, "npm", ["install"])
base.cmd_in_dir(server_dir, "grunt", ["--no-color", "-v"] + base.server_addons_param())
build_server_with_addons()

#env variables
product_version = base.get_env('PRODUCT_VERSION')
Expand All @@ -30,18 +29,16 @@ def make():

cur_date = datetime.date.today().strftime("%m/%d/%Y")

server_build_dir = server_dir + "/build/server"

base.replaceInFileRE(server_build_dir + "/Common/sources/commondefines.js", "const buildNumber = [0-9]*", "const buildNumber = " + build_number)
base.replaceInFileRE(server_build_dir + "/Common/sources/license.js", "const buildDate = '[0-9-/]*'", "const buildDate = '" + cur_date + "'")
base.replaceInFileRE(server_build_dir + "/Common/sources/commondefines.js", "const buildVersion = '[0-9.]*'", "const buildVersion = '" + product_version + "'")
base.replaceInFileRE(server_dir + "/Common/sources/commondefines.js", "const buildNumber = [0-9]*", "const buildNumber = " + build_number)
base.replaceInFileRE(server_dir + "/Common/sources/license.js", "const buildDate = '[0-9-/]*'", "const buildDate = '" + cur_date + "'")
base.replaceInFileRE(server_dir + "/Common/sources/commondefines.js", "const buildVersion = '[0-9.]*'", "const buildVersion = '" + product_version + "'")

custom_public_key = branding_dir + '/debug.js'

if(base.is_exist(custom_public_key)):
base.copy_file(custom_public_key, server_build_dir + '/Common/sources')
base.copy_file(custom_public_key, server_dir + '/Common/sources')

pkg_target = "node14"
pkg_target = "node16"

if ("linux" == base.host_platform()):
pkg_target += "-linux"
Expand All @@ -51,15 +48,25 @@ def make():
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_dir + "/DocService", "pkg", [".", "-t", pkg_target, "--options", "max_old_space_size=4096", "-o", "docservice"])
base.cmd_in_dir(server_dir + "/FileConverter", "pkg", [".", "-t", pkg_target, "-o", "converter"])
base.cmd_in_dir(server_dir + "/Metrics", "pkg", [".", "-t", pkg_target, "-o", "metrics"])

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"])
base.cmd_in_dir(example_dir, "npm", ["ci"])
base.cmd_in_dir(example_dir, "pkg", [".", "-t", pkg_target, "-o", "example"])

def build_server_with_addons():
addons = {}
addons["server"] = [True, False]
addons.update(base.get_server_addons())
for addon in addons:
if (addon):
addon_dir = base.get_script_dir() + "/../../" + addon
base.cmd_in_dir(addon_dir, "npm", ["ci"])
base.cmd_in_dir(addon_dir, "npm", ["run", "build"])

def build_server_develop():
server_dir = base.get_script_dir() + "/../../server"
base.cmd_in_dir(server_dir, "npm", ["ci"])
Expand Down
3 changes: 3 additions & 0 deletions scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def extend_option(name, value):
else:
options[name] = value

def set_option(name, value):
options[name] = value

def branding():
branding = option("branding-name")
if ("" == branding):
Expand Down
33 changes: 27 additions & 6 deletions scripts/core_common/modules/icu.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,44 @@
import config
import base
import os
import glob
import icu_android

def fetch_icu(major, minor):
base.cmd("git", ["clone", "--depth", "1", "--branch", "maint/maint-" + major, "https://github.com/unicode-org/icu.git", "./icu2"])
base.copy_dir("./icu2/icu4c", "./icu")
base.delete_dir_with_access_error("icu2")
#base.cmd("svn", ["export", "https://github.com/unicode-org/icu/tags/release-" + icu_major + "-" + icu_minor + "/icu4c", "./icu", "--non-interactive", "--trust-server-cert"])
return

def clear_module():
if base.is_dir("icu"):
base.delete_dir_with_access_error("icu")

# remove build
for child in glob.glob("./*"):
if base.is_dir(child):
base.delete_dir(child)

return

def make():
print("[fetch & build]: icu")

if (-1 != config.option("platform").find("android")):
icu_android.make()

base_dir = base.get_script_dir() + "/../../core/Common/3dParty/icu"
old_cur = os.getcwd()
os.chdir(base_dir)

icu_major = "58"
icu_minor = "2"
base.check_module_version("3", clear_module)

if (-1 != config.option("platform").find("android")):
icu_android.make()

icu_major = "58"
icu_minor = "3"

if not base.is_dir("icu"):
base.cmd("svn", ["export", "https://github.com/unicode-org/icu/tags/release-" + icu_major + "-" + icu_minor + "/icu4c", "./icu", "--non-interactive", "--trust-server-cert"])
fetch_icu(icu_major, icu_minor)

if ("windows" == base.host_platform()):
platformToolset = "v140"
Expand Down
11 changes: 9 additions & 2 deletions scripts/core_common/modules/icu_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
import base
import os

def fetch_icu(major, minor):
base.cmd("git", ["clone", "--depth", "1", "--branch", "maint/maint-" + major, "https://github.com/unicode-org/icu.git", "./icu2"])
base.copy_dir("./icu2/icu4c", "./icu")
base.delete_dir_with_access_error("icu2")
#base.cmd("svn", ["export", "https://github.com/unicode-org/icu/tags/release-" + icu_major + "-" + icu_minor + "/icu4c", "./icu", "--non-interactive", "--trust-server-cert"])
return

current_dir = base.get_script_dir() + "/../../core/Common/3dParty/icu/android"

toolshains_dir = current_dir + "/toolchains"
icu_major = "58"
icu_minor = "2"
icu_minor = "3"
icu_is_shared = False

current_path = base.get_env("PATH")
Expand Down Expand Up @@ -77,7 +84,7 @@ def make():
os.chdir(current_dir)

if not base.is_dir("icu"):
base.cmd("svn", ["export", "https://github.com/unicode-org/icu/tags/release-" + icu_major + "-" + icu_minor + "/icu4c", "./icu", "--non-interactive", "--trust-server-cert"])
fetch_icu(icu_major, icu_minor)
if ("linux" == base.host_platform()):
base.replaceInFile(current_dir + "/icu/source/i18n/digitlst.cpp", "xlocale", "locale")
if ("mac" == base.host_platform()):
Expand Down
2 changes: 1 addition & 1 deletion scripts/core_common/modules/icu_mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def restore_icu_defs(current_dir):
return

icu_major = "58"
icu_minor = "2"
icu_minor = "3"

current_dir_old = os.getcwd()
current_dir = base.get_script_dir() + "/../../core/Common/3dParty/icu"
Expand Down
Loading

0 comments on commit f801e77

Please sign in to comment.