Skip to content

Commit

Permalink
Back out verify magic number of swift incremental output
Browse files Browse the repository at this point in the history
Reviewed By: rmaz

Differential Revision: D69931903

fbshipit-source-id: 6001c0281b923f53f538f7dcebd2293dc4783add
  • Loading branch information
chatura-atapattu authored and facebook-github-bot committed Feb 20, 2025
1 parent a3a2b68 commit f2682e9
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions prelude/apple/tools/swift_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,41 +81,6 @@ def replace_module_prefixes(match):
f.truncate()


def _read_output_file_map(command):
for i in range(len(command)):
if command[i] == "-output-file-map":
with open(command[i + 1]) as f:
return json.load(f)

return None


def _validate_file_type_of_incremental_output(command):
output_file_map = _read_output_file_map(command)
if output_file_map is None:
print("Failed to read output file map", file=sys.stderr)
sys.exit(1)

for _, outputs in output_file_map.items():
swiftdeps = outputs.get("swift-dependencies", None)
if swiftdeps:
with open(swiftdeps, "rb") as f:
magic = f.read(4)
if not (magic == b"DDEP" or magic == b"DEPS"):
print(
f"Invalid magic number in {swiftdeps}: {magic}", file=sys.stderr
)
sys.exit(1)

obj = outputs.get("object", None)
if obj:
with open(obj, "rb") as f:
magic = f.read(4)
if magic != b"\xcf\xfa\xed\xfe":
print(f"Invalid magic number in {obj}: {magic}", file=sys.stderr)
sys.exit(1)


def main():
env = os.environ.copy()
if "INSIDE_RE_WORKER" in env and _RE_TMPDIR_ENV_VAR in env:
Expand Down Expand Up @@ -190,9 +155,6 @@ def main():
if should_remove_module_prefixes:
_remove_swiftinterface_module_prefixes(command)

if "-incremental" in command:
_validate_file_type_of_incremental_output(command)

sys.exit(result.returncode)


Expand Down

0 comments on commit f2682e9

Please sign in to comment.