~lattis/muon

f547c0475d4077ba91f5fa9cc581ecf16e0921f3 — Stone Tickle 1 year, 4 months ago 1c3c721
fix all hardcoded object extensions
2 files changed, 19 insertions(+), 7 deletions(-)

M src/functions/compiler.c
M src/functions/kernel/build_target.c
M src/functions/compiler.c => src/functions/compiler.c +3 -1
@@ 298,7 298,9 @@ compiler_check(struct workspace *wk, struct compiler_check_opts *opts,
		path_join(wk, &test_output_path, wk->muon_private, "compiler_check_exe");
		output_path = test_output_path.buf;
	} else {
		path_join(wk, &test_output_path, wk->muon_private, "test.o");
		path_join(wk, &test_output_path, wk->muon_private, "test.");
		sbuf_pushs(wk, &test_output_path, compiler_language_extension(comp->lang));
		sbuf_pushs(wk, &test_output_path, compilers[t].object_ext);
		output_path = test_output_path.buf;
	}


M src/functions/kernel/build_target.c => src/functions/kernel/build_target.c +16 -6
@@ 98,16 98,26 @@ determine_linker_from_objects_iter(struct workspace *wk, void *_ctx, obj val)

	enum compiler_language fl;

	const struct str *o = get_str(wk, *get_obj_file(wk, val));
	if (!str_endswith(o, &WKSTR(".o"))) {
		return ir_cont;
	}
	/*
	 * Try to see if the file looks like
	 * path/to/object.language.object_extension
	 *
	 * This means we expect two extensions, the first one will be stripped,
	 * and then the second will be used to determine the language of the
	 * file.
	 */

	const struct str *o = get_str(wk, *get_obj_file(wk, val));
	SBUF(path);
	sbuf_pushs(wk, &path, o->s);
	path.len -= 2;
	path_basename(wk, &path, o->s);
	const char *first_dot = strrchr(path.buf, '.');
	path.len = first_dot - path.buf;
	path.buf[path.len] = 0;

	if (!strrchr(path.buf, '.')) {
		return ir_cont;
	}

	if (!filename_to_compiler_language(path.buf, &fl)) {
		/* LOG_E("unable to determine language for '%s'", get_cstr(wk, src->dat.file)); */
		return ir_cont;