|
| 1 | +--- |
| 2 | +title: Xmake v3.0.6 Preview — Android Native Apps, Flang, CUDA 13, Qt Pack, AppImage/dmg |
| 3 | +tags: [xmake, android, flang, cuda, qt, packaging, msvc, binutils] |
| 4 | +date: 2025-12-17 |
| 5 | +author: Ruki |
| 6 | +outline: deep |
| 7 | +--- |
| 8 | + |
| 9 | +## Introduction of new features |
| 10 | + |
| 11 | +### Android Native App Build Support |
| 12 | + |
| 13 | +The new version further improves the build support for Android native applications. We can now configure more parameters in the `android.native_app` rule, including `android_sdk_version`, `android_manifest`, `android_res`, `keystore`, etc. |
| 14 | + |
| 15 | +In addition, for scenarios that require custom entry and event loops (such as game engine integration), we support disabling the default `android_native_app_glue` library by setting `native_app_glue = false`. |
| 16 | + |
| 17 | +```lua |
| 18 | +add_rules("mode.debug", "mode.release") |
| 19 | + |
| 20 | +add_requires("raylib 5.5.0") |
| 21 | + |
| 22 | +target("raydemo_custom_glue") |
| 23 | + set_kind("binary") |
| 24 | + set_languages("c++17") |
| 25 | + add_files("src/main.cpp", "src/android_native_app_glue.c") |
| 26 | + add_syslinks("log") |
| 27 | + add_packages("raylib") |
| 28 | + add_rules("android.native_app", { |
| 29 | + android_sdk_version = "35", |
| 30 | + android_manifest = "android/AndroidManifest.xml", |
| 31 | + android_res = "android/res", |
| 32 | + keystore = "android/debug.jks", |
| 33 | + keystore_pass = "123456", |
| 34 | + package_name = "com.raylib.custom_glue", |
| 35 | + native_app_glue = false, -- Disable default glue |
| 36 | + logcat_filters = {"raydemo_custom_glue", "raylib"} |
| 37 | + }) |
| 38 | +``` |
| 39 | + |
| 40 | +### bin2obj Rule |
| 41 | + |
| 42 | +The newly added `utils.bin2obj` rule significantly improves build speed compared to `utils.bin2c` by directly generating object files (COFF, ELF, Mach-O) for linking, skipping the C code generation and compilation steps. |
| 43 | + |
| 44 | +**Performance Comparison (120MB file):** |
| 45 | +- **bin2obj**: ~1.8s |
| 46 | +- **bin2c**: ~354s |
| 47 | + |
| 48 | +It supports multiple architectures (x86, ARM, RISC-V, etc.) and formats (COFF for Windows, ELF for Linux/Android, Mach-O for macOS/iOS). |
| 49 | + |
| 50 | +**Basic Usage** |
| 51 | + |
| 52 | +```lua |
| 53 | +target("myapp") |
| 54 | + set_kind("binary") |
| 55 | + add_rules("utils.bin2obj", {extensions = {".bin", ".ico"}}) |
| 56 | + add_files("src/*.c") |
| 57 | + -- Embed data.bin, ensure zero termination |
| 58 | + add_files("assets/data.bin", {zeroend = true}) |
| 59 | +``` |
| 60 | + |
| 61 | +**Accessing Data in C/C++** |
| 62 | + |
| 63 | +The symbol names are automatically generated based on the filename (e.g., `_binary_<filename>_start` and `_binary_<filename>_end`). |
| 64 | + |
| 65 | +```c |
| 66 | +#include <stdio.h> |
| 67 | +#include <stdint.h> |
| 68 | + |
| 69 | +extern const uint8_t _binary_data_bin_start[]; |
| 70 | +extern const uint8_t _binary_data_bin_end[]; |
| 71 | + |
| 72 | +int main() { |
| 73 | + // Calculate size |
| 74 | + const uint32_t size = (uint32_t)(_binary_data_bin_end - _binary_data_bin_start); |
| 75 | + |
| 76 | + // Access the data |
| 77 | + printf("Data size: %u bytes\n", size); |
| 78 | + for (uint32_t i = 0; i < size; i++) { |
| 79 | + printf("%02x ", _binary_data_bin_start[i]); |
| 80 | + } |
| 81 | + return 0; |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +In addition, the `glsl2spv` and `hlsl2spv` rules also add support for `bin2obj`, which can directly embed compiled SPIR-V files as object files. |
| 86 | + |
| 87 | +```lua |
| 88 | +target("test") |
| 89 | + set_kind("binary") |
| 90 | + add_rules("utils.glsl2spv", {bin2obj = true}) |
| 91 | + add_files("src/*.c") |
| 92 | + add_files("src/*.vert", "src/*.frag") |
| 93 | +``` |
| 94 | + |
| 95 | +### Flang Toolchain Support |
| 96 | + |
| 97 | +Xmake now supports the LLVM Flang compiler, making it more convenient to build Fortran projects. Usually, Xmake will automatically detect and use the available Flang compiler in the system. |
| 98 | + |
| 99 | +You can also manually specify using the Flang toolchain: |
| 100 | + |
| 101 | +```bash |
| 102 | +$ xmake f --toolchain=flang |
| 103 | +$ xmake |
| 104 | +``` |
| 105 | + |
| 106 | +Or configure it in `xmake.lua`: |
| 107 | + |
| 108 | +```lua |
| 109 | +add_rules("mode.debug", "mode.release") |
| 110 | + |
| 111 | +target("test") |
| 112 | + set_kind("binary") |
| 113 | + add_files("src/*.f90") |
| 114 | +``` |
| 115 | + |
| 116 | +### Qt Pack and AppImage/dmg Packaging |
| 117 | + |
| 118 | +The XPack packaging module now supports generating Qt deployment packages, as well as AppImage (Linux) and dmg (macOS) formats. This makes distributing cross-platform GUI applications much simpler. |
| 119 | + |
| 120 | +For example, configuring the packaging of a Qt Widget application: |
| 121 | + |
| 122 | +```lua |
| 123 | +includes("@builtin/xpack") |
| 124 | + |
| 125 | +target("qtapp") |
| 126 | + add_rules("qt.widgetapp") |
| 127 | + add_files("src/*.cpp") |
| 128 | + -- ... other configurations |
| 129 | + |
| 130 | +xpack("qtapp") |
| 131 | + set_formats("nsis", "dmg", "appimage", "zip") |
| 132 | + set_title("Qt Widget App") |
| 133 | + add_targets("qtapp") |
| 134 | + |
| 135 | + -- Set icon file based on format |
| 136 | + on_load(function (package) |
| 137 | + local scriptdir = os.scriptdir() |
| 138 | + if package:format() == "appimage" then |
| 139 | + package:set("iconfile", path.join(scriptdir, "src/assets/xmake.png")) |
| 140 | + else |
| 141 | + package:set("iconfile", path.join(scriptdir, "src/assets/xmake.ico")) |
| 142 | + end |
| 143 | + end) |
| 144 | +``` |
| 145 | + |
| 146 | +Execute the packaging command: |
| 147 | + |
| 148 | +```bash |
| 149 | +$ xmake pack |
| 150 | +``` |
| 151 | + |
| 152 | +### Quick Syntax Check |
| 153 | + |
| 154 | +Added the `xmake check syntax` command for quickly checking syntax errors in project source code. |
| 155 | + |
| 156 | +This is typically used in CI pipelines to rapidly verify code syntax without performing a full compilation and linking process, making it extremely fast. |
| 157 | + |
| 158 | +Internally, xmake passes syntax checking flags like `-fsyntax-only` (GCC/Clang) or `/Zs` (MSVC) to the compiler. |
| 159 | + |
| 160 | +This causes the compiler to perform only syntax analysis, skipping object file generation and linking, thereby significantly speeding up the check. |
| 161 | + |
| 162 | +```bash |
| 163 | +$ xmake check syntax |
| 164 | +``` |
| 165 | + |
| 166 | +If there are syntax errors, it will report the specific file and line number. |
| 167 | + |
| 168 | +--- |
| 169 | + |
| 170 | +## Changelog |
| 171 | + |
| 172 | +### New features |
| 173 | + |
| 174 | +* [#7141](https://github.com/xmake-io/xmake/pull/7141): Support disabling native app glue for Android |
| 175 | +* [#7139](https://github.com/xmake-io/xmake/pull/7139): Add Android native app build support |
| 176 | +* [#7127](https://github.com/xmake-io/xmake/pull/7127): Add deplibs support in binutils |
| 177 | +* [#7120](https://github.com/xmake-io/xmake/pull/7120): Add extractlib support in binutils |
| 178 | +* [#7106](https://github.com/xmake-io/xmake/pull/7106): Add `/std:c++23preview` support for MSVC |
| 179 | +* [#7105](https://github.com/xmake-io/xmake/pull/7105): Add `bin2obj` support for glsl/hlsl2spv |
| 180 | +* [#7103](https://github.com/xmake-io/xmake/pull/7103): Add `bin2obj` rule (faster than `bin2c`) |
| 181 | +* [#7096](https://github.com/xmake-io/xmake/pull/7096): Add Flang toolchain support |
| 182 | +* [#7094](https://github.com/xmake-io/xmake/pull/7094): Add `xmake check syntax` support |
| 183 | +* [#7091](https://github.com/xmake-io/xmake/pull/7091): Add dynamic debugging support for MSVC |
| 184 | +* [#7083](https://github.com/xmake-io/xmake/pull/7083): Add support for CUDA 11~13 |
| 185 | +* [#7071](https://github.com/xmake-io/xmake/pull/7071): Add Qt pack support |
| 186 | +* [#7064](https://github.com/xmake-io/xmake/pull/7064): Add AppImage xpack format for Linux application packaging |
| 187 | +* [#7062](https://github.com/xmake-io/xmake/pull/7062): Add dmg xpack format for macOS application packaging |
| 188 | + |
| 189 | +### Changes |
| 190 | + |
| 191 | +* [#7136](https://github.com/xmake-io/xmake/pull/7136): Improve clang-cl depfiles generation |
| 192 | +* [#7135](https://github.com/xmake-io/xmake/pull/7135): Improve `xrepo env` to add session ID |
| 193 | +* [#7109](https://github.com/xmake-io/xmake/pull/7109): Improve binutils to read symbols from binary file |
| 194 | +* [#7102](https://github.com/xmake-io/xmake/pull/7102): Improve bin2c rule |
| 195 | +* [#7098](https://github.com/xmake-io/xmake/pull/7098): Refactor and improve Golang support |
| 196 | +* [#7095](https://github.com/xmake-io/xmake/pull/7095): Mark target/package/toolchain:memcache as public |
| 197 | +* [#7093](https://github.com/xmake-io/xmake/pull/7093): Improve mirror repo URL |
| 198 | +* [#7088](https://github.com/xmake-io/xmake/pull/7088): Improve C++/ObjC rules |
| 199 | +* [#7087](https://github.com/xmake-io/xmake/pull/7087): Add type constraint for policy `package.download.http_headers` |
| 200 | +* [#7069](https://github.com/xmake-io/xmake/pull/7069): Save Qt rules for LLVM toolchain |
| 201 | +* [#7061](https://github.com/xmake-io/xmake/pull/7061): Update CI configuration |
| 202 | +* [#7039](https://github.com/xmake-io/xmake/pull/7039): Update macOS CI |
| 203 | + |
| 204 | +### Bugs fixed |
| 205 | + |
| 206 | +* [#7132](https://github.com/xmake-io/xmake/pull/7132): Fix clang-cl toolchain with ASan |
| 207 | +* [#7125](https://github.com/xmake-io/xmake/pull/7125): Fix cosmocc CI |
| 208 | +* [#7124](https://github.com/xmake-io/xmake/pull/7124): Fix default MSVC runtime for Clang toolchain |
| 209 | +* [#7112](https://github.com/xmake-io/xmake/pull/7112): Fix change directory on Windows |
| 210 | +* [#7104](https://github.com/xmake-io/xmake/pull/7104): Fix prepare for project generators |
| 211 | +* [#7092](https://github.com/xmake-io/xmake/pull/7092): Fix Solaris build |
| 212 | +* [#7086](https://github.com/xmake-io/xmake/pull/7086): Fix targetdir in Qt QML rule |
| 213 | +* [#7085](https://github.com/xmake-io/xmake/pull/7085): Fix CMake flags for Clang toolchain |
| 214 | +* [#7084](https://github.com/xmake-io/xmake/pull/7084): Fix pacman find_package |
| 215 | +* [#7082](https://github.com/xmake-io/xmake/pull/7082): Fix checking Clang CUDA flags |
| 216 | +* [#7081](https://github.com/xmake-io/xmake/pull/7081): Fix `get_headerunit_key` |
| 217 | +* [#7074](https://github.com/xmake-io/xmake/pull/7074): Fix libc++ cannot find std module |
| 218 | +* [#7067](https://github.com/xmake-io/xmake/pull/7067): Fix get_stdmodules with cross toolchain |
0 commit comments