#include "stdafx.h" Jenga::Common::Logger Program::logger( Jenga::Common::Environment::GetAppDir() + "\\logger.log", true ); Program program; void Program::Configurate() { Configuration configuration; const std::string filePath = Jenga::Common::Environment::GetAppDir() + "\\config.xml"; if( Jenga::Common::Path( filePath ).IsExistFile() ) { configuration.ReadXml( filePath ); } else { configuration.WriteXml( filePath ); } ActiveBasic::Common::Environment::SetAbdevRootPath( configuration.GetAbdevRootRelativePath() ); } bool Program::AnalysisCommandLines() { // コマンドラインを解析 const Jenga::Common::CmdLines cmdLines( PathGetArgs( GetCommandLine() ) ); int cmdLineIndex = 0; if( cmdLines.size() == 0 ) { // 何も指定されていないとき return true; } if( cmdLines[cmdLineIndex].IsNamelessCommand() ) { // 先頭に無名コマンドがきた場合、ソースファイル名として認識する std::string tempParam = cmdLines[cmdLineIndex].GetParameter(); Program::SetSourceFilePath( Jenga::Common::StringReplace( tempParam, "/", "\\" ) ); cmdLineIndex ++; if( cmdLines.size() == 1 ) { // ソースファイル名のみの指定だったとき return true; } // 出力ファイル名を取得 if( cmdLines[cmdLineIndex].IsNamelessCommand() ) { // 二番目にも無名コマンドがきた場合、出力ファイル名として認識する std::string tempParam = cmdLines[cmdLineIndex].GetParameter(); SetOutputFilePath( Jenga::Common::StringReplace( tempParam, "/", "\\" ) ); cmdLineIndex ++; } } for( ; cmdLineIndex < static_cast(cmdLines.size()); cmdLineIndex++ ) { const Jenga::Common::CmdLine &cmdLine = cmdLines[cmdLineIndex]; if( cmdLine.GetCommand() == "wnd" ) { // 親エディタのウィンドウ ハンドル isKickedFromEditor = true; sscanf( cmdLine.GetParameter().c_str(), "%p", &hOwnerEditor ); } else if( cmdLine.GetCommand() == "show_dlg" ) { isShowDlg = true; } else if( cmdLine.GetCommand() == "debug" ) { // デバッグ ビルド compiler.SetDebugMark( true ); } else if( cmdLine.GetCommand() == "run" ) { // デバッグ実行 isDebugRun = true; } else if( cmdLine.GetCommand() == "attach" ) { // アタッチ isDebugRun = true; isAttach = true; sscanf( cmdLine.GetParameter().c_str(), "%08x", &attachProcessId ); } else if( cmdLine.GetCommand() == "dll" ) { // DLLとしてビルド compiler.SetTargetModuleType( ActiveBasic::Common::TargetModuleType::Dll ); } else if( cmdLine.GetCommand() == "static_library" ) { // 静的リンクライブラリとしてビルド compiler.SetTargetModuleType( ActiveBasic::Common::TargetModuleType::Sll ); } else if( cmdLine.GetCommand() == "unicode" ) { // Unicode compiler.SetUnicodeMark( true ); typeOfPtrChar = MAKE_PTR_TYPE(DEF_WORD,1); typeOfPtrUChar = MAKE_PTR_TYPE(DEF_WORD,1); } else if( cmdLine.GetCommand() == "clip_compile_view" ) { //埋め込み型コンパイラビュー isClipCompileView = true; } else if( cmdLine.GetCommand() == "include_dir" ) { //インクルード ディレクトリ includeDir = cmdLines[cmdLineIndex].GetParameter(); // '/' があった場合は '\\' に置換 Jenga::Common::StringReplace( includeDir, "/", "\\" ); } else if( cmdLine.GetCommand() == "?" || cmdLine.GetCommand() == "help" ) { std::cout << "TODO: ActiveBasic command line help." << std::endl; } else { // 不正なコマンド std::string keyword = cmdLine.GetCommand(); if( keyword.size() == 0 ) { keyword = cmdLine.GetParameter(); } std::cout << keyword << " コマンドとして認識できません。" << std::endl; return false; } } return true; } const std::string Program::GetUserAppDir() { return Jenga::Common::Environment::GetUserAppDir() + "\\ActiveBasic\\abc"; } int Program::GetExitCode() const { if( !compiler.IsBuildSuccessful() ) { // ビルドに失敗 return 1; } // ビルドに成功 return 0; }