Commit 8f6e1bab authored by Michael Droettboom's avatar Michael Droettboom

Automatically rebuild packages if any patches or extra files change

parent 584c61ed
...@@ -221,8 +221,10 @@ $(CLAPACK): $(CPYTHONLIB) ...@@ -221,8 +221,10 @@ $(CLAPACK): $(CPYTHONLIB)
make -C CLAPACK make -C CLAPACK
build/packages.json: $(CPYTHONLIB) $(CLAPACK) build/packages.json: FORCE
make -C packages make -C packages
emsdk/emsdk/.complete: emsdk/emsdk/.complete:
make -C emsdk make -C emsdk
FORCE:
...@@ -19,8 +19,6 @@ def build_package(pkgname, dependencies, packagesdir, outputdir, args): ...@@ -19,8 +19,6 @@ def build_package(pkgname, dependencies, packagesdir, outputdir, args):
# Make sure all of the package's requirements are built first # Make sure all of the package's requirements are built first
for req in reqs: for req in reqs:
build_package(req, dependencies, packagesdir, outputdir, args) 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) buildpkg.build_package(packagesdir / pkgname / 'meta.yaml', args)
shutil.copyfile( shutil.copyfile(
packagesdir / pkgname / 'build' / (pkgname + '.data'), packagesdir / pkgname / 'build' / (pkgname + '.data'),
......
...@@ -147,15 +147,40 @@ def package_files(buildpath, srcpath, pkg, args): ...@@ -147,15 +147,40 @@ def package_files(buildpath, srcpath, pkg, args):
fd.write(b'\n') 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): def build_package(path, args):
pkg = common.parse_package(path) pkg = common.parse_package(path)
packagedir = pkg['package']['name'] + '-' + pkg['package']['version'] packagedir = pkg['package']['name'] + '-' + pkg['package']['version']
dirpath = path.parent dirpath = path.parent
orig_path = Path.cwd() orig_path = Path.cwd()
os.chdir(dirpath) os.chdir(dirpath)
try:
buildpath = dirpath / 'build' 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) os.makedirs(buildpath)
srcpath = download_and_extract(buildpath, packagedir, pkg, args) srcpath = download_and_extract(buildpath, packagedir, pkg, args)
patch(path, srcpath, 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