Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
1eed969b
Commit
1eed969b
authored
Jul 06, 2015
by
Lei Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Output wrapping #line directives for included content.
Also changed the includer interface to let it return the actual full path of the included file.
parent
2b4ebbb1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
20 deletions
+35
-20
preprocessor.include.disabled.vert.err
Test/baseResults/preprocessor.include.disabled.vert.err
+2
-2
preprocessor.include.enabled.vert.err
Test/baseResults/preprocessor.include.enabled.vert.err
+5
-5
Pp.cpp
glslang/MachineIndependent/preprocessor/Pp.cpp
+21
-7
ShaderLang.h
glslang/Public/ShaderLang.h
+7
-6
No files found.
Test/baseResults/preprocessor.include.disabled.vert.err
View file @
1eed969b
...
...
@@ -3,11 +3,11 @@ ERROR: 0:8000: '#include' : must be followed by a file designation
ERROR: 0:8001: '#include' : required extension not requested: GL_GOOGLE_include_directive
ERROR: 0:8001: '#include' : must be followed by a file designation
ERROR: 0:8002: '#include' : required extension not requested: GL_GOOGLE_include_directive
ERROR: 0:8002: '#
error
' : unexpected include directive
ERROR: 0:8002: '#
include
' : unexpected include directive
ERROR: 0:8003: '#include' : required extension not requested: GL_GOOGLE_include_directive
ERROR: 0:8003: '#include' : extra content after file designation
ERROR: 0:8004: '#include' : required extension not requested: GL_GOOGLE_include_directive
ERROR: 0:8004: '#
error
' : unexpected include directive
ERROR: 0:8004: '#
include
' : unexpected include directive
ERROR: 10 compilation errors. No code generated.
Test/baseResults/preprocessor.include.enabled.vert.err
View file @
1eed969b
ERROR: 0:8000: '#include' : must be followed by a file designation
ERROR: 0:8001: '#include' : must be followed by a file designation
ERROR: 0:8002: '#
error' : unexpected include directive
ERROR: 0:8003: '#include' : extra content after file designation
ERROR: 0:8004: '#
error' : unexpected include directive
ERROR: 0:8000: '#include' : must be followed by a file designation
ERROR: 0:8001: '#include' : must be followed by a file designation
ERROR: 0:8002: '#
include' : unexpected include directive
ERROR: 0:8003: '#include' : extra content after file designation
ERROR: 0:8004: '#
include' : unexpected include directive
ERROR: 5 compilation errors. No code generated.
glslang/MachineIndependent/preprocessor/Pp.cpp
View file @
1eed969b
...
...
@@ -83,6 +83,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdarg.h>
#include <stdio.h>
#include <sstream>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
...
...
@@ -605,23 +606,36 @@ int TPpContext::CPPinclude(TPpToken* ppToken)
// TODO: handle angle brackets.
parseContext
.
ppError
(
directiveLoc
,
"must be followed by a file designation"
,
"#include"
,
""
);
}
else
{
const
char
*
name
=
GetAtomString
(
ppToken
->
atom
);
// Make a copy of the name because it will be overwritten by the next token scan.
const
std
::
string
filename
=
ppToken
->
name
;
token
=
scanToken
(
ppToken
);
if
(
token
!=
'\n'
&&
token
!=
EndOfInput
)
{
parseContext
.
ppError
(
ppToken
->
loc
,
"extra content after file designation"
,
"#include"
,
""
);
}
else
{
if
(
!
inputStack
.
empty
())
ungetChar
()
;
std
::
string
sourceName
;
std
::
string
replacement
;
bool
success
;
std
::
tie
(
success
,
replacement
)
=
includer
.
include
(
name
);
if
(
success
)
{
pushInput
(
new
TokenizableString
(
directiveLoc
,
replacement
,
this
));
std
::
tie
(
sourceName
,
replacement
)
=
includer
.
include
(
filename
.
c_str
());
if
(
!
sourceName
.
empty
())
{
if
(
!
replacement
.
empty
())
{
const
bool
forNextLine
=
parseContext
.
lineDirectiveShouldSetNextLine
();
std
::
ostringstream
content
;
content
<<
"#line "
<<
forNextLine
<<
" "
<<
"
\"
"
<<
sourceName
<<
"
\"\n
"
;
content
<<
replacement
<<
(
replacement
.
back
()
==
'\n'
?
""
:
"
\n
"
);
content
<<
"#line "
<<
directiveLoc
.
line
+
forNextLine
<<
" "
;
if
(
directiveLoc
.
name
!=
nullptr
)
{
content
<<
"
\"
"
<<
directiveLoc
.
name
<<
"
\"
"
;
}
else
{
content
<<
directiveLoc
.
string
;
}
content
<<
"
\n
"
;
pushInput
(
new
TokenizableString
(
directiveLoc
,
content
.
str
(),
this
));
}
// At EOF, there's no "current" location anymore.
if
(
token
!=
EndOfInput
)
parseContext
.
setCurrentColumn
(
0
);
// Don't accidentally return EndOfInput, which will end all preprocessing.
return
'\n'
;
}
else
{
parseContext
.
ppError
(
ppToken
->
loc
,
"not found"
,
name
,
""
);
parseContext
.
ppError
(
directiveLoc
,
replacement
.
c_str
(),
"#include"
,
""
);
}
}
}
...
...
glslang/Public/ShaderLang.h
View file @
1eed969b
...
...
@@ -293,17 +293,18 @@ public:
// Interface to #include handlers.
class
Includer
{
public
:
// On success, returns true and the content that replaces "#include
// filename". On failure, returns false and an arbitrary string.
virtual
std
::
pair
<
bool
,
std
::
string
>
include
(
const
char
*
filename
)
const
=
0
;
// On success, returns the full path and content of the file with the given
// filename that replaces "#include filename". On failure, returns an empty
// string and an error message.
virtual
std
::
pair
<
std
::
string
,
std
::
string
>
include
(
const
char
*
filename
)
const
=
0
;
};
//
Generates #error as #include content
.
//
Returns an error message for any #include directive
.
class
ForbidInclude
:
public
Includer
{
public
:
std
::
pair
<
bool
,
std
::
string
>
include
(
const
char
*
filename
)
const
override
std
::
pair
<
std
::
string
,
std
::
string
>
include
(
const
char
*
filename
)
const
override
{
return
std
::
make_pair
<
bool
,
std
::
string
>
(
true
,
"#error unexpected include directive
\n
"
);
return
std
::
make_pair
<
std
::
string
,
std
::
string
>
(
""
,
"unexpected include directive
"
);
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment