Commit 28ba53c0 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Theodore Ts'o

unicode: refactor the rule for regenerating utf8data.h

scripts/mkutf8data is used only when regenerating utf8data.h,
which never happens in the normal kernel build. However, it is
irrespectively built if CONFIG_UNICODE is enabled.

Moreover, there is no good reason for it to reside in the scripts/
directory since it is only used in fs/unicode/.

Hence, move it from scripts/ to fs/unicode/.

In some cases, we bypass build artifacts in the normal build. The
conventional way to do so is to surround the code with ifdef REGENERATE_*.

For example,

 - 7373f4f8 ("kbuild: add implicit rules for parser generation")
 - 6aaf49b4 ("crypto: arm,arm64 - Fix random regeneration of S_shipped")

I rewrote the rule in a more kbuild'ish style.

In the normal build, utf8data.h is just shipped from the check-in file.

$ make
  [ snip ]
  SHIPPED fs/unicode/utf8data.h
  CC      fs/unicode/utf8-norm.o
  CC      fs/unicode/utf8-core.o
  CC      fs/unicode/utf8-selftest.o
  AR      fs/unicode/built-in.a

If you want to generate utf8data.h based on UCD, put *.txt files into
fs/unicode/, then pass REGENERATE_UTF8DATA=1 from the command line.
The mkutf8data tool will be automatically compiled to generate the
utf8data.h from the *.txt files.

$ make REGENERATE_UTF8DATA=1
  [ snip ]
  HOSTCC  fs/unicode/mkutf8data
  GEN     fs/unicode/utf8data.h
  CC      fs/unicode/utf8-norm.o
  CC      fs/unicode/utf8-core.o
  CC      fs/unicode/utf8-selftest.o
  AR      fs/unicode/built-in.a

I renamed the check-in utf8data.h to utf8data.h_shipped so that this
will work for the out-of-tree build.

You can update it based on the latest UCD like this:

$ make REGENERATE_UTF8DATA=1 fs/unicode/
$ cp fs/unicode/utf8data.h fs/unicode/utf8data.h_shipped

Also, I added entries to .gitignore and dontdiff.
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 0a790fe4
...@@ -176,6 +176,7 @@ mkprep ...@@ -176,6 +176,7 @@ mkprep
mkregtable mkregtable
mktables mktables
mktree mktree
mkutf8data
modpost modpost
modules.builtin modules.builtin
modules.order modules.order
...@@ -254,6 +255,7 @@ vsyscall_32.lds ...@@ -254,6 +255,7 @@ vsyscall_32.lds
wanxlfw.inc wanxlfw.inc
uImage uImage
unifdef unifdef
utf8data.h
wakeup.bin wakeup.bin
wakeup.elf wakeup.elf
wakeup.lds wakeup.lds
......
mkutf8data
utf8data.h
...@@ -5,15 +5,34 @@ obj-$(CONFIG_UNICODE_NORMALIZATION_SELFTEST) += utf8-selftest.o ...@@ -5,15 +5,34 @@ obj-$(CONFIG_UNICODE_NORMALIZATION_SELFTEST) += utf8-selftest.o
unicode-y := utf8-norm.o utf8-core.o unicode-y := utf8-norm.o utf8-core.o
# This rule is not invoked during the kernel compilation. It is used to $(obj)/utf8-norm.o: $(obj)/utf8data.h
# regenerate the utf8data.h header file.
utf8data.h.new: *.txt $(objdir)/scripts/mkutf8data # In the normal build, the checked-in utf8data.h is just shipped.
$(objdir)/scripts/mkutf8data \ #
-a DerivedAge.txt \ # To generate utf8data.h from UCD, put *.txt files in this directory
-c DerivedCombiningClass.txt \ # and pass REGENERATE_UTF8DATA=1 from the command line.
-p DerivedCoreProperties.txt \ ifdef REGENERATE_UTF8DATA
-d UnicodeData.txt \
-f CaseFolding.txt \ quiet_cmd_utf8data = GEN $@
-n NormalizationCorrections.txt \ cmd_utf8data = $< \
-t NormalizationTest.txt \ -a $(srctree)/$(src)/DerivedAge.txt \
-c $(srctree)/$(src)/DerivedCombiningClass.txt \
-p $(srctree)/$(src)/DerivedCoreProperties.txt \
-d $(srctree)/$(src)/UnicodeData.txt \
-f $(srctree)/$(src)/CaseFolding.txt \
-n $(srctree)/$(src)/NormalizationCorrections.txt \
-t $(srctree)/$(src)/NormalizationTest.txt \
-o $@ -o $@
$(obj)/utf8data.h: $(obj)/mkutf8data $(filter %.txt, $(cmd_utf8data)) FORCE
$(call if_changed,utf8data)
else
$(obj)/utf8data.h: $(src)/utf8data.h_shipped FORCE
$(call if_changed,shipped)
endif
targets += utf8data.h
hostprogs-y += mkutf8data
...@@ -55,15 +55,14 @@ released version of the UCD can be found here: ...@@ -55,15 +55,14 @@ released version of the UCD can be found here:
http://www.unicode.org/Public/UCD/latest/ http://www.unicode.org/Public/UCD/latest/
To build the utf8data.h file, from a kernel tree that has been built, Then, build under fs/unicode/ with REGENERATE_UTF8DATA=1:
cd to this directory (fs/unicode) and run this command:
make C=../.. objdir=../.. utf8data.h.new make REGENERATE_UTF8DATA=1 fs/unicode/
After sanity checking the newly generated utf8data.h.new file (the After sanity checking the newly generated utf8data.h file (the
version generated from the 12.1.0 UCD should be 4,109 lines long, and version generated from the 12.1.0 UCD should be 4,109 lines long, and
have a total size of 324k) and/or comparing it with the older version have a total size of 324k) and/or comparing it with the older version
of utf8data.h, rename it to utf8data.h. of utf8data.h_shipped, rename it to utf8data.h_shipped.
If you are a kernel developer updating to a newer version of the If you are a kernel developer updating to a newer version of the
Unicode Character Database, please update this README.utf8data file Unicode Character Database, please update this README.utf8data file
......
...@@ -20,7 +20,6 @@ hostprogs-$(CONFIG_ASN1) += asn1_compiler ...@@ -20,7 +20,6 @@ hostprogs-$(CONFIG_ASN1) += asn1_compiler
hostprogs-$(CONFIG_MODULE_SIG) += sign-file hostprogs-$(CONFIG_MODULE_SIG) += sign-file
hostprogs-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert hostprogs-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert
hostprogs-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert hostprogs-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
hostprogs-$(CONFIG_UNICODE) += mkutf8data
HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include
HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment