1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
Commit Graph

37 Commits

Author SHA1 Message Date
Martin Storsjo
b5caa2c2e4 [llvm-rc] Support not expressions.
Patch by Jacek Caban!

Differential Revision: https://reviews.llvm.org/D55242

llvm-svn: 348363
2018-12-05 13:22:56 +00:00
Martin Storsjo
d9380b2548 [llvm-rc] Support EXSTYLE statement.
Patch by Jacek Caban!

Differential Revision: https://reviews.llvm.org/D55020

llvm-svn: 347858
2018-11-29 12:17:39 +00:00
Petr Hosek
5b64a421da [llvm-rc] Support joined or separate spelling for /fo flag
CMake invokes rc using the joined spelling which appears to be supported
by Microsoft's rc implementation, so we should support it as well.

Differential Revision: https://reviews.llvm.org/D54191

llvm-svn: 346470
2018-11-09 03:16:53 +00:00
Martin Storsjo
059282774a [llvm-rc] Add support for the optional CLASS statement for dialogs
Differential Revision: https://reviews.llvm.org/D46875

llvm-svn: 332386
2018-05-15 19:21:28 +00:00
Martin Storsjo
19d53b6f8f [llvm-rc] Add support for parsing memory flags
Most of the handling is pretty straightforward; fetch the default
memory flags for the specific resource type before parsing the flags
and apply them on top of that, except that some flags imply others
and some flags clear more than one flag.

For icons and cursors, the flags set get passed on to all individual
single icon/cursor resources, while only some flags affect the icon/cursor
group resource.

For stringtables, the behaviour is pretty simple; the first stringtable
resource of a bundle sets the flags for the whole bundle.

The output of these tests match rc.exe byte for byte.

The actual use of these memory flags is deprecated and they have no
effect since Win16, but some resource script files may still happen
to have them in place.

Differential Revision: https://reviews.llvm.org/D46818

llvm-svn: 332329
2018-05-15 06:35:29 +00:00
Martin Storsjo
0b36643562 [llvm-rc] Add missing inputs for tag-icon-cursor.test.
This adds the missing input files used for this test, except for
the separate input files for specific error cases; matching
test input files were provided by Nico Weber.

The extra copying of files into the %t directory doesn't seem to
be necessary since that directory only ever is used for output here,
not for inputs.

Differential Revision: https://reviews.llvm.org/D46813

llvm-svn: 332297
2018-05-14 21:32:47 +00:00
Martin Storsjo
4b44f3b8e4 [llvm-rc] Handle C preprocessor output
When preprocessing resource scripts (which can easily be done outside
of llvm-rc), included headers can leave behind C declarations (despite
preprocessing with -DRC_INVOKED), that can't be parsed by a resource
compiler.

This is handled in all of rc.exe, by parsing the preprocessor output
line markers and ignoring content from files named *.h and *.c,
documented at [1].

In addition to this filtering, strip out any other preprocessor directive
that is left behind (like pragmas) which also can't be handled by the
tokenizer.

The added test uses both standard #line markers (supported by rc.exe) and
GNU style extended line markers, thus this test doesn't pass with rc.exe,
but passes with GNU windres. (Windres on the other hand doesn't filter
out files named *.c, only *.h.)

Differential Revision: https://reviews.llvm.org/D46579

