~lattis/muon

be9b2fa92e65dcee7008c80c889721ece051728a — Stone Tickle 12 minutes ago 97d394e master
implement meson.override_dependency()
M include/lang/workspace.h => include/lang/workspace.h +2 -0
@@ 61,6 61,8 @@ struct workspace {
	obj global_args;
	/* args dict for add_global_link_arguments() */
	obj global_link_args;
	/* overridden dependencies dict */
	obj dep_overrides;

	struct bucket_array chrs;
	struct bucket_array objs;

M src/functions/default/dependency.c => src/functions/default/dependency.c +11 -2
@@ 137,8 137,17 @@ get_dependency_pkgconfig(struct workspace *wk, struct dep_lookup_ctx *ctx, bool 
static bool
get_dependency(struct workspace *wk, struct dep_lookup_ctx *ctx)
{
	bool found;
	if (!get_dependency_pkgconfig(wk, ctx, &found)) {
	bool found = false;

	{
		obj dep;
		if (obj_dict_index(wk, wk->dep_overrides, ctx->name, &dep)) {
			*ctx->res = dep;
			found = true;
		}
	}

	if (!found && !get_dependency_pkgconfig(wk, ctx, &found)) {
		return false;
	}


M src/functions/meson.c => src/functions/meson.c +30 -15
@@ 180,7 180,22 @@ func_meson_is_unity(struct workspace *wk, obj _, uint32_t args_node, obj *res)
static bool
func_meson_override_dependency(struct workspace *wk, obj _, uint32_t args_node, obj *res)
{
	LOG_W("TODO: meson.override_dependency");
	struct args_norm an[] = { { obj_string }, { obj_dependency }, ARG_TYPE_NULL };
	enum kwargs {
		kw_static, // ignored
		kw_native, // ignored
	};
	struct args_kw akw[] = {
		[kw_static] = { "static", obj_bool },
		[kw_native] = { "native", obj_bool },
		0
	};

	if (!interp_args(wk, args_node, an, NULL, akw)) {
		return false;
	}

	obj_dict_set(wk, wk->dep_overrides, an[0].val, an[1].val);
	return true;
}



@@ 273,23 288,23 @@ func_meson_add_install_script(struct workspace *wk, obj _, uint32_t args_node, o
}

const struct func_impl_name impl_tbl_meson[] = {
	{ "get_compiler", func_meson_get_compiler },
	{ "project_name", func_meson_project_name },
	{ "project_version", func_meson_project_version },
	{ "version", func_meson_version },
	{ "current_source_dir", func_meson_current_source_dir },
	{ "current_build_dir", func_meson_current_build_dir },
	{ "source_root", func_meson_global_source_root },
	{ "project_source_root", func_meson_project_source_root },
	{ "global_source_root", func_meson_global_source_root },
	{ "add_install_script", func_meson_add_install_script },
	{ "backend", func_meson_backend },
	{ "build_root", func_meson_global_build_root },
	{ "project_build_root", func_meson_project_build_root },
	{ "current_build_dir", func_meson_current_build_dir },
	{ "current_source_dir", func_meson_current_source_dir },
	{ "get_compiler", func_meson_get_compiler },
	{ "global_build_root", func_meson_global_build_root },
	{ "is_subproject", func_meson_is_subproject },
	{ "override_dependency", func_meson_override_dependency },
	{ "backend", func_meson_backend },
	{ "global_source_root", func_meson_global_source_root },
	{ "is_cross_build", func_meson_is_cross_build },
	{ "is_subproject", func_meson_is_subproject },
	{ "is_unity", func_meson_is_unity },
	{ "add_install_script", func_meson_add_install_script },
	{ "override_dependency", func_meson_override_dependency },
	{ "project_build_root", func_meson_project_build_root },
	{ "project_name", func_meson_project_name },
	{ "project_source_root", func_meson_project_source_root },
	{ "project_version", func_meson_project_version },
	{ "source_root", func_meson_global_source_root },
	{ "version", func_meson_version },
	{ NULL, NULL },
};

M src/lang/workspace.c => src/lang/workspace.c +1 -0
@@ 257,6 257,7 @@ workspace_init(struct workspace *wk)
	make_obj(wk, &wk->subprojects, obj_dict);
	make_obj(wk, &wk->global_args, obj_dict);
	make_obj(wk, &wk->global_link_args, obj_dict);
	make_obj(wk, &wk->dep_overrides, obj_dict);
}

void