Skip to content

Commit

Permalink
change rebuild not to clone but to pull
Browse files Browse the repository at this point in the history
  • Loading branch information
sotarokashiuchi committed Jun 26, 2024
1 parent f3a73aa commit d08157b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 2 additions & 7 deletions microros_utils/library_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ def run(self, meta, toolchain, user_meta = ""):
self.build_mcu_environment(meta, toolchain, user_meta)
self.package_mcu_library()

# Delete build folders
shutil.rmtree(self.build_folder, ignore_errors=True)

def ignore_package(self, name):
for p in self.mcu_packages:
if p.name == name:
Expand All @@ -90,8 +87,7 @@ def check_env(self):
self.env = os.environ.copy()

def download_dev_environment(self):
shutil.rmtree(self.dev_src_folder, ignore_errors=True)
os.makedirs(self.dev_src_folder)
os.makedirs(self.dev_src_folder, exist_ok=True)
print("Downloading micro-ROS dev dependencies")
for repo in Sources.dev_environments[self.distro]:
repo.clone(self.dev_src_folder)
Expand All @@ -108,8 +104,7 @@ def build_dev_environment(self):
sys.exit(1)

def download_mcu_environment(self):
shutil.rmtree(self.mcu_src_folder, ignore_errors=True)
os.makedirs(self.mcu_src_folder)
os.makedirs(self.mcu_src_folder, exist_ok=True)
print("Downloading micro-ROS library")
for repo in Sources.mcu_environments[self.distro]:
repo.clone(self.mcu_src_folder)
Expand Down
8 changes: 8 additions & 0 deletions microros_utils/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ def __init__(self, name, url, distribution, branch=None):
def clone(self, folder):
self.path = folder + "/" + self.name
# TODO(pablogs) ensure that git is installed
if os.path.exists(self.path):
command = f"cd {self.path} && git pull {self.url} {self.branch}"
result = run_cmd(command)
if 0 != result.returncode:
print(f"{self.name} pull failed: \n{result.stderr.decode('utf-8')}")
sys.exit(1)
return

command = "git clone -b {} {} {}".format(self.branch, self.url, self.path)
result = run_cmd(command)

Expand Down

0 comments on commit d08157b

Please sign in to comment.