Exemple #1
0
void OutMode::CmdOptions()
{
	const Workspace& wspc = ide.IdeWorkspace();
	int pi = wspc.GetCount() > 0 ? 0 : -1;
	if (pi < 0) {
		PromptOK("No main package");
		return;
	}
	VectorMap<String, String> bm = ide.GetMethodVars(~method);
	if (bm.GetCount() == 0) {
		PromptOK("Invalid build method");
		return;
	}
	One<Host> host = ide.CreateHost(false);
	One<Builder> b = ide.CreateBuilder(~host);
	const String& p = wspc[pi];
	String output = NativePath(ide.OutDir(ide.PackageConfig(wspc, pi, bm, ~config, *host, *b), p, bm, true));
	if (output.Right(1) == ".")
		output = output.Left(output.GetCount() - 1);
	const ModePane& pane = ~mode == 0 ? debug : release;
	int blitzpackage = pane.package.Get(0, 2);
	bool blitzbuild = !wspc.package[pi].noblitz && pane.blitz
		&& (IsNull(blitzpackage) ? true : blitzpackage);
	CmdBuildOptionsWindow window(p, ~method, ~config, output,
		~mode, ide.hydra1_threads, pane.linkmode, blitzbuild, pane.map, ide.console.verbosebuild);
	LoadFromGlobal(window, "CmdBuildOptionsWindow");
	window.GenerateCmd();
	window.Run();
	StoreToGlobal(window, "CmdBuildOptionsWindow");
}
Exemple #2
0
String GetFileOnPath(const char* file, const char* paths, bool current, const char *curdir) {
	String ufn = NativePath(file);
	if(IsFullPath(ufn))
		return ufn;
	String fn;
#ifdef PLATFORM_WINCE
	if(current && curdir && FileExists(fn = NormalizePath(ufn, curdir)))
		;
#else
	String cd = curdir;
	if(!curdir)
		cd = GetCurrentDirectory();
	if(current && FileExists(fn = NormalizePath(ufn, cd)))
		;
#endif
	else if(paths)
	{
		fn = Null;
		while(*paths) {
			const char* start = paths;
#ifdef PLATFORM_WIN32
			while(*paths && *paths != ';')
				paths++;
#else
			while(*paths && *paths != ';' && *paths != ':')
				paths++;
#endif
			String dir(start, (int)(paths - start));
			if(!dir.IsEmpty()) {
#ifdef PLATFORM_WINCE
				dir = NormalizePath(AppendFileName(NativePath(dir), ufn));
#else
				dir = NormalizePath(AppendFileName(NativePath(dir), ufn), cd);
#endif
				if(FileExists(dir)) {
					fn = dir;
					break;
				}
			}
			if(*paths)
				paths++;
		}
	}
	return fn;
}
FileHandle* FileHandleBuilder::fromLump(File1& lump, bool dontBuffer)
{
    LOG_AS("FileHandle::fromLump");

    de::FileHandle* hndl = new de::FileHandle();
    // Init and load in the lump data.
    hndl->d->file = &lump;
    hndl->d->flags.open = true;
    if(!dontBuffer)
    {
        hndl->d->size = lump.size();
        hndl->d->pos = hndl->d->data = (uint8_t*) M_Malloc(hndl->d->size);
        if(!hndl->d->data) Con_Error("FileHandleBuilder::fromFileLump: Failed on allocation of %lu bytes for data buffer.", (unsigned long) hndl->d->size);

        LOG_DEV_TRACE("[%p] Buffering \"%s:%s\"...",
            dintptr(hndl) << NativePath(lump.container().composePath()).pretty() << NativePath(lump.composePath()).pretty());

        lump.read((uint8_t*)hndl->d->data, 0, lump.size());
    }
    return hndl;
}
Exemple #4
0
NativePath NativePath::expand(bool *didExpand) const
{
    if (first() == '>' || first() == '}')
    {
        if (didExpand) *didExpand = true;
        return App::app().nativeBasePath() / toString().mid(1);
    }
#ifdef UNIX
    else if (first() == '~')
    {
        if (didExpand) *didExpand = true;

        String const path = toString();
        int firstSlash = path.indexOf('/');
        if (firstSlash > 1)
        {
            // Parse the user's home directory (from passwd).
            QByteArray userName = path.mid(1, firstSlash - 1).toLatin1();
            struct passwd *pw = getpwnam(userName);
            if (!pw)
            {
                /// @throws UnknownUserError  User is not known.
                throw UnknownUserError("NativePath::expand",
                                       String("Unknown user '%1'").arg(QLatin1String(userName)));
            }

            return NativePath(pw->pw_dir) / path.mid(firstSlash + 1);
        }
        else
        {
            // Replace with the HOME path.
            return NativePath(QDir::homePath()) / path.mid(2);
        }
    }
#endif

    // No expansion done.
    if (didExpand) *didExpand = false;
    return *this;
}
Exemple #5
0
String Nest::PackagePath0(const String& name)
{
	String uppfile = NativePath(name);
	if(IsFullPath(uppfile)) return NormalizePath(uppfile);
	Vector<String> d = GetUppDirs();
	String p;
	for(int i = 0; i < d.GetCount(); i++) {
		p = NormalizePath(AppendFileName(AppendFileName(d[i], uppfile),
		                  GetFileName(uppfile)) + ".upp");
		if(FileExists(p)) return p;
	}
	return d.GetCount() ? NormalizePath(AppendFileName(AppendFileName(d[0], uppfile),
		                                GetFileName(uppfile)) + ".upp") : "";
}
Exemple #6
0
bool File::Open(const String& fileName, FileMode fileMode)
{
    Close();

    if (fileName.IsEmpty())
        return false;
    
    #ifdef _WIN32
    handle = _wfopen(WideNativePath(fileName).CString(), openModes[fileMode]);
    #else
    handle = fopen(NativePath(fileName).CString(), openModes[fileMode]);
    #endif

    // If file did not exist in readwrite mode, retry with write-update mode
    if (mode == FILE_READWRITE && !handle)
    {
        #ifdef _WIN32
        handle = _wfopen(WideNativePath(fileName).CString(), openModes[fileMode + 1]);
        #else
        handle = fopen(NativePath(fileName).CString(), openModes[fileMode + 1]);
        #endif
    }
    
    if (!handle)
        return false;

    name = fileName;
    mode = fileMode;
    position = 0;
    readSyncNeeded = false;
    writeSyncNeeded = false;

    fseek((FILE*)handle, 0, SEEK_END);
    size = ftell((FILE*)handle);
    fseek((FILE*)handle, 0, SEEK_SET);
    return true;
}
Exemple #7
0
Feed::PopulatedFiles StaticLibraryFeed::populate(Folder const &folder)
{
    PopulatedFiles files;
#if defined (DENG_STATIC_LINK)
    for (String name : Library::staticLibraries())
    {
        if (!folder.has(name))
        {
            files << new LibraryFile(NativePath(name));
        }
    }
#else
    DENG2_UNUSED(folder);
#endif
    return files;
}
Exemple #8
0
void SelectPackageDlg::OnNew() {
	TemplateDlg dlg;
	LoadFromGlobal(dlg, "NewPackage");
	int f = ~filter;
	dlg.Load(GetUppDirs(), f & MAIN);
	while(dlg.Run() == IDOK) {
		String nest = ~dlg.nest;
		String name = NativePath(String(~dlg.package));
		String path = AppendFileName(nest, AppendFileName(name, GetFileName(name) + ".upp"));
		if(FileExists(path) && !PromptYesNo("Package [* \1" + path + "\1] already exists.&"
		                                    "Do you wish to recreate the files?"))
			continue;
		RealizePath(path);
		if(!SaveFile(path, Null)) {
			Exclamation("Error writing the file [* \1" + path + "\1].");
			continue;
		}
		dlg.Create();
		selected = name;
		Break(IDYES);
		break;
	}
	StoreToGlobal(dlg, "NewPackage");
}
Exemple #9
0
NativePath NativePath::concatenatePath(String const &nativePath) const
{
    return concatenatePath(NativePath(nativePath));
}
Exemple #10
0
File1& File1::container() const
{
    if(!container_) throw NotContainedError("File1::container", "File \"" + NativePath(composePath()).pretty() + " is not contained");
    return *container_;
}
int main(int argc, char **argv)
{
  vtkMultiProcessController *controller=Initialize(&argc,&argv);
  int worldRank=controller->GetLocalProcessId();
  int worldSize=controller->GetNumberOfProcesses();

  // configure
  std::string dataRoot;
  std::string tempDir;
  std::string baseline;
  BroadcastConfiguration(controller,argc,argv,dataRoot,tempDir,baseline);

  std::string inputFileName;
  inputFileName=dataRoot+"/Data/SciberQuestToolKit/MagneticIslands/MagneticIslands.bov";

  std::string logFileName;
  logFileName=NativePath(tempDir+"/SciberQuestToolKit-TestFieldTracer.log");
  vtkSQLog::GetGlobalInstance()->SetFileName(logFileName.c_str());
  vtkSQLog::GetGlobalInstance()->SetGlobalLevel(1);

  // pipeline 1
  // ooc reader
  vtkSQBOVMetaReader *mr=vtkSQBOVMetaReader::New();
  mr->SetFileName(inputFileName.c_str());
  mr->SetPointArrayStatus("b",1);
  mr->SetNumberOfGhostCells(2);
  mr->SetXHasPeriodicBC(1);
  mr->SetYHasPeriodicBC(1);
  mr->SetZHasPeriodicBC(1);
  mr->SetBlockSize(8,8,8);
  mr->SetBlockCacheSize(1);

  // seed points
  vtkSQLineSource *p1=vtkSQLineSource::New();
  p1->SetPoint1(-0.125,-0.125,0.0);
  p1->SetPoint2(-0.5,-0.5,0.0);
  p1->SetResolution(3);

  // field tracer
  vtkSQFieldTracer *ft=vtkSQFieldTracer::New();
  ft->SetMode(vtkSQFieldTracer::MODE_STREAM);
  ft->SetIntegratorType(vtkSQFieldTracer::INTEGRATOR_RK4);
  ft->SetMaxStep(0.01);
  ft->SetMaxLineLength(300);
  //ft->SetMinSegmentLength(0.2); TODO --- this feature has a bug.
  ft->SetNullThreshold(0.001);
  ft->SetForwardOnly(0);
  ft->SetUseDynamicScheduler(0);
  ft->AddInputConnection(0,mr->GetOutputPort(0));
  ft->AddInputConnection(1,p1->GetOutputPort(0));
  ft->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS,"b");
  mr->Delete();
  p1->Delete();

  // pids
  vtkProcessIdScalars *pid=vtkProcessIdScalars::New();
  pid->SetInputConnection(0,ft->GetOutputPort(0));
  ft->Delete();

  // tubes
  vtkSQTubeFilter *tf=vtkSQTubeFilter::New();
  tf->SetRadius(0.025);
  tf->SetNumberOfSides(16);
  tf->SetInputConnection(pid->GetOutputPort(0));
  pid->Delete();

  // execute
  GetParallelExec(worldRank,worldSize,tf,0.0);
  tf->Update();

  int testStatus = SerialRender(
        controller,
        (vtkPolyData*)tf->GetOutput(),
        true,
        tempDir,
        baseline,
        "SciberQuestToolKit-TestFieldTracer",
        600,600,
        13,13,13,
        0,0,0,
        0,0,1,
        1.1,
        30.0);

  tf->Delete();

  return Finalize(controller,testStatus==vtkTesting::PASSED?0:1);
}
Exemple #12
0
String SourcePath(const String& package, const String& file) {
	if(IsFullPath(file)) return NativePath(file);
	return NormalizePath(AppendFileName(GetFileFolder(PackagePath(package)), file));
}
Exemple #13
0
NativePath NativePath::operator / (char const *nullTerminatedCStr) const
{
    return *this / NativePath(nullTerminatedCStr);
}
Exemple #14
0
void CppBuilder::AddMakeFile(MakeFile& makefile, String package,
	const Vector<String>& all_uses, const Vector<String>& all_libraries,
	const Index<String>& common_config, bool exporting)
{
	String packagepath = PackagePath(package);
	Package pkg;
	pkg.Load(packagepath);
	String packagedir = GetFileFolder(packagepath);
	Vector<String> src = GetUppDirs();
	for(int i = 0; i < src.GetCount(); i++)
		src[i] = UnixPath(src[i]);

	bool main = HasFlag("MAIN");
	bool is_shared = HasFlag("SO");
	bool libout = !main && !HasFlag("NOLIB");
	bool win32 = HasFlag("WIN32");

	String pack_ident = MakeIdent(package);
	String outdir = "OutDir_" + pack_ident;
	String macros = "Macro_" + pack_ident;
	String macdef = "$(Macro)";
	String objext = (HasFlag("MSC") || HasFlag("EVC") ? ".obj" : ".o");

	Vector<String> x(config.GetKeys(), 1);
	Sort(x);
	for(int i = 0; i < x.GetCount(); i++) {
		if(common_config.Find(x[i]) < 0)
			macdef << " -Dflag" << x[i];
		x[i] = InitCaps(x[i]);
	}

	makefile.outdir << "$(" << outdir << ")";
	makefile.outfile << AdjustMakePath(GetFileTitle(NativePath(package)));
	if(main)
		makefile.outfile << GetTargetExt();
	else if(is_shared)
		makefile.outfile << (win32 ? ".dll" : ".so");
	else
		makefile.outfile << (win32 && HasFlag("MSC") ? ".lib" : ".a");
	makefile.output << (main ? String("$(OutDir)") : makefile.outdir) << makefile.outfile;

	if(main) {
		makefile.config << "CXX = c++\n"
			"LINKER = $(CXX)\n";
		String flags;
		if(HasFlag("DEBUG"))
			flags << " -D_DEBUG " << debug_options;
		else
			flags << ' ' << release_options;
		if(HasFlag("DEBUG_MINIMAL"))
			flags << " -ggdb -g1";
		if(HasFlag("DEBUG_FULL"))
			flags << " -ggdb -g2";
		if(is_shared && !win32)
			flags << " -fPIC ";
		flags << ' ' << Gather(pkg.option, config.GetKeys());
		makefile.config << "CFLAGS =" << flags << "\n"
			"CXXFLAGS =" << flags << "\n"
			"LDFLAGS = " << (HasFlag("DEBUG") ? debug_link : release_link) << " $(LINKOPTIONS)\n"
			"LIBPATH =";
		for(int i = 0; i < libpath.GetCount(); i++)
			makefile.config << " -L" << GetMakePath(AdjustMakePath(GetHostPathQ(libpath[i])));
		makefile.config << "\n"
			"AR = ar -sr\n\n";
		makefile.install << "\t-mkdir -p $(OutDir)\n";
		Vector<String> lib;
		String lnk;
		lnk << "$(LINKER)";
		if(!HasFlag("SHARED"))
			lnk << " -static";
		if(HasFlag("WIN32")) {
			lnk << " -mwindows";
			if(!HasFlag("GUI"))
				makefile.linkfiles << " -mconsole";
		}
		lnk << " -o $(OutFile)";
		if(HasFlag("DEBUG") || HasFlag("DEBUG_MINIMAL") || HasFlag("DEBUG_FULL"))
			lnk << " -ggdb";
		else
			lnk << (!HasFlag("OSX11") ? " -Wl,-s" : "");

		lnk << " $(LIBPATH)";
		if (!HasFlag("OSX11"))
			lnk << " -Wl,-O,2";
		lnk << " $(LDFLAGS) -Wl,--start-group ";

		makefile.linkfiles = lnk;
	}

	makefile.config << outdir << " = $(UPPOUT)"
		<< GetMakePath(AdjustMakePath(String().Cat() << package << '/' << method << '-' << Join(x, "-") << '/')) << "\n"
		<< macros << " = " << macdef << "\n";

	makefile.install << "\t-mkdir -p $(" << outdir << ")\n";

	String libdep, libfiles;

	libdep << makefile.output << ":";
	if(is_shared)
	{
		libfiles = "c++ -shared -fPIC"; // -v";
		Point p = ExtractVersion();
		if(!IsNull(p.x)) {
			libfiles << " -Xlinker --major-image-version -Xlinker " << p.x;
			if(!IsNull(p.y))
				libfiles << " -Xlinker --minor-image-version -Xlinker " << p.y;
		}
		libfiles << " -o ";
	}
	else
		libfiles = "$(AR) ";
	libfiles << makefile.output;

	Vector<String> libs = Split(Gather(pkg.library, config.GetKeys()), ' ');
	for(int i = 0; i < libs.GetCount(); i++) {
		String ln = libs[i];
		String ext = ToLower(GetFileExt(ln));
		if(ext == ".a" || ext == ".so" || ext == ".dll")
			makefile.linkfileend << " \\\n\t\t\t" << GetHostPathQ(FindInDirs(libpath, ln));
		else
			makefile.linkfileend << " \\\n\t\t\t-l" << ln;
	}
	
	for(int i = 0; i < pkg.GetCount(); i++)
		if(!pkg[i].separator) {
			String gop = Gather(pkg[i].option, config.GetKeys());
			String fn = SourcePath(package, pkg[i]);
			String ext = ToLower(GetFileExt(fn));
			bool isc = ext == ".c";
			bool isrc = (ext == ".rc" && HasFlag("WIN32"));
			bool iscpp = (ext == ".cpp" || ext == ".cc" || ext == ".cxx");
			bool isicpp = (ext == ".icpp");
			if(ext == ".brc") {
				isc = true;
				fn << "c";
			}
			if(isc || isrc || iscpp || isicpp) {
				String outfile;
				outfile << makefile.outdir << AdjustMakePath(GetFileTitle(fn)) << (isrc ? "_rc" : "") << objext;
				String srcfile = GetMakePath(MakeSourcePath(src, fn, false, exporting));
				makefile.rules << outfile << ": " << srcfile;
				Vector<String> dep = HdependGetDependencies(fn);
				Sort(dep, GetLanguageInfo());
				for(int d = 0; d < dep.GetCount(); d++) {
					String dfn = MakeSourcePath(src, dep[d], true, exporting);
					if(!IsNull(dfn))
						makefile.rules << " \\\n\t" << GetMakePath(dfn);
				}
				makefile.rules << "\n"
					"\t$(CXX) -c " << (isc ? "-x c $(CFLAGS)" : "-x c++ $(CXXFLAGS)") << " $(CINC) $(" << macros << ") "
						<< gop << " " << srcfile << " -o " << outfile << "\n\n";
				if(!libout || isicpp) {
					makefile.linkdep << " \\\n\t" << outfile;
					makefile.linkfiles << " \\\n\t\t" << outfile;
				}
				else {
					libdep << " \\\n\t" << outfile;
					libfiles << " \\\n\t\t" << outfile;
				}
			}
			else
			if(ext == ".o" || ext == ".obj" || ext == ".a" || ext == ".so" || ext == ".lib" || ext == ".dll") {
				makefile.linkdep << " \\\n\t" << fn;
				makefile.linkfiles << ' ' << fn;
			}
		}

	if(libout) {
		makefile.rules << libdep << "\n\t" << libfiles << "\n\n";
		makefile.linkdep << " \\\n\t" << makefile.output;
		makefile.linkfiles << " \\\n\t\t\t" << makefile.output;
	}
/*
	if(main) {
		if(!HasFlag("SOLARIS")&&!HasFlag("OSX11"))
			makefile.linkfiles << " \\\n\t\t-Wl,--start-group ";
		DDUMPC(all_libraries);
		for(int i = 0; i < all_libraries.GetCount(); i++) {
			String ln = all_libraries[i];
			String ext = ToLower(GetFileExt(ln));
			if(ext == ".a" || ext == ".so" || ext == ".dll")
				makefile.linkfileend << " \\\n\t\t\t" << GetHostPathQ(FindInDirs(libpath, ln));
			else
				makefile.linkfileend << " \\\n\t\t\t-l" << ln;
		}
		if(!HasFlag("SOLARIS")&&!HasFlag("OSX11"))
			makefile.linkfileend << " \\\n\t\t-Wl,--end-group\n\n";
	}
*/
}
Exemple #15
0
NativePath NativePath::operator / (QString const &str) const
{
    return *this / NativePath(str);
}
Exemple #16
0
String ForceExt(const char* fn, const char* ext) {
	return NativePath(String(fn, GetFileExtPos(fn))) + ext;
}
Exemple #17
0
String AppendExt(const char* fn, const char* ext) {
	String result = NativePath(fn);
	if(!HasFileExt(fn))
		result += ext;
	return result;
}
int TestPlaneSource(int argc, char *argv[])
{
  vtkMultiProcessController *controller=Initialize(&argc,&argv);
  int worldRank=controller->GetLocalProcessId();
  int worldSize=controller->GetNumberOfProcesses();

  // configure
  std::string dataRoot;
  std::string tempDir;
  std::string baseline;
  BroadcastConfiguration(controller,argc,argv,dataRoot,tempDir,baseline);

  std::string logFileName;
  logFileName=NativePath(tempDir+"/SciberQuestToolKit-TestPlaneSource.log");
  vtkSQLog::GetGlobalInstance()->SetFileName(logFileName.c_str());
  vtkSQLog::GetGlobalInstance()->SetGlobalLevel(1);

  // plane
  const int nResolutions=4;
  int resolution[nResolutions][2]={
        {1,1,},
        {537,1,},
        {1,537,},
        {127,67},
        };

  const int nDecomps=2;
  int decomp[nDecomps]={
        vtkSQPlaneSource::DECOMP_TYPE_STRIPS,
        vtkSQPlaneSource::DECOMP_TYPE_PATCHES
        };

  const char *decompName[nDecomps]={
        "Strips",
        "Patches"};

  int ext[6]={-1,1,-1,1,0,0};

  int aTestFailed=0;
  for (int i=0; i<nResolutions; ++i)
    {
    for (int j=0; j<nDecomps; ++j)
      {
      int *res=resolution[i];

      vtkSQPlaneSource *p=vtkSQPlaneSource::New();
      p->SetOrigin(ext[0],ext[2],ext[4]);
      p->SetPoint1(ext[1],ext[2],ext[4]);
      p->SetPoint2(ext[0],ext[3],ext[4]);
      p->SetXResolution(res[0]);
      p->SetYResolution(res[1]);
      p->SetDecompType(decomp[j]);

      // process id
      vtkProcessIdScalars *pid=vtkProcessIdScalars::New();
      pid->SetInputConnection(0,p->GetOutputPort(0));
      p->Delete();

      // execute
      GetParallelExec(worldRank, worldSize, pid, 0.0);
      pid->Update();

      vtkPolyData *output=dynamic_cast<vtkPolyData*>(pid->GetOutput());

      // rename resolution dependent arrays
      std::ostringstream oss;
      oss << "Decomp-" << decompName[j] << "-" << res[0] << "x" << res[1];
      vtkDataArray *ids=output->GetPointData()->GetArray("ProcessId");
      if (ids)
        {
        ids->SetName(oss.str().c_str());
        }
      oss.str("");
      oss << "TCoords-"  << decompName[j] << "-" << res[0] << "x" << res[1];
      vtkDataArray *tcoord=output->GetPointData()->GetTCoords();
      if (tcoord)
        {
        tcoord->SetName(oss.str().c_str());
        }

      int testStatus = SerialRender(
            controller,
            output,
            false,
            tempDir,
            baseline,
            "SciberQuestToolKit-TestPlaneSource",
            300,300,
            63,63,128,
            0,0,0,
            0,1,0,
            1.25);
      if (testStatus==vtkTesting::FAILED)
        {
        aTestFailed=1;
        }

      pid->Delete();
      }
    }

  return Finalize(controller,aTestFailed);
}