Skip to content
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

Generate index for objective-c code. Remap and move index to deriveddata. #69

Merged
merged 4 commits into from
Jun 9, 2020

Conversation

amberdixon
Copy link
Collaborator

@amberdixon amberdixon commented May 29, 2020

This PR adds the index-store-path option when invoking clang to compile objective-c to build libraries. It also adds a step to the post-build installer which uses index-import to update the paths referenced by the index generated by bazel and place the index in the derived data directory.

I set the CLANG_ENABLE_MODULES setting to true, because in local development, I noticed that indexing was failing on some of my projects, due to this build setting not being set.

I also made the operations performed in the installer script write to log files in a new bazel-diagnostics directory that lives in derived data. This should make it easier to diagnose issues.

Other notes:
I called defaults write com.apple.dt.Xcode IDEIndexShowLog YES from Terminal and then was able to view what xcode's indexer was doing. Note that if Xcode's indexer isn't enabled or if the indexer fails when it runs clang on a source file, Xcode auto-complete functionality won't work! We still need to figure out a way to convince Xcode that it's indexer is working, so that autocomplete operations will work on the bazel generated index.

When the sample code that is used for testing in this repo is compiled, no index records or units are generated. Therefore, I did not test my implementation against this sample code. (In the future, we should tweak the sample code so that it will generate index files. This may involve adding some methods/classes/a public API to it.)

When I tested locally, I pointed my own iOS repo to my local rules_ios checkout.

  1. Generate an xcodeproject using bazel run :ProjectName.
  2. Clear the derived data Index/DataStore directory for this xcodeproject if one already exists.
  3. Disable Xcode's indexer by running defaults write com.apple.dt.XCode IDEIndexDisable 1 from terminal. This indexer will generate record and unit files (if it works) and then you won't necessarily be using bazel-generated record and unit files.
  4. Open the project in Xcode and build locally.
  5. Go into your derived data directory. Optionally:
    a. Check out the index-import library and build it. The latest version on master includes a binary called validate-index that ensures your unit paths are valid. Run validate-index on DerivedDataForYourProject/Index/DataStore. The command should return an exit status of 0.
    b. Run absolute-unit on one of the unit files in DerivedDataForYourProject/Index/DataStore/v5/units to sanity check that units are being generated and mapped correctly.

@amberdixon amberdixon requested a review from segiddins May 29, 2020 05:40
@amberdixon amberdixon marked this pull request as draft May 29, 2020 05:41
rules/library.bzl Outdated Show resolved Hide resolved
tools/xcodeproj-shims/installers/_indexstore.sh Outdated Show resolved Hide resolved
tools/xcodeproj-shims/installers/indexstores.sh Outdated Show resolved Hide resolved
@amberdixon amberdixon changed the title [WIP] Add indexing support Generate index for objective-c code. Remap and move index to deriveddata. Jun 5, 2020
@amberdixon amberdixon marked this pull request as ready for review June 5, 2020 23:45
@amberdixon amberdixon requested a review from ndizazzo June 5, 2020 23:45
Copy link
Member

@segiddins segiddins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should gitignore */.xcodeproj/bazelinstallers/index-import so we don't commit binaries into the repo?

@amberdixon amberdixon merged commit 53820fe into master Jun 9, 2020
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.

3 participants