mirror of https://github.com/pyodide/pyodide.git
Automatically rebuild packages if any patches or extra files change
This commit is contained in:
parent
584c61edc9
commit
8f6e1bab09
4
Makefile
4
Makefile
|
@ -221,8 +221,10 @@ $(CLAPACK): $(CPYTHONLIB)
|
|||
make -C CLAPACK
|
||||
|
||||
|
||||
build/packages.json: $(CPYTHONLIB) $(CLAPACK)
|
||||
build/packages.json: FORCE
|
||||
make -C packages
|
||||
|
||||
emsdk/emsdk/.complete:
|
||||
make -C emsdk
|
||||
|
||||
FORCE:
|
||||
|
|
|
@ -19,9 +19,7 @@ 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)
|
||||
buildpkg.build_package(packagesdir / pkgname / 'meta.yaml', args)
|
||||
shutil.copyfile(
|
||||
packagesdir / pkgname / 'build' / (pkgname + '.data'),
|
||||
outputdir / (pkgname + '.data'))
|
||||
|
|
|
@ -147,16 +147,41 @@ 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)
|
||||
buildpath = dirpath / 'build'
|
||||
try:
|
||||
buildpath = dirpath / 'build'
|
||||
if not buildpath.resolve().is_dir():
|
||||
os.makedirs(buildpath)
|
||||
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)
|
||||
compile(path, srcpath, pkg, args)
|
||||
|
|
Loading…
Reference in New Issue