Commit fe8f091d authored by Michael Droettboom's avatar Michael Droettboom Committed by GitHub

Merge pull request #336 from mdboom/rebuild-package-on-depchange

Automatically rebuild packages if any patches or extra files change
parents bdee2189 650d321b
......@@ -221,8 +221,10 @@ $(CLAPACK): $(CPYTHONLIB)
make -C CLAPACK
build/packages.json: $(CPYTHONLIB) $(CLAPACK)
build/packages.json: $(CLAPACK) FORCE
make -C packages
emsdk/emsdk/.complete:
make -C emsdk
FORCE:
......@@ -19,8 +19,6 @@ def build_package(pkgname, dependencies, packagesdir, outputdir, args):
# Make sure all of the package's requirements are built first
for req in reqs:
build_package(req, dependencies, packagesdir, outputdir, args)
if not (packagesdir / pkgname / 'build' / '.packaged').is_file():
print("BUILDING PACKAGE: " + pkgname)
buildpkg.build_package(packagesdir / pkgname / 'meta.yaml', args)
shutil.copyfile(
packagesdir / pkgname / 'build' / (pkgname + '.data'),
......
......@@ -151,15 +151,40 @@ def package_files(buildpath, srcpath, pkg, args):
fd.write(b'\n')
def needs_rebuild(pkg, path, buildpath):
"""
Determines if a package needs a rebuild because its meta.yaml, patches, or
sources are newer than the `.packaged` thunk.
"""
packaged_token = buildpath / '.packaged'
if not packaged_token.is_file():
return True
package_time = packaged_token.stat().st_mtime
def source_files():
yield path
yield from pkg.get('source', {}).get('patches', [])
yield from (x[0] for x in pkg.get('source', {}).get('extras', []))
for source_file in source_files():
source_file = Path(source_file)
if source_file.stat().st_mtime > package_time:
return True
def build_package(path, args):
pkg = common.parse_package(path)
packagedir = pkg['package']['name'] + '-' + pkg['package']['version']
dirpath = path.parent
orig_path = Path.cwd()
os.chdir(dirpath)
try:
buildpath = dirpath / 'build'
if not buildpath.resolve().is_dir():
try:
if not needs_rebuild(pkg, path, buildpath):
return
if buildpath.resolve().is_dir():
shutil.rmtree(buildpath)
os.makedirs(buildpath)
srcpath = download_and_extract(buildpath, packagedir, pkg, args)
patch(path, srcpath, pkg, args)
......
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