Programming Languages - Build Tools
Build toolchain: compiler + linker + libraries + others.
Build tools / package managers:
Tool | Config / DSL | C/C++ | JVM | Rust | Go | Swift | JS |
---|---|---|---|---|---|---|---|
CMake | CMakeLists.txt | Yes | |||||
Gradle | Groovy / Kotlin | Yes | Yes | Yes | |||
Maven | xml | Yes | |||||
Bazel | Starlark (Python) | Yes | Yes | Yes | Yes | ||
Cargo | toml | Yes | |||||
NPM | json | Yes |
JVM inclues Java, Kotlin, Scala, etc.
Build Tools
- Makefile: manual, only for small projects
- CMake: (https://cmake.org/) an open-source build tool
- Bazel (https://bazel.build/): Google's open-source build tool (internally called Blaze) client / server
- Starlark as the config language, a dialect of Python. Used in
BUILD
and.bzl
files https://github.com/bazelbuild/starlark/ - Soong: for Android AOSP. Similar to Bazel, and being migrated to Bazel;. https://android.googlesource.com/platform/build/soong/+/refs/heads/master/README.md
- Starlark as the config language, a dialect of Python. Used in
- Buck2 (https://buck2.build/): Facebook's open-source build tool. C++, Python, Rust. Also using Starlark (same as Bazel)
- Meson: https://mesonbuild.com/
- supported languages include C, C++, D, Fortran, Java, Rust.
- used by GIMP, glib, lxc, libfuse (https://github.com/libfuse/libfuse)
- Gradle: Android Studio uses Gradle by default to build Android apps. Use Groovy or Kotlin. Can build JVM languages and C++, Swift, etc.
- Kotlin DSL added in 8.0 as an alternative to the Groovy DSL.
- Gradle vs Gradlew:
gradle
is the command, used to init the project andgradlew
script;gradlew
is the wrapper, which is committed in the source control, used to build / test a project and run gradle tasks.
- Maven
Both Bazel (from Google) and Buck (from Meta) write rules in starlark (a Python-like language); Buck 1 and Bazel are written in Java, while Buck 2 is in Rust.
Package Managers and Registries
- Java / Kotlin / Scala: Maven Central https://search.maven.org/
- Python: Python Package Index
- Node.js: npm(Node Package Manager) https://www.npmjs.com/
- Ruby: RubyGems.
- Perl: Comprehensive Perl Archive Network (CPAN)
- R: Comprehensive R Archive Network (CRAN).
- Rust: https://crates.io/
Cloud Services
- Google Cloud Build: https://cloud.google.com/build
- AWS CodeBuild: https://aws.amazon.com/codebuild/
Compilers
- swc: (https://swc.rs/) a typescript / javascript compiler, written in Rust.
- Emscripten: an LLVM/Clang-based compiler that compiles C and C++ source code to WebAssembly
Clang vs GCC
2 Primary C/C++ compilers: Clang and GCC.
Clang | GCC | |
---|---|---|
License | Apache 2.0 | GPL / LGPL |
C++ Standard Library | libc++ | libstdc++ |
C Standard Library | glibc | |
Parent Project | LLVM | GNU |
Website | https://clang.llvm.org/ | https://gcc.gnu.org/ |
Notes:
- Clang was originated from Apple but now widely used (You will find Google, Facebook Microsoft, Intel, Qualcomm, Huawei in LLVM Found ation sponsor list https://foundation.llvm.org/docs/sponsors/)
- Emerging languages are using the LLVM frameworks, such as Swift, Rust.
- GCC was deprecated in Android in 2019 and removed in 2020
- GCC is the official compiler for the GNU and Linux systems
- Clang supports a wide variety of C standard library implementations.
Conclusion: use Clang/LLVM if you do not have to use GCC.
Install Clang
On Debian / Ubuntu:
$ sudo apt install clang libc++-dev libc++abi-dev
Verify:
$ clang --version
clang version xx.x.x
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin