Commit 4e711eae authored by Jorge Olmos's avatar Jorge Olmos
Browse files

source: fix Git extraction path for CMake recipes

When trying to build a recipe that uses both git and CMake, the following error message is shown:
CMake Error: The source directory "/home/jorge/cerbero/sources/android_universal/armv7/my-package-1.2" does not appear to contain CMakeLists.txt.

When using CMake:
self.build_dir == ARCH/PACKAGE-VERSION/_builddir (Path where Git extracts sources)
and
self.config_src_dir == ARCH/PACKAGE-VERSION (Path where Git should extract sources)

The problem is that Git class "extracts" sources to self.build_dir.
build_dir is the path to put binaries (as explained in the message of commit 2d520bfd)

Sources have to be extracted to self.config.sources:
- Tarball Class extracts the sources to self.config.sources.
- self.config.sources is also the path where patches are applied.

Part-of: <!700>
parent 7b8fa582
Pipeline #317393 passed with stages
in 100 minutes and 42 seconds
......@@ -690,6 +690,8 @@ class CMake (MakefilesBase):
shutil.rmtree(cmake_files)
self.make += ['VERBOSE=1']
await MakefilesBase.configure(self)
if not os.path.exists(self.build_dir):
os.makedirs(self.build_dir)
# as build_dir is different from source dir, makefile location will be in build_dir.
self.make_dir = self.build_dir
......
......@@ -271,7 +271,7 @@ class Tarball(BaseTarball, Source):
await super().fetch(redownload=redownload)
async def extract(self):
m.action(_('Extracting tarball to %s') % self.build_dir, logfile=get_logfile(self))
m.action(_('Extracting tarball to %s') % self.config_src_dir, logfile=get_logfile(self))
if os.path.exists(self.build_dir):
shutil.rmtree(self.build_dir)
......@@ -370,29 +370,29 @@ class Git (GitCache):
self.commit = self.config.recipe_commit(self.name) or self.commit
async def extract(self):
if os.path.exists(self.build_dir):
if os.path.exists(self.config_src_dir):
try:
commit_hash = git.get_hash(self.repo_dir, self.commit, logfile=get_logfile(self))
checkout_hash = git.get_hash(self.build_dir, 'HEAD', logfile=get_logfile(self))
checkout_hash = git.get_hash(self.config_src_dir, 'HEAD', logfile=get_logfile(self))
if commit_hash == checkout_hash and not self.patches:
return False
except Exception:
pass
shutil.rmtree(self.build_dir)
if not os.path.exists(self.build_dir):
os.makedirs(self.build_dir)
shutil.rmtree(self.config_src_dir)
if not os.path.exists(self.config_src_dir):
os.makedirs(self.config_src_dir)
# checkout the current version
await git.local_checkout(self.build_dir, self.repo_dir, self.commit, logfile=get_logfile(self))
await git.local_checkout(self.config_src_dir, self.repo_dir, self.commit, logfile=get_logfile(self))
for patch in self.patches:
if not os.path.isabs(patch):
patch = self.relative_path(patch)
if self.strip == 1:
git.apply_patch(patch, self.build_dir, logfile=get_logfile(self))
git.apply_patch(patch, self.config_src_dir, logfile=get_logfile(self))
else:
shell.apply_patch(patch, self.build_dir, self.strip, logfile=get_logfile(self))
shell.apply_patch(patch, self.config_src_dir, self.strip, logfile=get_logfile(self))
return True
......@@ -419,9 +419,9 @@ class GitExtractedTarball(Git):
return False
for match in self.matches:
self._files[match] = []
self._find_files(self.build_dir)
self._find_files(self.config_src_dir)
self._files['.in'] = [x for x in self._files['.in'] if
os.path.join(self.build_dir, 'm4') not in x]
os.path.join(self.config_src_dir, 'm4') not in x]
self._fix_ts()
def _fix_ts(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment