|
ds@1952
|
1 |
using System; |
|
ds@1952
|
2 |
using System.IO; |
|
ds@1952
|
3 |
using System.Diagnostics; |
|
ds@1952
|
4 |
|
|
ds@1952
|
5 |
namespace builder |
|
ds@1952
|
6 |
{ |
|
ds@1952
|
7 |
public class LinuxBuilder : ABuilder |
|
ds@1952
|
8 |
{ |
|
ds@1952
|
9 |
public LinuxBuilder(Config _cfg) |
|
ds@1952
|
10 |
{ |
|
ds@1952
|
11 |
cfg = _cfg; |
|
ds@1952
|
12 |
} |
|
ds@1952
|
13 |
|
|
ds@1952
|
14 |
public override string GetPawnCompilerName() |
|
ds@1952
|
15 |
{ |
|
ds@1952
|
16 |
return "spcomp"; |
|
ds@1952
|
17 |
} |
|
ds@1952
|
18 |
|
|
ds@1952
|
19 |
public override bool BuildLibrary(Package pkg, Library lib) |
|
ds@1952
|
20 |
{ |
|
ds@1952
|
21 |
ProcessStartInfo info = new ProcessStartInfo(); |
|
ds@1952
|
22 |
|
|
ds@1952
|
23 |
string path = Config.PathFormat("{0}/{1}", |
|
ds@1952
|
24 |
cfg.source_path, |
|
ds@1952
|
25 |
lib.source_path); |
|
ds@1952
|
26 |
|
|
ds@1952
|
27 |
/* PlatformExt ignored for us */ |
|
ds@1952
|
28 |
string binName = lib.binary_name; |
|
ds@1952
|
29 |
|
|
ds@1952
|
30 |
if (!lib.is_executable) |
|
ds@1952
|
31 |
{ |
|
ds@1952
|
32 |
if (lib.has_platform_ext) |
|
ds@1952
|
33 |
{ |
|
ds@1952
|
34 |
binName += "_i486.so"; |
|
ds@1952
|
35 |
} |
|
ds@1952
|
36 |
else |
|
ds@1952
|
37 |
{ |
|
ds@1952
|
38 |
binName += ".so"; |
|
ds@1952
|
39 |
} |
|
ds@1952
|
40 |
} |
|
ds@1952
|
41 |
|
|
ds@1952
|
42 |
string output_folder = (lib.release_mode == ReleaseMode.ReleaseMode_Release) ? "Release" : "Debug"; |
|
ds@1952
|
43 |
|
|
ds@1952
|
44 |
if (lib.build_mode == BuildMode.BuildMode_Episode2) |
|
ds@1952
|
45 |
{ |
|
ds@1952
|
46 |
output_folder += ".orangebox"; |
|
ds@1952
|
47 |
} |
|
ds@1952
|
48 |
else if (lib.build_mode == BuildMode.BuildMode_OldMetamod) |
|
ds@1952
|
49 |
{ |
|
ds@1952
|
50 |
output_folder += ".original"; |
|
ds@1952
|
51 |
} |
|
ds@1952
|
52 |
|
|
ds@1952
|
53 |
string binpath = Config.PathFormat("{0}/{1}/{2}", |
|
ds@1952
|
54 |
path, |
|
ds@1952
|
55 |
output_folder, |
|
ds@1952
|
56 |
binName); |
|
ds@1952
|
57 |
|
|
ds@1952
|
58 |
if (File.Exists(binpath)) |
|
ds@1952
|
59 |
{ |
|
ds@1952
|
60 |
File.Delete(binpath); |
|
ds@1952
|
61 |
} |
|
ds@1952
|
62 |
|
|
ds@1952
|
63 |
string makefile_args = ""; |
|
ds@1952
|
64 |
|
|
ds@1952
|
65 |
if (lib.build_mode == BuildMode.BuildMode_Episode1) |
|
ds@1952
|
66 |
{ |
|
ds@1952
|
67 |
makefile_args = null; |
|
ds@1952
|
68 |
} |
|
ds@1952
|
69 |
else if (lib.build_mode == BuildMode.BuildMode_Episode2) |
|
ds@1952
|
70 |
{ |
|
ds@1952
|
71 |
makefile_args = "ENGINE=\"orangebox\""; |
|
ds@1952
|
72 |
} |
|
ds@1952
|
73 |
else if (lib.build_mode == BuildMode.BuildMode_OldMetamod) |
|
ds@1952
|
74 |
{ |
|
ds@1952
|
75 |
makefile_args = "ENGINE=\"original\""; |
|
ds@1952
|
76 |
} |
|
ds@1952
|
77 |
|
|
ds@1952
|
78 |
/* Clean the project first */ |
|
ds@1952
|
79 |
info.WorkingDirectory = path; |
|
ds@1952
|
80 |
info.FileName = cfg.builder_path; |
|
ds@1952
|
81 |
info.Arguments = makefile_args + " clean"; |
|
ds@1952
|
82 |
info.UseShellExecute = false; |
|
ds@1952
|
83 |
|
|
ds@1952
|
84 |
Process p = Process.Start(info); |
|
ds@1952
|
85 |
p.WaitForExit(); |
|
ds@1952
|
86 |
p.Close(); |
|
ds@1952
|
87 |
|
|
ds@1952
|
88 |
/* Now build it */ |
|
ds@1952
|
89 |
info.WorkingDirectory = path; |
|
ds@1952
|
90 |
info.FileName = cfg.builder_path; |
|
ds@1952
|
91 |
info.Arguments = makefile_args; |
|
ds@1952
|
92 |
info.UseShellExecute = false; |
|
ds@1952
|
93 |
|
|
ds@1952
|
94 |
if (cfg.build_options != null) |
|
ds@1952
|
95 |
{ |
|
ds@1952
|
96 |
info.Arguments += " " + cfg.build_options; |
|
ds@1952
|
97 |
} |
|
ds@1952
|
98 |
|
|
ds@1952
|
99 |
p = Process.Start(info); |
|
ds@1952
|
100 |
p.WaitForExit(); |
|
ds@1952
|
101 |
p.Close(); |
|
ds@1952
|
102 |
|
|
ds@1952
|
103 |
if (!File.Exists(binpath)) |
|
ds@1952
|
104 |
{ |
|
ds@1952
|
105 |
return false; |
|
ds@1952
|
106 |
} |
|
ds@1952
|
107 |
|
|
ds@1952
|
108 |
path = Config.PathFormat("{0}/{1}/{2}/{3}", |
|
ds@1952
|
109 |
cfg.pkg_path, |
|
ds@1952
|
110 |
pkg.GetBaseFolder(), |
|
ds@1952
|
111 |
lib.package_path, |
|
ds@1952
|
112 |
binName); |
|
ds@1952
|
113 |
File.Copy(binpath, path, true); |
|
ds@1952
|
114 |
|
|
ds@1952
|
115 |
return true; |
|
ds@1952
|
116 |
} |
|
ds@1952
|
117 |
} |
|
ds@1952
|
118 |
} |