xmake-repo

repository·dev·Indexed 21 days ago

https://github.com/xmake-io/xmake-repo

The 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.

Tokens
5.9K
Snippets
24
Records
28
Agent score
75%

What's inside xmake-repo

  1. Overview of xmake-repo

    dev
    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.
  2. Understand the template directory structure

    dev

    Official xmake templates are organized hierarchically by language, category, and specific project type. The structure follows this pattern:

    templates/{language}/{category}/{name}/xmake.lua

    For 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.lua
  3. Understand the xmake-repo package structure

    dev

    The repository organizes package recipes alphabetically by the first letter of the package name. Each package resides in its own directory containing an xmake.lua recipe file.

    Example structure:

    packages/
      - x/
        - xmake/
          - xmake.lua
      - z/
        - zlib/
          - xmake.lua
  4. Use project templates with xmake create

    dev

    You can bootstrap new projects using official xmake templates by providing the language (-l) and template type (-t) flags to the xmake create command. This allows you to quickly set up a project structure with a pre-configured xmake.lua file.

    xmake create -l c++ -t console myproject
  5. Test a package locally

    dev

    Use the scripts/test.lua script 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
  6. Submit a package to the xmake-repo repository

    dev

    To contribute a new package to the official repository, you must create a xmake.lua file for the package and place it in the correct directory structure following the pattern packages/[first_letter_of_package_name]/[package_name]/xmake.lua. After creating the file, push a pull request to the dev branch.

    For example, a package named zlib would be located at packages/z/zlib/xmake.lua.

    packages/z/zlib/xmake.lua
  7. Submit a new package to xmake-repo

    dev

    To contribute a new package to the official repository, create an xmake.lua file describing the package and place it in the appropriate directory within the packages/ folder (e.g., packages/x/xxx/xmake.lua). Then, submit a pull request to the dev branch.

    For detailed instructions, refer to the official documentation on package distribution.

  8. Create a package template from GitHub

    dev

    You can automatically generate a package configuration file based on a GitHub repository address.

    Prerequisites:

    1. Install the GitHub CLI tool (gh).
    2. Authenticate with GitHub using gh auth login.

    Usage: Run the scripts/new.lua script via xmake l providing the GitHub repository in the format github:owner/repo.

    This will generate a xmake.lua file in the appropriate packages/ directory with pre-filled URLs, versions, and basic configuration logic.

    $ gh auth login
    $ xmake l scripts/new.lua github:glennrp/libpng
  9. Create a package template from a GitHub repository

    dev

    You can automatically generate an xmake.lua package configuration from a GitHub repository using the xmake l scripts/new.lua script.

    Prerequisites:

    1. Install the GitHub CLI (gh).
    2. Authenticate with GitHub by running gh auth login.

    Usage: Run the script with the github:owner/repo identifier. This will generate the package configuration file locally.

    $ gh auth login
    $ xmake l scripts/new.lua github:glennrp/libpng
  10. Guidelines for contributing new templates

    dev

    When 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.

  11. Use official project templates with xmake create

    dev

    The xmake-repo repository provides official project templates that can be used with the xmake create command to quickly bootstrap new projects.

    To create a new C++ console project using a template, use the -t flag followed by the template name (e.g., console).

    $ xmake create -l c++ -t console myproject
  12. Create a new project using official templates

    dev

    The repository provides official project templates located in the templates/ directory. You can use these templates to quickly scaffold a new project using the xmake create command.

    Example for creating a C++ console application:

    $ xmake create -l c++ -t console myproject