Skip to content

Commit 4890e0b

Browse files
committed
Fix dump compile commands & improve wrapcc
commit_hash:a205838b61e595c9e2e5ca27cd6bca2bc5fd0ee9
1 parent 74736b7 commit 4890e0b

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

build/conf/compilers/gnu_compiler.conf

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,22 @@ _C_CPP_KV_STYLE_NEW=${hide;kv:_C_CPP_KV_STYLE_P} ${hide;kv:_C_CPP_KV_STYLE_PC}
225225
_C_CPP_KV_STYLE_P=p CC
226226
_C_CPP_KV_STYLE_PC=pc green
227227

228-
_C_CPP_WRAPPER=$YMAKE_PYTHON3 ${input:"build/scripts/wrapcc.py"} ${input:SRC}
229-
when ($CLANG_TIDY_ARGS || $RETRY_ARGS || $YNDEXER_ARGS || $OPENSOURCE == "yes" || $RAW_COMPILE_CPP_CMD == "yes" ) {
228+
# --wrapcc-end argument must be the last one
229+
_C_CPP_WRAPPER=$YMAKE_PYTHON3 ${input:"build/scripts/wrapcc.py"} \
230+
--source-file ${input:SRC} \
231+
--source-root ${ARCADIA_ROOT} \
232+
--wrapcc-end
233+
234+
when ($CLANG_TIDY_ARGS || $OPENSOURCE == "yes" || $RAW_COMPILE_CPP_CMD == "yes" ) {
230235
_C_CPP_WRAPPER=
231236
}
232237

233238
_CPP_ARGS_NEW=\
234239
$CLANG_STATIC_ANALYZER_OPTIONS_NEW && \
235240
$CLANG_TIDY_ARGS \
241+
$_C_CPP_WRAPPER \
236242
$YNDEXER_ARGS \
237243
$RETRY_ARGS \
238-
$_C_CPP_WRAPPER \
239244
$CXX_COMPILER \
240245
$C_FLAGS_PLATFORM \
241246
$GCC_COMPILE_FLAGS \
@@ -254,9 +259,9 @@ _CPP_ARGS_NEW=\
254259

255260
_C_ARGS_NEW=\
256261
$CLANG_TIDY_ARGS \
262+
$_C_CPP_WRAPPER \
257263
$YNDEXER_ARGS \
258264
$RETRY_ARGS \
259-
$_C_CPP_WRAPPER \
260265
$C_COMPILER \
261266
$C_FLAGS_PLATFORM \
262267
$GCC_COMPILE_FLAGS \

build/scripts/wrapcc.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1+
import argparse
12
import subprocess
2-
import sys
3+
import sys, os
34

45

5-
def fix(path: str):
6+
WRAPCC_ARGS_END='--wrapcc-end'
7+
8+
def fix(source_file: str, source_root: str):
69
flags = []
710
return flags
811

12+
def parse_args():
13+
delimer = -1
14+
if WRAPCC_ARGS_END in sys.argv:
15+
delimer = sys.argv.index(WRAPCC_ARGS_END)
16+
assert delimer != -1, f"This wrapper should be called with {WRAPCC_ARGS_END} argument."
17+
18+
parser = argparse.ArgumentParser()
19+
parser.add_argument('--source-file', required=True)
20+
parser.add_argument('--source-root', required=True)
21+
cc_cmd = sys.argv[delimer+1:]
22+
return parser.parse_args(sys.argv[1:delimer]), cc_cmd
23+
924
if __name__ == '__main__':
10-
path = sys.argv[1]
11-
args = sys.argv[2:]
12-
cmd = args + fix(path)
13-
rc = subprocess.call(cmd, shell=False, stderr=sys.stderr, stdout=sys.stdout)
14-
sys.exit(rc)
25+
args, cc_cmd = parse_args()
26+
cmd = cc_cmd + fix(args.source_file, args.source_root)
27+
os.execv(cmd[0], cmd)

0 commit comments

Comments
 (0)