-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstalllib.lx
120 lines (86 loc) · 2.5 KB
/
installlib.lx
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
println("install mods script start..");
// 定义一些要用的函数
// 切换目录,之前写错的,不想很麻烦的给改掉 就这样了
sy_cd => (path){
sy_chdir(path);
}
// 编译一个 mod, 参数为项目路径
complieMod => ( projectDir ){
exist = sy_exists(projectDir) ;
if( !exist ){
println("工程目录" + projectDir + " 不存在,跳过" );
return ;
}
buildDir = projectDir + "/build" ;
exist = sy_exists(buildDir) ;
if ( !exist ){
sy_mkdir(buildDir);
}
// 把工作目录定位到build 里面
sy_chdir(buildDir);
sy_run_and_print("cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local"); //
sy_run_and_print("make && make install");
println("=========================================================");
println("| build " + projectDir + " over");
println("=========================================================");
}
dlFile => ( url ){
sy_run_and_print("wget " + url );
}
// 检测文件是否存在, 如果不存在则会询问用户是否要进行下载
checkExecExistsAndDownload => (execName, dlUrl, installFunc){
// usr/bin
exist = sy_exists("/usr/bin/" + execName);
if ( exist ){
return ;
}
exist = sy_exists("/usr/local/bin/" + execName);
if ( exist ){
return ;
}
askAndDL(execName, dlUrl, installFunc );
}
// 检测库是否存在, 不存在则尝试下载行为
checkLibExistsAndDownload => ( libName, dlUrl, installFunc ){
name = libName + ".so";
exist = sy_exists("/usr/lib/" + name);
if ( exist ){
return ;
}
exist = sy_exists("/usr/local/lib/" + name);
if ( exist ){
return ;
}
askAndDL(name, dlUrl, installFunc );
}
// 实际运行的脚本内容
// 获取当前所在目录
current_dir = sy_cwd();
println("============================================================================");
println("============================================================================");
println("current_dir: " + current_dir);
checkDir = current_dir + "/modProjects" ;
exist = sy_exists(checkDir);
if( !exist ){
println( checkDir + "不存在,请确认下");
exit(-1);
}
parentDir = checkDir;
// core 库
projectDir = parentDir + "/langX-Core";
complieMod(projectDir);
// json 库
projectDir = parentDir + "/langX-Json";
complieMod(projectDir);
// libevent 库
projectDir = parentDir + "/langX-libevent";
complieMod(projectDir);
// python 库
projectDir = parentDir + "/langX-Python";
complieMod(projectDir);
// mysql 库
projectDir = parentDir + "/langX-Mysql";
complieMod(projectDir);
println("");
println("");
println("install script run over!");