source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/src/Program.cpp@ 477

Last change on this file since 477 was 477, checked in by dai_9181, 16 years ago

構成管理を大幅に改良。

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