Skip to content

Commit 2e211df

Browse files
committed
Remove files if also removed in HPy during import update
1 parent 49a747b commit 2e211df

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,23 +2019,41 @@ def import_files(from_dir, to_dir):
20192019
dest_file = join(to_dir, relative_dir_path, filename)
20202020
import_file(src_file, dest_file)
20212021

2022+
def remove_inexisting_file(src_file, dest_file):
2023+
if not os.path.exists(dest_file):
2024+
mx.logv("Removing file {} since {} does not exist".format(src_file, dest_file))
2025+
vc.git_command(SUITE.dir, ["rm", src_file])
2026+
os.unlink(src_file, missing_ok=True)
2027+
2028+
def remove_inexisting_files(hpy_dir, our_dir):
2029+
mx.log("Looking for removed files in {} (HPy reference dir {})".format(our_dir, hpy_dir))
2030+
for dirpath, _, filenames in os.walk(our_dir):
2031+
relative_dir_path = os.path.relpath(dirpath, start=our_dir)
2032+
for filename in filenames:
2033+
src_file = join(dirpath, filename)
2034+
dest_file = join(hpy_dir, relative_dir_path, filename)
2035+
remove_inexisting_file(src_file, dest_file)
2036+
20222037
# headers go into 'com.oracle.graal.python.cext/include'
20232038
header_dest = join(mx.dependency("com.oracle.graal.python.cext").dir, "include")
20242039

20252040
# copy headers from .../hpy/hpy/devel/include' to 'header_dest'
20262041
# but exclude subdir 'cpython' (since that's only for CPython)
20272042
import_files(hpy_repo_include_dir, header_dest)
2043+
remove_inexisting_files(hpy_repo_include_dir, header_dest)
20282044

2029-
# runtime sources go into 'lib-graalpython/module/hpy/src'
2030-
runtime_files_dest = join(_get_core_home(), "modules", "hpy", "src")
2045+
# runtime sources go into 'lib-graalpython/module/hpy/devel/src'
2046+
runtime_files_dest = join(_get_core_home(), "modules", "hpy", "devel", "src")
20312047
import_files(hpy_repo_runtime_dir, runtime_files_dest)
2048+
remove_inexisting_files(hpy_repo_runtime_dir, runtime_files_dest)
20322049

20332050
# tests go to 'lib-graalpython/module/hpy/tests'
20342051
test_files_dest = _hpy_test_root()
20352052
import_files(hpy_repo_test_dir, test_files_dest)
2053+
remove_inexisting_files(hpy_repo_test_dir, test_files_dest)
20362054

2037-
# 'version.py' goes to 'lib-graalpython/module/hpy/'
2038-
import_file(join(hpy_repo_path, "hpy", "devel", "version.py"), join(_get_core_home(), "modules", "hpy", "version.py"))
2055+
# 'version.py' goes to 'lib-graalpython/module/hpy/devel/'
2056+
import_file(join(hpy_repo_path, "hpy", "devel", "version.py"), join(_get_core_home(), "modules", "hpy", "devel", "version.py"))
20392057

20402058
SUITE.vc.git_command(SUITE.dir, ["add", header_dest, runtime_files_dest, test_files_dest])
20412059
raw_input("Check that the updated files look as intended, then press RETURN...")

0 commit comments

Comments
 (0)