logplus/Workflow/WFEngine/WorkflowEngine/include/WorkflowCompiler.h

180 lines
6.0 KiB
C
Raw Normal View History

2026-01-16 17:18:41 +08:00
/**
* @file WorkflowCompiler.h
* @brief
*
* @author
* @date 2011-8-23
*/
#ifndef PAI_FRAME_WORKFLOWENGINE_WORKFLOWCOMPILER_H
#define PAI_FRAME_WORKFLOWENGINE_WORKFLOWCOMPILER_H
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include "ModuleManager.h"
#include "ModuleMetaData.h"
#include "WorkflowConstants.h"
#include "WorkFlowFile.h"
#include "ConfigureManager.h"
#include "StringUtils.h"
#include "DataSetRepository.h"
#include "DataSetInfo.h"
#include "Turtle.h"
using namespace pai::ios::seis;
namespace pai {
namespace workflow {
/*编译参数*/
typedef struct SCompileParam {
//编译主目录
std::string strCompileRootPath;
//代码文件名称
std::string strSoureCodeFileName;
//动态库名称
std::string strShareLibName;
//类库输出路径
std::string strOutputLibDir;
SCompileParam():strCompileRootPath(), strSoureCodeFileName(),
strShareLibName(), strOutputLibDir()
{
}
} SCompileParam;
/*编译内部参数*/
typedef struct SCompileInnerParam {
//部署路径
std::string strProjectDeployPath;
//Shell模板文件夹路径
std::string strCompileShellPath;
//Makefile模板文件夹路径
std::string strCompileMakePath;
//日志文件名称
std::string strLogFileName;
//工作流编译器固定的头文件全路径(临时)
std::string strFixedIncludePaths;
//工作流编译器固定的类库全路径(临时)
std::string strFixedLibPaths;
//工作流编译器固定的类库名称(临时)
std::string strFixedLibNames;
//工作流编译环境检查脚本路径
std::string strCompilerCheckShellPath;
SCompileInnerParam():strProjectDeployPath(), strCompileShellPath(), strCompileMakePath(), \
strLogFileName(), strFixedIncludePaths(), strFixedLibPaths(), strFixedLibNames(),\
strCompilerCheckShellPath(){}
} SCompileInnerParam;
struct SWorkflowResource;
/**
* @brief
*
*
* (1)
*
*/
class PAI_WORKFLOWENGINE_EXPORT CWorkflowCompiler {
public:
CWorkflowCompiler(const std::string& strConfigPath);
CWorkflowCompiler();
virtual ~CWorkflowCompiler();
public:
/*
* @brief
*
* (strCompileRootPath)
* (strOutputLibDir);
* errorMsg里
*
* @param[in] workFlowFile
* @param[in] SCompileParam
* @param[in/out] errorMsg
* @pre errorMsg
* @return
*/
bool CompileWorkflowFile(CWorkFlowFile* worflowFile,const SCompileParam& condition,std::string &strErrorMsg);
/*
* @brief MapReduce配置信息
* @param[in] workFlowFile
* @param[in/out] properties
*/
void GetWorkFlowProperties(CWorkFlowFile* worflowFile,Properties& properties);
/*
* @brief jar文件
* Jar模板文件.
* @param[in] strTemplateJarPath Jar模板文件路径
* @param[in] resource
* @param[in] strJobFilePath
* @return
*/
bool GeneratorJobFile(const std::string& strTemplateJarPath,const SWorkflowResource& resource,std::string& strJobFilePath);
/*
* @brief PSTM作业jar文件
* Jar模板文件,pstm.ini文件
* @param[in] strTemplateJarPath Jar模板文件路径
* @param[in] resource
* @param[in] strJobFilePath
* @return
*/
std::string GetConfigPath() const { return this->m_strConfigPath;}
void SetConfigPath(const std::string& strConfigPath ) { this->m_strConfigPath = strConfigPath; }
private:
//解析配置获取,编译内部需要的参数
void GetComipleInnerParam(SCompileInnerParam& param);
/*
* @brief
*
* ,@ref ModuleManager的GetLibInfo()
*
* @param[in] workFlowFile
* @param[in/out] reflibs
* @return
*/
bool AnalyzeRefLib(CWorkFlowFile* worflowFile,std::vector<CModuleMetaData*>* reflibs);
/*
* @brief
*
*
* ()Shell环境变量;
* comipler.sh(makfile模板-workflow.mk),
*
* @param[in] externalParam
* @param[in] innerParam
* @param[in] reflibs
* @param[in/out] errorMsg
* @pre errorMsg
* @return
*/
bool InnerCompiler(const SCompileParam& externalParam,const SCompileInnerParam& innerParam,std::vector<CModuleMetaData*>* reflibs,std::string& strErrorMsg);
//获取编译参数
std::string GetCompileParameters(const SCompileParam& externalParam, const SCompileInnerParam& innerParam, std::vector<
CModuleMetaData*>* reflibs);
//读取编译日志
bool ReadCompileLog(const std::string& strLogPath,std::string& strContents);
//检查编译参数
virtual bool CheckExternalParam(const SCompileParam& /*externalParam*/){ return true;}
//工作流编译环境检查
bool PreCompileCheck(const SCompileInnerParam& innerParam);
public:
//执行Shell系统调用
bool static CallSystemShell(const std::string& strCommand);
private:
std::string m_strConfigPath;
};
}
}
#endif