Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions mash/BitbakeRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,9 @@ def get_recipe_text(self):
lines.append(f'ROS_BRANCH ?= "branch={self.branch}"')
lines.append(f'SRC_URI = "{self.src_uri}"')
lines.append(f'SRCREV = "{self.srcrev}"')
# XXX: Only use WORKDIR for older Yocto releases like scarthgap

split_path = self.pkg_path.split(os.path.sep)
if len(split_path) > 2:
git_subdir = os.path.sep + os.path.join(*split_path[2:])
else:
git_subdir = ""

lines.append(f'S = "${{WORKDIR}}/git{git_subdir}"')
# XXX: Only use WORKDIR for older Yocto releases like scarthgap
lines.append(f'S = "${{WORKDIR}}/git{self.pkg_path}"')

lines.append("")
lines.append(f"ROS_BUILD_TYPE = \"{self.build_type}\"")
Expand Down
24 changes: 17 additions & 7 deletions mash/verb/bitbake.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from colcon_core.topological_order import topological_order_packages
from colcon_core.verb import VerbExtensionPoint
from git import Repo, GitCommandError
from pathlib import Path
from rosdistro import get_index, get_index_url, get_cached_distribution
from mash.BitbakeRecipe import BitbakeRecipe
from mash.PackageMetadata import PackageMetadata
Expand Down Expand Up @@ -137,9 +138,6 @@ def main(self, *, context): # noqa: D102

lines.append(f"{pkg.name:<30}\t{str(pkg.path):<30}\t({pkg.type})")

self.path = os.path.abspath(
os.path.join(os.getcwd(), str(pkg.path)))

recipe_name = pkg.name.lower().replace('_', '-')

recipe_dir = os.path.abspath(os.path.join(
Expand All @@ -156,12 +154,11 @@ def main(self, *, context): # noqa: D102
bitbake_recipe.set_rosdistro(args.rosdistro)
bitbake_recipe.set_internal_packages(released_packages)
bitbake_recipe.importPackage(pkg_metadata)
bitbake_recipe.set_pkg_path(str(pkg.path))

repo = None
# Get source URI and revision
try:
repo = Repo(pkg.path, search_parent_directories=True)
repo = Repo(str(pkg.path), search_parent_directories=True)
except Exception as e:
repo = None
print(f"\t- Warning: Could not open git repository for package {pkg.name}: {e}")
Expand All @@ -170,6 +167,8 @@ def main(self, *, context): # noqa: D102
branch = None
src_rev = None
tag_name = None
repo_path = None

if repo is not None:
try:
# Use origin remote
Expand Down Expand Up @@ -213,7 +212,19 @@ def main(self, *, context): # noqa: D102
# Get the current commit hash
src_rev = repo.head.commit.hexsha

repo_name = repo.working_tree_dir.split("/")[-1]
# get the path to the working copy
repo_path = Path(repo.working_tree_dir).resolve()
git_relpath = os.path.relpath(pkg.path, start=repo_path)

if git_relpath == ".":
git_relpath = ""
else:
git_relpath = "/" + git_relpath

bitbake_recipe.set_pkg_path(str(git_relpath))
lines.append(f"\t- Package repo path: {git_relpath}")

repo_name = os.path.split(repo.working_tree_dir)[-1]

try:
tag_name = repo.git.describe('--tags', '--abbrev=0')
Expand All @@ -222,7 +233,6 @@ def main(self, *, context): # noqa: D102

bitbake_recipe.set_git_metadata(src_uri, branch, src_rev, repo_name, tag_name)


ros_bitbake_recipe = os.path.join(recipe_dir, bitbake_recipe.bitbake_recipe_filename())
lines.append(f"\t- Bitbake recipe: {ros_bitbake_recipe}")

Expand Down
Loading