| 1 | #include "stdafx.h"
|
|---|
| 2 |
|
|---|
| 3 | Jenga::Common::Logger Program::logger( Program::GetAbcUserAppDir() + "\\logger.log", true );
|
|---|
| 4 |
|
|---|
| 5 | Program program;
|
|---|
| 6 |
|
|---|
| 7 | void Program::Configurate()
|
|---|
| 8 | {
|
|---|
| 9 | Configuration configuration;
|
|---|
| 10 | const std::string filePath = Jenga::Common::Environment::GetAppDir() + "\\config.xml";
|
|---|
| 11 | if( Jenga::Common::Path( filePath ).IsExistFile() )
|
|---|
| 12 | {
|
|---|
| 13 | configuration.ReadXml( filePath );
|
|---|
| 14 | }
|
|---|
| 15 | else
|
|---|
| 16 | {
|
|---|
| 17 | configuration.WriteXml( filePath );
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | ActiveBasic::Common::Environment::SetAbdevRootPath( configuration.GetAbdevRootRelativePath() );
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | bool Program::AnalysisCommandLines()
|
|---|
| 24 | {
|
|---|
| 25 | // コマンドラインを解析
|
|---|
| 26 | const Jenga::Common::CmdLines cmdLines( PathGetArgs( GetCommandLine() ) );
|
|---|
| 27 | int cmdLineIndex = 0;
|
|---|
| 28 |
|
|---|
| 29 | if( cmdLines.size() == 0 )
|
|---|
| 30 | {
|
|---|
| 31 | // 何も指定されていないとき
|
|---|
| 32 | return true;
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | if( cmdLines[cmdLineIndex].IsNamelessCommand() )
|
|---|
| 36 | {
|
|---|
| 37 | // 先頭に無名コマンドがきた場合、ソースファイル名として認識する
|
|---|
| 38 | std::string tempParam = cmdLines[cmdLineIndex].GetParameter();
|
|---|
| 39 | Program::SetSourceFilePath( Jenga::Common::StringReplace( tempParam, "/", "\\" ) );
|
|---|
| 40 |
|
|---|
| 41 | cmdLineIndex ++;
|
|---|
| 42 |
|
|---|
| 43 | if( cmdLines.size() == 1 )
|
|---|
| 44 | {
|
|---|
| 45 | // ソースファイル名のみの指定だったとき
|
|---|
| 46 | return true;
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | // 出力ファイル名を取得
|
|---|
| 50 | if( cmdLines[cmdLineIndex].IsNamelessCommand() )
|
|---|
| 51 | {
|
|---|
| 52 | // 二番目にも無名コマンドがきた場合、出力ファイル名として認識する
|
|---|
| 53 | std::string tempParam = cmdLines[cmdLineIndex].GetParameter();
|
|---|
| 54 | SetOutputFilePath( Jenga::Common::StringReplace( tempParam, "/", "\\" ) );
|
|---|
| 55 |
|
|---|
| 56 | cmdLineIndex ++;
|
|---|
| 57 | }
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | for( ; cmdLineIndex < static_cast<int>(cmdLines.size()); cmdLineIndex++ )
|
|---|
| 61 | {
|
|---|
| 62 | const Jenga::Common::CmdLine &cmdLine = cmdLines[cmdLineIndex];
|
|---|
| 63 |
|
|---|
| 64 | if( cmdLine.GetCommand() == "wnd" )
|
|---|
| 65 | {
|
|---|
| 66 | // 親エディタのウィンドウ ハンドル
|
|---|
| 67 | isKickedFromEditor = true;
|
|---|
| 68 | sscanf( cmdLine.GetParameter().c_str(), "%p", &hOwnerEditor );
|
|---|
| 69 | }
|
|---|
| 70 | else if( cmdLine.GetCommand() == "show_dlg" )
|
|---|
| 71 | {
|
|---|
| 72 | isShowDlg = true;
|
|---|
| 73 | }
|
|---|
| 74 | else if( cmdLine.GetCommand() == "debug" )
|
|---|
| 75 | {
|
|---|
| 76 | // デバッグ ビルド
|
|---|
| 77 | compiler.SetDebugMark( true );
|
|---|
| 78 | }
|
|---|
| 79 | else if( cmdLine.GetCommand() == "run" )
|
|---|
| 80 | {
|
|---|
| 81 | // デバッグ実行
|
|---|
| 82 | isDebugRun = true;
|
|---|
| 83 | }
|
|---|
| 84 | else if( cmdLine.GetCommand() == "attach" )
|
|---|
| 85 | {
|
|---|
| 86 | // アタッチ
|
|---|
| 87 | isDebugRun = true;
|
|---|
| 88 | isAttach = true;
|
|---|
| 89 | sscanf( cmdLine.GetParameter().c_str(), "%08x", &attachProcessId );
|
|---|
| 90 | }
|
|---|
| 91 | else if( cmdLine.GetCommand() == "dll" )
|
|---|
| 92 | {
|
|---|
| 93 | // DLLとしてビルド
|
|---|
| 94 | compiler.SetTargetModuleType( ActiveBasic::Common::TargetModuleType::Dll );
|
|---|
| 95 | }
|
|---|
| 96 | else if( cmdLine.GetCommand() == "static_library" )
|
|---|
| 97 | {
|
|---|
| 98 | // 静的リンクライブラリとしてビルド
|
|---|
| 99 | compiler.SetTargetModuleType( ActiveBasic::Common::TargetModuleType::Sll );
|
|---|
| 100 | }
|
|---|
| 101 | else if( cmdLine.GetCommand() == "unicode" )
|
|---|
| 102 | {
|
|---|
| 103 | // Unicode
|
|---|
| 104 | compiler.SetUnicodeMark( true );
|
|---|
| 105 | typeOfPtrChar = MAKE_PTR_TYPE(DEF_WORD,1);
|
|---|
| 106 | typeOfPtrUChar = MAKE_PTR_TYPE(DEF_WORD,1);
|
|---|
| 107 | }
|
|---|
| 108 | else if( cmdLine.GetCommand() == "clip_compile_view" )
|
|---|
| 109 | {
|
|---|
| 110 | //埋め込み型コンパイラビュー
|
|---|
| 111 | isClipCompileView = true;
|
|---|
| 112 | }
|
|---|
| 113 | else if( cmdLine.GetCommand() == "include_dir" )
|
|---|
| 114 | {
|
|---|
| 115 | //インクルード ディレクトリ
|
|---|
| 116 | includeDir = cmdLines[cmdLineIndex].GetParameter();
|
|---|
| 117 |
|
|---|
| 118 | // '/' があった場合は '\\' に置換
|
|---|
| 119 | Jenga::Common::StringReplace( includeDir, "/", "\\" );
|
|---|
| 120 | }
|
|---|
| 121 | else if( cmdLine.GetCommand() == "?" || cmdLine.GetCommand() == "help" )
|
|---|
| 122 | {
|
|---|
| 123 | std::cout << "TODO: ActiveBasic command line help." << std::endl;
|
|---|
| 124 | }
|
|---|
| 125 | else
|
|---|
| 126 | {
|
|---|
| 127 | // 不正なコマンド
|
|---|
| 128 | std::string keyword = cmdLine.GetCommand();
|
|---|
| 129 | if( keyword.size() == 0 )
|
|---|
| 130 | {
|
|---|
| 131 | keyword = cmdLine.GetParameter();
|
|---|
| 132 | }
|
|---|
| 133 | std::cout << keyword << " コマンドとして認識できません。" << std::endl;
|
|---|
| 134 | return false;
|
|---|
| 135 | }
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | return true;
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | const std::string Program::GetAbcUserAppDir()
|
|---|
| 142 | {
|
|---|
| 143 | return ActiveBasic::Common::Environment::GetUserAppDir() + "\\abc";
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | int Program::GetExitCode() const
|
|---|
| 147 | {
|
|---|
| 148 | if( !compiler.IsBuildSuccessful() )
|
|---|
| 149 | {
|
|---|
| 150 | // ビルドに失敗
|
|---|
| 151 | return 1;
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | // ビルドに成功
|
|---|
| 155 | return 0;
|
|---|
| 156 | }
|
|---|