Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: syzygy/integration_tests/make_integration_tests_clang.py

Issue 2946063002: Python script to compile and link the integration tests using llvm's clang-cl (Closed)
Patch Set: Modification made based on Seb's reviews Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: syzygy/integration_tests/make_integration_tests_clang.py
diff --git a/syzygy/integration_tests/make_integration_tests_clang.py b/syzygy/integration_tests/make_integration_tests_clang.py
index 90a3a70b60158be1f1e765fa38fc8735c22e0e61..78be63fd238274f74efff71d679e4f846a086ec6 100644
--- a/syzygy/integration_tests/make_integration_tests_clang.py
+++ b/syzygy/integration_tests/make_integration_tests_clang.py
@@ -9,6 +9,53 @@ import re
import subprocess
import sys
+def compile(clang_path, source_files, src_dir):
Sébastien Marchand 2017/06/21 19:51:37 Add a comment to describe what this function do.
njanevsk 2017/06/22 18:43:49 Done.
+ compiler_flags = [
+ '-c',
Sébastien Marchand 2017/06/21 19:51:36 Fix the indentation.
njanevsk 2017/06/22 18:43:49 Done.
+ '-fsanitize=address',
+ '-mllvm',
+ '-asan-instrumentation-with-call-threshold=0',
+ '-mllvm',
+ '-asan-stack=0',
+ '-DUNICODE',
+ '-D_UNICODE',
+ '-DNOMINMAX',
+ '-D_CRT_SECURE_NO_WARNINGS',
+ '-I' + src_dir
Sébastien Marchand 2017/06/21 19:51:36 s/+/,/ and move src_dir to the next line.
njanevsk 2017/06/22 18:43:49 Why? Cause this is a single flag. include the src
Sébastien Marchand 2017/06/22 19:34:16 Yes but this will also work with a comma, and here
+ ]
+ compile_command = [clang_path]
+ compile_command.extend(compiler_flags)
+ compile_command.extend(source_files)
+
+ ret = subprocess.call(compile_command)
+ if ret != 0:
+ print "Failed compiling the integration_tests using clang-cl"
Sébastien Marchand 2017/06/21 19:51:37 This isn't indented properly.
njanevsk 2017/06/22 18:43:49 Done.
+
+def link(clang_path, source_files, build_dir):
+ object_files = [os.path.splitext(filename)[0] + ".o" for filename in source_files]
Sébastien Marchand 2017/06/21 19:51:36 > 80 chars.
njanevsk 2017/06/22 18:43:49 Done.
+
+ compiler_controlled_linker_flags = [
+ '-o',
+ build_dir + '\integration_tests_dll.dll'
Sébastien Marchand 2017/06/21 19:51:36 Fix indentation, look at the other Python script f
njanevsk 2017/06/22 18:43:49 Done.
+ ]
+
+ linker_flags = [
+ '/link',
+ '/dll',
+ build_dir + '\export_dll.dll.lib',
+ build_dir + '\syzyasan_rtl.dll.lib',
+ '-defaultlib:libcmt'
+ ]
+
+ linker_command = [clang_path]
+ linker_command.extend(['-m32'])
Sébastien Marchand 2017/06/21 19:51:36 linker_command = [ clang_path, '-m32', ]
njanevsk 2017/06/22 18:43:48 Done.
+ linker_command.extend(object_files)
+ linker_command.extend(compiler_controlled_linker_flags)
+ linker_command.extend(linker_flags)
+ ret = subprocess.call(linker_command)
+
+ if ret != 0:
+ print "Failed to link the integration_tests using clang-cl"
Sébastien Marchand 2017/06/21 19:51:36 Fix indent.
njanevsk 2017/06/22 18:43:49 Done.
def main():
parser = optparse.OptionParser(usage='%prog [options]')
@@ -26,15 +73,12 @@ def main():
if not options.input_files:
parser.error('--input-files is required')
- clang_path = options.src_dir + "/third_party/llvm-build/Release+Asserts/bin/clang-cl.exe"
- compiler_flags = '-c -fsanitize=address -mllvm -asan-instrumentation-with-call-threshold=0 -mllvm -asan-stack=0 -DUNICODE -D_UNICODE -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -I' + options.src_dir
+ clang_path = options.src_dir + \
Sébastien Marchand 2017/06/21 19:51:37 Use parenthesis instead of \, better than that, mo
njanevsk 2017/06/22 18:43:49 Done.
+ "/third_party/llvm-build/Release+Asserts/bin/clang-cl.exe"
- print os.path.dirname(os.path.realpath(__file__))
source_files = re.findall(r'\b(\w+.cc)\b', options.input_files)
- print subprocess.check_output('"' + clang_path + '" ' + compiler_flags + ' ' + ' '.join(source_files), shell = True)
- object_files = [filename[:-3] + ".o" for filename in source_files]
-
- print subprocess.check_output('"' + clang_path + '" ' + '-m32' + ' ' + ' '.join(object_files) + ' -o' + ' ' + options.build_dir + '\integration_tests_dll.dll' + ' /link /dll ' + options.build_dir + '\export_dll.dll.lib ' + options.build_dir + '\syzyasan_rtl.dll.lib' + ' -defaultlib:libcmt', shell = True)
+ compile(clang_path, source_files, options.src_dir)
Sébastien Marchand 2017/06/21 19:51:36 Check the return value, don't try to link if the c
njanevsk 2017/06/22 18:43:49 Done.
+ link(clang_path, source_files, options.build_dir)
Sébastien Marchand 2017/06/21 19:51:36 Ditto.
njanevsk 2017/06/22 18:43:49 There is no need to check the return value here. I
Sébastien Marchand 2017/06/22 19:34:16 We still want the script to return something != 0
if __name__ == '__main__':
sys.exit(main())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698