Skip to content

Commit

Permalink
Add copy compile_commands.json to project dir feature
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkoSagadin committed Dec 13, 2022
1 parent ad08c8b commit 844739b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]

### Added

- Command _east build_ will now after every build step copy
`compile_commands.json`, if found, from the build directory to the project
directory. This makes job of locating this file easier for clangd. Help
description for _east build_ was updated to reflect that.

### Changed

- Make east.yml optional for everything, except for the usage of east build
Expand Down
11 changes: 10 additions & 1 deletion src/east/workspace_commands/basic_commands.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import os
import shutil as sh

import click

from ..east_context import east_command_settings
Expand Down Expand Up @@ -68,7 +71,7 @@ def build(east, board, build_type, build_dir, target, source_dir):
For additional info see chapter [bold]Building, Flashing and Debugging[/], section
[bold]One-Time CMake Arguments[/].
\n\n[bold]Note:[/] This command will, after build step, copy [bold]compile_commands.json[/], if found, from the build directory to the project directory. This makes job of locating this file easier for [bold yellow]clangd[/].
\n\n[bold]Note:[/] This command can be only run from inside of a [bold yellow]West workspace[/].
"""
Expand Down Expand Up @@ -107,6 +110,12 @@ def build(east, board, build_type, build_dir, target, source_dir):
# Determine conf files depending on the build type
east.run_west(build_cmd)

compile_file = os.path.join("build", "compile_commands.json")
if os.path.isfile(compile_file):
sh.copyfile(
compile_file, os.path.join(east.project_dir, "compile_commands.json")
)


@click.command(**east_command_settings)
@click.option("-d", "--build-dir", type=str, help="Build directory to create or use.")
Expand Down

0 comments on commit 844739b

Please sign in to comment.