Skip to content

Commit

Permalink
build: collect hunspell dictionaries into a zip file and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Oct 25, 2019
1 parent 629e28f commit a050fef
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 19 deletions.
42 changes: 28 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ env-ninja-status: &env-ninja-status
env-disable-run-as-node: &env-disable-run-as-node
GN_BUILDFLAG_ARGS: 'enable_run_as_node = false'

env-enable-spellchecker: &env-enable-spellchecker
GN_BUILDFLAG_ARGS: 'enable_builtin_spellchecker = true'

# Individual (shared) steps.
step-maybe-notify-slack-failure: &step-maybe-notify-slack-failure
run:
Expand Down Expand Up @@ -322,6 +319,8 @@ step-gn-check: &step-gn-check
gn check out/Default //electron:electron_app
gn check out/Default //electron:manifests
gn check out/Default //electron/shell/common/api:mojo
# Check the hunspell filenames
node electron/script/gen-hunspell-filenames.js --check
step-electron-build: &step-electron-build
run:
Expand Down Expand Up @@ -537,6 +536,20 @@ step-mksnapshot-store: &step-mksnapshot-store
path: src/out/Default/mksnapshot.zip
destination: mksnapshot.zip

step-hunspell-build: &step-hunspell-build
run:
name: mksnapshot build
command: |
cd src
if [ "$SKIP_DIST_ZIP" != "1" ]; then
ninja -C out/Default electron:hunspell_dictionaries_zip -j $NUMBER_OF_NINJA_PROCESSES
fi
step-hunspell-store: &step-hunspell-store
store_artifacts:
path: src/out/Default/hunspell_dictionaries.zip
destination: hunspell_dictionaries.zip

step-maybe-generate-breakpad-symbols: &step-maybe-generate-breakpad-symbols
run:
name: Generate breakpad symbols
Expand Down Expand Up @@ -862,6 +875,10 @@ steps-electron-build: &steps-electron-build
- *step-ffmpeg-build
- *step-ffmpeg-store

# hunspell
- *step-hunspell-build
- *step-hunspell-store

# Save all data needed for a further tests run.
- *step-persist-data-for-tests

Expand Down Expand Up @@ -937,6 +954,10 @@ steps-electron-build-with-inline-checkout-for-tests: &steps-electron-build-with-
- *step-ffmpeg-build
- *step-ffmpeg-store

# hunspell
- *step-hunspell-build
- *step-hunspell-store

# Save all data needed for a further tests run.
- *step-persist-data-for-tests

Expand Down Expand Up @@ -987,6 +1008,10 @@ steps-electron-build-for-publish: &steps-electron-build-for-publish
- *step-ffmpeg-build
- *step-ffmpeg-store

# hunspell
- *step-hunspell-build
- *step-hunspell-store

# typescript defs
- *step-maybe-generate-typescript-defs

Expand Down Expand Up @@ -1231,17 +1256,6 @@ jobs:
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
<<: *steps-electron-build-with-inline-checkout-for-tests

linux-x64-testing-spellchecker-fyi:
<<: *machine-linux-2xlarge
environment:
<<: *env-linux-2xlarge
<<: *env-testing-build
<<: *env-enable-sccache
<<: *env-ninja-status
<<: *env-enable-spellchecker
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
<<: *steps-electron-build-with-inline-checkout-for-tests

linux-x64-testing-gn-check:
<<: *machine-linux-medium
environment:
Expand Down
29 changes: 28 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import("buildflags/buildflags.gni")
import("electron_paks.gni")
import("filenames.auto.gni")
import("filenames.gni")
import("filenames.hunspell.gni")

if (is_mac) {
import("//build/config/mac/rules.gni")
Expand Down Expand Up @@ -538,7 +539,10 @@ source_set("electron_lib") {
}

if (enable_builtin_spellchecker) {
deps += [ ":chrome_spellchecker" ]
deps += [
":chrome_spellchecker",
"//components/spellcheck/browser",
]
}

if (is_mac) {
Expand Down Expand Up @@ -1328,9 +1332,14 @@ template("dist_zip") {
"outputs",
"testonly",
])
flatten = false
if (defined(invoker.flatten)) {
flatten = invoker.flatten
}
args = rebase_path(outputs + [ _runtime_deps_file ], root_build_dir) + [
target_cpu,
target_os,
"$flatten",
]
}
}
Expand Down Expand Up @@ -1416,6 +1425,24 @@ dist_zip("electron_mksnapshot_zip") {
]
}

copy("hunspell_dictionaries") {
sources = hunspell_dictionaries + hunspell_licenses
outputs = [
"$target_gen_dir/electron_hunspell/{{source_file_part}}",
]
}

dist_zip("hunspell_dictionaries_zip") {
data_deps = [
":hunspell_dictionaries",
]
flatten = true

outputs = [
"$root_build_dir/hunspell_dictionaries.zip",
]
}

