Ejemplo n.º 1
0
int main()
{
	// user only operate the compiler facade
	CCompiler objCompiler;
	objCompiler.Compile("TestFile.cpp", "TestFile.exe");

	return 0;
}
Ejemplo n.º 2
0
string exec_cmd(string user, string cmd, std::map<string, string> p){

		

	string r = "hello";
	// load user
	
	// get cmd
	
	cLOG("11");
	// send cmd to user
	// user::onCommand(command name, command param)
#if 0
	// test
 	BOOL ret = c.Compile("test/test.cs");
	// if (!ret){
	// 	printf("==== compiler error ===\n");
	// 	return "==== compiler error ===\n";
	// }
		
//	CCompiler::classDesTable.dump();
	CClassDes* pc = CCompiler::classDesTable.getClass("test/test");
//	printf("this=%x,==>ps=%x", &CCompiler::classDesTable, pc);
	vm.LoadObject(pc);
#endif

	cs->loadobj("test");
	
	cLOG("111");
	return r;
}
Ejemplo n.º 3
0
// =================================================================
//	Entry point
// =================================================================
int main(int argc, char* argv[])
{
#ifdef NDEBUG
	try
	{
#endif
		CCompiler compiler;
		return compiler.Process(argc, argv);
#ifdef NDEBUG
	}
	catch (...)
	{
		printf("Compiler threw unhandled exception and aborted unexpectedly.");
		return 1;
	}
#endif
}
    void createStaticLibrary(CCompiler<Base>& compiler,
                             Archiver& ar,
                             bool posIndepCode) {
        // backup output format so that it can be restored
        OStreamConfigRestore coutb(std::cout);

        this->modelLibraryHelper_->startingJob("", JobTimer::STATIC_MODEL_LIBRARY);

        const std::map<std::string, ModelCSourceGen<Base>*>& models = this->modelLibraryHelper_->getModels();
        try {
            for (const auto& p : models) {
                const std::map<std::string, std::string>& modelSources = this->getSources(*p.second);

                this->modelLibraryHelper_->startingJob("", JobTimer::COMPILING_FOR_MODEL);
                compiler.compileSources(modelSources, posIndepCode, this->modelLibraryHelper_);
                this->modelLibraryHelper_->finishedJob();
            }

            const std::map<std::string, std::string>& sources = this->getLibrarySources();
            compiler.compileSources(sources, posIndepCode, this->modelLibraryHelper_);

            const std::map<std::string, std::string>& customSource = this->modelLibraryHelper_->getCustomSources();
            compiler.compileSources(customSource, posIndepCode, this->modelLibraryHelper_);

            std::string libname = _libraryName;
            if (_customLibExtension != nullptr)
                libname += *_customLibExtension;
            else
                libname += system::SystemInfo<>::STATIC_LIB_EXTENSION;

            ar.create(libname, compiler.getObjectFiles(), this->modelLibraryHelper_);
        } catch (...) {
            compiler.cleanup();
            throw;
        }
        compiler.cleanup();

        this->modelLibraryHelper_->finishedJob();
    }
Ejemplo n.º 5
0
void CProcessingMachine::ConfigureBuildTool(CBuildTool *BuildTool)
{
 CBuildTool *bt = BuildTool;
 if (PSC().VarDefined("-desc"))
 {
  bt->Description() = PSC().VarNamed("-desc").GetString();
 }
 if (PSC().VarDefined("-program"))
 {
  bt->Program() = PSC().VarNamed("-program").GetString();
 }
 if (PSC().VarDefined("-command"))
 {
  bt->CommandTemplate() = PSC().VarNamed("-command").GetString();
 }
 if (PSC().VarDefined("-mkv"))
 {
  bt->MakeVariable() = PSC().VarNamed("-mkv").GetString();
 }
 if (PSC().VarDefined("-srcext"))
 {
  ParseStr(PSC().VarNamed("-srcext").GetString(),' ',bt->SourceExtensions());
  bt->SourceExtensions().RemoveDuplicates();
  bt->SourceExtensions().RemoveEmpty();
 }
 if (PSC().VarDefined("-outext"))
 {
  bt->TargetExtension() = PSC().VarNamed("-outext").GetString();
 }
 if (PSC().VarDefined("-quotepath"))
 {
  bt->NeedQuotedPath() = PSC().VarNamed("-quotepath").GetBoolean();
 }
 if (PSC().VarDefined("-fullpath"))
 {
  bt->NeedFullPath() = PSC().VarNamed("-fullpath").GetBoolean();
 }
 if (PSC().VarDefined("-unixpath"))
 {
  bt->NeedUnixPath() = PSC().VarNamed("-unixpath").GetBoolean();
 }
 CCompiler *cc = dynamic_cast<CCompiler *>(BuildTool);
 if (0!=cc)
 {
  if (PSC().VarDefined("-incsw"))
  {
   cc->IncludeDirSwitch() = PSC().VarNamed("-incsw").GetString();
  }
  if (PSC().VarDefined("-defsw"))
  {
   cc->DefineSwitch() = PSC().VarNamed("-defsw").GetString();
  }
  if (PSC().VarDefined("-deps"))
  {
   cc->NeedDependencies() = PSC().VarNamed("-deps").GetBoolean();
  }
 }
 CLinker *ln = dynamic_cast<CLinker *>(BuildTool);
 if (0!=ln)
 {
  if (PSC().VarDefined("-ldsw"))
  {
   ln->LibraryDirSwitch() = PSC().VarNamed("-ldsw").GetString();
  }
  if (PSC().VarDefined("-llsw"))
  {
   ln->LinkLibrarySwitch() = PSC().VarNamed("-llsw").GetString();
  }
  if (PSC().VarDefined("-lpfx"))
  {
   ln->LibraryPrefix() = PSC().VarNamed("-lpfx").GetString();
   ln->NeedLibraryPrefix() = !(ln->LibraryPrefix().IsEmpty());
  }
  if (PSC().VarDefined("-lext"))
  {
   ln->LibraryExtension() = PSC().VarNamed("-lext").GetString();
  }
  if (PSC().VarDefined("-objext"))
  {
   ln->ObjectExtension() = PSC().VarNamed("-objext").GetString();
  }
  if (PSC().VarDefined("-lflat"))
  {
   ln->NeedFlatObjects() = PSC().VarNamed("-lflat").GetBoolean();
  }
 }
}
Ejemplo n.º 6
0
int main(){
    CCompiler compiler;
    compiler.Run();
    return 0;
}