Beispiel #1
0
static int
install_rmkdir (const char *dir, unsigned int perm)
  /*@globals errno; @*/
{
  char path_buf [INSTALL_MAX_PATHLEN];
  size_t len;
  size_t pos;
  size_t buflen;
  size_t bufpos;
  int end;
  const char *ptr;
  char *ptr2;

  assert (dir != NULL);

  buflen = sizeof (path_buf);
  bufpos = 0;
  end = 0;
  len = strlen (dir);
  ptr = dir;

  if (len >= sizeof (path_buf)) { errno = ENAMETOOLONG; return 0; }

  for (;;) {
    if (len == 0) break;
    ptr2 = strchr (ptr, '/');
    if (ptr2 == NULL) {
      pos = len;
      end = 1;
    } else pos = (size_t) (ptr2 - ptr);
    if (buflen <= (size_t) pos + 1) break;
    memcpy (path_buf + bufpos, ptr, pos);
    bufpos += pos;
    buflen -= pos;
    path_buf [bufpos] = '/';
    ++bufpos;
    --buflen;
    path_buf [bufpos] = (char) 0;
    if (install_mkdir (path_buf, perm) == -1) {
      if (end == 0) {
        if (errno != EEXIST && errno != EISDIR) return 0;
      } else return 0;
    }
    ptr += pos;
    len -= pos;
    if (len != 0) {
      ++ptr;
      --len;
      if (len == 0) break;
    }
  }

  return 1;
}
Beispiel #2
0
// TODO!!!!!
// create the install_libname.bat installation batch file:
void gen_vc_install_bat(const Project &project, const Workspace &workspace)
{
	std::string bat_file = "Sources\\install_";
	bat_file += project.libname;
	bat_file += ".bat";

	std::ofstream bat(bat_file.c_str());

	std::string instdir = workspace.output_include_dir;
	instdir += "\\ClanLib";
	install_mkdir(bat, "API\\", instdir, &project);
	install_copydir(bat, "API\\", instdir, &project);
}
Beispiel #3
0
int
install_rmkdir (const char *dir, unsigned int perm)
{
  char path_buf [INSTALL_MAX_PATHLEN];
  unsigned int len;
  unsigned int pos;
  unsigned int buflen;
  unsigned int bufpos;
  int end;
  const char *ptr;
  char *ptr2;

  buflen = sizeof (path_buf);
  bufpos = 0;
  end = 0;
  len = strlen (dir);
  ptr = dir;

  if (len >= sizeof (path_buf)) { errno = ENAMETOOLONG; return 0; }

  for (;;) {
    if (!len) break;
    ptr2 = strchr (ptr, '/');
    if (!ptr2) {
      pos = len;
      end = 1;
    } else pos = ptr2 - ptr;
    if (buflen <= (unsigned int) pos + 1) break;
    memcpy (path_buf + bufpos, ptr, pos);
    bufpos += pos;
    buflen -= pos;
    path_buf [bufpos] = '/';
    ++bufpos;
    --buflen;
    path_buf [bufpos] = 0;
    if (install_mkdir (path_buf, perm) == -1) {
      if (!end) {
        if (errno != EEXIST && errno != EISDIR) return 0;
      } else return 0;
    }
    ptr += pos;
    len -= pos;
    if (len) {
      ++ptr;
      --len;
      if (!len) break;
    }
  }

  return 1;
}
void WorkspaceGenerator_MSVC8::write_install_batch_file(const Workspace &workspace, const Project &project)
{
	// create the install_libname.bat installation batch file:
	{
		std::string bat_file = "Projects\\install_clan";
		bat_file += project.name.c_str();
		bat_file += ".bat";

		std::ofstream bat(bat_file.c_str());
		bat << "mode con cp select=" << GetACP() << " > nul" << std::endl;

		install_mkdir(bat, workspace.output_lib_dir);

		std::string instdir = workspace.output_include_dir.c_str();
		instdir += "\\ClanLib";
		install_mkdir(bat, "API\\", std::string(instdir), &project);
		install_copydir(bat, "API\\", std::string(instdir), &project);

		bat << "copy %1 \"" << workspace.output_lib_dir.c_str() << "\\%4\" > nul" << std::endl;
		if (target_android)	//TODO: Fixme
			bat << "rem ";
		bat << "copy %2 \"" << workspace.output_lib_dir.c_str() << "\\%4\\%3\" > nul" << std::endl;
	}
}
void WorkspaceGenerator_MSVC8::install_mkdir(
	std::ofstream &bat,
	const std::string &src_dir,
	const std::string &dest_dir,
	const Project *project)
{
	static OSVERSIONINFO versionInfo;
	static bool firstCall = true;
	if (firstCall)
	{
		memset(&versionInfo, 0, sizeof(OSVERSIONINFO));
		GetVersionEx(&versionInfo);
		firstCall = false;
	}

	bool win9x = (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);

	if (win9x)
	{
		bat << "if not exist \"" << dest_dir << "\\nul\"" << " mkdir \"" << dest_dir << "\"" << std::endl;
	}
	else
	{
		bat << "if not exist \"" << dest_dir << "\"" << " mkdir \"" << dest_dir << "\"" << std::endl;
	}

	std::string path = src_dir.c_str();
	if (path[path.length() - 1] != '\\')
		path += '\\';

	std::string path_dest = dest_dir.c_str();
	if (path_dest[path_dest.length() - 1] != '\\')
		path_dest += '\\';

	if (project)
	{
		// first time call: 
		// - make sure we create Module specific directories

		path = path + project->name.c_str();
		if (path[path.length() - 1] != '\\')
			path += '\\';

		path_dest = path_dest + project->name.c_str();
		if (win9x)
		{
			bat << "if not exist \"" << std::string(path_dest) << "\\nul\"" << " mkdir \"" << std::string(path_dest) << "\"" << std::endl;
		}
		else
		{
			bat << "if not exist \"" << std::string(path_dest) << "\"" << " mkdir \"" << std::string(path_dest) << "\"" << std::endl;
		}

		if (path_dest[path_dest.length() - 1] != '\\')
			path_dest += '\\';
	}

	std::string prefix = "Sources\\";

	WIN32_FIND_DATAA data;
	HANDLE handle = FindFirstFileA((prefix + path + "*.*").c_str(), &data);
	if (handle == INVALID_HANDLE_VALUE) return;

	static const char *exclude_from_build[] =
	{
		".",
		"..",
		"CVS",
		".svn",
		".#", // don't add CVS revision backups.
		NULL
	};

	do
	{
		bool skip = false;

		for (int i=0; exclude_from_build[i] != NULL; i++)
			if (stricmp(data.cFileName, exclude_from_build[i]) == 0) skip = true;

		if (skip) continue;

		if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
		{
			std::string subdir = data.cFileName;
			install_mkdir(
				bat,
				std::string(path + subdir),
				std::string(path_dest + subdir),
				0);
		}
	} while (FindNextFileA(handle, &data));
}