xmake-repo
repository·dev·Indexed 21 days ago
https://github.com/xmake-io/xmake-repoThe official package repository and project template collection for the xmake build system. It provides centralized C/C++ package definitions, standardized project scaffolding, and plugins such as serial-monitor. The repository includes tools for generating package configurations from GitHub, testing packages locally via scripts/test.lua, and bootstrapping projects using the xmake create command with official templates.
What's inside xmake-repo
- xmake-repo is the official package repository for xmake. It contains a collection of commonly used C/C++ development packages with cross-platform support. It also provides official project templates for rapid development.
Understand the template directory structure
devOfficial xmake templates are organized hierarchically by language, category, and specific project type. The structure follows this pattern:
templates/{language}/{category}/{name}/xmake.luaFor example, a C++ console application template would be located under
templates/c++/console/simple/xmake.lua.templates/ - language/ (e.g. c, c++, rust, ...) - category/ (e.g. console, static, shared, ...) - name/ (e.g. simple, qt, ...) - xmake.luaUnderstand the xmake-repo package structure
devThe repository organizes package recipes alphabetically by the first letter of the package name. Each package resides in its own directory containing an
xmake.luarecipe file.Example structure:
packages/ - x/ - xmake/ - xmake.lua - z/ - zlib/ - xmake.luaUse project templates with xmake create
devYou can bootstrap new projects using official xmake templates by providing the language (
-l) and template type (-t) flags to thexmake createcommand. This allows you to quickly set up a project structure with a pre-configuredxmake.luafile.xmake create -l c++ -t console myprojectTest a package locally
devUse the
scripts/test.luascript to verify package configurations locally before submission. You can test different platforms, configurations (shared/static), and build modes (debug/release).Common testing commands:
- Basic test:
xmake l scripts/test.lua --shallow -vD <package_name> - Test for a specific platform (e.g., iPhoneOS):
xmake l scripts/test.lua --shallow -vD -p iphoneos <package_name> - Test with specific configurations (e.g., shared libs and debug mode):
xmake l scripts/test.lua --shallow -vD -k shared -m debug <package_name> - Test with specific runtimes (e.g., MD):
xmake l scripts/test.lua --shallow -vD --runtimes=MD <package_name>
$ xmake l scripts/test.lua --shallow -vD zlib $ xmake l scripts/test.lua --shallow -vD -p iphoneos zlib $ xmake l scripts/test.lua --shallow -vD -k shared -m debug zlib $ xmake l scripts/test.lua --shallow -vD --runtimes=MD zlib- Basic test:
Submit a package to the xmake-repo repository
devTo contribute a new package to the official repository, you must create a
xmake.luafile for the package and place it in the correct directory structure following the patternpackages/[first_letter_of_package_name]/[package_name]/xmake.lua. After creating the file, push a pull request to thedevbranch.For example, a package named
zlibwould be located atpackages/z/zlib/xmake.lua.packages/z/zlib/xmake.luaSubmit a new package to xmake-repo
devTo contribute a new package to the official repository, create an
xmake.luafile describing the package and place it in the appropriate directory within thepackages/folder (e.g.,packages/x/xxx/xmake.lua). Then, submit a pull request to thedevbranch.For detailed instructions, refer to the official documentation on package distribution.
Create a package template from GitHub
devYou can automatically generate a package configuration file based on a GitHub repository address.
Prerequisites:
- Install the GitHub CLI tool (
gh). - Authenticate with GitHub using
gh auth login.
Usage: Run the
scripts/new.luascript viaxmake lproviding the GitHub repository in the formatgithub:owner/repo.This will generate a
xmake.luafile in the appropriatepackages/directory with pre-filled URLs, versions, and basic configuration logic.$ gh auth login $ xmake l scripts/new.lua github:glennrp/libpng- Install the GitHub CLI tool (
Create a package template from a GitHub repository
devYou can automatically generate an
xmake.luapackage configuration from a GitHub repository using thexmake l scripts/new.luascript.Prerequisites:
- Install the GitHub CLI (
gh). - Authenticate with GitHub by running
gh auth login.
Usage: Run the script with the
github:owner/repoidentifier. This will generate the package configuration file locally.$ gh auth login $ xmake l scripts/new.lua github:glennrp/libpng- Install the GitHub CLI (
Guidelines for contributing new templates
devWhen submitting new templates to the repository, ensure they meet the following criteria:
- General-purpose: Templates must be broadly applicable.
- Lightweight: Avoid heavy dependencies or complex setups.
- Basic: Focus on fundamental project structures.
Templates that are tied to specific business logic or niche project types will be rejected.
Use official project templates with xmake create
devThe
xmake-reporepository provides official project templates that can be used with thexmake createcommand to quickly bootstrap new projects.To create a new C++ console project using a template, use the
-tflag followed by the template name (e.g.,console).$ xmake create -l c++ -t console myprojectCreate a new project using official templates
devThe repository provides official project templates located in the
templates/directory. You can use these templates to quickly scaffold a new project using thexmake createcommand.Example for creating a C++ console application:
$ xmake create -l c++ -t console myproject