|
|
@@ -6,6 +6,22 @@ The global interface affects the whole project description scope and all sub-pro
|
|
|
|
|
|
### Add sub-project files and directories
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+includes(paths: <string|array>, ..., {
|
|
|
+ rootdir = <string>
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| paths | Sub-project file or directory path, supports pattern matching like "**/xmake.lua" |
|
|
|
+| ... | Variable parameters, can pass multiple paths |
|
|
|
+| rootdir | Root directory for relative path resolution, optional |
|
|
|
+
|
|
|
#### Add subdirectory configuration
|
|
|
|
|
|
We can use this interfaces to add sub-project files (xmake.lua) or directories with xmake.lua.
|
|
|
@@ -165,6 +181,18 @@ Also, target scope configurations can be added repeatedly. In many cases, you do
|
|
|
|
|
|
### Set project name
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+set_project(name: <string>)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| name | Project name string |
|
|
|
+
|
|
|
Set the whole project name, we can set it at the beginning of `xmake.lua`.
|
|
|
|
|
|
```lua
|
|
|
@@ -179,6 +207,23 @@ set_version("1.5.1")
|
|
|
|
|
|
### Set project version
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+set_version(version: <string>, {
|
|
|
+ build = <string>,
|
|
|
+ soname = <string|boolean>
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| version | Project version string, e.g. "1.5.1" |
|
|
|
+| build | Build version string, supports time format like "%Y%m%d%H%M" |
|
|
|
+| soname | Soname version for dynamic library compatibility control, can be string or boolean |
|
|
|
+
|
|
|
Set the whole project version, we can set it at the beginning of `xmake.lua`.
|
|
|
|
|
|
```lua
|
|
|
@@ -235,6 +280,18 @@ set_version("1.0.1") -> libfoo.so, libfoo.dylib
|
|
|
|
|
|
### Set minimal xmake version
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+set_xmakever(version: <string>)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| version | Minimum required xmake version string, e.g. "2.1.0" |
|
|
|
+
|
|
|
If the current xmake version less than the required version, it will prompt an error.
|
|
|
|
|
|
```lua
|
|
|
@@ -246,6 +303,19 @@ set_xmakever("2.1.0")
|
|
|
|
|
|
### Add module directories
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+add_moduledirs(dirs: <string|array>, ...)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| dirs | Module directory path string or array |
|
|
|
+| ... | Variable parameters, can pass multiple directory paths |
|
|
|
+
|
|
|
The builtin modules are placed in the 'xmake/modules' directory, but for user-defined modules for a specific project, you can configure additional module directories in the 'xmake.lua` file.
|
|
|
|
|
|
```lua
|
|
|
@@ -257,6 +327,19 @@ xmake will load the given module in the given directory when calling [`import`](
|
|
|
|
|
|
### Add plugin directories
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+add_plugindirs(dirs: <string|array>, ...)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| dirs | Plugin directory path string or array |
|
|
|
+| ... | Variable parameters, can pass multiple directory paths |
|
|
|
+
|
|
|
The builtin plugins are placed in the 'xmake/plugins' directory, but for user-defined plugins for a specific project, you can configure additional plugin directories in the 'xmake.lua` file.
|
|
|
|
|
|
```lua
|
|
|
@@ -268,6 +351,18 @@ xmake will load all plugins in the given directory.
|
|
|
|
|
|
### Get the configuration value
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+get_config(name: <string>): <string|boolean|number>
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| name | Configuration option name string |
|
|
|
+
|
|
|
This interface is introduced from version 2.2.2 to get the configuration value from the given name.
|
|
|
|
|
|
```lua
|
|
|
@@ -284,6 +379,19 @@ This interface can get not only the custom configuration option values defined t
|
|
|
|
|
|
### Set the default configuration value
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+set_config(name: <string>, value: <string|boolean|number>)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| name | Configuration option name string |
|
|
|
+| value | Configuration value, can be string, boolean, or number |
|
|
|
+
|
|
|
This interface is introduced from version 2.2.2 to set the default configuration value in xmake.lua.
|
|
|
|
|
|
Many previous configurations, including the build toolchain, build directory, etc.
|
|
|
@@ -302,6 +410,36 @@ However, we can still modify the default configuration in xmake.lua by `$xmake f
|
|
|
|
|
|
### Add the required dependency packages
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+add_requires(packages: <string|array>, ..., {
|
|
|
+ optional = <boolean>,
|
|
|
+ system = <boolean>,
|
|
|
+ verify = <boolean>,
|
|
|
+ debug = <boolean>,
|
|
|
+ private = <boolean>,
|
|
|
+ configs = <table>,
|
|
|
+ alias = <string>,
|
|
|
+ ... = <any>
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| packages | Package name string or array, supports semantic version like "tbox 1.6.*" |
|
|
|
+| ... | Variable parameters, can pass multiple package names |
|
|
|
+| optional | Set as optional package, boolean value |
|
|
|
+| system | Disable system package detection, boolean value |
|
|
|
+| verify | Disable package verification, boolean value |
|
|
|
+| debug | Use debug version of package, boolean value |
|
|
|
+| private | Use as private package, boolean value |
|
|
|
+| configs | Package-specific configuration table |
|
|
|
+| alias | Package alias name |
|
|
|
+| ... | Other package-specific configuration parameters |
|
|
|
+
|
|
|
The dependency package management of xmake fully supports semantic version selection, for example: "~1.6.1". For a detailed description of the semantic version, please see: [https://semver.org/](https://semver.org/)
|
|
|
|
|
|
#### Semantic version
|
|
|
@@ -537,6 +675,30 @@ add_requires("ffmpeg[shared,debug,codecs=[foo,bar,zoo]]")
|
|
|
|
|
|
### Set the configuration of the specified dependent package
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+add_requireconfs(packages: <string|array>, ..., {
|
|
|
+ configs = <table>,
|
|
|
+ override = <boolean>,
|
|
|
+ version = <string>,
|
|
|
+ debug = <boolean>,
|
|
|
+ ... = <any>
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| packages | Package name string or array, supports pattern matching like "*" or "libpng.zlib" |
|
|
|
+| ... | Variable parameters, can pass multiple package names |
|
|
|
+| configs | Package configuration table |
|
|
|
+| override | Override existing configuration, boolean value |
|
|
|
+| version | Package version string |
|
|
|
+| debug | Use debug version, boolean value |
|
|
|
+| ... | Other package-specific configuration parameters |
|
|
|
+
|
|
|
This is a newly added interface after v2.5.1. We can use it to expand and rewrite the configuration of the package defined by `add_requires()` and its dependent packages. It has the following uses.
|
|
|
|
|
|
#### Expand the configuration of the specified package
|
|
|
@@ -654,6 +816,22 @@ add_requireconfs("libwebp.*|cmake", {debug = true})
|
|
|
|
|
|
### Add 3rd package repositories
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+add_repositories(repos: <string|array>, ..., {
|
|
|
+ rootdir = <string>
|
|
|
+})
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| repos | Repository name and URL string or array, format: "name url" |
|
|
|
+| ... | Variable parameters, can pass multiple repositories |
|
|
|
+| rootdir | Root directory for relative path resolution, optional |
|
|
|
+
|
|
|
If the required package is not in the official repository [xmake-repo](https://github.com/xmake-io/xmake-repo), we can submit the contribution code to the repository for support.
|
|
|
But if some packages are only for personal or private projects, we can create a private repository repo. The repository organization structure can be found at: [xmake-repo](https://github.com/xmake-io/xmake-repo)
|
|
|
|
|
|
@@ -698,6 +876,18 @@ However, this parameter setting is only supported by v2.5.7 and above.
|
|
|
|
|
|
### Set the default compilation platform
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+set_defaultplat(platform: <string>)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| platform | Default compilation platform name, e.g. "iphoneos", "windows" |
|
|
|
+
|
|
|
Only supported by v2.5.6 and above, it is used to set the default compilation platform of the project. If it is not set, the default platform follows the current system platform, which is os.host().
|
|
|
|
|
|
For example, the default compilation platform on macOS is macosx, if the current project is an ios project, you can set the default compilation platform to iphoneos.
|
|
|
@@ -712,6 +902,19 @@ It is equivalent to `xmake f -p iphoneos`.
|
|
|
|
|
|
### Set the default compilation architecture
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+set_defaultarchs(archs: <string|array>, ...)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| archs | Default compilation architecture string or array, supports platform-specific format like "iphoneos|arm64" |
|
|
|
+| ... | Variable parameters, can pass multiple architecture specifications |
|
|
|
+
|
|
|
Only supported by v2.5.6 and above, it is used to set the default compilation architecture of the project. If it is not set, the default platform follows the current system architecture, which is os.arch().
|
|
|
|
|
|
```lua
|
|
|
@@ -733,6 +936,18 @@ The arm64 architecture is compiled by default on iphoneos, and the x64 architect
|
|
|
|
|
|
### Set the default compilation mode
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+set_defaultmode(mode: <string>)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| mode | Default compilation mode name, e.g. "release", "debug", "releasedbg" |
|
|
|
+
|
|
|
Only supported by v2.5.6 and above, it is used to set the default compilation mode of the project. If it is not set, the default is to compile in release mode.
|
|
|
|
|
|
```lua
|
|
|
@@ -745,6 +960,19 @@ It is equivalent to `xmake f -m releasedbg`.
|
|
|
|
|
|
### Set the list of platforms allowed to compile
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+set_allowedplats(platforms: <string|array>, ...)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| platforms | Allowed compilation platform name string or array |
|
|
|
+| ... | Variable parameters, can pass multiple platform names |
|
|
|
+
|
|
|
It is only supported by v2.5.6 and above. It is used to set the list of compilation platforms supported by the project. If the user specifies other platforms, an error will be prompted. This is usually used to restrict the user from specifying the wrong invalid platform.
|
|
|
|
|
|
If it is not set, then there are no platform restrictions.
|
|
|
@@ -759,6 +987,19 @@ Set the current project to only support windows and mingw platforms.
|
|
|
|
|
|
### Set the platform architecture that allows compilation
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+set_allowedarchs(archs: <string|array>, ...)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| archs | Allowed compilation architecture string or array, supports platform-specific format like "windows|x64" |
|
|
|
+| ... | Variable parameters, can pass multiple architecture specifications |
|
|
|
+
|
|
|
Only supported by v2.5.6 and above. It is used to set the list of compiled architectures supported by the project. If the user specifies other architectures, an error will be prompted. This is usually used to restrict users from specifying incorrect invalid architectures.
|
|
|
|
|
|
If it is not set, then there are no architectural restrictions.
|
|
|
@@ -781,6 +1022,19 @@ Set the current project to only support x64 architecture on windows, and only su
|
|
|
|
|
|
### Set the list of allowed compilation modes
|
|
|
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+set_allowedmodes(modes: <string|array>, ...)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| modes | Allowed compilation mode name string or array |
|
|
|
+| ... | Variable parameters, can pass multiple mode names |
|
|
|
+
|
|
|
It is only supported by v2.5.6 and above. It is used to set the list of compilation modes supported by the project. If the user specifies other modes, an error will be prompted. This is usually used to restrict the user from specifying incorrect invalid modes.
|
|
|
|
|
|
If it is not set, then there is no mode restriction.
|
|
|
@@ -793,6 +1047,21 @@ Set the current project to only support the two compilation modes release/releas
|
|
|
|
|
|
## namespace
|
|
|
|
|
|
+### Enter namespace
|
|
|
+
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+namespace(name: <string>, script: <function>)
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| name | Namespace name string |
|
|
|
+| script | Namespace script function |
|
|
|
+
|
|
|
Enter the namespace, which is supported by xmake 2.9.8. It can be used to isolate various domain name conflicts such as duplicate target and option in sub-projects.
|
|
|
|
|
|
### Isolate target
|
|
|
@@ -1090,6 +1359,20 @@ end)
|
|
|
|
|
|
## namespace_end
|
|
|
|
|
|
+### End namespace
|
|
|
+
|
|
|
+#### Function Prototype
|
|
|
+
|
|
|
+```lua
|
|
|
+namespace_end()
|
|
|
+```
|
|
|
+
|
|
|
+#### Parameter Description
|
|
|
+
|
|
|
+| Parameter | Description |
|
|
|
+|-----------|-------------|
|
|
|
+| (none) | No parameters required |
|
|
|
+
|
|
|
End the current namespace.
|
|
|
|
|
|
```lua
|