[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa381033(v=vs.85).aspx

llvm-svn: 331903
2018-05-09 18:21:03 +00:00
Martin Storsjo
37d98c95b4 [llvm-rc] Add support for the RCDATA resource type
This is the same as any other user defined resource, but with
a specific allocated resource type number.

Differential Revision: https://reviews.llvm.org/D46636

llvm-svn: 331902
2018-05-09 18:20:56 +00:00
Martin Storsjo
ccb3a2484c [llvm-rc] Allow -1 for control IDs in old style dialogs with 16 bit fields
-1 is commonly used as ID for controls that one don't want to
refer to later. For DIALOG resources, the IDs are 16 bit numbers,
and -1 gets interpreted as UINT32_MAX earlier, which then later is
too large to write into a uint16_t.

Differential Revision: https://reviews.llvm.org/D46506

llvm-svn: 331901
2018-05-09 18:20:49 +00:00
Martin Storsjo
73a1fb1cfc [llvm-rc] Add support for all missing dialog controls
Differential Revision: https://reviews.llvm.org/D46507

llvm-svn: 331808
2018-05-08 20:55:58 +00:00
Martin Storsjo
86c2d3ee20 [llvm-rc] Don't strictly require quotes around external file names
Regardless of what docs may say, existing resource files in the
wild can use this syntax.

Rename a file used in an existing test, to make it usable for unquoted
paths.

Differential Revision: https://reviews.llvm.org/D46511

llvm-svn: 331747
2018-05-08 08:47:37 +00:00
Martin Storsjo
9ea045a3c6 [llvm-rc] Allow optional commas between the string table index and value
This form is even used in one of the examples at
https://msdn.microsoft.com/en-us/library/windows/desktop/aa381050(v=vs.85).aspx.

Differential Revision: https://reviews.llvm.org/D46508

llvm-svn: 331669
2018-05-07 20:27:28 +00:00
Martin Storsjo
2e58ad8a52 [llvm-rc] Exclude padding from sizes in versioninfo resources
Normally when writing something that requires padding, we first
measure the length of the written payload data, then write
padding if necessary.

For a recursive structure like versioninfo, this means that the
padding is excluded from the size of the inner element, but
included in the size of the enclosing block.

Rc.exe excludes the final padding (but not the padding of earlier
children) from all levels of the hierarchy.

To achieve this, don't pad after each block or value, but only
before starting the next one. We still pad after completing the
toplevel versioninfo resource, so this won't affect other resource
types.

Differential Revision: https://reviews.llvm.org/D46510

llvm-svn: 331668
2018-05-07 20:27:23 +00:00
Martin Storsjo
6a5bc398fd [llvm-rc] Add rudimentary support for codepages
Only support UTF-8 (since LLVM contains UTF-8 parsing support
already, and the code even does that already) and Windows-1252
(where most code points has the same value in unicode). Keep the
existing default as only allowing ASCII input.

Using the option type JoinedOrSeparate, since the real rc.exe
handles options in this form, even if llvm-rc uses Separate for
other similar existing options.

Rename the struct SearchParams to WriterParams since it's now used
for more than just include paths.

Add a missing getResourceTypeName method to the BundleResource class,
to fix error printing from within STRINGTABLE resources (used in
tests).

Differential Revision: https://reviews.llvm.org/D46238

llvm-svn: 331391
2018-05-02 19:43:44 +00:00
Zachary Turner
1a5684f1d0 [llvm-rc] Use proper search algorithm for finding resources.
Previously we would only look in the current directory for a
resource, which might not be the same as the directory of the
rc file.  Furthermore, MSVC rc supports a /I option, and can
also look in the system environment.  This patch adds support
for this search algorithm.

Differential Revision: https://reviews.llvm.org/D38740

llvm-svn: 315499
2017-10-11 20:12:09 +00:00
Zachary Turner
738623f975 [llvm-rc] Have the tokenizer discard single & block comments.
This allows rc files to have comments.  Eventually we should
just use clang's c preprocessor, but that's a bit larger
effort for minimal gain, and this is straightforward.

Differential Revision: https://reviews.llvm.org/D38651

llvm-svn: 315207
2017-10-09 15:46:13 +00:00
Zachary Turner
acd37087f2 [llvm-rc] Implement escape sequences in .rc files.
This allows the escape sequences (\a, \n, \r, \t, \\, \x[0-9a-f]*,
\[0-7]*, "") to appear in .rc scripts. These are parsed and output in
the same way as it's done in original MS implementation.

The way these sequences are processed depends on the type of the
resource it resides in, and on whether the user declared the string to
be "wide" or "narrow".

I tried to maintain the maximum compatibility with the original tool
(and fail in some erroneous situations that are accepted by .rc).
However, there are some (extremely rare) cases where Microsoft tool
outputs nonsense. I found it infeasible to detect such casses.

Patch by Marek Sokolowski

Differential Revision: https://reviews.llvm.org/D38426

llvm-svn: 315118
2017-10-06 22:05:15 +00:00
Zachary Turner
ab4c2ad7c5 [llvm-rc] Serialize user-defined resources to .res files.
This allows rc to serialize user-defined resources, as
documented at:

msdn.microsoft.com/en-us/library/windows/desktop/aa381054.aspx

Escape sequences are yet unavailable, and are to be added in one of
child patches.

Patch by: Marek Sokolowski

Differential Revision: https://reviews.llvm.org/D38423

llvm-svn: 315117
2017-10-06 21:52:15 +00:00
Zachary Turner
3dd4f77b2e [llvm-rc] Serialize STRINGTABLE statements to .res file.
This allows llvm-rc to serialize STRINGTABLE resources.

These are output in an unusual way: we locate them at the end of the
file, and strings are merged into bundles of max 16 strings, depending
on their IDs, language, and characteristics.

Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa381050.aspx

Patch by: Marek Sokolowski
Differential Revision: https://reviews.llvm.org/D38420

llvm-svn: 315112
2017-10-06 21:30:55 +00:00
Zachary Turner
761f2d07b0 [llvm-rc] Serialize VERSIONINFO resources to .res files.
This is now able to dump VERSIONINFO resources.

Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa381058.aspx

Differential Revision: https://reviews.llvm.org/D38410
Patch by: Marek Sokolowski

llvm-svn: 315110
2017-10-06 21:26:06 +00:00
Zachary Turner
e5d5fbb1ef [llvm-rc] Serialize CURSOR and ICON resources to .res
This is part 6 of llvm-rc serialization.

This adds ability to output cursors and icons as resources.

Unfortunately, we can't just copy .cur or .ico files to output - as each
file might contain multiple images, each of them needs to be unpacked
and stored as a separate resource. This forces us to parse cursor and
icon contents. (Fortunately, these formats are pretty similar and can be
processed by mostly common code).

As test files are binary, here is a short explanation of .cur and .ico
files stored:

cursor.cur, cursor-8.cur, cursor-32.cur are sample correct cursor files,
differing in their bit depth.

icon-old.ico, icon-new.ico are sample correct icon files;

icon-png.ico is a sample correct icon file in PNG format (instead of
usual BMP);

cursor-eof.cur is an incorrect cursor file - this is cursor.cur with
some of its final bytes removed.

cursor-bad-offset.cur is an incorrect cursor file - image header states
that image data begins at offset 0xFFFFFFFF.

Sample correct cursors and icons were created by Nico Weber.

Patch by Marek Sokolowski
Differential Revision: https://reviews.llvm.org/D37878

llvm-svn: 315109
2017-10-06 21:25:44 +00:00
Zachary Turner
c7eb72c5a8 [llvm-rc] Add optional serialization support for DIALOG(EX) resources.
This is part 5 of llvm-rc serialization support.

This allows DIALOG and DIALOGEX to serialize if dialog-specific optional
statements are provided. These are (as of now): CAPTION, FONT, and
STYLE.

Notably, FONT statement can take more than two arguments when describing
DIALOGEX resources (as in
msdn.microsoft.com/en-us/library/windows/desktop/aa381013.aspx). I made
some changes to the parser to reflect this fact.

Patch by Marek Sokolowski
Differential Revision: https://reviews.llvm.org/D37864

llvm-svn: 315104
2017-10-06 20:51:20 +00:00
Marek Sokolowski
22a04dbf48 [llvm-rc] Serialize DIALOG(EX) to .res files (serialization, pt 4).
This is now able to serialize DIALOG and DIALOGEX resources to .res
files. It still can't parse dialog-specific CAPTION, FONT, and STYLE
optional statement - these will be added in the following patch.

A limited set of controls is included. However, more can be easily added
by extending SupportedCtls map defined in ResourceScriptStmt.cpp.

Differential Revision: https://reviews.llvm.org/D37862

llvm-svn: 314578
2017-09-30 00:38:52 +00:00
Marek Sokolowski
138f2c0ded [llvm-rc] Serialize MENU resources to .res files (serialization, pt 3).
This allows MENU resources to be serialized.

MENU resource statement doc:
msdn.microsoft.com/en-us/library/windows/desktop/aa381025.aspx
POPUP sub-statement doc:
msdn.microsoft.com/en-us/library/windows/desktop/aa381030.aspx
MENUITEM sub-statement doc:
msdn.microsoft.com/en-us/library/windows/desktop/aa381024.aspx
MENUHEADER structure:
msdn.microsoft.com/en-us/library/windows/desktop/ms648018.aspx (and
NORMALMENUITEM, POPUPMENUITEM structs).

Thanks for Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D37828

llvm-svn: 314562
2017-09-29 22:25:05 +00:00
Marek Sokolowski
b0678b080e [llvm-rc] Serialize ACCELERATORS to .res files (serialization, pt 2).
This allows llvm-rc to serialize ACCELERATORS resources.

Additionally, as this is the first type of resource to support basic
optional resource statements (LANGUAGE, CHARACTERISTICS, VERSION),

ACCELERATORS statement documentation:
msdn.microsoft.com/en-us/library/windows/desktop/aa380610.aspx
Accelerator table structure documentation:
msdn.microsoft.com/en-us/library/windows/desktop/ms648010.aspx
Optional resource statement fields are described in:
msdn.microsoft.com/en-us/library/windows/desktop/ms648027.aspx

Thanks for Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D37824

llvm-svn: 314549
2017-09-29 19:07:44 +00:00
Marek Sokolowski
f3fcbe4a9d [llvm-rc] Serialize HTML resources to .res files (serialization, pt 1).
This allows to process HTML resources defined in .rc scripts and output
them to resulting .res files. Additionally, some infrastructure allowing
to output these files is created.

This is the first resource type we can operate on.

Thanks to Nico Weber for his original work in this area.

Differential Revision: reviews.llvm.org/D37283

llvm-svn: 314538
2017-09-29 17:14:09 +00:00
Marek Sokolowski
ad66b459bd [llvm-rc] Add user-defined resources parsing ability. [8/8]
This allows llvm-rc to parse user-defined resources (ref:
msdn.microsoft.com/en-us/library/windows/desktop/aa381054.aspx).
These statements either import files, or put the specified raw data in
the resulting resource file.

Thanks to Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D37033

llvm-svn: 314478
2017-09-29 00:14:18 +00:00
Marek Sokolowski
469da485f8 [llvm-rc] Add integer expressions parsing ability. [7/8]
This allows the ints to be written as integer expressions evaluating to
unsigned 16-bit/32-bit integers.

All the expressions may use the following operators: + - & | ~, and
parentheses. Minus token - can be also unary. There is no precedence of
the operators other than the unary operators binding stronger than their
binary counterparts.

Differential Revision: https://reviews.llvm.org/D37022

llvm-svn: 314477
2017-09-28 23:53:25 +00:00
Marek Sokolowski
7414d53a94 [llvm-rc] Add VERSIONINFO parsing ability. [6/8]
This extends the set of llvm-rc parser's available resources by
another one, VERSIONINFO.

Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa381058.aspx

Thanks to Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D37021

llvm-svn: 314468
2017-09-28 22:41:38 +00:00
Marek Sokolowski
b1004cdc09 [llvm-rc] Add DIALOG(EX) parsing ability (parser, pt 5/8).
This extends the set of resources parsed by llvm-rc by DIALOG and
DIALOGEX.

Additionally, three optional resource statements specific to these two
resources are added: CAPTION, FONT, and STYLE.

Thanks for Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D36905

llvm-svn: 312009
2017-08-29 16:49:59 +00:00
Marek Sokolowski
b2df2ba5d2 [llvm-rc] Add MENU parsing ability (parser, pt 4/8).
This extends llvm-rc parsing tool by MENU resource
(msdn.microsoft.com/en-us/library/windows/desktop/aa381025(v=vs.85).aspx).
As for now, MENUEX
(msdn.microsoft.com/en-us/library/windows/desktop/aa381023(v=vs.85).aspx)
seems unnecessary.

Thanks for Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D36898

llvm-svn: 311956
2017-08-28 23:46:30 +00:00
Marek Sokolowski
fb87fd513f [llvm-rc] Add ACCELERATORS parsing ability. (parser, pt 3/8).
This improves the current llvm-rc parser by the ability of parsing
ACCELERATORS statement.

Moreover, some small improvements to the original parsing commit
were made.

Thanks for Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D36894

llvm-svn: 311946
2017-08-28 22:58:31 +00:00
Marek Sokolowski
4f9f1f7705 [llvm-rc] Add ICON and HTML parsing ability (parser, pt 2/8).
This extends the current llvm-rc parser by ICON and HTML resources.
Moreover, some tests have been slightly rewritten.

Thanks for Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D36891

llvm-svn: 311939
2017-08-28 21:59:54 +00:00
Marek Sokolowski
0cbccbe294 Reapply: [llvm-rc] Add basic RC scripts parsing ability.
As for now, the parser supports a limited set of statements and
resources. This will be extended in the following patches.

Thanks to Nico Weber (thakis) for his original work in this area.

This patch was originally submitted as r311175 and got reverted
in r311177 because of the problems with compilation under gcc.

Differential Revision: https://reviews.llvm.org/D36340

llvm-svn: 311184
2017-08-18 18:24:17 +00:00
Marek Sokolowski
aea1c80dd2 Revert "[llvm-rc] Add basic RC scripts parsing ability."
This reverts commit r311175.

This failed some buildbots compilation.

llvm-svn: 311177
2017-08-18 17:25:55 +00:00
Marek Sokolowski
0823f275d4 [llvm-rc] Add basic RC scripts parsing ability.
As for now, the parser supports a limited set of statements and
resources. This will be extended in the following patches.

Thanks to Nico Weber (thakis) for his original work in this area.

Differential Revision: https://reviews.llvm.org/D36340

llvm-svn: 311175
2017-08-18 17:05:47 +00:00
Marek Sokolowski
d1ef0296e8 Add .rc scripts tokenizer.
This extends the shell of llvm-rc tool with the ability of tokenization
of the input files. Currently, ASCII and ASCII-compatible UTF-8 files
are supported.

Thanks to Nico Weber (thakis) for his original work in this area.

Differential Revision: https://reviews.llvm.org/D35957

llvm-svn: 310621
2017-08-10 16:21:44 +00:00