Skip to content

Commit

Permalink
bitbake: use own condition_context instead of whole os.environ
Browse files Browse the repository at this point in the history
* Use only ROS_OS_OVERRIDE, ROS_PYTHON_VERSION, ROS_VERSION variables
  with ROS_PYTHON_VERSION, ROS_VERSION derived from distro value
  instead of depending on ros-generate-recipes.sh script from meta-ros
  to export correct value in shell before calling superflore

* this is needed by DependencyWalker evaluate_condition_context
  parameter to correctly resolve the conditionals when evaluating
  dependencies and build_type

Signed-off-by: Martin Jansa <martin.jansa@lge.com>
  • Loading branch information
shr-project committed Nov 11, 2020
1 parent 07ba6f0 commit 1806769
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 3 additions & 4 deletions superflore/generators/bitbake/gen_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from catkin_pkg.package import InvalidPackage
from rosdistro.dependency_walker import DependencyWalker
from rosdistro.manifest_provider import get_release_tag
Expand Down Expand Up @@ -163,8 +161,9 @@ def _gen_recipe_for_package(
pkg_rosinstall, srcrev_cache, skip_keys
):
pkg_names = get_package_names(distro)
pkg_dep_walker = DependencyWalker(distro,
evaluate_condition_context=os.environ)
pkg_dep_walker = DependencyWalker(
distro,
evaluate_condition_context=yoctoRecipe._get_condition_context(distro))
pkg_buildtool_deps = pkg_dep_walker.get_depends(pkg_name, "buildtool")
pkg_build_deps = pkg_dep_walker.get_depends(pkg_name, "build")
pkg_build_export_deps = pkg_dep_walker.get_depends(
Expand Down
2 changes: 1 addition & 1 deletion superflore/generators/bitbake/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@


def main():
os.environ["ROS_OS_OVERRIDE"] = "openembedded"
overlay = None
parser = get_parser(
'Generate OpenEmbedded recipes for ROS packages',
Expand Down Expand Up @@ -162,6 +161,7 @@ def main():
for adistro in selected_targets:
yoctoRecipe.reset()
distro = get_distro(adistro)

distro_installers, _, distro_changes =\
generate_installers(
distro,
Expand Down
10 changes: 9 additions & 1 deletion superflore/generators/bitbake/yocto_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,14 @@ def _get_ros_version(distro):
def _get_ros_python_version(distro):
return '2' if distro not in ['melodic'] else '3'

@staticmethod
def _get_condition_context(distro):
context = dict()
context["ROS_OS_OVERRIDE"] = "openembedded"
context["ROS_VERSION"] = yoctoRecipe._get_ros_version(distro)
context["ROS_PYTHON_VERSION"] = yoctoRecipe._get_ros_python_version(
distro)

@staticmethod
def generate_superflore_datetime_inc(basepath, dist, now):
datetime_dir = '{0}/meta-ros{1}-{2}/conf/ros-distro/include/{2}/' \
Expand Down Expand Up @@ -567,7 +575,7 @@ def generate_ros_distro_inc(
conf_file.write('# DO NOT OVERRIDE ROS_PYTHON_VERSION\n')
conf_file.write(
'ROS_PYTHON_VERSION = "{}"\n\n'.format(
yoctoRecipe._get_ros_python_version(distro)))
yoctoRecipe._get_ros_python_version(distro)))
oe_skip_keys = map(
lambda skip_key: yoctoRecipe.convert_to_oe_name(skip_key),
skip_keys
Expand Down

0 comments on commit 1806769

Please sign in to comment.