void CConfiguration::LoadFromFile(const CString& FileName) { CStringList configuration, sub_strings; CStringListIterator iterator(&configuration); configuration.LoadFromFile(FileName); // for (int i = 0; i < configuration.GetCount(); i++) { ParseStr(configuration[i],"=;",sub_strings); CVariable variable = VarNamed(sub_strings[0]); if (variable.GetType()==VARIABLE_TYPE_CHAR) { CStringList sub_strings2; ParseStr(sub_strings[1],"''",sub_strings2); variable.SetString(sub_strings2[1]); } else if (variable.GetType()==VARIABLE_TYPE_STRING) { CStringList sub_strings2; ParseStr(sub_strings[1],"\"\"",sub_strings2); variable.SetString(sub_strings2[1]); } sub_strings.Clear(); } }
void MessagePackReader::ParseStr32() { log_trace(); unsigned length; if (is_.Read( reinterpret_cast<char*>(&length), 4 ) != 4) anyrpc_throw(AnyRpcErrorTermination, "Parsing was terminated"); length = _msgpack_be32( length ); ParseStr( length ); }
void CVirtualTarget::Read(const TiXmlElement *TargetRoot) { char *value = 0; if ((value = (char *)TargetRoot->Attribute("alias"))) { m_Alias = value; } if ((value = (char *)TargetRoot->Attribute("targets"))) { ParseStr(value,';',m_Targets); m_Targets.RemoveEmpty(); } // decorate target name { m_MFName = MakefileFriendly(m_Alias); m_UCName = UpperCase(m_MFName); m_LCName = LowerCase(m_MFName); } }
void MessagePackReader::ParseStr8() { log_trace(); ParseStr(is_.Get()); }
void MessagePackReader::ParseFixStr() { log_trace(); ParseStr(token_ & 0x1f); }
bool CProcessingMachine::Configure(const CString& FileName) { CGenericProcessingMachine::Configure(""/*FileName*/); if (DoShowHelp()) { DisplayHelpMessage(); return false; } if (BeVerbose()) { std::cout<<"Command line parameters:"<<std::endl; PSC().Print(std::cout); } if (PSC().VarDefined("--version")) { std::cout<<"cbp2make rev."<<REVISION_NUMBER<<std::endl; return false; } #ifdef REVISION_NUMBER if (!BeQuiet()) std::cout<<"Starting cbp2make rev."<<REVISION_NUMBER<<"..."<<std::endl; #endif m_BuildManager.Config().BeQuiet() = BeQuiet(); m_BuildManager.Config().BeVerbose() = BeVerbose(); CString cfg_name = ConfigurationName(); // Lookup configuration file // 1) if "-cfg" option is specified, use it as-is // 2) if "-cfg" option is not specified do following: // 2A) use default configuration in current directory // if it exists or "--local" option is specified. // 2B) find and/or create configuration in user's home directory, // if it is not possible, fallback to current directory. if (!PSC().VarDefined(GPM_VAR_NAME_CFG) && ((!FileExists(cfg_name) && !PSC().VarDefined("--local")) || PSC().VarDefined("--global"))) { CString cfg_path = JoinPaths(HomeDirPath(),".cbp2make"); if (!DirExists(cfg_path)) { MakeDir(cfg_path); } if (DirExists(cfg_path)) { cfg_name = JoinPaths(cfg_path,DefaultConfigurationName()); } } if (FileExists(cfg_name)) { if (!BeQuiet()) std::cout<<"Using configuration: "<<cfg_name.GetCString()<<std::endl; m_BuildManager.Config().Load(cfg_name); m_BuildManager.Config().BeQuiet() = BeQuiet(); m_BuildManager.Config().BeVerbose() = BeVerbose(); } else { if (!BeQuiet()) std::cout<<"Using default configuration."<<std::endl; m_BuildManager.Config().Platforms().AddDefault(); m_BuildManager.Config().ToolChains().AddDefault(); //do not create configuration file unless explicitly instructed to do so //m_BuildManager.Config().Save(cfg_name); } if (PSC().VarDefined("--default-options")) { m_BuildManager.Config().DefaultOptions() = PSC().VarNamed("--default-options").GetString(); } if (!m_BuildManager.Config().DefaultOptions().IsEmpty()) { PS().AddParameters(m_BuildManager.Config().DefaultOptions()); PSC().ProcessParameters(PS()); CGenericProcessingMachine::Configure(""); m_BuildManager.Config().BeQuiet() = BeQuiet(); m_BuildManager.Config().BeVerbose() = BeVerbose(); } // cache frequently used variables bool os_unix = PSC().VarDefined("-unix"); bool os_windows = PSC().VarDefined("-windows"); bool os_mac = PSC().VarDefined("-mac"); CPlatform::OS_Type os_type = CPlatform::OS_Unix; if (os_unix) os_type = CPlatform::OS_Unix; else if (os_windows) os_type = CPlatform::OS_Windows; else if (os_mac) os_type = CPlatform::OS_Mac; bool os_any = os_unix || os_windows || os_mac; // configure m_BuildManager.Config().Platforms().AddDefault(); if (PSC().VarDefined("--config")) { CString config_item_str = PSC().VarNamed("--config").GetString(); int config_item = GuessStr(config_item_str,"toolchain tool platform variable options", config_item_str,true); if (0==config_item) { CString chain_name = PSC().VarNamed("-chain").GetString(); if (PSC().VarDefined("--add")) { if (PSC().VarDefined("-chain")) { CToolChain *tc = m_BuildManager.ToolChains().Find(os_type,chain_name); if (0==tc) { tc = m_BuildManager.ToolChains().Add(os_type,chain_name); } if (0==tc) return false; ConfigureToolchain(tc); } } // add-toolchain else if (PSC().VarDefined("--remove")&&PSC().VarDefined("-chain")&&os_any) { m_BuildManager.ToolChains().Remove(os_type,chain_name); } } if (1==config_item) { CString chain_name = PSC().VarNamed("-chain").GetString(); if (PSC().VarDefined("--add")) { if (PSC().VarDefined("-chain")) { CToolChain *tc = m_BuildManager.ToolChains().Find(os_type,chain_name); if (0==tc) { tc = m_BuildManager.ToolChains().Add(os_type,chain_name); } if (0==tc) return false; if (PSC().VarDefined("-tool")&&PSC().VarDefined("-type")) { CString tool_type_str = PSC().VarNamed("-type").GetString(); int tool_type_int = GuessStr(tool_type_str,"other pp as cc rc sl dl el nl count", tool_type_str,false); CBuildTool::ToolType tool_type = (CBuildTool::ToolType)tool_type_int; CString tool_name = PSC().VarNamed("-tool").GetString(); CBuildTool *bt = tc->FindBuildToolByName(tool_name); if (0==bt) { bt = tc->CreateBuildTool(tool_type); bt->Alias() = tool_name; } if (0==bt) return false; ConfigureBuildTool(bt); } } } // add-tool else if (PSC().VarDefined("--remove")&&PSC().VarDefined("-chain")&&PSC().VarDefined("-tool")&&os_any) { CToolChain *tc = m_BuildManager.ToolChains().Find(os_type,chain_name); if (0!=tc) { return tc->RemoveToolByName(PSC().VarNamed("-tool").GetString()); } } } if (2==config_item) { if (os_any) { CPlatform *p = m_BuildManager.Platforms().Find(os_type); if (0==p) return false; ConfigurePlatform(p); } } if (3==config_item) { if (PSC().VarDefined("--add")) { CString set_name = PSC().VarNamed("-set").GetString(); if (PSC().VarDefined("-name") && PSC().VarDefined("-value")) { CString var_name = PSC().VarNamed("-name").GetString(); CGlobalVariableSet *vset = m_BuildManager.Config().GlobalVariables().Add(set_name); CGlobalVariable *var = vset->Add(var_name); if (PSC().VarDefined("-desc")) { var->Description() = PSC().VarNamed("-desc").GetString(); } if (PSC().VarDefined("-value")) { var->Add(PSC().VarNamed("-field").GetString(), PSC().VarNamed("-value").GetString()); } } } // add variable else if (PSC().VarDefined("--remove")) { CString set_name = PSC().VarNamed("-set").GetString(); if (PSC().VarDefined("-name")) { CString var_name = PSC().VarNamed("-name").GetString(); CGlobalVariableSet *vset = m_BuildManager.Config().GlobalVariables().Add(set_name); CGlobalVariable *var = vset->Add(var_name); if (PSC().VarDefined("-field")) { // if both variable and field names are defined, remove the field var->Remove(PSC().VarNamed("-field").GetString()); } else { // if variable name is defined, but field name is not, remove the variable vset->Remove(var_name); } } else { // if both variable and field names are not defined, // but set name is defined, remove the entire set if (PSC().VarDefined("-set")) { m_BuildManager.Config().GlobalVariables().Remove(set_name); } } } // remove variable } // config variable if (config_item < 0) m_BuildManager.Config().Show(); std::cout<<"Saving configuration: "<<cfg_name.GetCString()<<std::endl; m_BuildManager.Config().Save(cfg_name); return false; } // config // bool os_all = PSC().VarDefined("--all-os"); os_all = os_all || (os_unix && os_windows && os_mac); os_unix = os_unix || os_all; os_windows = os_windows || os_all; os_mac = os_mac || os_all; bool os_none = !os_all && !os_unix && !os_windows && !os_mac; if (os_none) { #ifdef OS_UNIX os_unix = true; #endif #ifdef OS_WIN os_windows = true; #endif #ifdef OS_MAC os_mac = true; #endif } if (os_unix) { CPlatform *p = m_BuildManager.Config().Platforms().Find(CPlatform::OS_Unix); if (p) p->Active() = true; } if (os_windows) { CPlatform *p = m_BuildManager.Config().Platforms().Find(CPlatform::OS_Windows); if (p) p->Active() = true; } if (os_mac) { CPlatform *p = m_BuildManager.Config().Platforms().Find(CPlatform::OS_Mac); if (p) p->Active() = true; } // { CString vset_name = PSC().VarNamed("-set").GetString(); CGlobalVariableSet *vset = m_BuildManager.Config().GlobalVariables().Find(vset_name); if (0!=vset) { vset->Active() = true; } } m_BuildManager.Config().FlatObjectNames() = PSC().VarDefined("--flat-objects"); m_BuildManager.Config().FlatObjectPaths() = PSC().VarDefined("--flat-objpath"); m_BuildManager.Config().MultilineObjects() = PSC().VarDefined("--wrap-objects"); m_BuildManager.Config().MultilineOptions() = PSC().VarDefined("--wrap-options"); m_BuildManager.Config().IncludeDependencies() = PSC().VarDefined("--with-deps"); { CString target_case_name = PSC().VarNamed("--target-case").GetString(); m_BuildManager.Config().TargetNameCase() = GuessStr(target_case_name,"keep lower upper",target_case_name,false); } { CString macros_case_name = PSC().VarNamed("--macros-case").GetString(); m_BuildManager.Config().MacroVariableCase() = GuessStr(macros_case_name,"keep lower upper",macros_case_name,false); } { CString quote_path_name = PSC().VarNamed("--quote-path").GetString(); m_BuildManager.Config().QuotePathMode() = GuessStr(quote_path_name,"auto never always",quote_path_name,false); } m_BuildManager.Config().KeepObjectDirectories() = PSC().VarDefined("--keep-objdir"); m_BuildManager.Config().KeepOutputDirectories() = PSC().VarDefined("--keep-outdir"); { CStringList targets; ParseStr(PSC().VarNamed("-targets").GetString(),',',targets); targets.RemoveEmpty(); targets.RemoveDuplicates(); m_BuildManager.Config().Targets() = targets; } //if (BeVerbose()) PSC().Print(std::cout); return true; }
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(); } } }
void CBuildTarget::Read(const TiXmlElement *TargetRoot) { char *value = 0; if ((value = (char *)TargetRoot->Attribute("title"))) m_Title = value; TiXmlNode *_option = (TiXmlNode *)TargetRoot->FirstChild("Option"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { char *value = 0; if ((value = (char *)option->Attribute("platforms"))) { ParseStr(value,';',m_Platforms); m_Platforms.RemoveEmpty(); } if ((value = (char *)option->Attribute("output"))) { m_Output = value; } if ((value = (char *)option->Attribute("prefix_auto"))) { m_AutoPrefix = StringToBoolean(value); } if ((value = (char *)option->Attribute("extension_auto"))) { m_AutoExtension = StringToBoolean(value); } if ((value = (char *)option->Attribute("working_dir"))) { m_WorkingDirectory = value; } if ((value = (char *)option->Attribute("object_output"))) { m_ObjectOutput = value; } if ((value = (char *)option->Attribute("external_deps"))) { ParseStr(value,';',m_ExternalDependencies); m_ExternalDependencies.RemoveEmpty(); } if ((value = (char *)option->Attribute("type"))) { m_Type = (CBuildTarget::TargetType)StringToInteger(value); } if ((value = (char *)option->Attribute("compiler"))) { m_Compiler = value; } if ((value = (char *)option->Attribute("projectCompilerOptionsRelation"))) { m_CompilerOptionsRelation = (CBuildTarget::OptionsRelation)StringToInteger(value); } if ((value = (char *)option->Attribute("projectLinkerOptionsRelation"))) { m_LinkerOptionsRelation = (CBuildTarget::OptionsRelation)StringToInteger(value); } if ((value = (char *)option->Attribute("projectIncludeDirsRelation"))) { m_IncludeDirectoriesRelation = (CBuildTarget::OptionsRelation)StringToInteger(value); } if ((value = (char *)option->Attribute("projectResourceIncludeDirsRelation"))) { m_ResourceIncludeDirectoriesRelation = (CBuildTarget::OptionsRelation)StringToInteger(value); } if ((value = (char *)option->Attribute("projectLibDirsRelation"))) { m_LibraryDirectoriesRelation = (CBuildTarget::OptionsRelation)StringToInteger(value); } /* if ((value = (char *)option->Attribute(""))) { = value; } */ } _option = (TiXmlNode *)TargetRoot->IterateChildren(_option); } // option TiXmlNode *_compiler = (TiXmlNode *)TargetRoot->FirstChild("Compiler"); if (0!=_compiler) { TiXmlNode *_option = (TiXmlNode *)_compiler->FirstChild("Add"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { char *value = 0; if ((value = (char *)option->Attribute("option"))) { m_CompilerOptions.Insert(value); } if ((value = (char *)option->Attribute("directory"))) { m_CompilerDirectories.Insert(value); } } _option = (TiXmlNode *)_compiler->IterateChildren(_option); } // option } // compiler TiXmlNode *_res_compiler = (TiXmlNode *)TargetRoot->FirstChild("ResourceCompiler"); if (0!=_res_compiler) { TiXmlNode *_option = (TiXmlNode *)_res_compiler->FirstChild("Add"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { char *value = 0; if ((value = (char *)option->Attribute("directory"))) { m_ResourceCompilerDirectories.Insert(value); } } _option = (TiXmlNode *)_res_compiler->IterateChildren(_option); } // option } // resource compiler TiXmlNode *_linker = (TiXmlNode *)TargetRoot->FirstChild("Linker"); if (0!=_linker) { TiXmlNode *_option = (TiXmlNode *)_linker->FirstChild("Add"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { if (strcmp(option->Value(),"Add")) break; char *value = 0; if ((value = (char *)option->Attribute("option"))) { m_LinkerOptions.Insert(value); } if ((value = (char *)option->Attribute("directory"))) { m_LinkerDirectories.Insert(value); } if ((value = (char *)option->Attribute("library"))) { m_LinkerLibraries.Insert(value); } } _option = (TiXmlNode *)_linker->IterateChildren(_option); } // option } // linker TiXmlNode *_extra_cmd = (TiXmlNode *)TargetRoot->FirstChild("ExtraCommands"); if (0!=_extra_cmd) { TiXmlNode *_option = (TiXmlNode *)_extra_cmd->FirstChild("Add"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { if (strcmp(option->Value(),"Add")) break; char *value = 0; if ((value = (char *)option->Attribute("before"))) { m_BeforeBuildCommands.Insert(value); } if ((value = (char *)option->Attribute("after"))) { m_AfterBuildCommands.Insert(value); } } _option = (TiXmlNode *)_extra_cmd->IterateChildren(_option); } // option _option = (TiXmlNode *)_extra_cmd->FirstChild("Mode"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { if (strcmp(option->Value(),"Mode")) break; char *value = 0; if ((value = (char *)option->Attribute("before"))) { m_ForceBeforeBuildCommands = (strcmp(value,"always")==0); } if ((value = (char *)option->Attribute("after"))) { m_ForceAfterBuildCommands = (strcmp(value,"always")==0); } } _option = (TiXmlNode *)_extra_cmd->IterateChildren(_option); } // option } // extra commands // decorate target name { m_MFName = MakefileFriendly(m_Title); m_UCName = UpperCase(m_MFName); m_LCName = LowerCase(m_MFName); m_ObjectOutput = RemoveTrailingPathDelimiter(m_ObjectOutput); } }
bool wxsCustomEditorProperty::PGRead(wxsPropertyContainer* Object,wxPropertyGridManager* Grid, wxPGId PGId,long Index) { return CanParseStr() && ParseStr(Object,Grid->GetPropertyValue(PGId).GetString()); }
void CParameterString::AddParameters(const CString& Parameters) { CStringList l_Parameters; ParseStr(Parameters,' ',l_Parameters); m_Parameters.Insert(l_Parameters); }
void CParameterString::SetParameters(const CString& Parameters) { m_Parameters.Clear(); ParseStr(Parameters,' ',m_Parameters); }