add_moduledirs

edit

add_packagedirs

edit

add_platformdirs

edit

add_plugindirs

edit

add_repositories

edit

add_requireconfs

edit

add_requires

edit

format

string format(string formatstr[, ...])

Formatting a string

If you just want to format the string and don't output it, you can use this interface. This interface is equivalent to the string.format interface, just a simplified version of the interface name.

local s = format("hello %s", xmake)

See also

string.format, vformat

edit

get_config

edit

getenv

edit

has_config

edit

has_package

edit

includes

edit

ipairs

for traversing arrays

This is lua's native built-in api. In xmake, it has been extended in its original behavior to simplify some of the daily lua traversal code.

First look at the default native notation:

for idx, val in ipairs({"a", "b", "c", "d", "e", "f"}) do
     print("%d %s", idx, val)
end

The extension is written like the pairs interface, for example:

for idx, val in ipairs({"a", "b", "c", "d", "e", "f"}, function (v) return v:upper() end) do
     print("%d %s", idx, val)
end

for idx, val in ipairs({"a", "b", "c", "d", "e", "f"}, function (v, a, b) return v:upper() .. a .. b end, "a", "b") do
     print("%d %s", idx, val)
end

This simplifies the logic of the for block code. For example, if I want to traverse the specified directory and get the file name, but not including the path, I can simplify the writing by this extension:

for _, filename in ipairs(os.dirs("*"), path.filename) do
    -- ...
end

See also

pairs

edit

is_config

edit

is_cross

edit

is_kind

edit

pairs

Used to traverse the dictionary

This is lua's native built-in api. In xmake, it has been extended in its original behavior to simplify some of the daily lua traversal code.

First look at the default native notation:

local t = {a = "a", b = "b", c = "c", d = "d", e = "e", f = "f"}

for key, val in pairs(t) do
    print("%s: %s", key, val)
end

This is sufficient for normal traversal operations, but if we get the uppercase for each of the elements it traverses, we can write:

for key, val in pairs(t, function (v) return v:upper() end) do
     print("%s: %s", key, val)
end

Even pass in some parameters to the second function, for example:

for key, val in pairs(t, function (v, a, b) return v:upper() .. a .. b end, "a", "b") do
     print("%s: %s", key, val)
end

See also

ipairs

edit

print

Wrapping print terminal log

This interface is also the native interface of lua. xmake is also extended based on the original behavior, and supports: formatted output, multivariable output.

First look at the way native support:

print("hello xmake!")
print("hello", "xmake!", 123)

And also supports extended formatting:

print("hello %s!", "xmake")
print("hello xmake! %d", 123)

Xmake will support both types of writing at the same time, and the internal will automatically detect and select the output behavior.

See also

printf, vprint, cprint, dprint

edit

printf

No line printing terminal log

Like the print interface, the only difference is that it doesn't wrap.

See also

print, vprintf

edit

set_allowedarchs

edit

set_allowedmodes

edit

set_allowedplats

edit

set_config

edit

set_defaultarchs

edit

set_defaultmode

edit

set_defaultplat

edit

set_description

edit

set_project

edit

set_xmakever

edit

tonumber

edit

tostring

edit

type

edit

unpack

edit
Interfaces
add_moduledirs
add_packagedirs
add_platformdirs
add_plugindirs
add_repositories
add_requireconfs
add_requires
format
get_config
getenv
has_config
has_package
includes
ipairs
is_config
is_cross
is_kind
pairs
print
printf
set_allowedarchs
set_allowedmodes
set_allowedplats
set_config
set_defaultarchs
set_defaultmode
set_defaultplat
set_description
set_project
set_xmakever
tonumber
tostring
type
unpack