diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /intl/icu/source/tools/genccode | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | intl/icu/source/tools/genccode/Makefile.in | 97 | ||||
-rw-r--r-- | intl/icu/source/tools/genccode/genccode.8.in | 108 | ||||
-rw-r--r-- | intl/icu/source/tools/genccode/genccode.c | 214 | ||||
-rw-r--r-- | intl/icu/source/tools/genccode/genccode.vcxproj | 80 | ||||
-rw-r--r-- | intl/icu/source/tools/genccode/genccode.vcxproj.filters | 22 | ||||
-rw-r--r-- | intl/icu/source/tools/genccode/sources.txt | 1 |
6 files changed, 522 insertions, 0 deletions
diff --git a/intl/icu/source/tools/genccode/Makefile.in b/intl/icu/source/tools/genccode/Makefile.in new file mode 100644 index 0000000000..6a1bab571b --- /dev/null +++ b/intl/icu/source/tools/genccode/Makefile.in @@ -0,0 +1,97 @@ +## Makefile.in for ICU - tools/genccode +## Copyright (C) 2016 and later: Unicode, Inc. and others. +## License & terms of use: http://www.unicode.org/copyright.html +## Copyright (c) 1999-2011, International Business Machines Corporation and +## others. All Rights Reserved. +## Steven R. Loomis + +## Source directory information +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ + +top_builddir = ../.. + +include $(top_builddir)/icudefs.mk + +## Build directory information +subdir = tools/genccode + +TARGET_STUB_NAME = genccode + +SECTION = 8 + +MAN_FILES = $(TARGET_STUB_NAME).$(SECTION) + + +## Extra files to remove for 'make clean' +CLEANFILES = *~ $(DEPS) $(MAN_FILES) + +## Target information +TARGET = $(BINDIR)/$(TARGET_STUB_NAME)$(EXEEXT) + +CPPFLAGS += -I$(top_srcdir)/common -I$(srcdir)/../toolutil +LIBS = $(LIBICUTOOLUTIL) $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M) + +SOURCES = $(shell cat $(srcdir)/sources.txt) +OBJECTS = $(SOURCES:.c=.o) + +DEPS = $(OBJECTS:.o=.d) + +## List of phony targets +.PHONY : all all-local install install-local clean clean-local \ +distclean distclean-local dist dist-local check check-local install-man + +## Clear suffix list +.SUFFIXES : + +## List of standard targets +all: all-local +install: install-local +clean: clean-local +distclean : distclean-local +dist: dist-local +check: all check-local + +all-local: $(TARGET) $(MAN_FILES) + +install-local: all-local install-man + $(MKINSTALLDIRS) $(DESTDIR)$(sbindir) + $(INSTALL) $(TARGET) $(DESTDIR)$(sbindir) + +install-man: $(MAN_FILES) + $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$(SECTION) + $(INSTALL_DATA) $? $(DESTDIR)$(mandir)/man$(SECTION) + +dist-local: + +clean-local: + test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) + $(RMV) $(TARGET) $(OBJECTS) + +distclean-local: clean-local + $(RMV) Makefile + +check-local: all-local + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(TARGET) : $(OBJECTS) + $(LINK.cc) $(OUTOPT)$@ $^ $(LIBS) + $(POST_BUILD_STEP) + + +%.$(SECTION): $(srcdir)/%.$(SECTION).in + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +ifeq (,$(MAKECMDGOALS)) +-include $(DEPS) +else +ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),) +-include $(DEPS) +endif +endif + diff --git a/intl/icu/source/tools/genccode/genccode.8.in b/intl/icu/source/tools/genccode/genccode.8.in new file mode 100644 index 0000000000..f39980db70 --- /dev/null +++ b/intl/icu/source/tools/genccode/genccode.8.in @@ -0,0 +1,108 @@ +.\" Hey, Emacs! This is -*-nroff-*- you know... +.\" +.\" genccode.8: manual page for the gennames utility +.\" +.\" Copyright (C) 2016 and later: Unicode, Inc. and others. +.\" License & terms of use: http://www.unicode.org/copyright.html +.\" Copyright (C) 2003-2004 IBM, Inc. and others. +.\" +.TH GENCCODE 8 "11 March 2004" "ICU MANPAGE" "ICU @VERSION@ Manual" +.SH NAME +.B genccode +\- generate C or platform specific assembly code from an ICU data file. +.SH SYNOPSIS +.B genccode +[ +.BR "\-h\fP, \fB\-?\fP, \fB\-\-help" +] +[ +.BI "\-a\fP, \fB\-\-assembly" " name" +] +[ +.BI "\-d\fP, \fB\-\-destdir" " destination" +] +[ +.BI "\-n\fP, \fB\-\-name" " name" +] +[ +.BI "\-e\fP, \fB\-\-entrypoint" " name" +] +[ +.BI "\-f\fP, \fB\-\-filename" " name" +] +[ +.IR filename " .\|.\|." +] +.SH DESCRIPTION +.B genccode +reads each of the supplied +.I filename +and writes out a C file containing a compilable definition of the data in +the data file. +The C file name is made by taking the base name of the data +.IR filename , +replacing dots by underscores, and adding a +.I .c +file extension. +.PP +If the \fB-a\fP option is used, platform specific assembly +code is generated instead of C code. +Most C compilers will accept both C and assembly files. +Instead of writing a filename with a +.I .c +file extension, a filename with a +.I .s +will be written instead. +.PP +If +.B genccode +is called with no +.I filename +it terminates gracefully. +.SH OPTIONS +.TP +.BR "\-h\fP, \fB\-?\fP, \fB\-\-help" +Print help about usage and exit. +.TP +.BI "\-a\fP, \fB\-\-assembly" " name" +Output assembly code instead of C code. +Use \fB-h\fP to see the list of available types of assembly to generate and +to specify for this option. +.TP +.BI "\-d\fP, \fB\-\-destdir" " destination" +Set the destination directory to +.IR destination . +The default destination directory is the current directory. +.TP +.BI "\-n\fP, \fB\-\-name" " name" +Set the data name to +.I name +instead of the default. This name is also used as the base name of the +output. The default name is made of the +.I icudt +prefix, followed by a two-digit version number corresponding to +the current version of the ICU release, and a single letter indicating +the endianness of the data (the letter +.I b +indicated big endian data, and the letter +.I l +indicates little endian ones). +.TP +.BI "\-f\fP, \fB\-\-filename" " name" +Normally, an ICU data file such as mydata.icu will be turned into mydata_icu.c and mydata_icu.o. +However, if this parameter was set to "somedata", the output files will be somedata.o and +somedata.c, respectively. +.TP +.BI "\-e\fP, \fB\-\-entrypoint" " name" +Set the data entry point (used for linking against the data in a +shared library form) to +.IR name . +The default entry point name is made of the data (set by the +.BI "\-n\fP, \fB\-\-name" +option) followed by an underscore and the type of the data (set by the +.BI "\-t\fP, \fB\-\-type" +option). +.SH VERSION +@VERSION@ +.SH COPYRIGHT +Copyright (C) 2000-2004 IBM, Inc. and others. diff --git a/intl/icu/source/tools/genccode/genccode.c b/intl/icu/source/tools/genccode/genccode.c new file mode 100644 index 0000000000..9fb7dbcdf2 --- /dev/null +++ b/intl/icu/source/tools/genccode/genccode.c @@ -0,0 +1,214 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +/* + ******************************************************************************* + * Copyright (C) 1999-2016, International Business Machines + * Corporation and others. All Rights Reserved. + ******************************************************************************* + * file name: gennames.c + * encoding: UTF-8 + * tab size: 8 (not used) + * indentation:4 + * + * created on: 1999nov01 + * created by: Markus W. Scherer + * + * This program reads a binary file and creates a C source code file + * with a byte array that contains the data of the binary file. + * + * 12/09/1999 weiv Added multiple file handling + */ + +#include "unicode/utypes.h" + +#if U_PLATFORM_HAS_WIN32_API +# define VC_EXTRALEAN +# define WIN32_LEAN_AND_MEAN +# define NOUSER +# define NOSERVICE +# define NOIME +# define NOMCX +#include <windows.h> +#include <time.h> +#endif + +#if U_PLATFORM_IS_LINUX_BASED && U_HAVE_ELF_H +# define U_ELF +#endif + +#ifdef U_ELF +# include <elf.h> +# if defined(ELFCLASS64) +# define U_ELF64 +# endif + /* Old elf.h headers may not have EM_X86_64, or have EM_X8664 instead. */ +# ifndef EM_X86_64 +# define EM_X86_64 62 +# endif +# define ICU_ENTRY_OFFSET 0 +#endif + +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include "unicode/putil.h" +#include "cmemory.h" +#include "cstring.h" +#include "filestrm.h" +#include "toolutil.h" +#include "unicode/uclean.h" +#include "uoptions.h" +#include "pkg_genc.h" + +enum { + kOptHelpH = 0, + kOptHelpQuestionMark, + kOptDestDir, + kOptQuiet, + kOptName, + kOptEntryPoint, +#ifdef CAN_GENERATE_OBJECTS + kOptObject, + kOptMatchArch, + kOptSkipDllExport, +#endif + kOptFilename, + kOptAssembly +}; + +static UOption options[]={ +/*0*/UOPTION_HELP_H, + UOPTION_HELP_QUESTION_MARK, + UOPTION_DESTDIR, + UOPTION_QUIET, + UOPTION_DEF("name", 'n', UOPT_REQUIRES_ARG), + UOPTION_DEF("entrypoint", 'e', UOPT_REQUIRES_ARG), +#ifdef CAN_GENERATE_OBJECTS +/*6*/UOPTION_DEF("object", 'o', UOPT_NO_ARG), + UOPTION_DEF("match-arch", 'm', UOPT_REQUIRES_ARG), + UOPTION_DEF("skip-dll-export", '\0', UOPT_NO_ARG), +#endif + UOPTION_DEF("filename", 'f', UOPT_REQUIRES_ARG), + UOPTION_DEF("assembly", 'a', UOPT_REQUIRES_ARG) +}; + +#define CALL_WRITECCODE 'c' +#define CALL_WRITEASSEMBLY 'a' +#define CALL_WRITEOBJECT 'o' +extern int +main(int argc, char* argv[]) { + UBool verbose = true; + char writeCode; + + U_MAIN_INIT_ARGS(argc, argv); + + options[kOptDestDir].value = "."; + + /* read command line options */ + argc=u_parseArgs(argc, argv, UPRV_LENGTHOF(options), options); + + /* error handling, printing usage message */ + if(argc<0) { + fprintf(stderr, + "error in command line argument \"%s\"\n", + argv[-argc]); + } + if(argc<0 || options[kOptHelpH].doesOccur || options[kOptHelpQuestionMark].doesOccur) { + fprintf(stderr, + "usage: %s [-options] filename1 filename2 ...\n" + "\tread each binary input file and \n" + "\tcreate a .c file with a byte array that contains the input file's data\n" + "options:\n" + "\t-h or -? or --help this usage text\n" + "\t-d or --destdir destination directory, followed by the path\n" + "\t-q or --quiet do not display warnings and progress\n" + "\t-n or --name symbol prefix, followed by the prefix\n" + "\t-e or --entrypoint entry point name, followed by the name (_dat will be appended)\n" + "\t-r or --revision Specify a version\n" + , argv[0]); +#ifdef CAN_GENERATE_OBJECTS + fprintf(stderr, + "\t-o or --object write a .obj file instead of .c\n" + "\t-m or --match-arch file.o match the architecture (CPU, 32/64 bits) of the specified .o\n" + "\t ELF format defaults to i386. Windows defaults to the native platform.\n" + "\t--skip-dll-export Don't export the ICU data entry point symbol (for use when statically linking)\n"); +#endif + fprintf(stderr, + "\t-f or --filename Specify an alternate base filename. (default: symbolname_typ)\n" + "\t-a or --assembly Create assembly file. (possible values are: "); + + printAssemblyHeadersToStdErr(); + } else { + const char *message, *filename; + /* TODO: remove void (*writeCode)(const char *, const char *); */ + + if(options[kOptAssembly].doesOccur) { + message="generating assembly code for %s\n"; + writeCode = CALL_WRITEASSEMBLY; + /* TODO: remove writeCode=&writeAssemblyCode; */ + + if (!checkAssemblyHeaderName(options[kOptAssembly].value)) { + fprintf(stderr, + "Assembly type \"%s\" is unknown.\n", options[kOptAssembly].value); + return -1; + } + } +#ifdef CAN_GENERATE_OBJECTS + else if(options[kOptObject].doesOccur) { + message="generating object code for %s\n"; + writeCode = CALL_WRITEOBJECT; + /* TODO: remove writeCode=&writeObjectCode; */ + } +#endif + else + { + message="generating C code for %s\n"; + writeCode = CALL_WRITECCODE; + /* TODO: remove writeCode=&writeCCode; */ + } + if (options[kOptQuiet].doesOccur) { + verbose = false; + } + while(--argc) { + filename=getLongPathname(argv[argc]); + if (verbose) { + fprintf(stdout, message, filename); + } + + switch (writeCode) { + case CALL_WRITECCODE: + writeCCode(filename, options[kOptDestDir].value, + options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL, + options[kOptName].doesOccur ? options[kOptName].value : NULL, + options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL, + NULL, + 0); + break; + case CALL_WRITEASSEMBLY: + writeAssemblyCode(filename, options[kOptDestDir].value, + options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL, + options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL, + NULL, + 0); + break; +#ifdef CAN_GENERATE_OBJECTS + case CALL_WRITEOBJECT: + writeObjectCode(filename, options[kOptDestDir].value, + options[kOptEntryPoint].doesOccur ? options[kOptEntryPoint].value : NULL, + options[kOptMatchArch].doesOccur ? options[kOptMatchArch].value : NULL, + options[kOptFilename].doesOccur ? options[kOptFilename].value : NULL, + NULL, + 0, + !options[kOptSkipDllExport].doesOccur); + break; +#endif + default: + /* Should never occur. */ + break; + } + /* TODO: remove writeCode(filename, options[kOptDestDir].value); */ + } + } + + return 0; +} diff --git a/intl/icu/source/tools/genccode/genccode.vcxproj b/intl/icu/source/tools/genccode/genccode.vcxproj new file mode 100644 index 0000000000..aad028f8c7 --- /dev/null +++ b/intl/icu/source/tools/genccode/genccode.vcxproj @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup Label="Globals"> + <ProjectGuid>{FDD3C4F2-9805-44EB-9A77-BC1C1C95B547}</ProjectGuid> + </PropertyGroup> + <PropertyGroup Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <!-- The following import will include the 'default' configuration options for VS projects. --> + <Import Project="..\..\allinone\Build.Windows.ProjectConfiguration.props" /> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir>.\$(Platform)\$(Configuration)\</OutDir> + <IntDir>.\$(Platform)\$(Configuration)\</IntDir> + <!-- The ICU projects use "Win32" to mean "x86", so we need to special case it. --> + <OutDir Condition="'$(Platform)'=='Win32'">.\x86\$(Configuration)\</OutDir> + <IntDir Condition="'$(Platform)'=='Win32'">.\x86\$(Configuration)\</IntDir> + <!-- Disable Incremental Linking for Release builds as it prevents Link-time Code Generation --> + <LinkIncremental Condition="'$(Configuration)'=='Debug'">true</LinkIncremental> + <LinkIncremental Condition="'$(Configuration)'=='Release'">false</LinkIncremental> + </PropertyGroup> + <!-- Options that are common to *all* configurations --> + <ItemDefinitionGroup> + <Midl> + <TypeLibraryName>$(OutDir)/genccode.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <CompileAs>Default</CompileAs> + <DisableLanguageExtensions>false</DisableLanguageExtensions> + <AdditionalIncludeDirectories>..\..\common;..\toolutil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PrecompiledHeaderOutputFile>$(OutDir)/genccode.pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>$(OutDir)/</AssemblerListingLocation> + <ObjectFileName>$(OutDir)/</ObjectFileName> + <ProgramDataBaseFileName>$(OutDir)/genccode.pdb</ProgramDataBaseFileName> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <OutputFile>$(OutDir)/genccode.exe</OutputFile> + <AdditionalLibraryDirectories>..\..\..\$(IcuLibOutputDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + </Link> + <CustomBuildStep> + <Command>copy "$(TargetPath)" ..\..\..\$(IcuBinOutputDir)</Command> + <Outputs>..\..\..\$(IcuBinOutputDir)\$(TargetFileName);%(Outputs)</Outputs> + </CustomBuildStep> + </ItemDefinitionGroup> + <!-- Options that are common to all 'Debug' project configurations --> + <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'"> + <ClCompile> + <BrowseInformation>true</BrowseInformation> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + </ClCompile> + <Link> + <AdditionalDependencies>icuucd.lib;icutud.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <!-- Options that are common to all 'Release' project configurations --> + <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'"> + <ClCompile> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + </ClCompile> + <Link> + <AdditionalDependencies>icuuc.lib;icutu.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="genccode.c" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/intl/icu/source/tools/genccode/genccode.vcxproj.filters b/intl/icu/source/tools/genccode/genccode.vcxproj.filters new file mode 100644 index 0000000000..87d4e05025 --- /dev/null +++ b/intl/icu/source/tools/genccode/genccode.vcxproj.filters @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{e71f343e-4f13-4d9f-a050-57e1a45e1d0e}</UniqueIdentifier> + <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{e7ef9b3f-40af-4fb6-a566-a733e6b718ee}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{a2128bc1-f7fe-41cb-bbbb-c298cb2b91db}</UniqueIdentifier> + <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="genccode.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/intl/icu/source/tools/genccode/sources.txt b/intl/icu/source/tools/genccode/sources.txt new file mode 100644 index 0000000000..d5eb02587e --- /dev/null +++ b/intl/icu/source/tools/genccode/sources.txt @@ -0,0 +1 @@ +genccode.c |