Add support for non-native ABI on hybrid build,

by following the steps taken by TranslatorRoster and LocaleRoster.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37900 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin 2010-08-04 14:05:59 +00:00
parent 3426ce1404
commit 39f372d1d7
2 changed files with 35 additions and 5 deletions

View File

@ -33,7 +33,8 @@ GLRendererRoster::GLRendererRoster(BGLView *view, ulong options)
: fNextID(0),
fView(view),
fOptions(options),
fSafeMode(false)
fSafeMode(false),
fABISubDirectory(NULL)
{
char parameter[32];
size_t parameterLength = sizeof(parameter);
@ -49,7 +50,7 @@ GLRendererRoster::GLRendererRoster(BGLView *view, ulong options)
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
fSafeMode = true;
}
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, &parameterLength) == B_OK)
#else
@ -61,7 +62,24 @@ GLRendererRoster::GLRendererRoster(BGLView *view, ulong options)
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
fSafeMode = true;
}
// We might run in compatibility mode on a system with a different ABI. The
// renderers matching our ABI can usually be found in respective
// subdirectories of the opengl add-ons directories.
system_info info;
if (get_system_info(&info) == B_OK
&& (info.abi & B_HAIKU_ABI_MAJOR)
!= (B_HAIKU_ABI & B_HAIKU_ABI_MAJOR)) {
switch (B_HAIKU_ABI & B_HAIKU_ABI_MAJOR) {
case B_HAIKU_ABI_GCC_2:
fABISubDirectory = "gcc2";
break;
case B_HAIKU_ABI_GCC_4:
fABISubDirectory = "gcc4";
break;
}
}
AddDefaultPaths();
}
@ -111,6 +129,16 @@ GLRendererRoster::AddPath(const char* path)
if (status < B_OK)
return status;
// if a subdirectory for our ABI exists, use that instead
if (fABISubDirectory != NULL) {
BEntry entry(&directory, fABISubDirectory);
if (entry.IsDirectory()) {
status = directory.SetTo(&entry);
if (status != B_OK)
return status;
}
}
node_ref nodeRef;
status = directory.GetNodeRef(&nodeRef);
if (status < B_OK)
@ -181,7 +209,7 @@ GLRendererRoster::CreateRenderer(const entry_ref& ref)
unload_add_on(image);
return B_UNSUPPORTED;
}
if (AddRenderer(renderer, image, &ref, nodeRef.node) != B_OK) {
renderer->Release();
// this will delete the renderer

View File

@ -27,7 +27,7 @@ class GLRendererRoster {
private:
void AddDefaultPaths();
status_t AddPath(const char* path);
status_t AddRenderer(BGLRenderer* renderer,
status_t AddRenderer(BGLRenderer* renderer,
image_id image, const entry_ref* ref, ino_t node);
status_t CreateRenderer(const entry_ref& ref);
@ -36,6 +36,8 @@ class GLRendererRoster {
BGLView *fView;
ulong fOptions;
bool fSafeMode;
const char* fABISubDirectory;
};
#endif /* _GLRENDERER_ROSTER_H */