build-hyb.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # Copyright 2020 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # `mk_hyb_file.py` is a program to generate hyphen data file for minikin.
  6. mk_hyb=./mk_hyb_file.py
  7. if [[ ! -f $mk_hyb_file ]]; then
  8. mk_hyb_url="https://android.googlesource.com/platform/frameworks/minikin/+/refs/heads/master/tools/mk_hyb_file.py"
  9. echo "Downloading mk_hyb_file from $mk_hyb_url"
  10. curl "$mk_hyb_url?format=TEXT" | base64 --decode >$mk_hyb
  11. chmod +x $mk_hyb
  12. fi
  13. # Read pattern_locales from `src/Android.mk`, expecting the format like this:
  14. # pattern_locales := \
  15. # as/as \
  16. # be/be \
  17. # :
  18. # te/te \
  19. # tk/tk
  20. # (blank line)
  21. pattern_mk=src/Android.mk
  22. pattern_locales () {
  23. awk -e '
  24. /^pattern_locales :=/ {flag=1; next}
  25. !flag {next}
  26. /^$/ {flag=0; next}
  27. {print $1}
  28. ' $pattern_mk
  29. }
  30. # Rebuild the data file in `$hyb`.
  31. src=src/
  32. hyb=hyb/
  33. LICENSE=LICENSE
  34. rm -rf "$hyb"
  35. mkdir -p "$hyb"
  36. rm -f "$LICENSE"
  37. PRE=''
  38. pattern_locales | while IFS=/ read dir name; do
  39. (set -x; $mk_hyb "$src$dir/hyph-$name.pat.txt" "${hyb}hyph-$name.hyb")
  40. # Concatenate to the LICENSE file.
  41. echo -e "${PRE}hyph-$name.hyb\n" >> "$LICENSE"
  42. for name in 'NOTICE' 'LICENSE'; do
  43. if [ -f "$src$dir/$name" ]; then
  44. echo "Appending $src$dir/$name to $LICENSE"
  45. cat "$src$dir/$name" >> "$LICENSE"
  46. fi
  47. done
  48. PRE='\n'
  49. done
  50. rm -f $mk_hyb