Skip to content

Commit

Permalink
Prepare to support dev workflow with clangd/emacs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-golubev committed Dec 25, 2021
1 parent c0f848b commit 72d6dc0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Makefile
*.*~
.vscode/
build/
compile_commands.json
24 changes: 22 additions & 2 deletions script/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def parse_args():
help='Build in debug mode.')
parser.add_argument('--cmake-args', default=[], nargs='*',
help='Pass raw arguments to cmake.')
parser.add_argument('--dev-build', action='store_true', default=False,
help='Enable developer build configuration.')
return parser.parse_args()


Expand Down Expand Up @@ -72,20 +74,38 @@ def test(debug_mode, cmake_args, work_dir='.'):
def main():
"""Main entrypoint"""
args = parse_args()
workdir = os.path.join(os.path.dirname(__file__), '..', 'build')
sourcedir = os.path.join(os.path.dirname(__file__), '..')
workdir = os.path.join(sourcedir, 'build')

# setup build/ dir
if os.path.exists(workdir):
if args.rebuild:
shutil.rmtree(workdir)
os.makedirs(workdir)
else:
os.makedirs(workdir)

cmake_args = args.cmake_args
for i, arg in enumerate(cmake_args):
if not arg.startswith('-D'):
cmake_args[i] = '-D' + arg

if args.dev_build:
cmake_args.append('-DCMAKE_EXPORT_COMPILE_COMMANDS=1')

test(args.debug, cmake_args, workdir)
return 0

if not args.dev_build:
return 0

try:
os.symlink(os.path.join(workdir, 'compile_commands.json'),
os.path.join(sourcedir, 'compile_commands.json'))
except:
print('os.symlink failed')
return 1

return 0

if __name__ == "__main__":
sys.exit(main())

0 comments on commit 72d6dc0

Please sign in to comment.