group("electron") {
public_deps = [
":electron_app",
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ build_script:
- ninja -C out/Default electron:electron_dist_zip
- ninja -C out/Default shell_browser_ui_unittests
- ninja -C out/Default electron:electron_mksnapshot_zip
- ninja -C out/Default electron:hunspell_dictionaries_zip
- ninja -C out/Default electron:electron_chromedriver_zip
- ninja -C out/Default third_party/electron_node:headers
- appveyor PushArtifact out/Default/dist.zip
Expand All @@ -94,6 +95,7 @@ build_script:
- 7z a node_headers.zip out\Default\gen\node_headers
- appveyor PushArtifact node_headers.zip
- appveyor PushArtifact out/Default/mksnapshot.zip
- appveyor PushArtifact out/Default/hunspell_dictionaries.zip
- appveyor PushArtifact out/Default/electron.lib
- ps: >-
if ($env:GN_CONFIG -eq 'release') {
Expand Down
7 changes: 4 additions & 3 deletions build/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ def execute(argv):
raise e

def main(argv):
dist_zip, runtime_deps, target_cpu, target_os = argv
dist_zip, runtime_deps, target_cpu, target_os, flatten_val = argv
should_flatten = flatten_val == "true"
dist_files = set()
with open(runtime_deps) as f:
for dep in f.readlines():
dep = dep.strip()
dist_files.add(dep)
if sys.platform == 'darwin':
if sys.platform == 'darwin' and not should_flatten:
execute(['zip', '-r', '-y', dist_zip] + list(dist_files))
else:
with zipfile.ZipFile(dist_zip, 'w', zipfile.ZIP_DEFLATED, allowZip64=True) as z:
Expand All @@ -67,7 +68,7 @@ def main(argv):
basename = os.path.basename(dep)
dirname = os.path.dirname(dep)
arcname = os.path.join(dirname, 'chrome-sandbox') if basename == 'chrome_sandbox' else dep
z.write(dep, arcname)
z.write(dep, os.path.basename(arcname) if should_flatten else arcname)

if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
60 changes: 60 additions & 0 deletions filenames.hunspell.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
hunspell_dictionaries = [
"//third_party/hunspell_dictionaries/af-ZA-3-0.bdic",
"//third_party/hunspell_dictionaries/bg-BG-3-0.bdic",
"//third_party/hunspell_dictionaries/ca-ES-3-0.bdic",
"//third_party/hunspell_dictionaries/cs-CZ-3-0.bdic",
"//third_party/hunspell_dictionaries/cy-GB-1-0.bdic",
"//third_party/hunspell_dictionaries/da-DK-3-0.bdic",
"//third_party/hunspell_dictionaries/de-DE-3-0.bdic",
"//third_party/hunspell_dictionaries/el-GR-3-0.bdic",
"//third_party/hunspell_dictionaries/en-AU-8-0.bdic",
"//third_party/hunspell_dictionaries/en-CA-8-0.bdic",
"//third_party/hunspell_dictionaries/en-GB-8-0.bdic",
"//third_party/hunspell_dictionaries/en-US-8-0.bdic",
"//third_party/hunspell_dictionaries/es-ES-3-0.bdic",
"//third_party/hunspell_dictionaries/et-EE-3-0.bdic",
"//third_party/hunspell_dictionaries/fa-IR-8-0.bdic",
"//third_party/hunspell_dictionaries/fo-FO-3-0.bdic",
"//third_party/hunspell_dictionaries/fr-FR-3-0.bdic",
"//third_party/hunspell_dictionaries/he-IL-3-0.bdic",
"//third_party/hunspell_dictionaries/hi-IN-3-0.bdic",
"//third_party/hunspell_dictionaries/hr-HR-3-0.bdic",
"//third_party/hunspell_dictionaries/hu-HU-3-0.bdic",
"//third_party/hunspell_dictionaries/hy-1-0.bdic",
"//third_party/hunspell_dictionaries/id-ID-3-0.bdic",
"//third_party/hunspell_dictionaries/it-IT-3-0.bdic",
"//third_party/hunspell_dictionaries/ko-3-0.bdic",
"//third_party/hunspell_dictionaries/lt-LT-3-0.bdic",
"//third_party/hunspell_dictionaries/lv-LV-3-0.bdic",
"//third_party/hunspell_dictionaries/nb-NO-3-0.bdic",
"//third_party/hunspell_dictionaries/nl-NL-3-0.bdic",
"//third_party/hunspell_dictionaries/pl-PL-3-0.bdic",
"//third_party/hunspell_dictionaries/pt-BR-3-0.bdic",
"//third_party/hunspell_dictionaries/pt-PT-3-0.bdic",
"//third_party/hunspell_dictionaries/ro-RO-3-0.bdic",
"//third_party/hunspell_dictionaries/ru-RU-3-0.bdic",
"//third_party/hunspell_dictionaries/sh-3-0.bdic",
"//third_party/hunspell_dictionaries/sh-4-0.bdic",
"//third_party/hunspell_dictionaries/sk-SK-3-0.bdic",
"//third_party/hunspell_dictionaries/sl-SI-3-0.bdic",
"//third_party/hunspell_dictionaries/sq-3-0.bdic",
"//third_party/hunspell_dictionaries/sr-3-0.bdic",
"//third_party/hunspell_dictionaries/sr-4-0.bdic",
"//third_party/hunspell_dictionaries/sv-SE-3-0.bdic",
"//third_party/hunspell_dictionaries/ta-IN-3-0.bdic",
"//third_party/hunspell_dictionaries/tg-TG-5-0.bdic",
"//third_party/hunspell_dictionaries/tr-TR-4-0.bdic",
"//third_party/hunspell_dictionaries/uk-UA-3-0.bdic",
"//third_party/hunspell_dictionaries/vi-VN-3-0.bdic",
"//third_party/hunspell_dictionaries/xx-XX-3-0.bdic",
]

hunspell_licenses = [
"//third_party/hunspell_dictionaries/COPYING",
"//third_party/hunspell_dictionaries/COPYING.Apache",
"//third_party/hunspell_dictionaries/COPYING.LESSER",
"//third_party/hunspell_dictionaries/COPYING.LGPL",
"//third_party/hunspell_dictionaries/COPYING.MIT",
"//third_party/hunspell_dictionaries/COPYING.MPL",
"//third_party/hunspell_dictionaries/LICENSE",
]
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
"node script/gen-filenames.js",
"python script/check-trailing-whitespace.py --fix",
"git add filenames.auto.gni"
],
"DEPS": [
"node script/gen-hunspell-filenames.js"
]
},
"dependencies": {
Expand Down
35 changes: 35 additions & 0 deletions script/gen-hunspell-filenames.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require('fs')
const path = require('path')

const check = process.argv.includes('--check')

const dictsPath = path.resolve(__dirname, '..', '..', 'third_party', 'hunspell_dictionaries')
const gclientPath = 'third_party/hunspell_dictionaries'

const allFiles = fs.readdirSync(dictsPath)

const dictionaries = allFiles
.filter(file => path.extname(file) === '.bdic')

const licenses = allFiles
.filter(file => file.startsWith('LICENSE') || file.startsWith('COPYING'))

const content = `hunspell_dictionaries = [
${dictionaries.map(f => `"//${path.posix.join(gclientPath, f)}"`).join(',\n ')}
]
hunspell_licenses = [
${licenses.map(f => `"//${path.posix.join(gclientPath, f)}"`).join(',\n ')}
]
`

const filenamesPath = path.resolve(__dirname, '..', 'filenames.hunspell.gni')

if (check) {
const currentContent = fs.readFileSync(filenamesPath, 'utf8')
if (currentContent !== content) {
throw new Error('hunspell filenames need to be regenerated, latest generation does not match current file. Please run node gen-hunspell-filenames.js')
}
} else {
fs.writeFileSync(filenamesPath, content)
}
1 change: 1 addition & 0 deletions script/release/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function assetsForVersion (version, validatingRelease) {
`electron-${version}-win32-arm64.zip`,
`electron-api.json`,
`electron.d.ts`,
`hunspell_dictionaries.zip`,
`ffmpeg-${version}-darwin-x64.zip`,
`ffmpeg-${version}-linux-arm64.zip`,
`ffmpeg-${version}-linux-armv7l.zip`,
Expand Down
5 changes: 5 additions & 0 deletions script/release/uploaders/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def main():
shutil.copy2(os.path.join(OUT_DIR, 'mksnapshot.zip'), mksnapshot_zip)
upload_electron(release, mksnapshot_zip, args)

if PLATFORM == 'linux' and get_target_arch() == 'x64':
# Upload the hunspell dictionaries only from the linux x64 build
hunspell_dictionaries_zip = os.path.join(OUT_DIR, 'hunspell_dictionaries.zip')
upload_electron(release, hunspell_dictionaries_zip, args)

if not tag_exists and not args.upload_to_s3:
# Upload symbols to symbol server.
run_python_upload_script('upload-symbols.py')
Expand Down
5 changes: 4 additions & 1 deletion shell/browser/api/atom_api_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "components/prefs/value_map_pref_store.h"
#include "components/proxy_config/proxy_config_dictionary.h"
#include "components/proxy_config/proxy_config_pref_names.h"
#include "components/spellcheck/browser/pref_names.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_item_utils.h"
Expand Down Expand Up @@ -70,6 +69,10 @@
#include "shell/browser/extensions/atom_extension_system.h"
#endif

#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
#include "components/spellcheck/browser/pref_names.h"
#endif

using content::BrowserThread;
using content::StoragePartition;

Expand Down

0 comments on commit a050fef

Please sign in to comment.