-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.aardio
More file actions
169 lines (144 loc) · 4.34 KB
/
main.aardio
File metadata and controls
169 lines (144 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import win.ui;
/*DSG{{*/
mainForm = win.form(text="cmdSpecial";right=1135;bottom=702)
mainForm.add()
/*}}*/
//如果运行或发布遇到问题,请先卸载 WebView2 再运行示例以更新该组件。
import web.view;
var wb = web.view(mainForm);
import process.popen;
import fsys;
import fsys.ini
import console;
configFile = io.splitpath(io._exefile).name + ".ini"
if not io.exist(configFile){
ini = fsys.ini(configFile);
if(_STUDIO_INVOKED){
ini.write("Makefile","路径","./makefile");
}
else {
ini.write("Makefile","路径","./");
}
ini.write("Makefile","文件名","project_*.mk");
string.save(configFile, '\r\n', true);
ini.write("编译模块配置","new","new");
ini.write("编译模块配置","app","app");
ini.write("编译模块配置","simulator","simulator");
ini.write("编译模块配置","resource","resource");
string.save(configFile, '\r\n', true);
ini.write("编译配置","job","job=8");
ini.write("编译配置","j","-j4");
ini.write("编译配置","job","job=8");
string.save(configFile, '\r\n', true);
ini.write("市场名","OP","开放");
ini.write("市场名","IN","印度");
ini.write("市场名","RU","俄罗斯");
}else {
ini = fsys.ini(configFile)
}
var getAllProjectFiles = function(path, fileName){
var data = {};
fsys.enum( path, fileName,
function(dirname,filename,fullpath,findData){
if(filename){
table.insert(data, filename);
}
}
,false/*如果此参数为false则忽略子目录*/
);
return data;
}
var listToDict = function(p_list){
class DictStruct {
project_name;
makefile_name;
}
var all_project_files_list_dict = {};
for(i=1;#p_list;1){
var temp = DictStruct();
temp.project_name = string.split(p_list[i],"_")[3];
temp.makefile_name = p_list[i];
table.push(all_project_files_list_dict,temp)
}
return all_project_files_list_dict;
}
var tableUnique = function(arr,key){
var rAr = {};
var temp = {};
for(k,v in arr){
var a = v[key];
if(!rAr[a]){
rAr[a]= v;
table.insert(temp, a);
}
}
return temp;
}
//获取所有文件名
var allMakefileName = getAllProjectFiles(ini.read("Makefile","路径"), ini.read("Makefile","文件名"));
//设置文件名、项目名的键值对
var allPrjFileDict = listToDict(allMakefileName);
//提取唯一项目名
var allPrjName = tableUnique(allPrjFileDict,"project_name")
table.sort(allPrjName);
var dicData = table.array();
for(sub, prjName in allPrjName){
var temp = table.array();
for(k,prjFile in allPrjFileDict){
if(prjFile.project_name == prjName){
table.insert(temp, prjFile.makefile_name)
}
}
dicData[prjName] = temp;
}
// wb.export 导出的函数被JS调用返回的值使用JSON自动转换为JS对象
wb.export(
getAllPrjName = function(){
return allPrjName;
}
getAllMakefile = function(prjName){
return dicData[prjName];
}
//console.dump(ini.getSection("市场名").OP)
getMarketName = function(makefile){
var marketStr = string.split(makefile,"_");
var allMarketName = {};
marketStr = string.split(marketStr[#marketStr],".")[1];
allMarketName = ini.read("市场名",marketStr)
return allMarketName ? allMarketName : string.find(marketStr,"^En") ? "OP" : marketStr;;
}
getMakefilePath = function(makefile){
return io._exedir + makefile;
}
cmdSpecial = function(command){
if(_STUDIO_INVOKED){
if(string.find(command,"make")){
var configFile = io.splitpath(io._exefile).name + ".ini";
var ini = fsys.ini(configFile);
var makefilePath = string.replace(ini.getSection("Makefile").路径, "\\", "/");
if(!string.endWith(makefilePath,"/")){
makefilePath = makefilePath + "/";
}
command = string.replace(command, "make", makefilePath+"make.bat");
mainForm.msgbox(command);
return;
}
mainForm.msgbox(command);
//return;
}
//同步有同步的优势,扬长避短是智慧,倒行逆施最累人。
prcs = process.popen(command);
for( all,out,err in prcs.each() ){
wb.invoke("insertAtTheEndOfEditor", all);
}
wb.invoke("insertAtTheEndOfEditor", "---->>>End<<<----");
return;
}
isT117 = function(){
return true
}
)
import wsock.tcp.simpleHttpServer;
wb.go(wsock.tcp.simpleHttpServer.startSpaUrl("\web\index.html"))
mainForm.show();
win.loopMessage();