Skip to main content
  1. Posts/

asdf-clang-tools — A New Way to Install Clang Tools Using asdf

·619 words·2 mins· ·
Xianpeng Shen
Author
Xianpeng Shen
DevOps & Build Engineer | Python Enthusiast | Open Source Maintainer
Table of Contents

Recently, I released a new repository under the cpp-linter organization called asdf-clang-tools. This project is a fork of amrox/asdf-clang-tools. Due to the original author’s lack of maintenance for many years, I have repaired, upgraded, and expanded its functionality, giving it a new lease on life. In short, asdf-clang-tools is an asdf plugin for installing and managing Clang Tools, such as clang-format, clang-tidy, clang-query, and clang-apply-replacements.

A New Installation Method: asdf in Addition to pip
#

Previously, I released the clang-tools-pip toolkit, allowing users to install a complete set of Clang executable tools (including clang-format, clang-tidy, clang-query, and clang-apply-replacements) using pip install clang-tools.

asdf-clang-tools provides another approach—using the asdf version manager to install these tools. In short, this gives developers who prefer using asdf to manage tool versions another option.

These two methods are not mutually exclusive: you can easily install and manage Clang tools using either pip or asdf. The choice depends on your workflow and personal preferences.

What is the asdf Version Manager?
#

Many developers may not be familiar with asdf. asdf is a polyglot, multi-tool version manager.

It can manage versions of multiple runtime environments with a single command-line tool and supports a plugin mechanism.

For example, you can use asdf to manage versions of Python, Node.js, Ruby, and other languages, as well as Clang tools (like the asdf-clang-tools I introduced).

All tool version information is recorded in a shared .tool-versions file, allowing teams to easily synchronize configurations across different machines.

In short, the advantage of asdf is “one tool to manage all dependencies,” unifying the versions of various tools required by a project and eliminating the hassle of using different version managers for each tool.

Installation and Usage Example
#

Installing Clang tools using asdf-clang-tools is very simple. Assuming you have already installed asdf, simply follow the instructions in the official repository:

  • First, add the plugin: Using clang-format as an example, run the following in your terminal:

    asdf plugin add clang-format https://github.com/cpp-linter/asdf-clang-tools.git
    

    Similarly, clang-query, clang-tidy, clang-apply-replacements, and other tools use the same repository address; just change the plugin name to the corresponding name.

  • View available versions: After adding the plugin, you can run asdf list all clang-format to list all installable clang-format versions.

  • Install the tool: Choose a version (e.g., the latest latest), and execute:

    asdf install clang-format latest
    

    This will download and install the specified version of the clang-format binary.

  • Set the global version: After installation, you can execute:

    asdf set clang-format latest
    

    This will write the version to the ~/.tool-versions file, making it globally available. After this, you can directly use commands like clang-format on the command line.

After completing the above steps, clang-format, clang-tidy, and other tools will be integrated into asdf management. Refer to the official asdf documentation for more details.

Welcome to Try and Provide Feedback
#

In summary, asdf-clang-tools provides a new installation method for developers who need Clang Tools.

It complements other tools from the cpp-linter organization (such as clang-tools-pip).

I sincerely welcome everyone to try the entire C/C++ lint solution provided by cpp-linter and choose the tools that best suit their workflow.

Also, if you encounter any problems or have suggestions for improvement during use, please submit them through GitHub Issues, the discussion area, etc. Let’s work together to improve the Cpp Linter toolchain and make C/C++ formatting and static analysis more convenient and efficient!


Please indicate the author and source when reprinting this article, and do not use it for any commercial purposes. Welcome to follow the WeChat public account “DevOps攻城狮”

Related

Still Using Wiki/Confluence? You Might Be Producing Garbage
·574 words·2 mins
In enterprises, documentation tools like Wiki and Confluence, if lacking unified management and review mechanisms, can lead to information chaos and knowledge sedimentation failure. This article explores how to avoid this situation and draws on the successful experiences of open-source communities.
Still using pip and venv? You're outdated! Try uv!
·570 words·3 mins
uv is a Python package management tool developed by the Astral team. It replaces the functionality of pip, venv, and pip-tools, offering faster dependency resolution and a more modern project management approach.
Microsoft and NASA Use It? My 4-Year-Old Side Project Hit 100 Stars
cpp-linter-action is a GitHub Action that provides C/C++ code formatting and static analysis capabilities. It uses clang-format and clang-tidy, supporting various configurations and custom rules. Since its creation in 2021, the project has been used by several well-known organizations and open-source projects.
My Patience with Accessing GitHub is Wearing Thin
·299 words·1 min
Many programmers, especially those in China, are frustrated by access issues with GitHub. This article shares my personal experiences and reflections on network problems.
Setting up Sphinx + ReadTheDocs from Scratch - Rapidly Deploying Automated Documentation
·562 words·2 mins
In open-source projects or team collaborations, Sphinx + ReadTheDocs provides an easy-to-maintain, automatically deployable documentation system. This article documents the configuration process and considerations.
Markdown — Not So Great Anymore? Why More and More Python Projects Use RST?
·600 words·2 mins
Markdown and reStructuredText (RST) are two commonly used markup languages. This article compares their advantages and disadvantages and shares usage suggestions in different scenarios.