Merge "Prevent androidmk crash on art/tools/ahat/Android.mk"
This commit is contained in:
@@ -80,13 +80,25 @@ func (f *bpFile) addErrorText(message string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *bpFile) setMkPos(pos, end scanner.Position) {
|
func (f *bpFile) setMkPos(pos, end scanner.Position) {
|
||||||
if pos.Line < f.mkPos.Line {
|
// It is unusual but not forbidden for pos.Line to be smaller than f.mkPos.Line
|
||||||
panic(fmt.Errorf("out of order lines, %q after %q", pos, f.mkPos))
|
// For example:
|
||||||
}
|
//
|
||||||
|
// if true # this line is emitted 1st
|
||||||
|
// if true # this line is emitted 2nd
|
||||||
|
// some-target: some-file # this line is emitted 3rd
|
||||||
|
// echo doing something # this recipe is emitted 6th
|
||||||
|
// endif #some comment # this endif is emitted 4th; this comment is part of the recipe
|
||||||
|
// echo doing more stuff # this is part of the recipe
|
||||||
|
// endif # this endif is emitted 5th
|
||||||
|
//
|
||||||
|
// However, if pos.Line < f.mkPos.Line, we treat it as though it were equal
|
||||||
|
if pos.Line >= f.mkPos.Line {
|
||||||
f.bpPos.Line += (pos.Line - f.mkPos.Line)
|
f.bpPos.Line += (pos.Line - f.mkPos.Line)
|
||||||
f.mkPos = end
|
f.mkPos = end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
type conditional struct {
|
type conditional struct {
|
||||||
cond string
|
cond string
|
||||||
eq bool
|
eq bool
|
||||||
|
@@ -425,6 +425,41 @@ cc_library_shared {
|
|||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// the important part of this test case is that it confirms that androidmk doesn't
|
||||||
|
// panic in this case
|
||||||
|
desc: "multiple directives inside recipe",
|
||||||
|
in: `
|
||||||
|
ifeq ($(a),true)
|
||||||
|
ifeq ($(b),false)
|
||||||
|
imABuildStatement: somefile
|
||||||
|
echo begin
|
||||||
|
endif # a==true
|
||||||
|
echo middle
|
||||||
|
endif # b==false
|
||||||
|
echo end
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
// ANDROIDMK TRANSLATION ERROR: unsupported conditional
|
||||||
|
// ifeq ($(a),true)
|
||||||
|
|
||||||
|
// ANDROIDMK TRANSLATION ERROR: unsupported conditional
|
||||||
|
// ifeq ($(b),false)
|
||||||
|
|
||||||
|
// ANDROIDMK TRANSLATION ERROR: unsupported line
|
||||||
|
// rule: imABuildStatement: somefile
|
||||||
|
// echo begin
|
||||||
|
// # a==true
|
||||||
|
// echo middle
|
||||||
|
// # b==false
|
||||||
|
// echo end
|
||||||
|
//
|
||||||
|
// ANDROIDMK TRANSLATION ERROR: endif from unsupported contitional
|
||||||
|
// endif
|
||||||
|
// ANDROIDMK TRANSLATION ERROR: endif from unsupported contitional
|
||||||
|
// endif
|
||||||
|
`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func reformatBlueprint(input string) string {
|
func reformatBlueprint(input string) string {
|
||||||
|
Reference in New Issue
Block a user