46 #ifndef WIN32_LEAN_AND_MEAN    47 #define WIN32_LEAN_AND_MEAN    58 #define QUOTESTR(x) #x    59 #define TOSTRING(x) QUOTESTR(x)    63 static const Filename openmaya_filename = 
"bin/OpenMaya.so";
    65 static const Filename openmaya_filename = 
"MacOS/libOpenMaya.dylib";
    67 static const Filename openmaya_filename = 
"lib/libOpenMaya.so";
    72 find_pyzip(
const Filename &maya_location) {
    75   Filename dirname(maya_location, 
"bin");
    77   vector_string results;
    79   if (glob.match_files(results, dirname) != 0) {
    80     return Filename(dirname, results[0]);
    87   const char *ver, *key;
    90 struct MayaVerInfo maya_versions[] = {
    96   { 
"MAYA2008", 
"2008"},
    97   { 
"MAYA2009", 
"2009"},
    98   { 
"MAYA2010", 
"2010"},
    99   { 
"MAYA2011", 
"2011"},
   100   { 
"MAYA2012", 
"2012"},
   101   { 
"MAYA2013", 
"2013"},
   102   { 
"MAYA20135", 
"2013.5"},
   103   { 
"MAYA2014", 
"2014"},
   104   { 
"MAYA2015", 
"2015"},
   105   { 
"MAYA2016", 
"2016"},
   106   { 
"MAYA20165", 
"2016.5"},
   107   { 
"MAYA2017", 
"2017"},
   108   { 
"MAYA2018", 
"2018"},
   113 get_version_number(
const char *ver) {
   114   for (
int i = 0; maya_versions[i].ver != 0; ++i) {
   115     if (strcmp(maya_versions[i].ver, ver) == 0) {
   116       return maya_versions[i].key;
   124 get_maya_location(
const char *ver, 
string &loc) {
   126   const char *developer;
   129   for (
int dev=0; dev<3; dev++) {
   131     case 0: developer=
"Alias|Wavefront"; 
break;
   132     case 1: developer=
"Alias"; 
break;
   133     case 2: developer=
"Autodesk"; 
break;
   135     sprintf(fullkey, 
"SOFTWARE\\%s\\Maya\\%s\\Setup\\InstallPath", developer, ver);
   136     for (
int hive=0; hive<2; hive++) {
   138       res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, fullkey, 0, KEY_READ | (hive ? 256:0), &hkey);
   139       if (res == ERROR_SUCCESS) {
   142         char result[4096 + 1];
   143         res = RegQueryValueEx(hkey, 
"MAYA_INSTALL_LOCATION", 
nullptr, &dtype, (LPBYTE)result, &size);
   144         if ((res == ERROR_SUCCESS)&&(dtype == REG_SZ)) {
   154 #elif defined(__APPLE__)   156 get_maya_location(
const char *ver, 
string &loc) {
   158   sprintf(mpath, 
"/Applications/Autodesk/maya%s/Maya.app/Contents", ver);
   160   if(stat(mpath, &st) == 0) {
   167 get_maya_location(
const char *ver, 
string &loc) {
   170   sprintf(mpath, 
"/usr/autodesk/maya%s-x64", ver);
   172   sprintf(mpath, 
"/usr/autodesk/maya%s", ver);
   175   if(stat(mpath, &st) == 0) {
   179     sprintf(mpath, 
"/usr/aw/maya%s-x64", ver);
   181     sprintf(mpath, 
"/usr/aw/maya%s", ver);
   183     if(stat(mpath, &st) == 0) {
   193 main(
int argc, 
char *argv[]) {
   221   if (!maya_location.empty()) {
   231     const char *key = get_version_number(TOSTRING(MAYAVERSION));
   232     if (key == 
nullptr) {
   233       cerr << 
"Unknown Maya version: " << TOSTRING(MAYAVERSION) << 
"\n";
   236       get_maya_location(key, loc);
   238         cerr << 
"Cannot locate " << TOSTRING(MAYAVERSION) << 
": it does not appear to be installed.\n";
   243     if (!standard_maya_location.empty()) {
   249 #endif  // MAYAVERSION   254     if (!maya_location.empty()) {
   262     if (maya_location.empty()) {
   264       maya_location = standard_maya_location;
   266     } 
else if (maya_location != standard_maya_location) {
   269       Filename openmaya_given = Filename::dso_filename(
Filename(maya_location, openmaya_filename));
   270       Filename openmaya_standard = Filename::dso_filename(
Filename(standard_maya_location, openmaya_filename));
   272       if (openmaya_given != openmaya_standard) {
   276         HashVal hash_given, hash_standard;
   277         if (!hash_standard.hash_file(openmaya_standard)) {
   281           if (!hash_given.hash_file(openmaya_given)) {
   284             maya_location = standard_maya_location;
   287             if (hash_standard != hash_given) {
   289               cerr << 
"$MAYA_LOCATION points to wrong version; using standard location instead.\n";
   290               maya_location = standard_maya_location;
   296 #else // HAVE_OPENSSL   298         off_t size_given, size_standard;
   300         if (size_standard == 0) {
   305           if (size_given == 0) {
   308             maya_location = standard_maya_location;
   311             if (size_standard != size_given) {
   313               cerr << 
"$MAYA_LOCATION points to wrong version; using standard location instead.\n";
   314               maya_location = standard_maya_location;
   322 #endif  // HAVE_OPENSSL   327   if (maya_location.empty()) {
   328     cerr << 
"$MAYA_LOCATION is not set!\n";
   332   cerr << 
"MAYA_LOCATION: " << maya_location.
to_os_specific() << endl;
   334     cerr << 
"The directory referred to by $MAYA_LOCATION does not exist!\n";
   339   Filename openmaya = Filename::dso_filename(
Filename(maya_location, openmaya_filename));
   341     cerr << 
"Could not find $MAYA_LOCATION/" << Filename::dso_filename(openmaya_filename).
to_os_specific() << 
"!\n";
   347     string putenv_str = 
"MAYA_LOCATION=" + maya_location.
to_os_specific();
   348     char *putenv_cstr = strdup(putenv_str.c_str());
   365       char *putenv_cstr = strdup(putenv_str.c_str());
   371       Filename pyzip = find_pyzip(maya_location);
   372       if (!pyzip.empty() && pyzip.
exists()) {
   377       Filename site_packages(python, 
"lib/site-packages");
   378       if (site_packages.is_directory()) {
   380         putenv_str += site_packages.to_os_specific();
   383       char *putenv_cstr = strdup(putenv_str.c_str());
   395     const char *path = getenv(
"PATH");
   396     if (path == 
nullptr) {
   400     char *putenv_cstr = strdup(putenv_str.c_str());
   407     const char *path = getenv(
"DYLD_LIBRARY_PATH");
   408     if (path == 
nullptr) {
   412     string putenv_str = 
"DYLD_LIBRARY_PATH=" + bin.
to_os_specific() + sep + path;
   413     char *putenv_cstr = strdup(putenv_str.c_str());
   420     const char *path = getenv(
"DYLD_FALLBACK_FRAMEWORK_PATH");
   421     if (path == 
nullptr) {
   425     string putenv_str = 
"DYLD_FALLBACK_FRAMEWORK_PATH=" + fw_dir.
to_os_specific() + sep + path;
   426     char *putenv_cstr = strdup(putenv_str.c_str());
   430 #elif !defined(_WIN32)   433     const char *path = getenv(
"LD_LIBRARY_PATH");
   434     if (path == 
nullptr) {
   438     string putenv_str = 
"LD_LIBRARY_PATH=" + bin.
to_os_specific() + sep + path;
   439     char *putenv_cstr = strdup(putenv_str.c_str());
   448   putenv((
char *)
"PANDA_INCOMPATIBLE_PYTHON=1");
   455   char *command_line = strdup(GetCommandLine());
   456   STARTUPINFO startup_info;
   457   PROCESS_INFORMATION process_info;
   458   GetStartupInfo(&startup_info);
   459   BOOL result = CreateProcess(os_command.c_str(),
   461                               nullptr, 
nullptr, 
true, 0,
   466     WaitForSingleObject(process_info.hProcess, INFINITE);
   469     if (GetExitCodeProcess(process_info.hProcess, &exit_code)) {
   470       if (exit_code != 0) {
   471         cerr << 
"Program exited with status " << exit_code << 
"\n";
   475     CloseHandle(process_info.hProcess);
   476     CloseHandle(process_info.hThread);
   479   cerr << 
"Couldn't execute " << command << 
": " << GetLastError() << 
"\n";
   483   execvp(os_command.c_str(), argv);
 void set_extension(const std::string &s)
Replaces the file extension.
static Filename expand_from(const std::string &user_string, Type type=T_general)
Returns the same thing as from_os_specific(), but embedded environment variable references (e....
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool resolve_filename(const DSearchPath &searchpath, const std::string &default_extension=std::string())
Searches the given search path for the filename.
bool make_canonical()
Converts this filename to a canonical name by replacing the directory part with the fully-qualified d...
Stores a 128-bit value that represents the hashed contents (typically MD5) of a file or buffer.
bool is_fully_qualified() const
Returns true if the filename is fully qualified, e.g.
The name of a file, such as a texture file or an Egg file.
std::string get_fullpath() const
Returns the entire filename: directory, basename, extension.
std::string to_os_long_name() const
This is the opposite of to_os_short_name(): it returns the "long name" of the filename,...
bool is_regular_file() const
Returns true if the filename exists and is the name of a regular file (i.e.
std::string get_extension() const
Returns the file extension.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_directory() const
Returns true if the filename exists and is a directory name, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::streamsize get_file_size() const
Returns the size of the file in bytes, or 0 if there is an error.
This class stores a list of directories that can be searched, in order, to locate a particular file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void append_path(const std::string &path, const std::string &separator=std::string())
Adds all of the directories listed in the search path to the end of the search list.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::string to_os_specific() const
Converts the filename from our generic Unix-like convention (forward slashes starting with the root a...
bool exists() const
Returns true if the filename exists on the disk, false otherwise.
static Filename from_os_specific(const std::string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes,...
This class can be used to test for string matches against standard Unix- shell filename globbing conv...
get_environment_variable
Returns the definition of the indicated environment variable, or the empty string if the variable is ...