From 0a72ac45c5ba0a5a2c13cb55ed6bfda127fe8617 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 1 Oct 2012 20:47:11 +0000 Subject: [PATCH] fix some issues with platform matching --- direct/src/plugin/p3dHost.cxx | 31 ++++++++++++++++++++++++++----- direct/src/plugin/p3dPackage.cxx | 5 +++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/direct/src/plugin/p3dHost.cxx b/direct/src/plugin/p3dHost.cxx index e9155ca4d5..83d683a220 100644 --- a/direct/src/plugin/p3dHost.cxx +++ b/direct/src/plugin/p3dHost.cxx @@ -458,7 +458,10 @@ choose_suitable_platform(string &selected_platform, const string &package_name, const string &package_version, const string &package_platform) { + nout << "choose_suitable_platform(" << package_name << ", " + << package_version << ", " << package_platform << ")\n"; if (_xcontents == NULL) { + nout << " xcontents is null\n"; return false; } @@ -466,9 +469,9 @@ choose_suitable_platform(string &selected_platform, TiXmlElement *xpackage; - // For the "panda3d" package only, we allow searching for any - // available supported platform. - if (package_name == "panda3d" && package_platform == "") { + // If the platform is initially unspecified, we allow searching for + // any available supported platform. + if (package_platform == "") { int num_supported_platforms = inst_mgr->get_num_supported_platforms(); for (int pi = 0; pi < num_supported_platforms; ++pi) { string supported_platform = inst_mgr->get_supported_platform(pi); @@ -477,16 +480,20 @@ choose_suitable_platform(string &selected_platform, const char *name = xpackage->Attribute("name"); const char *platform = xpackage->Attribute("platform"); const char *version = xpackage->Attribute("version"); + if (platform == NULL) { + platform = ""; + } if (version == NULL) { version = ""; } - if (name != NULL && platform != NULL && + if (name != NULL && package_name == name && supported_platform == platform && package_version == version) { // Here's the matching package definition. selected_platform = platform; per_platform = parse_bool_attrib(xpackage, "per_platform", false); + nout << " found match for " << selected_platform << "\n"; return true; } @@ -497,28 +504,37 @@ choose_suitable_platform(string &selected_platform, // Now, we look for an exact match for the expected platform. xpackage = _xcontents->FirstChildElement("package"); + nout << " scanning, xpackage = " << xpackage << "\n"; while (xpackage != NULL) { const char *name = xpackage->Attribute("name"); const char *platform = xpackage->Attribute("platform"); const char *version = xpackage->Attribute("version"); + if (platform == NULL) { + platform = ""; + } if (version == NULL) { version = ""; } - if (name != NULL && platform != NULL && + nout << " considering " << name << ", " << platform << ", " << version + << "\n"; + if (name != NULL && package_name == name && package_platform == platform && package_version == version) { // Here's the matching package definition. + nout << " match!\n"; selected_platform = platform; per_platform = parse_bool_attrib(xpackage, "per_platform", false); return true; } + nout << " no match.\n"; xpackage = xpackage->NextSiblingElement("package"); } // Look one more time, this time looking for a non-platform-specific // version. + nout << " further scanning\n"; xpackage = _xcontents->FirstChildElement("package"); while (xpackage != NULL) { const char *name = xpackage->Attribute("name"); @@ -536,6 +552,7 @@ choose_suitable_platform(string &selected_platform, package_version == version) { selected_platform = platform; per_platform = parse_bool_attrib(xpackage, "per_platform", false); + nout << " found empty platform\n"; return true; } @@ -543,6 +560,7 @@ choose_suitable_platform(string &selected_platform, } // Couldn't find a suitable platform. + nout << " couldn't find.\n"; return false; } @@ -579,6 +597,9 @@ get_package_desc_file(FileSpec &desc_file, // out const char *version = xpackage->Attribute("version"); const char *seq = xpackage->Attribute("seq"); const char *solo = xpackage->Attribute("solo"); + if (platform == NULL) { + platform = ""; + } if (version == NULL) { version = ""; } diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index 19f85a59fa..bb85878476 100755 --- a/direct/src/plugin/p3dPackage.cxx +++ b/direct/src/plugin/p3dPackage.cxx @@ -648,7 +648,7 @@ host_got_contents_file() { } } else { nout << "Couldn't find a platform for " << get_package_name() - << " matching " << inst_mgr->get_platform() << ".\n"; + << " matching \"" << inst_mgr->get_platform() << "\".\n"; } nout << "_per_platform for " << get_package_name() << " = " << _per_platform << "\n"; @@ -689,7 +689,8 @@ download_desc_file() { _package_name, _package_version, _package_platform)) { nout << "Couldn't find package " << _package_fullname - << " in contents file.\n"; + << ", platform \"" << _package_platform + << "\" in contents file.\n"; redownload_contents_file(NULL); return; }