v8/tools/snapshot/asm_to_inline_asm.py
Shu-yu Guo a8973c72ba Revert "[snapshot] Rename embedded*.S files to .asm"
This reverts commit 68a7736bdf.

Reason for revert: Broke Bazel and gcc builds
https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Linux64%20-%20bazel%20-%20builder/2237/overview
https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Linux%20gcc%20-%20builder/2103/overview

Original change's description:
> [snapshot] Rename embedded*.S files to .asm
>
> We want to use llvm-ml to assemble files on Windows, but it only
> recognizes .asm files as input files. See
> https://chromium-review.googlesource.com/c/v8/v8/+/3668287.
>
> Change-Id: I34ff6d2693a34653c8e22a7c2d093853505cd455
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3672420
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#80782}

Change-Id: I92f4435aca26da16555734b95b9aabe3271af15c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3673428
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Shu-yu Guo <syg@chromium.org>
Owners-Override: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80784}
2022-05-27 17:47:54 +00:00

32 lines
1.1 KiB
Python

#!/usr/bin/env python
# Copyright 2018 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
'''
Converts a given file in clang assembly syntax to a corresponding
representation in inline assembly. Specifically, this is used to convert
embedded.S to embedded.cc for Windows clang builds.
'''
import argparse
import sys
def asm_to_inl_asm(in_filename, out_filename):
with open(in_filename, 'r') as infile, open(out_filename, 'wb') as outfile:
outfile.write(b'__asm__(\n')
for line in infile:
# Escape " in .S file before outputing it to inline asm file.
line = line.replace('"', '\\"')
outfile.write(b' "%s\\n"\n' % line.rstrip().encode('utf8'))
outfile.write(b');\n')
return 0
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('input', help='Name of the input assembly file')
parser.add_argument('output', help='Name of the target CC file')
args = parser.parse_args()
sys.exit(asm_to_inl_asm(args.input, args.output))