编译动作的回调函数
(target, source, env)
| 39 | return '${CCCOM}' |
| 40 | |
| 41 | def on_compile(target, source, env): |
| 42 | """编译动作的回调函数""" |
| 43 | print(f" Processing compilation for {len(source)} source files") |
| 44 | for src in source: |
| 45 | src_path = str(src) |
| 46 | if src_path in collected_files: |
| 47 | continue |
| 48 | |
| 49 | collected_files.add(src_path) |
| 50 | directory = os.path.abspath(os.path.dirname(src_path)) |
| 51 | |
| 52 | # 构建编译命令 |
| 53 | command = env.subst(get_command_string(source, target, env, True)) |
| 54 | |
| 55 | # 解析include路径 |
| 56 | includes = [] |
| 57 | for path in env.get('CPPPATH', []): |
| 58 | includes.append('-I' + str(path)) |
| 59 | |
| 60 | # 添加编译命令记录 |
| 61 | entry = { |
| 62 | 'directory': directory, |
| 63 | 'command': f"{command} {' '.join(includes)}", |
| 64 | 'file': os.path.abspath(src_path), |
| 65 | 'output': str(target[0]) if target else '' |
| 66 | } |
| 67 | compile_commands.append(entry) |
| 68 | print(f" Added compile command for: {os.path.basename(src_path)}") |
| 69 | |
| 70 | return on_compile, compile_commands |
| 71 |
nothing calls this directly
no test coverage detected