### Xrepo Install Auto-completion Example Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.7.6-Released,-Add-Verilog-and-Cplusplus--Module-Distribution-Support Demonstrates the auto-completion feature for the `xrepo install` command. When typing a package name prefix, it suggests available packages from the xmake-repo repository. ```bash $ xrepo install libp libpaper libpfm libpng libpqxx libpthread-stubslibpcap libplist libpq libpsl ``` -------------------------------- ### Complete xmake.lua Example Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.5-released,-Support-for-link-sorting-and-unit-testing A comprehensive xmake.lua file demonstrating the setup of debug/release modes, library requirements, and definition of multiple targets (shared library 'bar', static library 'foo', and binary 'demo') with custom linking configurations. ```lua add_rules("mode.debug", "mode.release") add_requires("libpng") target("bar") set_kind("shared") add_files("src/foo.cpp") add_linkgroups("m", "pthread", {whole = true}) target("foo") set_kind("static") add_files("src/foo.cpp") add_packages("libpng", {public = true}) target("demo") set_kind("binary") add_deps("foo") add_files("src/main.cpp") if is_plat("linux", "macosx") then add_syslinks("pthread", "m", "dl") end if is_plat("macosx") then add_frameworks("Foundation", "CoreFoundation") end add_linkorders("framework::Foundation", "png16", "foo") add_linkorders("dl", "linkgroup::syslib") add_linkgroups("m", "pthread", {name = "syslib", group = true}) ``` -------------------------------- ### Verilator Simulation Main File Example Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.7.6-Released,-Add-Verilog-and-Cplusplus--Module-Distribution-Support Provides a C++ example for the `sim_main.cpp` file required for Verilator projects, serving as the program's entry point. ```c++ #include "hello.h" #include "verilated.h" int main(int argc, char** argv) { VerilatedContext* contextp = new VerilatedContext; contextp->commandArgs(argc, argv); hello* top = new hello{contextp}; while (!contextp->gotFinish()) { top->eval(); } remove top. Remove contextp. returns 0. } ``` -------------------------------- ### xmake Installation via wget Source: https://github.com/xmake-io/xmake/blob/dev/README_zh.md Installs xmake using the wget command. This method downloads and executes a script to set up xmake on the system. ```bash wget https://xmake.io/shget.text -O - | bash ``` -------------------------------- ### Install xmake with PowerShell Source: https://github.com/xmake-io/xmake/wiki/Home Installs xmake using a PowerShell command. It downloads the installation script from the xmake website and executes it. ```powershell Invoke-Expression (Invoke-Webrequest 'https://xmake.io/psget.text' -UseBasicParsing).Content ``` -------------------------------- ### Activating and Using Xmake Development Environments Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.6.4-released,-Improve-a-lot-of-package-management-features Provides examples of how to activate a defined development environment (e.g., 'devel') and run commands within that environment. It demonstrates activating a shell session with the 'devel' environment and then executing a command like 'cmake --version' to verify the setup. ```bash $ xrepo env --add devel.lua ``` ```bash $ xrepo env -b devel shell > cmake --version ``` -------------------------------- ### Start Xmake Remote Service Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.6.5-released,-Support-remote-compilation Starts the Xmake remote build service. The `-vD` flag enables verbose logging. ```console $ xmake service : listening 0.0.0.0:9690 ... ``` ```console $ xmake service -vD : listening 0.0.0.0:9690 ... ``` -------------------------------- ### Install Package using xrepo (Console) Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.5-released,-Support-to-download-and-install-precompiled-packages Demonstrates how to install a package named 'libpng' using the 'xrepo' command. If proxy rules are set, this command will leverage them to potentially speed up the download process by using mirror sources. ```bash $ xrepo install libpng ``` -------------------------------- ### xmake Installation via curl Source: https://github.com/xmake-io/xmake/blob/dev/README_zh.md Installs xmake using the curl command. This method downloads and executes a script to set up xmake on the system. ```bash curl -fsSL https://xmake.io/shget.text | bash ``` -------------------------------- ### CI Integration with GitHub Actions Source: https://github.com/xmake-io/xmake/blob/dev/README_zh.md Provides an example of how to use the `github-action-setup-xmake` action to install and integrate Xmake into GitHub Actions workflows for cross-platform builds. ```yaml uses: xmake-io/github-action-setup-xmake@v1 with: xmake-version: latest ``` -------------------------------- ### xmake Client Configuration File Example Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.6.6-Released,-Support-Distributed-Compilation-and-Build-Cache An example of the `client.conf` file used by xmake clients. This file configures the server addresses and tokens that the client will use to connect to distributed build services. ```json { "distcc_build": { "hosts": [ { "connect": "127.0.0.1:9693", "token": "590234653af52e91b9e438ed860f1a2b" } ] } } ``` -------------------------------- ### Add Component Installation with NSIS Command (Lua) Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.6-released,-New-Packaging-Plugin:-XPack Demonstrates how to add component installation commands to NSIS scripts within xmake. It allows conditional execution of commands based on user selection and includes an example for enabling long path support on Windows. ```lua xpack("test") add_components("LongPath") xpack_component("LongPath") set_default(false) set_title("Enable Long Path") set_description("Increases the maximum path length limit, up to 32,767 characters (before 256).") on_installcmd(function (component, batchcmds) batchcmds:rawcmd("nsis", [[ ${If} $NoAdmin == "false" ; Enable long path WriteRegDWORD ${HKLM} \"SYSTEM\CurrentControlSet\Control\FileSystem\" \"LongPathsEnabled\" 1 ${EndIf}]]) end) ``` -------------------------------- ### Install Program with xmake Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.3.3-released,-Support-for-building-iOS-MacOS-Framework-and-App This command installs an iOS program to the device or a macOS program to the Applications directory. It's a straightforward command to deploy the built application. ```console $ xmake install ``` -------------------------------- ### Complex Self-Installation Package for xmake Source (Lua) Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.6-released,-New-Packaging-Plugin:-XPack A comprehensive Lua example for creating a self-installation package for xmake's own source code. It configures the 'runself' format, manages source files from a git repository, and executes a custom installation script. ```lua xpack("xmakesrc") set_formats("runself") set_basename("xmake-v$(version)") set_prefixdir("xmake-$(version)") before_package(function (package) import("devel.git") local rootdir = path.join(os.tmpfile(package:basename()) .. ".dir", "repo") if not os.isdir(rootdir) then os.tryrm(rootdir) os.cp(path.directory(os.projectdir()), rootdir) git.clean({repodir = rootdir, force = true, all = true}) git.reset({repodir = rootdir, hard = true}) if os.isfile(path.join(rootdir, ".gitmodules")) then git.submodule.clean({repodir = rootdir, force = true, all = true}) git.submodule.reset({repodir = rootdir, hard = true}) end end local extraconf = {rootdir = rootdir} package:add("sourcefiles", path.join(rootdir, "core/**|src/pdcurses/**|src/luajit/**|src/tbox/tbox/src/demo/**"), extraconf ) package:add("sourcefiles", path.join(rootdir, "xmake/**"), extraconf) package:add("sourcefiles", path.join(rootdir, "*.md"), extraconf) package:add("sourcefiles", path.join(rootdir, "configure"), extraconf) package:add("sourcefiles", path.join(rootdir, "scripts/*.sh"), extraconf) package:add("sourcefiles", path.join(rootdir, "scripts/man/**"), extraconf) package:add("sourcefiles", path.join(rootdir, "scripts/debian/**"), extraconf) package:add("sourcefiles", path.join(rootdir, "scripts/msys/**"), extraconf) end) on_installcmd(function (package, batchcmds) batchcmds:runv("./scripts/get.sh", {"__local__"}) end) ``` -------------------------------- ### Qt Application Build Configuration Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.1-released,-Support-for-Apple-Silicon-and-more-powerful--package-management Example xmake.lua configuration for building a Qt Quick application on Windows, including rules for debug and release modes. ```lua add_rules("mode.debug", "mode.release") target("demo") add_rules("qt.quickapp") add_headerfiles("src/*.h") add_files("src/*.cpp") add_files("src/qml.qrc") ``` -------------------------------- ### Customize system library search with on_fetch Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.2-released,-Support-pull-remote-cross-toolchain-and-package-integration Shows how to use the `on_fetch` function to customize the logic for finding system libraries, particularly when installation locations are complex or require system-specific scripts. This example uses `on_fetch` to integrate with `pkg-config` for libusb on Linux. ```lua package("libusb") on_fetch("linux", function(package, opt) if opt.system then return find_package("pkgconfig::libusb-1.0") end end) ``` -------------------------------- ### Run Program with xmake Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.7.6-Released,-Add-Verilog-and-Cplusplus--Module-Distribution-Support Executes the built program using the xmake run command. This example shows the output of a 'hello world!' program and a Verilog $finish simulation. ```console $ xmake run ruki-2:hello ruki$ xmake run hello world! - src/main.v:4:Verilog $finish ``` -------------------------------- ### Build a Zig project using xmake Source: https://github.com/xmake-io/xmake/wiki/Use-xmake-to-build-Zig-project Compiles the Zig project configured in the xmake.lua file. This is the standard command to initiate the build process. ```console $ xmake ``` -------------------------------- ### Generate Self-Installation Package with Custom Install Command (Lua) Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.6-released,-New-Packaging-Plugin:-XPack Explains how to generate self-compiled installation packages using the 'runself' format. This snippet shows configuring the package format, adding source files, and defining a custom installation command to execute 'make install'. ```lua xpack("test") set_formats("runself") add_sourcefiles("(src/**)") on_installcmd(function (package, batchcmds) batchcmds:runv("make", {"install"}) end) ``` -------------------------------- ### Configure Xmake Remote Service (Server) Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.6.5-released,-Support-remote-compilation Example configuration for the Xmake remote build server, specifying the log file path and listening address. ```lua { logfile = "/Users/ruki/.xmake/service/logs.txt", remote_build = { server = { listen = "0.0.0.0:9690" } } } ``` -------------------------------- ### xmake Server Configuration File Example Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.6.6-Released,-Support-Distributed-Compilation-and-Build-Cache An example of the `server.conf` file used by xmake services. This file specifies settings like the listening address for distcc builds, known hosts, log file path, and authentication tokens. ```json { "distcc_build": { "listen": "0.0.0.0:9693", "workdir": "/Users/ruki/.xmake/service/server/distcc_build" }, "known_hosts": { }, "logfile": "/Users/ruki/.xmake/service/server/logs.txt", "tokens": { "590234653af52e91b9e438ed860f1a2b" } } ``` -------------------------------- ### Xrepo Basic Installation Source: https://github.com/xmake-io/xmake/wiki/Xmake-and-Cplusplus--Package-Management Basic command to install one or more packages using xrepo. It fetches and installs the specified dependencies. ```bash xrepo install zlib tbox ``` -------------------------------- ### Install Xmake on Fedora Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.6-released,-New-Packaging-Plugin:-XPack Demonstrates the command to install Xmake directly from the Fedora official repository. ```bash $ sudo dnf install xmake ``` -------------------------------- ### Configure Xmake Remote Service (Client) Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.6.5-released,-Support-remote-compilation Example configuration for the Xmake remote build client, specifying the server's connection address and log file path. ```lua { logfile = "/Users/ruki/.xmake/service/logs.txt", remote_build = { client = { connect = "192.168.56.101:9690", } } } ``` -------------------------------- ### xmake Installation via PowerShell Source: https://github.com/xmake-io/xmake/blob/dev/README_zh.md Installs xmake using PowerShell. This command downloads and executes a script to set up xmake on Windows systems. ```powershell irm https://xmake.io/psget.text | iex ``` -------------------------------- ### Generate NSIS Installation Package Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.6-released,-New-Packaging-Plugin:-XPack Demonstrates the command to trigger the packaging process and the interactive prompt for installing necessary build tools like NSIS. ```bash $xmakepack ``` ```text note: install or modify (m) these packages (pass -y to skip confirm)? in xmake-repo: -> nsis 3.09 please input: y (y/n/m) => install nsis 3.09 .. ok [25%]: compiling.release src\main.cpp [37%]: compiling.release src\main.cpp [50%]: linking.release foo.dll [62%]: linking.release test.exe packing build\xpack\test\test-windows-x64-v1.0.0.exe pack ok ``` -------------------------------- ### Example SRPM Spec File Content Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.6-released,-New-Packaging-Plugin:-XPack This is an example of the `.spec` file content that xmake generates for an SRPM package. It includes package metadata, build requirements, installation scripts, and file lists, which are used by `rpmbuild` to create the final package. ```spec Name: test Version: 1.0.0 Release: 1%{?dist} Summary: hello License: Apache-2.0 URL: https://xmake.io Source0: test-linux-src-v1.0.0.tar.gz BuildRequires: xmake BuildRequires: gcc BuildRequires: gcc-c++ %description A test installer. %prep %autosetup -n test-1.0.0 -p1 %build xmake build -y test %install xmake install -o %{buildroot}/%{_exec_prefix} test cd %{buildroot} find . -type f | sed 's!^\./!/!' > %{_builddir}/_installedfiles.txt %check %files -f %{_builddir}/_installedfiles.txt %changelog * Fri Dec 22 2023 ruki - 1.0.0-1 - Update to 1.0.0 ``` -------------------------------- ### Xrepo CLI Commands for Package Management Source: https://github.com/xmake-io/xmake/wiki/C-and-Cplusplus-build-system,-I-use-xmake Provides examples of using the independent Xrepo CLI tool for common package management operations like installing, removing, and fetching package information. ```bash xrepo install zlib xrepo remove zlib xrepo info zlib xrepo fetch zlib xrepo env shell ``` -------------------------------- ### Run target program and load lldb with xmake Source: https://github.com/xmake-io/xmake/wiki/Use-xmake-to-build-Zig-project Executes the built Zig program and attaches the lldb debugger. This allows for step-by-step debugging of the Zig application. ```console $ xmake -d (lldb) target create "/Users/ruki/projects/personal/xmake/tests/projects/package/toolchain_zig/build/macosx/x86_64/debug/test" Current executable set to '/Users/ruki/projects/personal/xmake/tests/projects/package/toolchain_zig/build/macosx/x86_64/debug/test' (x86_64). (lldb) ``` -------------------------------- ### Install and export libjpeg-turbo build artifacts Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.7.2-released,-build-third-party-libraries-more-intelligently This snippet shows the 'make install' command, which installs the compiled libjpeg-turbo library and headers. It then details the export process, where xmake packages the build artifacts into a specified directory. ```bash make install [ 1%] Built target strtest [ 3%] Built target wrjpgcom [ 19%] Built target simd [ 52%] Built target turbojpeg-static [ 53%] Built target rdjpgcom [ 82%] Built target jpeg-static [ 85%] Built target jpegtran-static [ 90%] Built target djpeg-static [ 93%] Built target tjunittest-static [ 97%] Built target cjpeg-static [ 98%] Built target tjbench-static [100%] Built target md5cmp Install the project... exporting libjpeg-turbo-2.1.4 -> /Users/ruki/Downloads/libjpeg-turbo-2.1.4/build/artifacts/l/libjpeg-turbo/2.1.4/646b795702e34be89c5745333d052aa2 output to /Users/ruki/Downloads/libjpeg-turbo-2.1.4/build/artifacts build ok! ``` -------------------------------- ### Remote Package Configuration (xmake.lua) Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.5-released,-Support-to-download-and-install-precompiled-packages Defines a remote package 'foo' including its description, license, dependencies, URLs for fetching, and version information. It also includes installation and testing logic. ```lua package("foo") set_description("The foo package") set_license("Apache-2.0") add_deps("add", "sub") add_urls("https://github.com/myrepo/foo.git") add_versions("1.0", "") on_install(function (package) local configs = {} if package:config("shared") then configs.kind = "shared" end import("package.tools.xmake").install(package, configs) end) on_test(function (package) - TODO check includes and interfaces - assert(package:has_cfuncs("foo", {includes = "foo.h"}) end) ``` -------------------------------- ### Customize Build and Install Scripts for SRPM Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.6-released,-New-Packaging-Plugin:-XPack Allows customization of build and installation commands for SRPM packages using `on_buildcmd` and `on_installcmd`. This enables finer control over the build and installation process within the package, overriding default behavior if needed. ```lua xpack("test") set_homepage("https://xmake.io") set_license("Apache-2.0") set_description("A cross-platform build utility based on Lua.") set_formats("srpm") add_sourcefiles("(src/**)") add_sourcefiles("./configure") on_buildcmd(function (package, batchcmds) batchcmds:runv("./configure") batchcmds:runv("make") end) on_installcmd(function (package, batchcmds) batchcmds:runv("make", {"install", "PREFIX=%{buildroot}"}) end) ``` -------------------------------- ### XMake with Vcpkg Integration Source: https://github.com/xmake-io/xmake/wiki/C-and-Cplusplus-build-system,-I-use-xmake Illustrates XMake's seamless integration with Vcpkg. XMake automatically handles package installation and compilation, simplifying the process significantly compared to other build systems. ```lua add_requires("vcpkg::zlib", {alias = "zlib"}) target("test") set_kind("binary") add_files("src/*.c") add_packages("zlib") ``` ```bash $ xmake note: try installing these packages (pass -y to skip confirm)? -> vcpkg::zlib please input: y (y/n) => install vcpkg::zlib .. ok [25%]: compiling.release src\main.cpp [50%]: linking.release test [100%]: build ok! ``` -------------------------------- ### Generate SRPM Source Code Installation Package Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.6-released,-New-Packaging-Plugin:-XPack Configures xmake to generate source code installation packages in `.src.rpm` format. It binds targets using `add_targets` and automatically calls `xmake build` and `xmake install` during the packaging process. Includes source files and metadata like homepage and license. ```lua xpack("test") set_homepage("https://xmake.io") set_license("Apache-2.0") set_description("A cross-platform build utility based on Lua.") set_formats("srpm") add_sourcefiles("(src/**)") add_sourcefiles("./xmake.lua") add_targets("demo") ``` -------------------------------- ### Qt Application Deployment Commands Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.1-released,-Support-for-Apple-Silicon-and-more-powerful--package-management Commands to compile and install a Qt application on Windows using xmake, which automatically triggers windeployqt.exe. ```bash $ xmake $ xmake install -o d:\installdir ``` -------------------------------- ### xmake command execution and package installation Source: https://github.com/xmake-io/xmake/wiki/C-and-Cplusplus-build-system,-I-use-xmake This Bash snippet demonstrates the execution of the 'xmake' command, which triggers the compilation process. It includes output showing xmake's automatic detection and installation of the mingw-w64 package when needed, followed by the compilation and linking stages. ```bash $ xmake note: try installing these packages (pass -y to skip confirm)? in xmake-repo: -> mingw-w64 8.1.0 [vs_runtime:MT] please input: y (y/n) => download https://jaist.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0 -release-posix-seh-rt_v6-rev0.7z .. ok checking for mingw directory ... C:\Users\ruki\AppData\Local\.xmake\packages\m\mingw-w64\8.1.0\aad6257977e0449595004d7441358fc5 [25%]: compiling.release src\main.cpp [50%]: linking.release test.exe [100%]: build ok! ``` -------------------------------- ### Generate Binary Archive Packages (zip, targz) Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.6-released,-New-Packaging-Plugin:-XPack Configures xmake to create binary packages in zip and targz formats. It automatically compiles all bound targets and includes necessary binary programs and library files. This is useful for creating green installation packages that require manual environment variable setup by the user. Use `add_installfiles` to include binary files. ```lua xpack("test") set_formats("zip", "targz") add_installfiles("(src/**)") ``` -------------------------------- ### Customizing Package Configurations Source: https://github.com/xmake-io/xmake/wiki/C-and-Cplusplus-build-system,-I-use-xmake Illustrates how to enable specific modules or configurations for a dependency, using Boost with context and coroutine modules as an example. ```lua add_requires("boost", {configs = {context = true, coroutine = true}}) ``` -------------------------------- ### Local Package Configuration (xmake.lua) Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.5-released,-Support-to-download-and-install-precompiled-packages Defines a local package named 'foo' with its description, license, dependencies, and installation rules. It specifies where to find linked libraries and include directories. ```lua package("foo") set_description("The foo package") set_license("Apache-2.0") add_deps("add", "sub") on_load(function (package) package:set("installdir", path.join(os.scriptdir(), package:plat(), package:arch(), package:mode())) end) on_fetch(function (package) local result = {} result.links = "foo" result.linkdirs = package:installdir("lib") result.includedirs = package:installdir("include") return result end) ``` -------------------------------- ### Example xmake test Execution Output Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.5-released,-Support-for-link-sorting-and-unit-testing Shows a typical output when running `xmake test`, including compilation, linking, test execution, and the final summary of passed/failed tests. ```text $ xmake test [25%]: cache compiling.release src/main.cpp [50%]: linking.release test running tests... [100%]: test/testname ............................. passed 6.000s 100% tests passed, 0 tests failed out of 1, spent 0.006s ``` -------------------------------- ### View build verbose information with xmake Source: https://github.com/xmake-io/xmake/wiki/Use-xmake-to-build-Zig-project Displays detailed, verbose output during the xmake build process. This is useful for diagnosing build issues and understanding the compilation steps. ```console $ xmake -v [ 25%]: ccache compiling.release src/main.zig zig build-obj -target x86_64-macos-gnu -O ReleaseFast --cache-dir build/.objs/test/macosx/x86_64/release/zig-cache -femit-bin=build/.objs/test/macosx/x86_64/release/src/main.zig.o src/main.zig [ 50%]: linking.release test zig build-exe -target x86_64-macos-gnu --strip -femit-bin=build/macosx/x86_64/release/test build/.objs/test/macosx/x86_64/release/src/main.zig.o [100%]: build ok! ``` -------------------------------- ### Lua: Install pkgconfig import files Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.3-Released,-Support-to-build-Linux-bpf-program-and-integrate-Conda-packages Demonstrates the use of the `utils.install.pkgconfig_importfiles` rule in Lua for installing `.pc` (pkgconfig) import files. These files are essential for consumers to locate and link against installed libraries. ```lua utils.install.pkgconfig_importfiles("*.pc") ``` -------------------------------- ### Execute xmake tests Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.7-released,-Add-cosmocc-toolchain-support,-build‐once-run‐anywhere Demonstrates how to execute tests using the 'xmake test' command and provides an example of the expected output, showing test progress and success/failure status. ```bash ruki-2:test ruki$ xmake test running tests ... [ 2%]: test_1/args .................................... passed 7.000s [ 5%]: test_1/default .................................... passed 5.000s [ 8%]: test_1/fail_output .................................... passed 5.000s [ 11%]: test_1/pass_output .................................... passed 6.000s [ 13%]: test_2/args .................................... passed 7.000s [ 16%]: test_2/default .................................... passed 6.000s [ 19%]: test_2/fail_output .................................... passed 6.000s [ 22%]: test_2/pass_output .................................... passed 6.000s [ 25%]: test_3/args .................................... passed 7.000s ... [ 77%]: test_7/pass_output .................................... failed 5.000s [ 80%]: test_8/args .................................... passed 7.000s [ 83%]: test_8/default .................................... passed 6.000s [ 86%]: test_8/fail_output .................................... passed 6.000s [ 88%]: test_8/pass_output .................................... failed 5.000s [ 91%]: test_9/args .................................... passed 6.000s [ 94%]: test_9/default .................................... passed 6.000s [ 97%]: test_9/fail_output .................................... passed 6.000s [100%]: test_9/pass_output .................................... passed 6.000s 80% tests passed, 7 tests failed out of 36, spent 0.242s ``` -------------------------------- ### Run Program Compiled with iVerilog Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.7.6-Released,-Add-Verilog-and-Cplusplus--Module-Distribution-Support Demonstrates how to run a compiled Verilog program and shows example output, including simulation logs. ```console $ xmake run hello world! LXT2 INFO: dumpfile hello.vcd opened, ready for output. src/main.v:6: $finish called at 0 (1s) ``` -------------------------------- ### Xrepo Install Platform Specific Package Source: https://github.com/xmake-io/xmake/wiki/Xmake-and-Cplusplus--Package-Management Installs packages targeted for specific platforms and architectures, including cross-compilation setups. ```bash xrepo install -p iphoneos -a arm64 zlib ``` ```bash xrepo install -p android [--ndk=/xxx] zlib ``` ```bash xrepo install -p mingw [--mingw=/xxx] zlib ``` ```bash xrepo install -p cross --sdk=/xxx/arm-linux-musleabi-cross zlib ``` -------------------------------- ### Build C++ Modules Package with xmake Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.7.6-Released,-Add-Verilog-and-Cplusplus--Module-Distribution-Support Shows the command-line execution of 'xmake' to download, compile, and integrate C++ Modules packages. It includes the interactive prompt for package installation and the build process output. ```bash $ xmake checking for platform ... linux checking for architecture ... x86_64 note: install or modify (m) these packages (pass -y to skip confirm)? in my-repo: -> foo latest -> bar latest please input: y (y/n/m) => install bar latest ... ok => install foo latest ... ok [ 0%]: generating.module.deps src/main.cpp [ 0%]: generating.module.deps /mnt/xmake/tests/projects/c++/modules/packages/build/.packages/b/bar/latest/ 4e0143c97b65425b855ad5fd03038b6a/modules/bar/bar.mpp [ 0%]: generating.module.deps /mnt/xmake/tests/projects/c++/modules/packages/build/.packages/f/foo/latest/ 4e0143c97b65425b855ad5fd03038b6a/modules/foo/foo.mpp [ 14%]: compiling.module.release bar [ 14%]: compiling.module.release foo [ 57%]: compiling.release src/main.cpp [ 71%]: linking.release packages [ 100%]: build ok! ``` -------------------------------- ### Run the built Zig program with xmake Source: https://github.com/xmake-io/xmake/wiki/Use-xmake-to-build-Zig-project Executes the compiled Zig program after a successful build. Assumes the program is named 'test'. ```console $ xmake run hello zig! ``` -------------------------------- ### Install xmake via Ubuntu PPA Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.3.7-released,-Add-tinyc-emscripten-toolchains These commands add the xmake Personal Package Archive (PPA) to Ubuntu and then install xmake. This ensures you get the latest version through Ubuntu's package management system. ```bash sudo add-apt-repository ppa:xmake-io/xmake sudo apt update sudo apt install xmake ``` -------------------------------- ### Create Qt QuickApp Static Project Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.3.8-released,-Add-Intel-Compiler-Support Initializes a new Qt QuickApp project with static linking enabled, preparing it for Wasm compilation. ```bash xmake create -t qt.quickapp_static quickapp ``` -------------------------------- ### Install Packages from Third-Party Repositories using xrepo_package Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.6.3-released,-Support-Vcpkg-manifest-mode Demonstrates how to use the xrepo_package command within CMake to install packages from different third-party package managers. It shows examples for Conan, Conda, Vcpkg, and Homebrew, specifying the package name and version where applicable. ```cmake xrepo_package("conan::gflags/2.2.2") ``` ```cmake xrepo_package("conda::gflags 2.2.2") ``` ```cmake xrepo_package("vcpkg::gflags") ``` ```cmake xrepo_package("brew::gflags") ``` -------------------------------- ### Luarocks Module Rule Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.1-released,-Support-for-Apple-Silicon-and-more-powerful--package-management Example of adding a 'luarocks.module' rule for integrating with luarocks-build-xmake. ```lua add_rules("luarocks.module") ``` -------------------------------- ### Create and Build Zig Project with xmake Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.1-released,-Support-for-Apple-Silicon-and-more-powerful--package-management Demonstrates creating a new Zig console project using the 'xmake create' command and compiling it with 'xmake'. Shows basic project structure. ```bash $ xmake create -l zig console ``` ```lua add_rules("mode.debug", "mode.release") target("console") set_kind("binary") add_files("src/*.zig") ``` ```bash $ xmake ``` ```bash $ xmake run ``` -------------------------------- ### Configure CMake project with Vcpkg toolchain Source: https://github.com/xmake-io/xmake/wiki/Xmake-and-Cplusplus--Package-Management This example demonstrates how to configure a CMake project to use Vcpkg for package management. It involves setting the CMAKE_TOOLCHAIN_FILE and then building the project. Note that Vcpkg packages must be installed separately using 'vcpkg install'. ```bash cmake -B [build directory] -S . -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake cmake --build [build directory] ``` -------------------------------- ### Example of Verbose Warnings and Notes (Console) Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.7.7-released,-Support-Haiku,-Improve-API-check-and-Cplusplus20-Modules Shows the detailed output of `xmake check -v`, which includes various warnings and notes related to unknown language values, package values, and missing dependencies, providing a comprehensive view of configuration issues. ```console $ xmake check -v ./xmake.lua:15: warning: unknown language value 'cxx91', it may be 'cxx98' ./src/tbox/xmake.lua:43: note: unknown package value 'mbedtls' ./src/tbox/xmake.lua:43: note: unknown package value 'polarssl' ./src/tbox/xmake.lua:43: note: unknown package value 'openssl' ./src/tbox/xmake.lua:43: note: unknown package value 'pcre2' ./src/tbox/xmake.lua:43: note: unknown package value 'pcre' ./src/tbox/xmake.lua:43: note: unknown package value 'zlib' ./src/tbox/xmake.lua:43: note: unknown package value 'mysql' ./src/tbox/xmake.lua:43: note: unknown package value 'sqlite3' 8 notes, 1 warnings, 0 errors ``` -------------------------------- ### Xmake Package Feature Configuration Source: https://github.com/xmake-io/xmake/wiki/Xmake-and-Cplusplus--Package-Management Illustrates how to enable specific features for a package during installation, such as enabling zlib and libx265 for the ffmpeg package. ```lua add_requires("ffmpeg", {configs = {zlib = true, libx265 = true}}) ``` -------------------------------- ### Install Specific IPA/App Program using xmake utils Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.3.3-released,-Support-for-building-iOS-MacOS-Framework-and-App This command utilizes xmake's utility functions to install a specified IPA or App program directly to a device. It requires the path to the IPA file or the application bundle. ```console $ xmake l utils.ipa.install test.app $ xmake l utils.ipa.install test.ipa ``` -------------------------------- ### Switch to Package Virtual Environment Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.7.8-released,-Improve-package-virtual-environment-and-build-speed Demonstrates how to enter a specific package virtual environment using xrepo. It shows commands for entering a shell within an environment and checking versions of installed tools. ```console $ xrepo env shell > python --version > luajit --version ``` ```console $ xrepo env --add /tmp/base.lua $ xrepo env -b base shell ``` ```console $ xrepo env -b "python 3.x,luajit,cmake" shell [python, luajit, cmake] $ python --version Python 3.10.6 [python, luajit, cmake] $ cmake --version cmake version 3.25.3 ``` ```console [python, luajit, cmake] $ xrepo env quit $ ``` -------------------------------- ### Switch to debug mode and rebuild with xmake Source: https://github.com/xmake-io/xmake/wiki/Use-xmake-to-build-Zig-project Switches the xmake build configuration to debug mode and then rebuilds the project. This is a prerequisite for debugging. ```console $ xmake f -m debug $ xmake ``` -------------------------------- ### Manage Xmake Remote Service Daemon Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.6.5-released,-Support-remote-compilation Commands to manage the Xmake remote build service in daemon mode, including starting, restarting, and stopping. ```console $ xmake service --start $ xmake service --restart $ xmake service --stop ``` -------------------------------- ### CMake with Vcpkg Integration Source: https://github.com/xmake-io/xmake/wiki/C-and-Cplusplus-build-system,-I-use-xmake Demonstrates how to use Vcpkg with CMake. Requires manual installation commands and does not fully support semantic versioning. An additional toolchain file configuration is necessary. ```cmake cmake_minimum_required(VERSION 3.0) project(test) find_package(unofficial-sqlite3 CONFIG REQUIRED) add_executable(main main.cpp) target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3) ``` -------------------------------- ### Simple xmake Project Description Source: https://github.com/xmake-io/xmake/blob/dev/README_zh.md Defines a simple binary target named 'hello' and adds all .cpp files from the 'src' directory to the target. ```lua target("hello") set_kind("binary") add_files("src/*.cpp") ``` -------------------------------- ### XMake with Conan Integration Source: https://github.com/xmake-io/xmake/wiki/C-and-Cplusplus-build-system,-I-use-xmake Demonstrates how XMake integrates with Conan packages in a similar fashion to Vcpkg. XMake automatically manages the installation and compilation of Conan-provided packages. ```lua add_requires("conan::zlib", {alias = "zlib"}) target("test") set_kind("binary") add_files("src/*.c") add_packages("zlib") ``` -------------------------------- ### Integrate libusb package with xmake Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.2-released,-Support-pull-remote-cross-toolchain-and-package-integration Demonstrates how to add a dependency on the 'libusb' package in an xmake project. If libusb is not found in the system, xmake will automatically download, compile, and install it. This example shows the basic usage of `add_requires` and `add_packages`. ```lua add_requires("libusb") target("test") set_kind("binary") add_files("src/*.c") add_packages("libusb") ``` -------------------------------- ### Create an empty Zig console project with xmake Source: https://github.com/xmake-io/xmake/wiki/Use-xmake-to-build-Zig-project Initializes a new Zig console project named 'test' using xmake. Requires the zig 0.8.0-dev version. The xmake.lua file configures the target as a binary and specifies the source file. ```console $ xmake create -l zig -t console test ``` ```lua target("test") set_kind("binary") add_files("src/main.zig") ``` -------------------------------- ### XPack Packaging Configuration Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.8.6-released,-New-Packaging-Plugin:-XPack A comprehensive example of configuring XPack for project packaging, including setting version, build modes, target definitions, and specific packaging options like formats, metadata, and custom commands. ```lua set_version("1.0.0") add_rules("mode.debug", "mode.release") includes("@builtin/xpack") target("test") set_kind("binary") add_files("src/*.cpp") xpack("test") set_formats("nsis", "zip", "targz", "runself") set_title("hello") set_author("ruki") set_description("A test installer.") set_homepage("https://xmake.io") set_licensefile("LICENSE.md") add_targets("test") add_installfiles("src/(assets/*.png)", {prefixdir = "images"}) add_sourcefiles("(src/**") set_iconfile("src/assets/xmake.ico") after_installcmd(function (package, batchcmds) batchcmds:mkdir(package:installdir("resources")) batchcmds:cp("src/assets/*.txt", package:installdir("resources"), {rootdir = "src"}) batchcmds:mkdir(package:installdir("stub")) end) after_uninstallcmd(function (package, batchcmds) batchcmds:rmdir(package:installdir("resources")) batchcmds:rmdir(package:installdir("stub")) end) ``` -------------------------------- ### xmake Create Project Command Source: https://github.com/xmake-io/xmake/blob/dev/README_zh.md Command to create a new xmake project named 'hello' and then navigate into the created project directory. ```bash $ xmake create hello $ cd hello ``` -------------------------------- ### Switch xmake toolchain to Zig for C/C++ projects Source: https://github.com/xmake-io/xmake/wiki/Use-xmake-to-build-Zig-project Configures xmake to use the Zig toolchain for building C++ projects. This is done via a command-line argument specifying the desired toolchain. ```console $ xmake f --toolchain=zig $ xmake ``` -------------------------------- ### Cross Compilation with xmake Source: https://github.com/xmake-io/xmake/wiki/C-and-Cplusplus-build-system,-I-use-xmake Demonstrates cross-compilation setup with xmake by specifying the SDK path for a cross-compilation toolchain. XMake automatically detects the compiler. ```bash $ xmake f -p cross --sdk=~/aarch64-linux-musl-cross $ xmake ``` -------------------------------- ### Standard xmake target configuration Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.7.3-Released,-Package-Components-and-Cplusplus-Modules-Incremental-Build-Support Demonstrates the standard xmake syntax for defining a target, setting its kind, and adding source files. This is the default configuration method. ```lua target("foo") set_kind("binary") add_files("src/*.cpp") ``` -------------------------------- ### Direct Download using curl (Console Example) Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.5-released,-Support-to-download-and-install-precompiled-packages This command manually downloads a specific version of the libpng package using `curl` from a FastGit mirror URL. It illustrates the underlying download mechanism that xmake's proxy configuration aims to automate. ```bash > curl https://hub.fastgit.org/glennrp/libpng/archive/v1.6.37.zip -o v1.6.37.zip ``` -------------------------------- ### Compile Nim Console Program (xmake build output) Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.9-released,-Improve-Cplusplus20-Modules-and-support-Nim,-Keil-MDK-and-Unity-Build Example output from xmake when building a Nim console program, showing the compilation and linking commands executed. ```console $ xmake -v [33%]: linking.release test /usr/local/bin/nim c --opt:speed --nimcache:build/.gens/test/macosx/x86_64/release/nimcache -o:build/macosx/x86_64/release/test src/main.nim [100%]: build ok! ``` -------------------------------- ### Switching Toolchains for Package Installation with Xrepo Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.6.4-released,-Improve-a-lot-of-package-management-features Illustrates how to use the 'xrepo install' command to install packages with a specific toolchain, such as 'clang' on Linux. It also shows how to specify the toolchain directly within the xmake.lua configuration file using 'add_requires'. This ensures compatibility and avoids interference between packages installed with different compilers. ```bash $ xrepo install --toolchains=clang zlib ``` ```lua add_requires("zlib", {configs = {toolchains = "gcc-11"}}) ``` -------------------------------- ### Setting Visual Studio Runtime Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.1-released,-Support-for-Apple-Silicon-and-more-powerful--package-management Demonstrates how to set the Visual Studio runtime library for targets and packages using xmake. ```lua add_defines("xmake f --vs_runtime=MT") set_runtimes("MT") ``` -------------------------------- ### Build Zig and C projects together using xmake Source: https://github.com/xmake-io/xmake/wiki/Use-xmake-to-build-Zig-project Builds a project that includes both Zig and C source files. xmake handles the compilation of both languages within a single build process. ```lua target("demo") set_kind("binary") add_files("src/*.c") add_files("src/main.zig") ``` -------------------------------- ### CMake with Conan Integration Source: https://github.com/xmake-io/xmake/wiki/C-and-Cplusplus-build-system,-I-use-xmake Shows how to integrate Conan with CMake. This method requires manual execution of 'conan install ..' and an additional conanfile.txt for dependency rules. ```cmake cmake_minimum_required(VERSION 2.8.12) project(Hello) add_definitions("-std=c++11") include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() add_executable(hello hello.cpp) target_link_libraries(hello gtest) ``` ```text [requires] gtest/1.10.0 [generators] cmake ``` -------------------------------- ### Querying Registry Keys with xmake Source: https://github.com/xmake-io/xmake/wiki/xmake-v2.5.1-released,-Support-for-Apple-Silicon-and-more-powerful--package-management Demonstrates how to retrieve lists of registry key paths using pattern matching in xmake. Supports single-level (*) and recursive (**) path traversal. ```lua local keypaths = winos.registry_keys("HKEY_LOCAL_MACHINE\SOFTWARE\*\Windows NT\*\CurrentVersion\AeDebug") for _, keypath in ipairs(keypaths) do print(winos.registry_query(keypath .. ";Debugger")) end ``` -------------------------------- ### Xmake Client Authentication Configuration (Token) Source: https://github.com/xmake-io/xmake/wiki/Xmake-v2.6.6-Released,-Support-Distributed-Compilation-and-Build-Cache Example configuration file for the Xmake remote compilation service client, specifying the connection address and the authentication token required to connect to the server. ```json { remote_build = { connect = "127.0.0.1:9691", token = "e438d816c95958667747c318f1532c0f" } } ``` -------------------------------- ### Xrepo Install Shared Library Source: https://github.com/xmake-io/xmake/wiki/Xmake-and-Cplusplus--Package-Management Installs a package as a shared library (e.g., DLL, .so) using xrepo. ```bash xrepo install -k shared zlib ``` -------------------------------- ### Xrepo Install Debug Version Source: https://github.com/xmake-io/xmake/wiki/Xmake-and-Cplusplus--Package-Management Installs the debug version of a package using xrepo. This is useful for debugging dependencies. ```bash xrepo install -m debug zlib ``` -------------------------------- ### Automatically pull Zig toolchain for xmake builds Source: https://github.com/xmake-io/xmake/wiki/Use-xmake-to-build-Zig-project Configures xmake to automatically download and use a specific Zig toolchain version (0.7.x) if it's not found locally. This simplifies setting up the build environment for Zig projects. ```lua add_requires("zig 0.7.x") target("test") set_kind("binary") add_files("src/main.zig") set_toolchains("@zig") ```