-
Notifications
You must be signed in to change notification settings - Fork 63
Setting up CLion on MacOS for Authservice development
Ryan Richard edited this page Jun 9, 2020
·
14 revisions
Update March 25, 2020: The new MacOS command line tools v11.4 that just recently came out cannot compile the version of Boost that Authservice uses. As a workaround, you can download and install Command_Line_Tools_for_Xcode_11.3.1.dmg
from the Apple Developer web site.
You can see which version of the command line tools you have installed using pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
. E.g.:
% pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 11.3.1.0.1.1576735732
volume: /
location: /
install-time: 1591727491
groups: com.apple.FindSystemFiles.pkg-group
First install CLion and Bazel.
- Install CLion, e.g.
brew cask install clion
. - Install the same version of bazel that we use for Authservice compilation. See here for latest version.
pushd /tmp BAZEL_VERSION=0.29.1 curl -LO https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-darwin-x86_64.sh chmod +x bazel-${BAZEL_VERSION}-installer-darwin-x86_64.sh ./bazel-${BAZEL_VERSION}-installer-darwin-x86_64.sh bazel --version popd
To finish setting up CLion:
- Launch Clion
- Answer all of the first-time prompts
- When you get to the "Welcome to CLion" dialog box, pull down the Configure menu and choose Preferences.
- In the Preferences dialog box, search for "plugins".
- Install the Bazel plugin.
- Quit CLion.
- Start CLion.
- On the Welcome to CLion dialog box, choose Import Bazel Project.
- For the workspace, choose /Users/pivotal/workspace/authservice
- For the Select Project View, choose Create from Scratch
- For the project data directory, again choose the directory where you cloned the repo, e.g.
/Users/pivotal/workspace/authservice
For the project name, enterauthservice
For infer name from, choose the Workspace radio button - As a workaround for a an issue for handling dynamic linking on MacOS, follow these directions. Please be careful to not commit and push that workaround, as it causes linux builds to fail. Hopefully we can find a better way to handle this in the future so that no workaround is required.
- If the project sync fails complaining that the
bazel
command does not exist, then open the CLion Preferences and choose Bazel Settings. Change the Bazel Binary Location to/usr/local/bin/bazel
, then click Save. - Click the Sync Project button to re-run Bazel.
- If CLion did not auto-detect that this project uses git for source control, then open the CLion Preferences, click on Version Control, click the '+' button, click on the Project radio button, choose git, click OK, click OK.
- Add some commonly used run configurations:
- Click "Add Configuration..." on the toolbar.
- Click '+' and choose Bazel Command.
- Name:
Build and Run All Tests
- Target expression:
//test/...
- Bazel command:
test
- Bazel flags:
--incompatible_depset_is_not_iterable=false --verbose_failures --strategy=TestRunner=standalone --test_output=all
- Click Apply
- Click '+' and choose Bazel Command.
- Name:
Build All Prod Code
- Target expression:
//src/...
- Bazel command:
build
- Bazel flags:
--incompatible_depset_is_not_iterable=false --verbose_failures
- Click OK
- Run both of the new targets that you just created to compile and run tests
- Adjust the auto-format settings to conform to the project's preferred settings. Open the CLion Preferences dialog, unfold Editor, unfold Code Style, choose C/C++, switch the Scheme to "Project", click on "Set from..." and choose "Google". Note that you must quit and restart CLion for this change to take effect, even though CLion will not tell you that.
- Optional: If you are using git-duet with
rubymine-git-wrapper
, then open the CLion Preferences dialog box, unfold Version Control, choose Git, change the Path to Git executable to be the path to the executable, e.g./usr/local/bin/rubymine-git-wrapper
. This will enable making commits in the CLion UI using the appropriate git-duet settings.
Note: The first time that you run unit tests in CLion, a dialog box will appear that says "Please update 'Google Test' past ba96d0b...". This has already been done, so you can ignore this warning.