summaryrefslogtreecommitdiffstats
path: root/intl/icu/source/tools/genren
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /intl/icu/source/tools/genren
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'intl/icu/source/tools/genren')
-rw-r--r--intl/icu/source/tools/genren/Makefile105
-rw-r--r--intl/icu/source/tools/genren/README47
-rwxr-xr-xintl/icu/source/tools/genren/genren.pl275
3 files changed, 427 insertions, 0 deletions
diff --git a/intl/icu/source/tools/genren/Makefile b/intl/icu/source/tools/genren/Makefile
new file mode 100644
index 0000000000..f0ab666999
--- /dev/null
+++ b/intl/icu/source/tools/genren/Makefile
@@ -0,0 +1,105 @@
+# Copyright (C) 2016 and later: Unicode, Inc. and others.
+# License & terms of use: http://www.unicode.org/copyright.html
+#******************************************************************************
+#
+# Copyright (C) 2002-2011, International Business Machines
+# Corporation and others. All Rights Reserved.
+#
+#******************************************************************************
+
+TOP=../..
+
+srcdir = .
+top_srcdir = $(TOP)
+top_builddir = $(TOP)
+
+# override if you have an out-of-source build (not yet working.)
+BUILDDIR = $(top_builddir)
+
+ICUDIR=ICUunrenamed
+
+# Extra flags to prevent internal API from being hidden.
+# This is important because ELF (Linux) based platforms that don't hide internal
+# API will allow a duplicate internal name to resolve to an external library.
+# See the gcc manual on the "visibility" attribute for details.
+FLAG_OVERRIDE= LIBCFLAGS= LIBCXXFLAGS= $(EXTRA_MAKE_OPTIONS)
+
+## any local overrides
+-include Makefile.local
+
+# load definition of .SO, etc (but not if we are doing 'make clean')
+ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
+include $(BUILDDIR)/icudefs.mk
+endif
+
+# For MinGW, do we want the DLL to go in the bin location?
+ifeq ($(MINGW_MOVEDLLSTOBINDIR),YES)
+installdir = bin
+else
+installdir = lib
+endif
+
+COM=$(ICUDIR)/$(installdir)/libicuuc.$(SO)
+I18=$(ICUDIR)/$(installdir)/libicui18n.$(SO)
+LEX=$(ICUDIR)/$(installdir)/libiculx.$(SO)
+DAT=$(ICUDIR)/stubdata/libicudata.$(SO)
+UIO=$(ICUDIR)/$(installdir)/libicuio.$(SO)
+
+LIBS=$(COM) $(I18) $(LEX) $(UIO)
+
+## Targets.
+
+
+all:
+ @cat README
+
+clean:
+ -rm -rf $(ICUDIR) urename.* *~
+
+# We use config.status to mean we have a valid out of source tree.
+
+$(ICUDIR)/config.status:
+ -mv $(ICUDIR) $(ICUDIR)old
+ -(rm -rf $(ICUDIR)old &)
+ mkdir $(ICUDIR)
+ ( cd $(ICUDIR) ; CPPFLAGS="-DU_DISABLE_RENAMING=1 -DUCONFIG_ENABLE_PLUGINS" $(GENREN_CONFIGURE_ENV) $(top_srcdir)/../configure --with-data-packaging=archive --enable-tests=no --prefix=`pwd` $(GENREN_CONFIGURE_OPTS) )
+ # cause lib and bin to be created, and any other general sanity
+ $(MAKE) $(FLAG_OVERRIDE) -C $(ICUDIR) clean
+ $(MAKE) $(FLAG_OVERRIDE) -C $(ICUDIR) all-local
+
+# build the libraries
+$(DAT): $(ICUDIR)/config.status Makefile
+ $(MAKE) $(FLAG_OVERRIDE) -C $(ICUDIR)/stubdata all-local
+
+$(COM): $(DAT) $(ICUDIR)/config.status Makefile
+ $(MAKE) $(FLAG_OVERRIDE) -C $(ICUDIR)/common all-local
+
+$(I18): $(DAT) $(COM) $(ICUDIR)/config.status Makefile
+ $(MAKE) $(FLAG_OVERRIDE) -C $(ICUDIR)/i18n all-local
+
+$(LEX): $(DAT) $(I18) $(COM) $(ICUDIR)/config.status Makefile
+ $(MAKE) $(FLAG_OVERRIDE) -C $(ICUDIR)/layoutex all-local
+
+$(UIO): $(DAT) $(I18) $(COM) $(ICUDIR)/config.status Makefile
+ $(MAKE) $(FLAG_OVERRIDE) -C $(ICUDIR)/io all-local
+
+# the header itself
+urename.h: $(LIBS) genren.pl
+ -cp urename.h urename.h.old
+ perl ./genren.pl $(GENREN_PL_OPTS) $(LIBS)
+
+# This is still here, but less useful with the "new" macro-based rename. Just use 'svn diff'.
+sorts: urename.sort urename.old.sort
+ @echo "*** Please check urename.h manually before committing it."
+ @echo "Try 'diff --side-by-side urename.old.sort urename.sort'"
+
+urename.sort: urename.h
+ sort urename.h > $@
+
+urename.old.sort: $(top_srcdir)/common/unicode/urename.h
+ sort $(top_srcdir)/common/unicode/urename.h > $@
+
+install-header: urename.h
+ cp urename.h $(top_srcdir)/common/unicode/
+ @echo "*** Please check urename.h manually before committing it."
+
diff --git a/intl/icu/source/tools/genren/README b/intl/icu/source/tools/genren/README
new file mode 100644
index 0000000000..a18c294136
--- /dev/null
+++ b/intl/icu/source/tools/genren/README
@@ -0,0 +1,47 @@
+Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html
+Copyright (c) 2002-2011, International Business Machines Corporation and others. All Rights Reserved.
+
+The genren.pl script is used to generate source/common/unicode/urename.h header file, which is needed for renaming the ICU exported names.
+
+This script is intended to be used on Linux, although it should work on any platform that has Perl and nm command. Makefile may need to be updated, it's not 100% portable.
+
+It also does not currently work well in an out-of-source situation.
+
+The following instructions are for Linux version.
+- urename.h file should be generated after implementation is complete for a release.
+- the version number for a release should be set according to the list in source/common/unicode/uvernum.h
+- Note: If you are running the script in a clean checkout, you must run the runConfigureICU at least once before
+ running the make install-header command below.
+
+Before generating urename.h, the layout engine header files must be installed from the harfbuzz project.
+This is prerequisite for the icu layoutex (Paragraph Layout) project, which is subject to renaming.
+(Using the svn command is the simplest way of getting just the files from one subdirectory of the git project.)
+
+ cd icu4c/source
+ svn export https://github.com/behdad/icu-le-hb/trunk/src layout
+
+(As an alternative to the above handling of layout engine header files, you can do the following:
+1. In the Makefile in this directory, temporarily delete $(LEX) from the list of objects for LIBS
+ before running make install-header
+2. After running make install-header, restore the deleted $(LEX) in the Makefile
+3. Then when comparing the old urename.h to the newly generated one, copy all of the lines beginning
+ "#define pl_" from the old version to the new one.
+ - Peter E)
+
+- Regenerate urename.h
+
+ cd icu4c/source/tools/genren
+ make install-header
+
+- urename.h will be updated in icu/source/common/unicode/urename.h **in your original source directory**
+- Warnings concerning bad namespace (not 'icu') on UCaseMap can be ignored.
+- The defines for "__bss_start", "_edata", and "_end" should be ignored/removed (See ICU-20176).
+- Eyeball the new file for errors
+
+ cd icu4c/source
+ git diff common/unicode/urename.h
+
+- Other make targets here
+
+ clean - cleans out intermediate files
+ urename.h -just builds ./urename.h
diff --git a/intl/icu/source/tools/genren/genren.pl b/intl/icu/source/tools/genren/genren.pl
new file mode 100755
index 0000000000..f85b96ac60
--- /dev/null
+++ b/intl/icu/source/tools/genren/genren.pl
@@ -0,0 +1,275 @@
+#!/usr/bin/perl
+# Copyright (C) 2016 and later: Unicode, Inc. and others.
+# License & terms of use: http://www.unicode.org/copyright.html
+#*
+#*******************************************************************************
+#* Copyright (C) 2001-2012, International Business Machines
+#* Corporation and others. All Rights Reserved.
+#*******************************************************************************
+#*
+#* file name: genren.pl
+#* encoding: UTF-8
+#* tab size: 8 (not used)
+#* indentation:4
+#*
+#* Created by: Vladimir Weinstein
+#* 07/19/2001
+#*
+#* Used to generate renaming headers.
+#* Run on UNIX platforms (linux) in order to catch all the exports
+
+use POSIX qw(strftime);
+
+$headername = 'urename.h';
+
+$path = substr($0, 0, rindex($0, "/")+1)."../../common/unicode/uversion.h";
+
+$nmopts = '-Cg -f s';
+$post = '';
+
+$mode = 'POSIX';
+
+(-e $path) || die "Cannot find uversion.h";
+
+open(UVERSION, $path);
+
+while(<UVERSION>) {
+ if(/\#define U_ICU_VERSION_SUFFIX/) {
+ chop;
+ s/\#define U_ICU_VERSION_SUFFIX //;
+ $U_ICU_VERSION_SUFFIX = "$_";
+ last;
+ }
+}
+
+while($ARGV[0] =~ /^-/) { # detects whether there are any arguments
+ $_ = shift @ARGV; # extracts the argument for processing
+ /^-v/ && ($VERBOSE++, next); # verbose
+ /^-h/ && (&printHelpMsgAndExit, next); # help
+ /^-o/ && (($headername = shift (@ARGV)), next); # output file
+ /^-n/ && (($nmopts = shift (@ARGV)), next); # nm opts
+ /^-p/ && (($post = shift (@ARGV)), next); # nm opts
+ /^-x/ && (($mode = shift (@ARGV)), next); # nm opts
+ /^-S/ && (($U_ICU_VERSION_SUFFIX = shift(@ARGV)), next); # pick the suffix
+ warn("Invalid option $_\n");
+ &printHelpMsgAndExit;
+}
+
+unless(@ARGV > 0) {
+ warn "No libraries, exiting...\n";
+ &printHelpMsgAndExit;
+}
+
+#$headername = "uren".substr($ARGV[0], 6, index(".", $ARGV[0])-7).".h";
+
+$HEADERDEF = uc($headername); # this is building the constant for #define
+$HEADERDEF =~ s/\./_/;
+
+
+ open HEADER, ">$headername"; # opening a header file
+
+#We will print our copyright here + warnings
+
+print HEADER <<"EndOfHeaderComment";
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+/*
+*******************************************************************************
+* Copyright (C) 2002-2016, International Business Machines
+* Corporation and others. All Rights Reserved.
+*******************************************************************************
+*
+* file name: $headername
+* encoding: UTF-8
+* tab size: 8 (not used)
+* indentation:4
+*
+* Created by: Perl script tools/genren.pl written by Vladimir Weinstein
+*
+* Contains data for renaming ICU exports.
+* Gets included by umachine.h
+*
+* THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
+* YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
+*/
+
+#ifndef $HEADERDEF
+#define $HEADERDEF
+
+/* U_DISABLE_RENAMING can be defined in the following ways:
+ * - when running configure, e.g.
+ * runConfigureICU Linux --disable-renaming
+ * - by changing the default setting of U_DISABLE_RENAMING in uconfig.h
+ */
+
+#include "unicode/uconfig.h"
+
+#if !U_DISABLE_RENAMING
+
+// Disable Renaming for Visual Studio's IntelliSense feature, so that 'Go-to-Definition' (F12) will work.
+#if !(defined(_MSC_VER) && defined(__INTELLISENSE__))
+
+/* We need the U_ICU_ENTRY_POINT_RENAME definition. There's a default one in unicode/uvernum.h we can use, but we will give
+ the platform a chance to define it first.
+ Normally (if utypes.h or umachine.h was included first) this will not be necessary as it will already be defined.
+ */
+
+#ifndef U_ICU_ENTRY_POINT_RENAME
+#include "unicode/umachine.h"
+#endif
+
+/* If we still don't have U_ICU_ENTRY_POINT_RENAME use the default. */
+#ifndef U_ICU_ENTRY_POINT_RENAME
+#include "unicode/uvernum.h"
+#endif
+
+/* Error out before the following defines cause very strange and unexpected code breakage */
+#ifndef U_ICU_ENTRY_POINT_RENAME
+#error U_ICU_ENTRY_POINT_RENAME is not defined - cannot continue. Consider defining U_DISABLE_RENAMING if renaming should not be used.
+#endif
+
+EndOfHeaderComment
+
+$fileCount = 0;
+$itemCount = 0;
+$symbolCount = 0;
+
+for(;@ARGV; shift(@ARGV)) {
+ $fileCount++;
+ @NMRESULT = `nm $nmopts $ARGV[0] $post`;
+ if($?) {
+ warn "Couldn't do 'nm' for $ARGV[0], continuing...\n";
+ next; # Couldn't do nm for the file
+ }
+ if($mode =~ /POSIX/) {
+ splice @NMRESULT, 0, 6;
+ } elsif ($mode =~ /Mach-O/) {
+# splice @NMRESULT, 0, 10;
+ }
+ foreach (@NMRESULT) { # Process every line of result and stuff it in $_
+ $itemCount++;
+ if($mode =~ /POSIX/) {
+ &verbose(" $_");
+ ($_, $address, $type) = split(/\|/);
+ chop $qtype;
+ } elsif ($mode =~ /Mach-O/) {
+ ($address, $type, $_) = split(/ /);
+ if(/^_(.*)$/) {
+ $_ = $1;
+ } else {
+ next;
+ }
+ } else {
+ die "Unknown mode $mode";
+ }
+ &verbose( "type: \"$type\" ");
+ if(!($type =~ /[UAwW?]/)) {
+ if(/@@/) { # These would be imports
+ &verbose( "Import: $_ \"$type\"\n");
+ &verbose( "C++ method: $_\n");
+ } elsif (/^[^\(]*::/) { # C++ methods, stuff class name in associative array
+ ## DON'T match ... ( foo::bar ... want :: to be to the left of paren
+ ## icu::CharString::~CharString(void) -> CharString
+ @CppName = split(/::/); ## remove scope stuff
+
+ if(@CppName>1) {
+ ## MessageFormat virtual table -> MessageFormat
+ if(! ($CppName[0] =~ /icu/ )) {
+ # *** WARNING Bad namespace (not 'icu') on ShoeSize::ShoeSize()
+ warn "*** WARNING Bad namespace (not 'icu') on $_\n";
+ next;
+ }
+ &verbose ( "(Chopping scope $CppName[0] )");
+ @CppName = split(/ /, $CppName[1]); ## remove debug stuff
+ }
+ ## ures_getUnicodeStringByIndex(UResourceBundle -> ures_getUnicodeStringByIndex
+ @CppName = split(/\(/, $CppName[0]); ## remove function args
+ if($CppName[0] =~ /^operator/) {
+ &verbose ("Skipping C++ function: $_\n");
+ } elsif($CppName[0] =~ /^~/) {
+ &verbose ("Skipping C++ destructor: $_\n");
+ } else {
+ &verbose( "Skipping C++ class: '$CppName[0]': $_ \n");
+ # $CppClasses{$CppName[0]}++;
+ # $symbolCount++;
+ }
+ } elsif ( my ($cfn) = m/^([A-Za-z0-9_]*)\(.*/ ) {
+ &verbose ( "$ARGV[0]: got global C++ function $cfn with '$_'\n" );
+ $CFuncs{$cfn}++;
+ $symbolCount++;
+ } elsif ( /\(/) { # These are strange functions
+ print STDERR "$ARGV[0]: Not sure what to do with '$_'\n";
+ } elsif ( /^_init/ ) {
+ &verbose( "$ARGV[0]: Skipped initializer $_\n" );
+ } elsif ( /^_fini/ ) {
+ &verbose( "$ARGV[0]: Skipped finilizer $_\n" );
+ } elsif ( /icu_/) {
+ print STDERR "$ARGV[0]: Skipped strange mangled function $_\n";
+ } elsif ( /^vtable for /) {
+ print STDERR "$ARGV[0]: Skipped vtable $_\n";
+ } elsif ( /^typeinfo/) {
+ print STDERR "$ARGV[0]: Skipped typeinfo $_\n";
+ } elsif ( /operator\+/ ) {
+ print STDERR "$ARGV[0]: Skipped ignored function $_\n";
+ } else { # This is regular C function
+ &verbose( "C func: $_\n");
+ @funcname = split(/[\(\s+]/);
+ $CFuncs{$funcname[0]}++;
+ $symbolCount++;
+ }
+ } else {
+ &verbose( "Skipped: $_ $1\n");
+ }
+ }
+}
+
+if( $fileCount == 0 ) {
+ die "Error: $itemCount lines from $fileCount files processed, but $symbolCount symbols were found.\n";
+}
+
+if( $symbolCount == 0 ) {
+ die "Error: $itemCount lines from $fileCount files processed, but $symbolCount symbols were found.\n";
+}
+
+print " Loaded $symbolCount symbols from $itemCount lines in $fileCount files.\n";
+
+print HEADER "\n/* C exports renaming data */\n\n";
+foreach(sort keys(%CFuncs)) {
+ print HEADER "#define $_ U_ICU_ENTRY_POINT_RENAME($_)\n";
+# print HEADER "#define $_ $_$U_ICU_VERSION_SUFFIX\n";
+}
+
+
+print HEADER <<"EndOfHeaderFooter";
+
+#endif /* !(defined(_MSC_VER) && defined(__INTELLISENSE__)) */
+#endif /* U_DISABLE_RENAMING */
+#endif /* URENAME_H */
+
+EndOfHeaderFooter
+
+
+close HEADER;
+
+sub verbose {
+ if($VERBOSE) {
+ print STDERR @_;
+ }
+}
+
+
+sub printHelpMsgAndExit {
+ print STDERR <<"EndHelpText";
+Usage: $0 [OPTIONS] LIBRARY_FILES
+ Options:
+ -v - verbose
+ -h - help
+ -o - output file name (defaults to 'urename.h'
+ -S - suffix (defaults to _MAJOR_MINOR of current ICU version)
+Will produce a renaming .h file
+
+EndHelpText
+
+ exit 0;
+
+}