Skip to content

Add CompilationDatabase and CompileCommand. #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

juhwangKim
Copy link

Summary

This PR adds the CompilationDatabase and CompileCommand functions of the clang. It is used to load build information from the compile_commands.json generated by the cmake project.

The CompilationDatabase tries to load a compile_commands.json from a given directory path string. After initialization, the CompileCommand can be retrieved by a variable or functions.

The CompileCommand contains filename and argument for a single source, so the TranslationUnit can be initialized with it.

do {
  let db = try CompilationDatabase(directory: "/dir/contains/compile_commands.json/")
  let command = db.compileCommands[0]
  let tu = try TranslationUnit(compileCommand: command)
} catch { ... }

Others

  • ClangTests.swift
    • Add three test cases.
    • The var projectRoot: URL is added to find a project folder for the test from Xcode. I'm not sure this is a proper way.
  • utils/make-compile_commands.swift, input_tests/CMakeLists.txt
    • It will build the sources in the input_tests files as a single library.
    • the .build/build.input_tests/compile_commands.json will be made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant