aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2012-03-26 22:45:34 +0800
committerMu Qiao <qiaomuf@gentoo.org>2012-05-26 18:40:50 +0800
commit50457583ba5c4242fbf9eedf35cd3e4f77c42ce6 (patch)
tree46c80fa5712aad09d7badd54be60cdb6cdaf8b28
parentUtils: handle RDEPEND for metadata generation (diff)
downloadlibbash-50457583ba5c4242fbf9eedf35cd3e4f77c42ce6.tar.gz
libbash-50457583ba5c4242fbf9eedf35cd3e4f77c42ce6.tar.bz2
libbash-50457583ba5c4242fbf9eedf35cd3e4f77c42ce6.zip
Builtin: handle __export_funcs_var in inherit
-rw-r--r--src/builtins/inherit_builtin.cpp19
-rwxr-xr-xutils/isolated-functions.sh2
2 files changed, 17 insertions, 4 deletions
diff --git a/src/builtins/inherit_builtin.cpp b/src/builtins/inherit_builtin.cpp
index 1490e5b..96dab9b 100644
--- a/src/builtins/inherit_builtin.cpp
+++ b/src/builtins/inherit_builtin.cpp
@@ -83,8 +83,8 @@ int inherit_builtin::exec(const std::vector<std::string>& bash_args)
{
location = eclassdir + *iter + ".eclass";
_walker.set_value("ECLASS", *iter);
- export_funcs_var = "__export_functions_" + _walker.resolve<std::string>("ECLASS_DEPTH");
- _walker.unset(export_funcs_var);
+ _walker.define("__export_funcs_var", "__export_functions_" + _walker.resolve<std::string>("ECLASS_DEPTH"));
+ _walker.unset(_walker.resolve<std::string>("__export_funcs_var"));
// Portage implementation performs actions for overlays here but we don't do it for now
@@ -108,7 +108,20 @@ int inherit_builtin::exec(const std::vector<std::string>& bash_args)
restore_global("RDEPEND", B_RDEPEND);
restore_global("PDEPEND", B_PDEPEND);
- // Portage implementation exports functions here but we don't do it for now
+ if(!_walker.is_unset(_walker.resolve<std::string>("__export_funcs_var")))
+ {
+ std::stringstream func_names(_walker.resolve<std::string>(_walker.resolve<std::string>("__export_funcs_var")));
+ std::string func_name;
+
+ while(func_names >> func_name)
+ {
+ std::stringstream func;
+ func << func_name << "() { " << _walker.resolve<std::string>("ECLASS") << "_" << func_name
+ << " \"$@\" ; }";
+ _walker.execute_builtin("eval", {func.str()});
+ }
+ }
+ _walker.unset(_walker.resolve<std::string>("__export_funcs_var"));
if(!hasq(*iter, "INHERITED"))
_walker.set_value("INHERITED", _walker.resolve<std::string>("INHERITED") + " " + *iter);
diff --git a/utils/isolated-functions.sh b/utils/isolated-functions.sh
index 9d189ed..150fe4b 100755
--- a/utils/isolated-functions.sh
+++ b/utils/isolated-functions.sh
@@ -19,7 +19,7 @@ EXPORT_FUNCTIONS() {
die "EXPORT_FUNCTIONS without a defined ECLASS"
return 1
fi
- __export_funcs_var="$__export_funcs_var $*"
+ eval $__export_funcs_var+=\" $*\"
}
use() {