Skip to content

Commit b8865ec

Browse files
committed
Honor CC env in get_enum_for
1 parent 576379a commit b8865ec

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

src/utils.vala

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,35 @@ public string get_enums_for (string str, GLib.List<string> includefiles) {
3939
} catch (FileError e) {
4040
error (e.message);
4141
}
42-
string[] gcc_args = {"gcc", "-x", "c", "-o", enums_exec, "-"};
42+
string cc = Environment.get_variable ("CC");
43+
if (cc == null || cc == "")
44+
cc = "cc";
45+
string[] cc_args = {cc, "-x", "c", "-o", enums_exec, "-"};
4346
foreach (var i in include_dirs)
44-
gcc_args += "-I"+i;
47+
cc_args += "-I"+i;
4548
try {
46-
Pid gcc_pid;
47-
int gcc_stdinfd;
48-
Process.spawn_async_with_pipes (null, gcc_args, null,
49+
Pid cc_pid;
50+
int cc_stdinfd;
51+
Process.spawn_async_with_pipes (null, cc_args, null,
4952
SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD,
50-
null, out gcc_pid, out gcc_stdinfd);
51-
var gcc_stdin = FileStream.fdopen (gcc_stdinfd, "w");
52-
if (gcc_stdin == null)
53-
throw new SpawnError.IO ("Cannot open gcc's stdin");
53+
null, out cc_pid, out cc_stdinfd);
54+
var cc_stdin = FileStream.fdopen (cc_stdinfd, "w");
55+
if (cc_stdin == null)
56+
throw new SpawnError.IO ("Cannot open %s's stdin".printf (cc));
5457
foreach (string i in includefiles)
55-
gcc_stdin.printf ("#include <%s>\n", i);
56-
gcc_stdin.printf ("int main(){%s;return 0;}\n", str);
57-
gcc_stdin = null;
58+
cc_stdin.printf ("#include <%s>\n", i);
59+
cc_stdin.printf ("int main(){%s;return 0;}\n", str);
60+
cc_stdin = null;
5861
int status;
5962
#if W32
60-
status = Windows.waitpid (gcc_pid);
63+
status = Windows.waitpid (cc_pid);
6164
#else
62-
Posix.waitpid (gcc_pid, out status, 0);
65+
Posix.waitpid (cc_pid, out status, 0);
6366
#endif
6467

65-
Process.close_pid (gcc_pid);
68+
Process.close_pid (cc_pid);
6669
if (status != 0)
67-
throw new SpawnError.FAILED ("gcc exited with status %d", status);
70+
throw new SpawnError.FAILED ("%s exited with status %d", cc, status);
6871
Process.spawn_sync (null, {enums_exec}, null, 0, null, out enums_out, null, out status);
6972
if (status != 0)
7073
throw new SpawnError.FAILED ("enums helper exited with status %d", status);

0 commit comments

Comments
 (0)