mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Interrogate include-path alterations
This commit is contained in:
parent
79c549108a
commit
1e7c8513c3
@ -1397,35 +1397,40 @@ handle_include_directive(const string &args, int first_line,
|
|||||||
|
|
||||||
found_file = false;
|
found_file = false;
|
||||||
|
|
||||||
|
// Search the current directory.
|
||||||
if (!angle_quotes && !found_file && filename.exists()) {
|
if (!angle_quotes && !found_file && filename.exists()) {
|
||||||
found_file = true;
|
found_file = true;
|
||||||
source = CPPFile::S_local;
|
source = CPPFile::S_local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Search the same directory as the includer.
|
||||||
if (!angle_quotes && !found_file) {
|
if (!angle_quotes && !found_file) {
|
||||||
DSearchPath local_search_path(Filename(get_file()._filename.get_dirname()));
|
Filename match(get_file()._filename.get_dirname(), filename);
|
||||||
|
if (match.exists()) {
|
||||||
// Now look for it in the same directory as the includer.
|
filename = match;
|
||||||
if (!found_file && filename.resolve_filename(local_search_path)) {
|
|
||||||
found_file = true;
|
found_file = true;
|
||||||
source = CPPFile::S_alternate;
|
source = CPPFile::S_alternate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now look for it on the primary include path. We have to search
|
// Now search the angle-include-path
|
||||||
// this path, even if the file was named with angle quotes, so
|
if (angle_quotes && !found_file && filename.resolve_filename(_angle_include_path)) {
|
||||||
// that we will search parser-inc before the system path.
|
|
||||||
if (!found_file && filename.resolve_filename(_include_path)) {
|
|
||||||
found_file = true;
|
|
||||||
source = CPPFile::S_alternate;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now look for it on the system include path.
|
|
||||||
if (!found_file && filename.resolve_filename(_system_include_path)) {
|
|
||||||
found_file = true;
|
found_file = true;
|
||||||
source = CPPFile::S_system;
|
source = CPPFile::S_system;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now search the quote-include-path
|
||||||
|
if (!angle_quotes && !found_file) {
|
||||||
|
for (int dir=0; dir<_quote_include_path.get_num_directories(); dir++) {
|
||||||
|
Filename match(_quote_include_path.get_directory(dir), filename);
|
||||||
|
if (match.exists()) {
|
||||||
|
filename = match;
|
||||||
|
found_file = true;
|
||||||
|
source = _quote_include_kind[dir];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!found_file) {
|
if (!found_file) {
|
||||||
warning("Cannot find " + filename.get_fullpath(),
|
warning("Cannot find " + filename.get_fullpath(),
|
||||||
first_line, first_col, first_file);
|
first_line, first_col, first_file);
|
||||||
|
@ -75,8 +75,9 @@ public:
|
|||||||
typedef map<string, CPPManifest *> Manifests;
|
typedef map<string, CPPManifest *> Manifests;
|
||||||
Manifests _manifests;
|
Manifests _manifests;
|
||||||
|
|
||||||
DSearchPath _include_path;
|
pvector<CPPFile::Source> _quote_include_kind;
|
||||||
DSearchPath _system_include_path;
|
DSearchPath _quote_include_path;
|
||||||
|
DSearchPath _angle_include_path;
|
||||||
|
|
||||||
CPPComments _comments;
|
CPPComments _comments;
|
||||||
|
|
||||||
|
@ -327,13 +327,16 @@ main(int argc, char *argv[]) {
|
|||||||
case 'I':
|
case 'I':
|
||||||
fn = Filename::from_os_specific(optarg);
|
fn = Filename::from_os_specific(optarg);
|
||||||
fn.make_absolute();
|
fn.make_absolute();
|
||||||
parser._include_path.append_directory(fn);
|
parser._quote_include_path.append_directory(fn);
|
||||||
|
parser._quote_include_kind.push_back(CPPFile::S_alternate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
fn = Filename::from_os_specific(optarg);
|
fn = Filename::from_os_specific(optarg);
|
||||||
fn.make_absolute();
|
fn.make_absolute();
|
||||||
parser._system_include_path.append_directory(fn);
|
parser._angle_include_path.append_directory(fn);
|
||||||
|
parser._quote_include_path.append_directory(fn);
|
||||||
|
parser._quote_include_kind.push_back(CPPFile::S_system);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
|
@ -217,11 +217,14 @@ main(int argc, char *argv[]) {
|
|||||||
while (flag != EOF) {
|
while (flag != EOF) {
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
case 'I':
|
case 'I':
|
||||||
parser._include_path.append_directory(optarg);
|
parser._quote_include_path.append_directory(optarg);
|
||||||
|
parser._quote_include_kind.push_back(CPPFile::S_alternate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
parser._system_include_path.append_directory(optarg);
|
parser._angle_include_path.append_directory(optarg);
|
||||||
|
parser._quote_include_path.append_directory(optarg);
|
||||||
|
parser._quote_include_kind.push_back(CPPFile::S_system);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user