fix some issues with platform matching

This commit is contained in:
David Rose 2012-10-01 20:47:11 +00:00
parent da9ee4c165
commit 0a72ac45c5
2 changed files with 29 additions and 7 deletions

View File

@ -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 = "";
}

View File

@ -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;
}