llvm.org GIT mirror llvm / b13b025
[llvm-rc] Support '--' for delimiting options from input paths This allows avoiding conflicts between paths that begin with the same chars as some llvm-rc options (which can be used with either slashes or dashes). Differential Revision: https://reviews.llvm.org/D56743 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351305 91177308-0d34-0410-b5e6-96231b3b80d8 Martin Storsjo 7 months ago
22 changed file(s) with 34 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: touch %t.manifest
11 ; RUN: echo "1 24 \"%t.manifest\"" > %t.rc
2 ; RUN: llvm-rc %t.rc
2 ; RUN: llvm-rc -- %t.rc
None ; RUN: llvm-rc /C 65001 /FO %t.utf8.res %p/Inputs/utf8.rc
0 ; RUN: llvm-rc /C 65001 /FO %t.utf8.res -- %p/Inputs/utf8.rc
11 ; RUN: llvm-readobj %t.utf8.res | FileCheck %s --check-prefix=UTF8
22
33 ; UTF8: Resource type (int): 6
None ; RUN: llvm-rc /FO %t %p/Inputs/cpp-output.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/cpp-output.rc
11 ; RUN: llvm-readobj %t | FileCheck %s
22
33 ; CHECK: Resource type (int): 6
None ; RUN: llvm-rc /dry-run /FO %t %p/Inputs/empty.rc 2>&1 | FileCheck %s --allow-empty --check-prefix=FO
1 ; RUN: llvm-rc /dry-run /FO%t %p/Inputs/empty.rc 2>&1 | FileCheck %s --allow-empty --check-prefix=FO
0 ; RUN: llvm-rc /dry-run /FO %t -- %p/Inputs/empty.rc 2>&1 | FileCheck %s --allow-empty --check-prefix=FO
1 ; RUN: llvm-rc /dry-run /FO%t -- %p/Inputs/empty.rc 2>&1 | FileCheck %s --allow-empty --check-prefix=FO
22
33 ; FO-NOT: Exactly one input file should be provided.
0 ; Should find the bitmap if it is in the same folder as the rc file.
11 ; RUN: rm -f %t.include.res
2 ; RUN: llvm-rc /FO %t.include.res %p/Inputs/include.rc
2 ; RUN: llvm-rc /FO %t.include.res -- %p/Inputs/include.rc
33 ; RUN: llvm-readobj %t.include.res | FileCheck --check-prefix=FOUND %s
44
55 ; Try including files without quotes.
66 ; RUN: rm -f %t.noquotes.res
7 ; RUN: llvm-rc /FO %t.noquotes.res %p/Inputs/include-noquotes.rc
7 ; RUN: llvm-rc /FO %t.noquotes.res -- %p/Inputs/include-noquotes.rc
88 ; RUN: llvm-readobj %t.noquotes.res | FileCheck --check-prefix=FOUND %s
99
1010 ; Should find the bitmap if the folder is explicitly specified.
1111 ; RUN: rm -f %t.nested-include.res
12 ; RUN: llvm-rc /FO %t.nested-include.res /I %p/Inputs/nested %p/Inputs/deep-include.rc
12 ; RUN: llvm-rc /FO %t.nested-include.res /I %p/Inputs/nested -- %p/Inputs/deep-include.rc
1313 ; RUN: llvm-readobj %t.nested-include.res | FileCheck --check-prefix=FOUND %s
1414
1515 ; Otherwise, it should not find the bitmap.
1616 ; RUN: rm -f %t.nested-include.res
17 ; RUN: not llvm-rc /FO %t.nested-include.res %p/Inputs/deep-include.rc 2>&1 \
17 ; RUN: not llvm-rc /FO %t.nested-include.res -- %p/Inputs/deep-include.rc 2>&1 \
1818 ; RUN: | FileCheck --check-prefix=MISSING %s
1919
2020 ; Should find the bitmap if the process's current working directory
2323 ; failure of other tests if run first.
2424 ; RUN: rm -f %t.nested-include.res
2525 ; RUN: cd %p/Inputs/nested
26 ; RUN: llvm-rc /FO %t.nested-include.res %p/Inputs/include.rc
26 ; RUN: llvm-rc /FO %t.nested-include.res -- %p/Inputs/include.rc
2727 ; RUN: llvm-readobj %t.nested-include.res | FileCheck --check-prefix=FOUND %s
2828
2929 FOUND: Resource type (int): 2
None ; RUN: llvm-rc /FO %t %p/Inputs/memoryflags-stringtable.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/memoryflags-stringtable.rc
11 ; RUN: llvm-readobj %t | FileCheck %s
22
33 ; CHECK: Resource type (int): 6
None ; RUN: llvm-rc /FO %t %p/Inputs/memoryflags.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/memoryflags.rc
11 ; RUN: llvm-readobj %t | FileCheck %s
22
33 ; CHECK: Resource type (int): 1
None ; RUN: llvm-rc /FO %t %p/Inputs/not-expr.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/not-expr.rc
11 ; RUN: llvm-readobj %t | FileCheck %s --check-prefix=NOTEXPR
22
33 ; NOTEXPR: Resource type (int): 5
None ; RUN: llvm-rc /dry-run /V %p/Inputs/parser-expr.rc | FileCheck %s
0 ; RUN: llvm-rc /dry-run /V -- %p/Inputs/parser-expr.rc | FileCheck %s
11
22 ; CHECK: Language: 5, Sublanguage: 1
33 ; CHECK-NEXT: Language: 3, Sublanguage: 2
None ; RUN: llvm-rc /dry-run /V %p/Inputs/parser-correct-everything.rc | FileCheck %s --check-prefix PGOOD
0 ; RUN: llvm-rc /dry-run /V -- %p/Inputs/parser-correct-everything.rc | FileCheck %s --check-prefix PGOOD
11
22 ; PGOOD: Icon (meh): "hello.bmp"
33 ; PGOOD-NEXT: Icon (Icon): "Icon"
None ; RUN: llvm-rc /FO %t %p/Inputs/tag-accelerators.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/tag-accelerators.rc
11 ; RUN: llvm-readobj %t | FileCheck %s --check-prefix=ACCELERATORS
22
33 ; ACCELERATORS: Resource type (int): 9
None ; RUN: llvm-rc /FO %t %p/Inputs/tag-dialog.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/tag-dialog.rc
11 ; RUN: llvm-readobj %t | FileCheck %s --check-prefix=DIALOG
22
33 ; DIALOG: Resource type (int): 5
None ; RUN: llvm-rc /FO %t %p/Inputs/tag-escape.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/tag-escape.rc
11 ; RUN: llvm-readobj %t | FileCheck %s
22
33 ; CHECK: Resource type (int): 4
0 ; RUN: rm -rf %t && mkdir %t && cd %t
11 ; RUN: cp %p/Inputs/webpage*.html .
2 ; RUN: llvm-rc /FO %t/tag-html.res %p/Inputs/tag-html.rc
2 ; RUN: llvm-rc /FO %t/tag-html.res -- %p/Inputs/tag-html.rc
33 ; RUN: llvm-readobj %t/tag-html.res | FileCheck %s --check-prefix HTML
44
55 ; HTML: Resource type (int): 23
0 ; RUN: rm -rf %t
11 ; RUN: mkdir %t
22
3 ; RUN: llvm-rc /FO %t/tag-icon-cursor.res %p/Inputs/tag-icon-cursor.rc
3 ; RUN: llvm-rc /FO %t/tag-icon-cursor.res -- %p/Inputs/tag-icon-cursor.rc
44 ; RUN: llvm-readobj %t/tag-icon-cursor.res | FileCheck %s
55
66 ; CHECK: Resource type (int): 1
None ; RUN: llvm-rc /FO %t %p/Inputs/tag-menu.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/tag-menu.rc
11 ; RUN: llvm-readobj %t | FileCheck %s --check-prefix=MENU
22
33 ; Test running llvm-rc without an explicit output file.
44 ; RUN: cp %p/Inputs/tag-menu.rc %t.implicit.rc
5 ; RUN: llvm-rc %t.implicit.rc
5 ; RUN: llvm-rc -- %t.implicit.rc
66 ; RUN: llvm-readobj %t.implicit.res | FileCheck --check-prefix=MENU %s
77
88 ; MENU: Resource type (int): 4
None ; RUN: llvm-rc /FO %t %p/Inputs/tag-stringtable-basic.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/tag-stringtable-basic.rc
11 ; RUN: llvm-readobj %t | FileCheck %s
22
33 ; CHECK: Resource type (int): 6
11 ; RUN: mkdir %t
22 ; RUN: cd %t
33 ; RUN: cp %p/Inputs/bitmap.bmp .
4 ; RUN: llvm-rc /FO %t/tag-user.res %p/Inputs/tag-user.rc
4 ; RUN: llvm-rc /FO %t/tag-user.res -- %p/Inputs/tag-user.rc
55 ; RUN: llvm-readobj %t/tag-user.res | FileCheck %s
66
77 ; CHECK: Resource type (int): 500
None ; RUN: llvm-rc /FO %t %p/Inputs/tag-versioninfo.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/tag-versioninfo.rc
11 ; RUN: llvm-readobj %t | FileCheck %s
22
33 ; CHECK: Resource type (int): 16
None ; RUN: not llvm-rc /V /FO %t.res %p/Inputs/tokens.rc | FileCheck %s
0 ; RUN: not llvm-rc /V /FO %t.res -- %p/Inputs/tokens.rc | FileCheck %s
11 ; llvm-rc fails now on this sample because it is an invalid resource file
22 ; script. We silence the error message and just analyze the output.
33
None ; RUN: llvm-rc /FO %t %p/Inputs/versioninfo-padding.rc
0 ; RUN: llvm-rc /FO %t -- %p/Inputs/versioninfo-padding.rc
11 ; RUN: llvm-readobj %t | FileCheck %s
22
33 ; CHECK: Resource type (int): 16
3030 #include "llvm/Support/Signals.h"
3131 #include "llvm/Support/raw_ostream.h"
3232
33 #include
3334 #include
3435
3536 using namespace llvm;
8485
8586 RcOptTable T;
8687 unsigned MAI, MAC;
87 ArrayRef ArgsArr = makeArrayRef(Argv + 1, Argc - 1);
88 const char **DashDash = std::find_if(
89 Argv + 1, Argv + Argc, [](StringRef Str) { return Str == "--"; });
90 ArrayRef ArgsArr = makeArrayRef(Argv + 1, DashDash);
91
8892 opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
8993
9094 // The tool prints nothing when invoked with no command-line arguments.
96100 const bool BeVerbose = InputArgs.hasArg(OPT_VERBOSE);
97101
98102 std::vector InArgsInfo = InputArgs.getAllArgValues(OPT_INPUT);
103 if (DashDash != Argv + Argc)
104 InArgsInfo.insert(InArgsInfo.end(), DashDash + 1, Argv + Argc);
99105 if (InArgsInfo.size() != 1) {
100106 fatalError("Exactly one input file should be provided.");
101107 }