Unnamed: 0
int64 0
0
| repo_id
stringlengths 5
186
| file_path
stringlengths 15
223
| content
stringlengths 1
32.8M
⌀ |
---|---|---|---|
0 | repos/xmake/tests/apis/rules | repos/xmake/tests/apis/rules/src/test.c.in | int test(int a, int b)
{
return a + b;
}
|
0 | repos/xmake/tests/apis/rules | repos/xmake/tests/apis/rules/src/main.c | #include <stdio.h>
extern int test(int a, int b);
int main(int argc, char** argv)
{
printf("1 + 1 = %d\n", test(1, 1));
return 0;
}
|
0 | repos/xmake/tests/apis/rules | repos/xmake/tests/apis/rules/src/index.md | ## hello xmake
|
0 | repos/xmake/tests/apis/rules | repos/xmake/tests/apis/rules/src/main2.c | #include <stdio.h>
extern int test(int a, int b);
int main(int argc, char** argv)
{
printf("1 + 1 = %d\n", test(1, 1));
return 0;
}
|
0 | repos/xmake/tests/apis/rules/src | repos/xmake/tests/apis/rules/src/man/man3.in | hello [name]!
|
0 | repos/xmake/tests/apis/rules/src | repos/xmake/tests/apis/rules/src/man/man2.in | hello [name]!
|
0 | repos/xmake/tests/apis/rules/src | repos/xmake/tests/apis/rules/src/man/man1.in | hello [name]!
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/custom_scopeapis/xmake.lua | add_rules("mode.debug", "mode.release")
interp_add_scopeapis("myscope.set_name", "myscope.add_list", {kind = "values"})
interp_add_scopeapis("myscope.on_script", {kind = "script"})
myscope("hello")
set_name("foo")
add_list("value1", "value2")
on_script(function ()
print("hello")
end)
target("test")
set_kind("binary")
add_files("src/*.cpp")
on_config(function (target)
import("core.project.project")
local myscope = project.scope("myscope")
for name, scope in pairs(myscope) do
print("myscope(%s)", name)
print(" name: %s", scope:get("name"))
print(" list: %s", table.concat(scope:get("list"), ", "))
print(" script:")
local script = scope:get("script")
if script then
script()
end
end
end)
|
0 | repos/xmake/tests/apis/custom_scopeapis | repos/xmake/tests/apis/custom_scopeapis/src/main.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "hello world!" << endl;
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_allowedxxx/xmake.lua | add_rules("mode.debug", "mode.release")
set_defaultmode("releasedbg")
set_defaultplat("linux")
set_defaultarchs("macosx|arm64", "linux|i386", "armv7")
set_allowedmodes("releasedbg", "debug")
set_allowedplats("windows", "linux", "macosx")
set_allowedarchs("macosx|arm64", "macosx|x86_64", "linux|i386", "linux|x86_64")
target("test")
set_kind("binary")
add_files("src/*.cpp")
--
-- If you want to known more usage about xmake, please see https://xmake.io
--
-- ## FAQ
--
-- You can enter the project directory firstly before building project.
--
-- $ cd projectdir
--
-- 1. How to build project?
--
-- $ xmake
--
-- 2. How to configure project?
--
-- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release]
--
-- 3. Where is the build output directory?
--
-- The default output directory is `./build` and you can configure the output directory.
--
-- $ xmake f -o outputdir
-- $ xmake
--
-- 4. How to run and debug target after building project?
--
-- $ xmake run [targetname]
-- $ xmake run -d [targetname]
--
-- 5. How to install target to the system directory or other output directory?
--
-- $ xmake install
-- $ xmake install -o installdir
--
-- 6. Add some frequently-used compilation flags in xmake.lua
--
-- @code
-- -- add debug and release modes
-- add_rules("mode.debug", "mode.release")
--
-- -- add macro definition
-- add_defines("NDEBUG", "_GNU_SOURCE=1")
--
-- -- set all warnings as errors
-- set_warnings("all", "error")
--
-- -- set language: c99, c++11
-- set_languages("c99", "c++11")
--
-- -- set optimization: none, faster, fastest, smallest
-- set_optimize("fastest")
--
-- -- add include search directories
-- add_includedirs("/usr/include", "/usr/local/include")
--
-- -- add link libraries and search directories
-- add_links("tbox")
-- add_linkdirs("/usr/local/lib", "/usr/lib")
--
-- -- add system link libraries
-- add_syslinks("z", "pthread")
--
-- -- add compilation and link flags
-- add_cxflags("-stdnolib", "-fno-strict-aliasing")
-- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true})
--
-- @endcode
--
|
0 | repos/xmake/tests/apis/add_allowedxxx | repos/xmake/tests/apis/add_allowedxxx/src/main.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "hello world!" << endl;
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/rules_order/test.lua | function main()
os.exec("xmake")
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/rules_order/xmake.lua |
rule("markdown")
add_deps("man", {order = true})
set_extensions(".md", ".markdown")
before_build_file(function (target, sourcefile)
print("before_build_file: %s", sourcefile)
end)
on_build_file(function (target, sourcefile)
print("on_build_file: %s", sourcefile)
end)
after_build_file(function (target, sourcefile)
print("after_build_file: %s", sourcefile)
end)
rule("man")
set_extensions(".man")
before_build_file(function (target, sourcefile)
print("before_build_file: %s", sourcefile)
end)
on_build_file(function (target, sourcefile)
print("on_build_file: %s", sourcefile)
end)
after_build_file(function (target, sourcefile)
print("after_build_file: %s", sourcefile)
end)
target("test")
set_kind("binary")
add_rules("markdown")
add_files("src/*.c")
add_files("src/*.md")
add_files("src/*.man")
before_build_file(function (target, sourcefile)
print("target.before_build_file: %s", sourcefile)
end)
--[[
on_build_file(function (target, sourcefile)
print("target.on_build_file: %s", sourcefile)
end)]]
after_build_file(function (target, sourcefile)
print("target.after_build_file: %s", sourcefile)
end)
|
0 | repos/xmake/tests/apis/rules_order | repos/xmake/tests/apis/rules_order/src/main.c | #include <stdio.h>
int main(int argc, char** argv)
{
return 0;
}
|
0 | repos/xmake/tests/apis/rules_order | repos/xmake/tests/apis/rules_order/src/test.md | ## hello xmake
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_defines/test.lua | function main()
os.exec("xmake")
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_defines/xmake.lua | add_rules("mode.debug", "mode.release")
target("test")
set_kind("binary")
add_files("src/*.cpp")
add_defines("TEST1=\"hello\"")
add_defines("TEST2=\"hello xmake\"")
add_defines("TEST3=3")
add_cxflags("-DTEST4=\"hello\"")
add_cxflags("-DTEST5=\"hello xmake\" -DTEST6=3")
|
0 | repos/xmake/tests/apis/add_defines | repos/xmake/tests/apis/add_defines/src/main.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << TEST1 << endl;
cout << TEST2 << endl;
cout << TEST3 << endl;
cout << TEST4 << endl;
cout << TEST5 << endl;
cout << TEST6 << endl;
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/rules_inject_deps/test.lua | function main()
os.exec("xmake -j1")
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/rules_inject_deps/xmake.lua | rule("cppfront")
set_extensions(".cpp2")
on_load(function (target)
local rule = target:rule("c++.build"):clone()
rule:add("deps", "cppfront", {order = true})
target:rule_add(rule)
end)
on_build_file(function (target, sourcefile, opt)
print("build cppfront file")
local objectfile = target:objectfile(sourcefile:gsub("cpp2", "cpp"))
assert(not os.isfile(objectfile), "invalid rule order!")
end)
target("test")
set_kind("binary")
add_rules("cppfront")
add_files("src/*.cpp")
add_files("src/*.cpp2")
before_build_file(function (target, sourcefile, opt)
local objectfile = target:objectfile(sourcefile)
os.tryrm(objectfile)
end)
|
0 | repos/xmake/tests/apis/rules_inject_deps | repos/xmake/tests/apis/rules_inject_deps/src/main.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "hello world!" << endl;
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/rules_override_cxx/test.lua | function main()
os.exec("xmake")
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/rules_override_cxx/xmake.lua | rule("xx")
add_deps("c++")
on_load(function (target)
-- add .xx
local rule = target:rule("c++.build"):clone()
rule:set("extensions", ".xx")
target:rule_add(rule)
-- patch sourcebatch for .xx
local sourcebatch = target:sourcebatches()["c++.build"]
sourcebatch.sourcekind = "cxx"
sourcebatch.objectfiles = {}
sourcebatch.dependfiles = {}
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
local objectfile = target:objectfile(sourcefile)
local dependfile = target:dependfile(objectfile)
table.insert(sourcebatch.objectfiles, objectfile)
table.insert(sourcebatch.dependfiles, dependfile)
end
-- force as c++ source file
if target:is_plat("windows") then
target:add("cxxflags", "/TP")
else
target:add("cxxflags", "-x c++")
end
end)
target("test")
set_kind("binary")
add_rules("xx")
add_files("src/*.xx", "src/*.cc")
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/xxx_script/test.lua | function main()
os.exec("xmake f -c")
os.exec("xmake")
if os.host() == "macosx" then
os.exec("xmake f -p iphoneos")
os.exec("xmake")
os.exec("xmake f -p iphoneos -a arm64")
os.exec("xmake")
end
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/xxx_script/xmake.lua | target("test")
before_build("iphoneos|arm64", "macosx", function (target)
assert(target:is_plat("macosx") or (target:is_plat("iphoneos") and target:is_arch("arm64")))
end)
before_build(function (target)
print("before_build")
end)
on_build("macosx|native", function (target)
print("build macosx:native")
end)
on_build(function (target)
print("build")
end)
after_build(function (target)
print("after_build")
end)
after_build("!macosx", function (target)
print("after_build !macosx")
end)
after_build("!linux", function (target)
print("after_build !linux")
end)
after_build("!iphoneos", function (target)
print("after_build !iphoneos")
end)
after_build("linux|*", function (target)
assert(target:is_plat("linux"))
end)
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/clone_target/test.lua | function main()
os.exec("xmake -vD")
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/clone_target/xmake.lua | target("test")
set_kind("binary")
add_files("src/*.cpp")
add_defines("TEST")
after_load(function (target)
import("core.project.project")
local t = target:clone()
t:name_set("test2")
t:add("deps", "test")
t:add("defines", "TEST2")
t:set("link_before", function (target)
print("link1", target:name())
assert(target:dep("test"):data("linked"))
end)
project.target_add(t)
end)
before_link(function (target)
print("link2", target:name())
target:data_set("linked", true)
end)
|
0 | repos/xmake/tests/apis/clone_target | repos/xmake/tests/apis/clone_target/src/main.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "hello world!" << endl;
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_xxx/test.lua | function main()
os.exec("xmake")
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_xxx/xmake.lua | add_defines("TEST1")
target("test")
add_defines("TEST2")
on_build(function (target)
local defines = table.concat(target:get("defines"), " ")
assert(defines:find("TEST1", 1, true))
assert(defines:find("TEST2", 1, true))
end)
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_deps/test.lua | function main()
os.exec("xmake")
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_deps/xmake.lua |
target("dep1")
set_kind("static")
add_files("src/*.c")
add_cflags("-DFLAG1")
add_cflags("-DFLAG2", {interface = true})
add_includedirs("inc1", {public = true})
add_defines("TEST1", {public = true})
target("dep2")
set_kind("shared")
add_deps("dep1")
add_files("src/*.c")
add_includedirs("inc2", {interface = true})
add_defines("TEST2", {interface = true})
on_load(function (target)
print(target:extraconf("includedirs"))
print(target:extraconf("defines", "TEST2"))
print(target:extraconf("defines", "TEST2", "interface"))
print(target:get("files"))
print(target:get("files", {private = true}))
print(target:get("files", {public = true}))
print(target:get("files", {interface = true}))
print(target:get("defines"))
print(target:get("defines", {private = true}))
print(target:get("defines", {public = true}))
print(target:get("defines", {interface = true}))
end)
target("dep3")
set_kind("static")
add_files("src/*.c")
add_includedirs("inc3")
target("dep4")
set_kind("static")
add_files("src/*.c")
add_includedirs("inc4", {public = true})
add_defines("TEST4", {public = true})
target("demo")
set_kind("binary")
add_deps("dep2", "dep3")
add_deps("dep4", {inherit = false})
add_files("src/*.c")
|
0 | repos/xmake/tests/apis/add_deps | repos/xmake/tests/apis/add_deps/src/main.c | #include <stdio.h>
int main(int argc, char** argv)
{
printf("hello world!\n");
return 0;
}
|
0 | repos/xmake/tests/apis/add_deps | repos/xmake/tests/apis/add_deps/src/interface.c | #include "interface.h"
int add(int a, int b)
{
return a + b;
}
|
0 | repos/xmake/tests/apis/add_deps | repos/xmake/tests/apis/add_deps/src/interface.h | #ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32)
# define __export __declspec(dllexport)
#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
# define __export __attribute__((visibility("default")))
#else
# define __export
#endif
/*! calculate add(a, b)
*
* @param a the first argument
* @param b the second argument
*
* @return the result
*/
__export int add(int a, int b);
#ifdef __cplusplus
}
#endif
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/target_get_from/xmake.lua | add_rules("mode.debug", "mode.release")
add_requires("zlib")
option("bar")
set_default(true)
add_defines("BAR")
target("foo")
set_kind("static")
add_files("src/foo.cpp")
add_defines("foo")
add_defines("FOO", {public = true})
add_options("bar")
add_linkgroups("m", "pthread", {group = true})
target("test")
set_kind("binary")
add_deps("foo")
add_files("src/main.cpp")
add_defines("TEST")
add_packages("zlib")
on_config(function (target)
print("self", target:get_from("defines", "self"))
print("dep::foo", target:get_from("defines", "dep::foo"))
print("dep::*", target:get_from("defines", "dep::*"))
print("dep::foo/option::bar", target:get_from("defines", "dep::foo/option::bar"))
print("dep::foo/option::*", target:get_from("defines", "dep::foo/option::*"))
print("*", target:get_from("defines", "*"))
print("package::zlib", target:get_from("links", "package::zlib"))
print("extraconf(dep::foo)", target:extraconf_from("linkgroups", "dep::foo"))
end)
|
0 | repos/xmake/tests/apis/target_get_from | repos/xmake/tests/apis/target_get_from/src/foo.h | #ifdef __cplusplus
extern "C" {
#endif
int add(int a, int b);
#ifdef __cplusplus
}
#endif
|
0 | repos/xmake/tests/apis/target_get_from | repos/xmake/tests/apis/target_get_from/src/foo.cpp | #include "foo.h"
int add(int a, int b) {
return a + b;
}
|
0 | repos/xmake/tests/apis/target_get_from | repos/xmake/tests/apis/target_get_from/src/main.cpp | #include "foo.h"
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout << "add(1, 2) = " << add(1, 2) << endl;
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_configfiles/test.c.in | int test()
{
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_configfiles/main.c | #include <stdio.h>
#include <stdlib.h>
#include "config.h"
int main(int argc, char** argv)
{
printf("hello %s\n", HELLO);
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_configfiles/config2.h.in | #define HAVE_@module@_H
#define HELLO2 "@hello@ @ARCH@ @PLAT@"
@define FOO_ENABLE@
@define FOO_ENABLE2@
@define FOO_STRING@
@define FOO2_ENABLE@
@define FOO2_ENABLE2@
@define FOO2_STRING@
#define DEFAULT_TEST @default default_test 0@
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_configfiles/config.h.in | #define HAVE_${module}_H
#define HELLO "${hello} ${ARCH} ${PLAT}"
${define FOO_ENABLE}
${define FOO_ENABLE2}
${define FOO_STRING}
${define FOO_DEFINE}
${define FOO2_ENABLE}
${define FOO2_ENABLE2}
${define FOO2_STRING}
#define HAVE_SSE2 ${default HAVE_SSE2 0}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_configfiles/test.lua | function main()
os.exec("xmake")
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_configfiles/main2.c | #include <stdio.h>
#include <stdlib.h>
#include "config2.h"
int main(int argc, char** argv)
{
printf("hello2 %s\n", HELLO2);
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_configfiles/xmake.lua |
option("foo")
set_default("foo")
set_description("The Foo Info")
option_end()
if has_config("foo") then
set_configvar("FOO_ENABLE", 1)
set_configvar("FOO_ENABLE2", false)
set_configvar("FOO_STRING", get_config("foo"))
set_configvar("FOO_DEFINE", get_config("foo"), {quote = false})
end
option("foo2")
set_default(true)
set_description("Enable Foo2")
set_configvar("FOO2_ENABLE", true)
set_configvar("FOO2_STRING", "foo")
option_end()
target("test")
set_kind("binary")
add_files("main.c")
set_configvar("module", "test")
set_configdir("$(buildir)/config")
add_configfiles("test.c.in", {filename = "mytest.c"})
add_configfiles("config.h.in", {variables = {hello = "xmake"}, prefixdir = "header"})
add_configfiles("*.man", {onlycopy = true, prefixdir = "man"})
add_includedirs("$(buildir)/config/header")
target("test2")
set_kind("binary")
add_files("main2.c")
set_configvar("module", "test2")
set_configdir("$(buildir)/config2")
add_configfiles("test.c.in", {filename = "mytest.c"})
add_configfiles("config2.h.in", {variables = {hello = "xmake2"}, pattern = "@([^\n]-)@", prefixdir = "header"})
add_configfiles("*.man", {onlycopy = true, prefixdir = "man"})
add_includedirs("$(buildir)/config2/header")
add_options("foo2")
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/check_xxx/main.c | int main(int argc, char** argv)
{
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/check_xxx/config.h.in | ${define HAS_STRING_H}
${define HAS_STRING_AND_STDIO_H}
${define HAS_WCHAR_AND_FLOAT}
${define HAS_PTHREAD}
${define HAS_STATIC_ASSERT}
${define HAS_SETJMP}
${define HAS_CONSTEXPR}
${define HAS_CONSEXPR_AND_STATIC_ASSERT}
${define HAS_SSE2}
${define HAS_LONG_8}
${define HAS_CXX_STD_98}
${define HAS_CXX_STD_11}
${define HAS_CXX_STD_14}
${define HAS_CXX_STD_17}
${define HAS_CXX_STD_20}
${define HAS_C_STD_89}
${define HAS_C_STD_99}
${define HAS_C_STD_11}
${define HAS_C_STD_17}
${define HAS_GCC}
${define HAS_CXX20}
${define IS_BIG_ENDIAN}
${define NO_GCC}
${define PTR_SIZE}
${define HAVE_VISIBILITY}
${define CUSTOM_ASSERT}
#define HAS_WCHAR ${default HAS_WCHAR 0}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/check_xxx/test.lua | function main()
os.exec("xmake")
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/check_xxx/foo.c | #include "config.h"
int foo()
{
return 0;
}
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/check_xxx/xmake.lua | includes("@builtin/check")
target("foo")
set_kind("static")
add_files("foo.c")
add_includedirs("$(buildir)")
add_configfiles("config.h.in")
check_bigendian("IS_BIG_ENDIAN")
check_ctypes("HAS_WCHAR", "wchar_t")
check_cincludes("HAS_STRING_H", "string.h")
check_csnippets("HAS_INT_4", "return (sizeof(int) == 4)? 0 : -1;", {tryrun = true})
check_csnippets("HAS_INT_4_IN_MAIN", [[
int test() {
return (sizeof(int) == 4)? 0 : -1;
}
int main(int argc, char** argv)
{
return test();
}]], {tryrun = true})
check_csnippets("INT_SIZE", 'printf("%d", sizeof(int)); return 0;', {output = true, number = true})
check_sizeof("LONG_SIZE", "long")
check_sizeof("STRING_SIZE", "std::string", {includes = "string"})
configvar_check_bigendian("IS_BIG_ENDIAN")
configvar_check_cincludes("HAS_STRING_AND_STDIO_H", {"string.h", "stdio.h"})
configvar_check_ctypes("HAS_WCHAR_AND_FLOAT", {"wchar_t", "float"})
configvar_check_links("HAS_PTHREAD", {"pthread", "m", "dl"})
configvar_check_csnippets("HAS_STATIC_ASSERT", "_Static_assert(1, \"\");")
configvar_check_cfuncs("HAS_SETJMP", "setjmp", {includes = {"signal.h", "setjmp.h"}})
configvar_check_features("HAS_CONSTEXPR", "cxx_constexpr", {languages = "c++11"})
configvar_check_features("HAS_CONSEXPR_AND_STATIC_ASSERT", {"cxx_constexpr", "c_static_assert"}, {languages = "c++11"})
configvar_check_features("HAS_CXX_STD_98", "cxx_std_98")
configvar_check_features("HAS_CXX_STD_11", "cxx_std_11", {languages = "c++11"})
configvar_check_features("HAS_CXX_STD_14", "cxx_std_14", {languages = "c++14"})
configvar_check_features("HAS_CXX_STD_17", "cxx_std_17", {languages = "c++17"})
configvar_check_features("HAS_CXX_STD_20", "cxx_std_20", {languages = "c++20"})
configvar_check_features("HAS_C_STD_89", "c_std_89")
configvar_check_features("HAS_C_STD_99", "c_std_99")
configvar_check_features("HAS_C_STD_11", "c_std_11", {languages = "c11"})
configvar_check_features("HAS_C_STD_17", "c_std_17", {languages = "c17"})
configvar_check_cflags("HAS_SSE2", "-msse2")
configvar_check_csnippets("HAS_LONG_8", "return (sizeof(long) == 8)? 0 : -1;", {tryrun = true})
configvar_check_csnippets("PTR_SIZE", 'printf("%d", sizeof(void*)); return 0;', {output = true, number = true})
configvar_check_csnippets("HAVE_VISIBILITY", 'extern __attribute__((__visibility__("hidden"))) int hiddenvar;', {default = 0})
configvar_check_csnippets("CUSTOM_ASSERT=assert", 'assert(1);', {default = "", quote = false})
configvar_check_macros("HAS_GCC", "__GNUC__")
configvar_check_macros("NO_GCC", "__GNUC__", {defined = false})
configvar_check_macros("HAS_CXX20", "__cplusplus >= 202002L", {languages = "c++20"})
local features_cxx17 = {
"cxx_aggregate_bases",
"cxx_aligned_new",
"cxx_capture_star_this",
"cxx_constexpr",
"cxx_deduction_guides",
"cxx_enumerator_attributes",
"cxx_fold_expressions",
"cxx_guaranteed_copy_elision",
"cxx_hex_float",
"cxx_if_constexpr",
"cxx_inheriting_constructors",
"cxx_inline_variables",
"cxx_namespace_attributes",
"cxx_noexcept_function_type",
"cxx_nontype_template_args",
"cxx_nontype_template_parameter_auto",
"cxx_range_based_for",
"cxx_static_assert",
"cxx_structured_bindings",
"cxx_template_template_args",
"cxx_variadic_using"}
for _, feature in ipairs(features_cxx17) do
check_features("HAS_17_" .. feature:upper(), feature, {languages = "c++17"})
end
local features_cxx20 = {
"cxx_aggregate_paren_init",
"cxx_char8_t",
"cxx_concepts",
"cxx_conditional_explicit",
"cxx_consteval",
"cxx_constexpr",
"cxx_constexpr_dynamic_alloc",
"cxx_constexpr_in_decltype",
"cxx_constinit",
"cxx_deduction_guides",
"cxx_designated_initializers",
"cxx_generic_lambdas",
"cxx_impl_coroutine",
"cxx_impl_destroying_delete",
"cxx_impl_three_way_comparison",
"cxx_init_captures",
"cxx_modules",
"cxx_nontype_template_args",
"cxx_using_enum"}
for _, feature in ipairs(features_cxx20) do
check_features("HAS_20_" .. feature:upper(), feature, {languages = "c++20"})
end
target("test")
add_deps("foo")
set_kind("binary")
add_files("main.c")
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_imports/test.lua | function main()
os.exec("xmake")
end
|
0 | repos/xmake/tests/apis | repos/xmake/tests/apis/add_imports/xmake.lua | target("test")
add_imports("core.base.option", "core.base.task")
before_build(function (target)
assert(option)
assert(task)
end)
on_build(function (target)
assert(option)
assert(task)
end)
after_build(function (target)
assert(option)
assert(task)
end)
|
0 | repos/xmake/tests/actions | repos/xmake/tests/actions/install/test.lua | function main(t)
if is_host("windows", "linux", "macosx") and os.arch():startswith("x") then
os.vrun("xmake -y")
os.vrun("xmake run app")
os.vrun("xmake install -o build/usr")
if not is_host("linux") then -- TODO, change rpath has been not supported yet on linux.
os.vrun("./build/usr/app/bin/app" .. (is_host("windows") and ".exe" or ""))
end
end
end
|
0 | repos/xmake/tests/actions | repos/xmake/tests/actions/install/xmake.lua | add_rules("mode.debug", "mode.release")
set_version("1.0.1", {soname = true})
add_requires("libzip", {system = false, configs = {shared = true}})
target("foo")
set_kind("shared")
add_files("src/foo.cpp")
add_packages("libzip", {public = true})
add_headerfiles("src/foo.h", {public = true})
add_installfiles("src/foo.txt", {prefixdir = "assets", public = true})
set_prefixdir("/", {libdir = "foo_lib"})
target("app")
set_kind("binary")
add_deps("foo")
add_files("src/main.cpp")
set_prefixdir("app", {libdir = "app_lib"})
add_rpathdirs("@loader_path/../app_lib", {installonly = true})
includes("@builtin/xpack")
xpack("test")
add_targets("app")
set_formats("zip")
|
0 | repos/xmake/tests/actions/install | repos/xmake/tests/actions/install/src/foo.h | #ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32)
# define __export __declspec(dllexport)
#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
# define __export __attribute__((visibility("default")))
#else
# define __export
#endif
__export int add(int a, int b);
#ifdef __cplusplus
}
#endif
|
0 | repos/xmake/tests/actions/install | repos/xmake/tests/actions/install/src/foo.cpp | #include "foo.h"
int add(int a, int b) {
return a + b;
}
|
0 | repos/xmake/tests/actions/install | repos/xmake/tests/actions/install/src/main.cpp | #include "foo.h"
#include <iostream>
int main(int argc, char** argv) {
std::cout << "add(1, 2) = " << add(1, 2) << std::endl;
return 0;
}
|
0 | repos/xmake/tests/actions | repos/xmake/tests/actions/config/test.lua |
function test_workdir(t)
os.tryrm("test")
os.tryrm("build")
os.tryrm("build2")
os.tryrm(".xmake")
os.exec("xmake create test")
os.exec("xmake config -P test")
os.exec("xmake")
t:require(os.isdir("build"))
t:require(os.isdir(".xmake"))
t:require_not(os.isdir("test/build"))
t:require_not(os.isdir("test/.xmake"))
os.exec("xmake config -o build2")
os.exec("xmake")
t:require(os.isdir("build2"))
os.tryrm("build")
os.tryrm("build2")
os.tryrm(".xmake")
os.cd("test")
os.exec("xmake create -P subtest")
os.cd("subtest")
os.exec("xmake config -P .")
os.exec("xmake")
t:require(os.isdir("build"))
t:require(os.isdir(".xmake"))
t:require_not(os.isdir("../build"))
t:require_not(os.isdir("../.xmake"))
t:require_not(os.isdir("../../build"))
t:require_not(os.isdir("../../.xmake"))
end
|
0 | repos/xmake/tests/actions/package | repos/xmake/tests/actions/package/localpkg/test.lua | function main(t)
if (os.subarch():startswith("x") or os.subarch() == "i386") and not is_host("bsd") then
os.cd("libfoo")
os.exec("xmake package -D -o ../bar/build")
os.cd("../bar")
os.exec("xmake f -c -D")
os.exec("xmake -D")
os.exec("xmake run")
end
end
|
0 | repos/xmake/tests/actions/package/localpkg | repos/xmake/tests/actions/package/localpkg/bar/xmake.lua | add_rules("mode.debug", "mode.release")
add_repositories("local-repo build")
add_requires("foo")
target("bar")
set_kind("binary")
add_files("src/*.cpp")
add_packages("foo")
|
0 | repos/xmake/tests/actions/package/localpkg/bar | repos/xmake/tests/actions/package/localpkg/bar/src/main.cpp | #include "foo.h"
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "foo(1, 2) = " << foo(1, 2) << endl;
return 0;
}
|
0 | repos/xmake/tests/actions/package/localpkg | repos/xmake/tests/actions/package/localpkg/libfoo/xmake.lua | add_rules("mode.debug", "mode.release")
set_license("Apache-2.0")
target("sub")
set_kind("static")
add_files("src/sub.cpp")
add_headerfiles("src/sub.h")
target("add")
set_kind("static")
add_files("src/add.cpp")
add_headerfiles("src/add.h")
target("foo")
add_deps("add", "sub")
set_kind("static")
add_files("src/foo.cpp")
add_headerfiles("src/foo.h")
|
0 | repos/xmake/tests/actions/package/localpkg/libfoo | repos/xmake/tests/actions/package/localpkg/libfoo/src/foo.h | #ifdef __cplusplus
extern "C" {
#endif
/*! calculate foo(a, b)
*
* @param a the first argument
* @param b the second argument
*
* @return the result
*/
int foo(int a, int b);
#ifdef __cplusplus
}
#endif
|
0 | repos/xmake/tests/actions/package/localpkg/libfoo | repos/xmake/tests/actions/package/localpkg/libfoo/src/sub.h | #ifdef __cplusplus
extern "C" {
#endif
/*! calculate sub(a, b)
*
* @param a the first argument
* @param b the second argument
*
* @return the result
*/
int sub(int a, int b);
#ifdef __cplusplus
}
#endif
|
0 | repos/xmake/tests/actions/package/localpkg/libfoo | repos/xmake/tests/actions/package/localpkg/libfoo/src/foo.cpp | #include "add.h"
#include "sub.h"
#include "foo.h"
int foo(int a, int b)
{
return add(sub(a, b), sub(b, a));
}
|
0 | repos/xmake/tests/actions/package/localpkg/libfoo | repos/xmake/tests/actions/package/localpkg/libfoo/src/add.cpp | #include "add.h"
int add(int a, int b)
{
return a + b;
}
|
0 | repos/xmake/tests/actions/package/localpkg/libfoo | repos/xmake/tests/actions/package/localpkg/libfoo/src/add.h | #ifdef __cplusplus
extern "C" {
#endif
/*! calculate add(a, b)
*
* @param a the first argument
* @param b the second argument
*
* @return the result
*/
int add(int a, int b);
#ifdef __cplusplus
}
#endif
|
0 | repos/xmake/tests/actions/package/localpkg/libfoo | repos/xmake/tests/actions/package/localpkg/libfoo/src/sub.cpp | #include "sub.h"
int sub(int a, int b)
{
return a - b;
}
|
0 | repos/xmake/tests/actions | repos/xmake/tests/actions/test/test.lua | function main(t)
os.exec("xmake test")
end
|
0 | repos/xmake/tests/actions | repos/xmake/tests/actions/test/xmake.lua | add_rules("mode.debug", "mode.release")
set_policy("test.return_zero_on_failure", true)
for _, file in ipairs(os.files("src/test_*.cpp")) do
local name = path.basename(file)
target(name)
set_kind("binary")
set_default(false)
add_files("src/" .. name .. ".cpp")
add_tests("default")
add_tests("args", {runargs = {"foo", "bar"}})
add_tests("pass_output", {trim_output = true, runargs = "foo", pass_outputs = "hello foo"})
add_tests("fail_output", {fail_outputs = {"hello2 .*", "hello xmake"}})
end
target("test_10")
set_kind("binary")
set_default(false)
add_files("src/compile_1.cpp")
add_tests("compile_fail", {build_should_fail = true})
target("test_11")
set_kind("binary")
set_default(false)
add_files("src/compile_2.cpp")
add_tests("compile_pass", {build_should_pass = true})
target("test_13")
set_kind("binary")
set_default(false)
add_files("src/test_1.cpp")
add_tests("stub_1", {files = "tests/stub_1.cpp", defines = "STUB_1"})
target("test_14")
set_kind("binary")
set_default(false)
add_files("src/test_2.cpp")
add_tests("stub_2", {files = "tests/stub_2.cpp", defines = "STUB_2"})
target("test_15")
set_kind("binary")
set_default(false)
add_files("src/test_1.cpp")
add_tests("stub_n", {files = "tests/stub_n*.cpp", defines = "STUB_N"})
target("test_timeout")
set_kind("binary")
set_default(false)
add_files("src/run_timeout.cpp")
add_tests("run_timeout", {run_timeout = 1000})
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/tests/stub_n2.cpp | #ifndef STUB_N
#error
#endif
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/tests/stub_n1.cpp | #ifndef STUB_N
#error
#endif
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/tests/stub_2.cpp | #ifndef STUB_2
#error
#endif
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/tests/stub_1.cpp | #ifndef STUB_1
#error
#endif
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/run_timeout.cpp | #ifdef _MSC_VER
# include <windows.h>
#else
# include <unistd.h>
#endif
int main(int argc, char** argv) {
#ifdef _MSC_VER
Sleep(10 * 1000);
#else
usleep(10 * 100 * 1000);
#endif
return 0;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/test_5.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
char const* arg = argc > 1? argv[1] : "xmake";
cout << "hello2 " << arg << endl;
return 0;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/test_2.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
char const* arg = argc > 1? argv[1] : "xmake";
cout << "hello " << arg << endl;
return 0;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/test_9.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
char const* arg = argc > 1? argv[1] : "xmake";
cout << "hello " << arg << endl;
return 0;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/compile_2.cpp | #include <stdio.h>
int main(int argc, char** argv) {
static_assert(0, "error");
return 0;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/test_7.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
char const* arg = argc > 1? argv[1] : "xmake";
cout << "hello " << arg << endl;
return -1;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/test_8.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout << "hello xmake" << endl;
return 0;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/test_4.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
char const* arg = argc > 1? argv[1] : "xmake";
cout << "hello " << arg << endl;
return 0;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/test_3.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
char const* arg = argc > 1? argv[1] : "xmake";
cout << "hello " << arg << endl;
return 0;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/test_1.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
char const* arg = argc > 1? argv[1] : "xmake";
cout << "hello " << arg << endl;
return 0;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/test_6.cpp | #include <iostream>
using namespace std;
int main(int argc, char** argv)
{
char const* arg = argc > 1? argv[1] : "xmake";
cout << "hello " << arg << endl;
return 0;
}
|
0 | repos/xmake/tests/actions/test | repos/xmake/tests/actions/test/src/compile_1.cpp | #include <stdio.h>
int main(int argc, char** argv) {
static_assert(0, "error");
return 0;
}
|
0 | repos/xmake/tests | repos/xmake/tests/test/test.lua | function test_are_same(t)
t:are_same(1, 1)
t:are_same("1", "1")
t:are_same(nil, nil)
t:are_same(true, true)
t:are_same(1.34, 1.34)
t:are_same(test_are_same, test_are_same)
t:are_not_same({}, {})
t:are_not_same(1, "1")
end
function test_are_equal(t)
t:are_equal(1, 1)
t:are_equal("1", "1")
t:are_equal(nil, nil)
t:are_equal(true, true)
t:are_equal(1.34, 1.34)
t:are_equal(test_are_same, test_are_same)
t:are_equal({}, {})
t:are_equal({ a = 1 }, { a = 1 })
t:are_equal({ a = { a= 1}}, { a = {a=1} })
t:are_not_equal(1, "1")
t:are_not_equal({ a = 1 }, { a = 1, b = 2 })
t:are_not_equal({ a = 1, c = 3 }, { a = 1, b = 2 })
t:are_not_equal({ a = 1}, { a = 1, b = 2 })
t:are_not_equal({ a = { a= 1}}, { a = {a=2} })
end
function test_require(t)
t:require(true)
t:require({})
t:require(0)
t:require("")
t:require_not(false)
t:require_not(nil)
end
function test_will_raise(t)
t:will_raise(function ()
raise("error: xxx")
end, "error")
t:will_raise(function ()
raise(" ")
end, "%s")
t:will_raise(function ()
raise("")
end)
t:will_raise(function ()
print("A test failed message will be printed")
t:will_raise(function() end)
end, "aborting because of ${red}failed assertion${reset}")
end
|
0 | repos/xmake/tests | repos/xmake/tests/cli/test.lua | import("core.base.cli")
function test_args(t)
local parsed = cli.parse("abc def")
t:are_equal(#parsed, 2)
t:are_equal(parsed[1].type, "arg")
t:are_equal(parsed[1].value, "abc")
t:are_equal(parsed[2].type, "arg")
t:are_equal(parsed[2].value, "def")
end
function test_args_escaped(t)
local parsed = cli.parse([[a\\bc "def \"g"]])
t:are_equal(#parsed, 2)
t:are_equal(parsed[1].type, "arg")
t:are_equal(parsed[1].value, "a\\bc")
t:are_equal(parsed[2].type, "arg")
t:are_equal(parsed[2].value, "def \"g")
end
function test_long(t)
local parsed = cli.parse([[--long-flag --long-option="1 3" --long-option:=2 args]])
t:are_equal(#parsed, 4)
t:are_equal(parsed[1].type, "flag")
t:are_equal(parsed[1].key, "long-flag")
t:are_equal(parsed[2].type, "option")
t:are_equal(parsed[2].key, "long-option")
t:are_equal(parsed[2].value, "1 3")
t:are_equal(parsed[3].type, "option")
t:are_equal(parsed[3].key, "long-option")
t:are_equal(parsed[3].value, "=2")
end
function test_raw(t)
local parsed = cli.parse([[--long-flag -- --long-option="1 3" --long-option:=2 args -rx]])
t:are_equal(#parsed, 6)
t:are_equal(parsed[1].type, "flag")
t:are_equal(parsed[1].key, "long-flag")
t:are_equal(parsed[2].type, "sep")
t:are_equal(parsed[3].type, "arg")
t:are_equal(parsed[3].value, "--long-option=1 3")
t:are_equal(parsed[4].type, "arg")
t:are_equal(parsed[4].value, "--long-option:=2")
t:are_equal(parsed[5].type, "arg")
t:are_equal(parsed[5].value, "args")
t:are_equal(parsed[6].type, "arg")
t:are_equal(parsed[6].value, "-rx")
end
function test_short1(t)
local parsed = cli.parse([[-rx args -args]], {})
t:are_equal(#parsed, 3)
t:are_equal(parsed[1].type, "option")
t:are_equal(parsed[1].key, "r")
t:are_equal(parsed[1].value, "x")
t:are_equal(parsed[3].type, "arg")
t:are_equal(parsed[3].value, "-args")
end
function test_short2(t)
local parsed = cli.parse([[-r x args args]], {})
t:are_equal(#parsed, 3)
t:are_equal(parsed[1].type, "option")
t:are_equal(parsed[1].key, "r")
t:are_equal(parsed[1].value, "x")
end
function test_short3(t)
local parsed = cli.parse([[-r"x d" args args]], {})
t:are_equal(#parsed, 3)
t:are_equal(parsed[1].type, "option")
t:are_equal(parsed[1].key, "r")
t:are_equal(parsed[1].value, "x d")
end
function test_short4(t)
local parsed = cli.parse([["-rx d" args args]], {})
t:are_equal(#parsed, 3)
t:are_equal(parsed[1].type, "option")
t:are_equal(parsed[1].key, "r")
t:are_equal(parsed[1].value, "x d")
end
function test_short5(t)
local parsed = cli.parse([[-r "x d" args args]], {})
t:are_equal(#parsed, 3)
t:are_equal(parsed[1].type, "option")
t:are_equal(parsed[1].key, "r")
t:are_equal(parsed[1].value, "x d")
end
function test_short_flags1(t)
local parsed = cli.parse([[-rx args args]], {"r"})
t:are_equal(#parsed, 3)
t:are_equal(parsed[1].type, "flag")
t:are_equal(parsed[1].key, "r")
t:are_equal(parsed[2].type, "option")
t:are_equal(parsed[2].key, "x")
t:are_equal(parsed[2].value, "args")
end
function test_short_flags2(t)
local parsed = cli.parse([[-r x args args]], {"r"})
t:are_equal(#parsed, 4)
t:are_equal(parsed[1].type, "flag")
t:are_equal(parsed[1].key, "r")
t:are_equal(parsed[2].type, "arg")
t:are_equal(parsed[2].value, "x")
end
function test_short_flags3(t)
local parsed = cli.parse([[-r"x d" args args]], {"r"})
t:are_equal(#parsed, 4)
t:are_equal(parsed[1].type, "flag")
t:are_equal(parsed[1].key, "r")
t:are_equal(parsed[2].type, "option")
t:are_equal(parsed[2].key, "x")
t:are_equal(parsed[2].value, " d")
end
function test_short_flags4(t)
local parsed = cli.parse([["-rx d" args args]], {"r"})
t:are_equal(#parsed, 4)
t:are_equal(parsed[1].type, "flag")
t:are_equal(parsed[1].key, "r")
t:are_equal(parsed[2].type, "option")
t:are_equal(parsed[2].key, "x")
t:are_equal(parsed[2].value, " d")
end
function test_short_flags5(t)
local parsed = cli.parse([[-r "x d" args args]], {"r"})
t:are_equal(#parsed, 4)
t:are_equal(parsed[1].type, "flag")
t:are_equal(parsed[1].key, "r")
t:are_equal(parsed[2].type, "arg")
t:are_equal(parsed[2].value, "x d")
end
|
0 | repos/xmake/tests/cli | repos/xmake/tests/cli/utils/test.lua | function test_version(t)
local output = os.iorunv("xmake", {"--version"})
local vstr = output:match("xmake v(.-),")
t:are_equal(vstr, tostring(xmake.version()))
end
function test_help(t)
import("core.base.task")
for _, taskname in ipairs(task.names()) do
os.runv("xmake", {taskname, "--help"})
end
end
|
0 | repos/xmake/tests | repos/xmake/tests/ui/dialog.lua | --!A cross-platform build utility based on Lua
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file dialog.lua
--
-- imports
import("core.ui.log")
import("core.ui.rect")
import("core.ui.view")
import("core.ui.label")
import("core.ui.event")
import("core.ui.boxdialog")
import("core.ui.textdialog")
import("core.ui.inputdialog")
import("core.ui.application")
-- the demo application
local demo = application()
-- init demo
function demo:init()
-- init name
application.init(self, "demo")
-- init background
self:background_set("blue")
-- init main dialog
self:insert(self:dialog_main())
-- init input dialog
self:insert(self:dialog_input(), {centerx = true, centery = true})
-- init tips dialog
self:insert(self:dialog_tips(), {centerx = true, centery = true})
end
-- main dialog
function demo:dialog_main()
local dialog_main = self._DIALOG_MAIN
if not dialog_main then
dialog_main = boxdialog:new("dialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "main dialog")
dialog_main:text():text_set("The project focuses on making development and building easier and provides many features (.e.g package, install, plugin, macro, action, option, task ...), so that any developer can quickly pick it up and enjoy the productivity boost when developing and building project.")
dialog_main:button_add("tips", "< Tips >", function (v) self:view("dialog.tips"):show(true, {focused = true}) end)
dialog_main:button_add("input", "< Input >", function (v) self:view("dialog.input"):show(true, {focused = true}) end)
dialog_main:button_add("help", "< Help >", function (v) self:insert(self:dialog_help()) end)
dialog_main:button_add("quit", "< Quit >", "cm_quit")
self._DIALOG_MAIN = dialog_main
end
return dialog_main
end
-- help dialog
function demo:dialog_help()
local dialog_help = self._DIALOG_HELP
if not dialog_help then
dialog_help = textdialog:new("dialog.help", rect {1, 1, self:width() - 1, self:height() - 1}, "README")
dialog_help:option_set("scrollable", true)
local helptext = nil
local file = io.open("./LICENSE.md", 'r')
if file then
helptext = file:read("*a")
file:close()
end
if helptext then
dialog_help:text():text_set(helptext)
end
dialog_help:button_add("exit", "< Exit >", function (v) self:remove(dialog_help) end)
self._DIALOG_HELP = dialog_help
end
return dialog_help
end
-- input dialog
function demo:dialog_input()
local dialog_input = self._DIALOG_INPUT
if not dialog_input then
dialog_input = inputdialog:new("dialog.input", rect {0, 0, 50, 8}):background_set(self:dialog_main():frame():background())
dialog_input:frame():background_set("cyan")
dialog_input:text():text_set("please input text:"):textattr_set("red")
dialog_input:button_add("no", "< No >", function (v) dialog_input:show(false) end)
dialog_input:button_add("yes", "< Yes >", function (v)
self:dialog_main():text():text_set(dialog_input:textedit():text())
dialog_input:show(false)
end)
dialog_input:show(false)
self._DIALOG_INPUT = dialog_input
end
return dialog_input
end
-- tips dialog
function demo:dialog_tips()
local dialog_tips = self._DIALOG_TIPS
if not dialog_tips then
dialog_tips = textdialog:new("dialog.tips", rect {0, 0, 50, 8}):background_set(self:dialog_main():frame():background())
dialog_tips:frame():background_set("cyan")
dialog_tips:text():text_set("hello ltui! (https://tboox.org)\nA cross-platform terminal ui library based on Lua"):textattr_set("red")
dialog_tips:button_add("yes", "< Yes >", function (v) dialog_tips:show(false) end)
dialog_tips:button_add("no", "< No >", function (v) dialog_tips:show(false) end)
self._DIALOG_TIPS = dialog_tips
end
return dialog_tips
end
-- on resize
function demo:on_resize()
self:dialog_main():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})
self:dialog_help():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})
self:center(self:dialog_input(), {centerx = true, centery = true})
self:center(self:dialog_tips(), {centerx = true, centery = true})
application.on_resize(self)
end
-- main entry
function main(...)
demo:run(...)
end
|
0 | repos/xmake/tests | repos/xmake/tests/ui/inputdialog.lua | --!A cross-platform build utility based on Lua
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file inputdialog.lua
--
-- imports
import("core.ui.log")
import("core.ui.rect")
import("core.ui.view")
import("core.ui.label")
import("core.ui.event")
import("core.ui.inputdialog")
import("core.ui.application")
-- the demo application
local demo = application()
-- init demo
function demo:init()
-- init name
application.init(self, "demo")
-- init background
self:background_set("blue")
-- init input dialog
self:insert(self:dialog_input(), {centerx = true, centery = true})
end
-- input dialog
function demo:dialog_input()
local dialog_input = self._DIALOG_INPUT
if not dialog_input then
dialog_input = inputdialog:new("dialog.input", rect{0, 0, math.floor(self:width() / 2), math.floor(self:height() / 3)})
dialog_input:text():text_set("please input text:")
dialog_input:button_add("no", "< No >", function (v) dialog_input:quit() end)
dialog_input:button_add("yes", "< Yes >", function (v) dialog_input:quit() end)
self._DIALOG_INPUT = dialog_input
end
return dialog_input
end
-- on resize
function demo:on_resize()
self:dialog_input():bounds_set(rect{0, 0, math.floor(self:width() / 2), math.floor(self:height() / 3)})
self:center(self:dialog_input(), {centerx = true, centery = true})
application.on_resize(self)
end
-- main entry
function main(...)
demo:run(...)
end
|
0 | repos/xmake/tests | repos/xmake/tests/ui/desktop.lua | --!A cross-platform build utility based on Lua
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file desktop.lua
--
-- imports
import("core.ui.log")
import("core.ui.rect")
import("core.ui.view")
import("core.ui.label")
import("core.ui.event")
import("core.ui.button")
import("core.ui.application")
-- the demo application
local demo = application()
-- init demo
function demo:init()
-- init name
application.init(self, "demo")
-- show desktop, menubar and statusbar
self:insert(self:desktop())
self:insert(self:menubar())
self:insert(self:statusbar())
-- init title
self:menubar():title():text_set("Menu Bar (Hello)")
-- add title label
self:desktop():insert(label:new("title", rect {0, 0, 12, 1}, "hello ltui!"):textattr_set("white"), {centerx = true})
-- add yes button
self:desktop():insert(button:new("yes", rect {0, 1, 7, 2}, "< Yes >"):textattr_set("white"), {centerx = true})
-- add no button
self:desktop():insert(button:new("no", rect {0, 2, 6, 3}, "< No >"):textattr_set("white"), {centerx = true})
end
-- on event
function demo:on_event(e)
if application.on_event(self, e) then
return true
end
if e.type == event.ev_keyboard then
self:statusbar():info():text_set(e.key_name)
if e.key_name == "s" then
self:statusbar():show(not self:statusbar():state("visible"))
elseif e.key_name == "m" then
self:menubar():show(not self:menubar():state("visible"))
elseif e.key_name == "d" then
self:desktop():show(not self:desktop():state("visible"))
end
end
end
-- on resize
function demo:on_resize()
for v in self:desktop():views() do
self:center(v, {centerx = true})
end
application.on_resize(self)
end
-- main entry
function main(...)
demo:run(...)
end
|
0 | repos/xmake/tests | repos/xmake/tests/ui/mconfdialog.lua | --!A cross-platform build utility based on Lua
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file mconfdialog.lua
--
-- imports
import("core.ui.log")
import("core.ui.rect")
import("core.ui.view")
import("core.ui.label")
import("core.ui.event")
import("core.ui.action")
import("core.ui.menuconf")
import("core.ui.mconfdialog")
import("core.ui.application")
-- the demo application
local demo = application()
-- init demo
function demo:init()
-- init name
application.init(self, "demo")
-- init background
self:background_set("blue")
-- init configs
local configs_sub2 = {}
table.insert(configs_sub2, menuconf.boolean {description = "boolean config sub-item2"})
table.insert(configs_sub2, menuconf.number {value = 10, default = 10, description = "number config sub-item2"})
table.insert(configs_sub2, menuconf.string {value = "armv7", description = "string config sub-item2"})
table.insert(configs_sub2, menuconf.menu {description = "menu config sub-item2"})
local configs_sub = {}
table.insert(configs_sub, menuconf.boolean {description = "boolean config sub-item"})
table.insert(configs_sub, menuconf.number {value = 90, default = 10, description = "number config sub-item"})
table.insert(configs_sub, menuconf.string {value = "arm64", description = "string config sub-item"})
table.insert(configs_sub, menuconf.menu {description = "menu config sub-item", configs = configs_sub2})
table.insert(configs_sub, menuconf.choice {value = 2, values = {2, 5, 16, 87}, description = "choice config sub-item"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item1"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item2"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item3"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item4"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item5"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item6"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item7"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item8"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item9"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item10"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item11"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item12"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item13"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item14"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item15"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item16"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item17"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item18"})
table.insert(configs_sub, menuconf.number {value = 6, default = 10, description = "number config item19"})
local configs = {}
table.insert(configs, menuconf.boolean {description = "boolean config item"})
table.insert(configs, menuconf.boolean {default = true, new = false, description = {"boolean config item2",
" - more description info",
" - more description info",
" - more description info"}})
table.insert(configs, menuconf.number {value = 6, default = 10, description = "number config item"})
table.insert(configs, menuconf.string {value = "x86_64", description = "string config item"})
table.insert(configs, menuconf.menu {description = "menu config item", configs = configs_sub})
table.insert(configs, menuconf.choice {value = 3, values = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, default = 2, description = "choice config item"})
-- init menu config dialog
self:dialog_mconf():load(configs)
self:insert(self:dialog_mconf())
end
-- get mconfdialog
function demo:dialog_mconf()
local dialog_mconf = self._DIALOG_MCONF
if not dialog_mconf then
dialog_mconf = mconfdialog:new("mconfdialog.main", rect{1, 1, self:width() - 1, self:height() - 1}, "menu config")
dialog_mconf:action_set(action.ac_on_exit, function (v) self:quit() end)
dialog_mconf:action_set(action.ac_on_save, function (v)
-- TODO save configs
dialog_mconf:quit()
end)
self._DIALOG_MCONF = dialog_mconf
end
return dialog_mconf
end
-- on resize
function demo:on_resize()
self:dialog_mconf():bounds_set(rect{1, 1, self:width() - 1, self:height() - 1})
application.on_resize(self)
end
-- main entry
function main(...)
demo:run(...)
end
|
0 | repos/xmake/tests | repos/xmake/tests/ui/utf8dialog.lua | --!A cross-platform build utility based on Lua
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki, laelnasan
-- @file inputdialog.lua
--
-- imports
import("core.ui.log")
import("core.ui.rect")
import("core.ui.view")
import("core.ui.label")
import("core.ui.event")
import("core.ui.button")
import("core.ui.boxdialog")
import("core.ui.textdialog")
import("core.ui.inputdialog")
import("core.ui.application")
-- the demo application
local demo = application()
-- init demo
function demo:init()
-- init name
application.init(self, "demo")
-- init background
self:background_set("blue")
-- init main dialog
self:insert(self:dialog_main())
-- init input dialog
self:insert(self:dialog_input(), {centerx = true, centery = true})
-- init tips dialog
self:insert(self:dialog_tips(), {centerx = true, centery = true})
end
-- main dialog
function demo:dialog_main()
local dialog_main = self._DIALOG_MAIN
if not dialog_main then
dialog_main = boxdialog:new("dialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "main dialog")
dialog_main:text():text_set([[LTUI是一个基于lua的跨平台字符终端UI界面库。
此框架源于xmake中图形化菜单配置的需求,类似linux kernel的menuconf去配置编译参数,因此基于curses和lua实现了一整套跨平台的字符终端ui库。 而样式风格基本上完全参照的kconfig-frontends,当然用户也可以自己定制不同的ui风格。]])
dialog_main:button_add("tips", "< ☝ Tips >", function (v) self:view("dialog.tips"):show(true, {focused = true}) end)
dialog_main:button_add("input", "< ☺ Input >", function (v) self:view("dialog.input"):show(true, {focused = true}) end)
dialog_main:button_add("help", "< ☕Help >", function (v) self:insert(self:dialog_help()) end)
dialog_main:button_add("quit", "< ☠ Quit >", "cm_quit")
self._DIALOG_MAIN = dialog_main
end
return dialog_main
end
-- help dialog
function demo:dialog_help()
local dialog_help = self._DIALOG_HELP
if not dialog_help then
dialog_help = textdialog:new("dialog.help", rect {1, 1, self:width() - 1, self:height() - 1}, "README")
dialog_help:option_set("scrollable", true)
local helptext = nil
local file = io.open("./LICENSE.md", 'r')
if file then
helptext = file:read("*a")
file:close()
end
if helptext then
dialog_help:text():text_set(helptext)
end
dialog_help:button_add("exit", "< Exit >", function (v) self:remove(dialog_help) end)
self._DIALOG_HELP = dialog_help
end
return dialog_help
end
-- input dialog
function demo:dialog_input()
local dialog_input = self._DIALOG_INPUT
if not dialog_input then
dialog_input = inputdialog:new("dialog.input", rect {0, 0, 50, 8}):background_set(self:dialog_main():frame():background())
dialog_input:frame():background_set("cyan")
dialog_input:text():text_set("please input text:"):textattr_set("red")
dialog_input:button_add("no", "< No >", function (v) dialog_input:show(false) end)
dialog_input:button_add("yes", "< Yes >", function (v)
self:dialog_main():text():text_set(dialog_input:textedit():text())
dialog_input:show(false)
end)
dialog_input:show(false)
self._DIALOG_INPUT = dialog_input
end
return dialog_input
end
-- tips dialog
function demo:dialog_tips()
local dialog_tips = self._DIALOG_TIPS
if not dialog_tips then
dialog_tips = textdialog:new("dialog.tips", rect {0, 0, 50, 8}):background_set(self:dialog_main():frame():background())
dialog_tips:frame():background_set("cyan")
dialog_tips:text():text_set("hello ltui! (https://tboox.org)\nA cross-platform terminal ui library based on Lua"):textattr_set("red")
dialog_tips:button_add("yes", "< Yes >", function (v) dialog_tips:show(false) end)
dialog_tips:button_add("no", "< No >", function (v) dialog_tips:show(false) end)
self._DIALOG_TIPS = dialog_tips
end
return dialog_tips
end
-- on resize
function demo:on_resize()
self:dialog_main():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})
self:dialog_help():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})
self:center(self:dialog_input(), {centerx = true, centery = true})
self:center(self:dialog_tips(), {centerx = true, centery = true})
application.on_resize(self)
end
-- main entry
function main(...)
demo:run(...)
end
|
0 | repos/xmake/tests | repos/xmake/tests/ui/window.lua | --!A cross-platform build utility based on Lua
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file window.lua
--
-- imports
import("core.ui.log")
import("core.ui.rect")
import("core.ui.view")
import("core.ui.label")
import("core.ui.event")
import("core.ui.window")
import("core.ui.application")
-- the demo application
local demo = application()
-- init demo
function demo:init()
-- init name
application.init(self, "demo")
-- init background
self:background_set("blue")
-- init body window
self:insert(self:body_window())
end
-- get body window
function demo:body_window()
if not self._BODY_WINDOW then
self._BODY_WINDOW = window:new("window.body", rect {1, 1, self:width() - 1, self:height() - 1}, "main window", true)
end
return self._BODY_WINDOW
end
-- on resize
function demo:on_resize()
self:body_window():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})
application.on_resize(self)
end
-- main entry
function main(...)
demo:run(...)
end
|
0 | repos/xmake/tests | repos/xmake/tests/ui/events.lua | --!A cross-platform terminal ui library based on Lua
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file events.lua
--
-- imports
import("core.ui.rect")
import("core.ui.label")
import("core.ui.event")
import("core.ui.window")
import("core.ui.application")
-- the demo application
local demo = application()
-- init demo
function demo:init()
-- init name
application.init(self, "demo")
-- init background
self:background_set("black")
-- init body window
self:insert(self:body_window())
-- init teste
self:body_window():panel():insert(self:teste())
end
-- get body window
function demo:body_window()
if not self._BODY_WINDOW then
self._BODY_WINDOW = window:new("window.body", rect {1, 1, self:width() - 1, self:height() - 1}, "main window")
end
return self._BODY_WINDOW
end
-- get teste label
function demo:teste()
if not self._TESTE then
self._TESTE = label:new('demo.label', rect {0, 0, 40, 5}, 'this is a test')
end
return self._TESTE
end
-- on resize
function demo:on_resize()
self:body_window():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})
application.on_resize(self)
end
-- on event
function demo:on_event(e)
if e.type < event.ev_max then
self:teste():text_set('type: ' ..
tostring(e.type) ..
'; name: ' ..
tostring(e.key_name or e.btn_name) ..
'; code: ' ..
tostring(e.key_code or e.x) ..
'; meta: ' ..
tostring(e.key_code or e.y))
end
application.on_event(self, e)
end
-- main entry
function main(...)
demo:run(...)
end
|
0 | repos/xmake | repos/xmake/core/xpack.lua | xpack("xmake")
set_homepage("https://xmake.io")
set_title("Xmake build utility ($(arch))")
set_description("A cross-platform build utility based on Lua.")
set_copyright("Copyright (C) 2015-present, TBOOX Open Source Group")
set_author("ruki <[email protected]>")
set_licensefile("../LICENSE.md")
set_formats("nsis", "wix", "zip")
add_targets("demo")
set_bindir(".")
set_iconfile("src/demo/xmake.ico")
add_components("LongPath")
on_load(function (package)
local arch = package:arch()
if package:is_plat("windows") then
if arch == "x64" then
arch = "win64"
elseif arch == "x86" then
arch = "win32"
end
end
package:set("basename", "xmake-v$(version)." .. arch)
local format = package:format()
if format == "zip" then
package:set("prefixdir", "xmake")
end
end)
before_package(function (package)
import("net.http")
import("utils.archive")
import("core.base.global")
local format = package:format()
if package:is_plat("windows") and (format == "nsis" or format == "wix" or format == "zip") then
local winenv = path.join(os.programdir(), "winenv")
if os.isdir(winenv) then
package:add("installfiles", path.join(winenv, "**"), {rootdir = path.directory(winenv)})
else
local arch = package:arch()
local url_7z = "https://github.com/xmake-mirror/7zip/releases/download/24.07/7z24.07-" .. arch .. ".zip"
local curl_version = "8.8.0_2"
local url_curl = "https://curl.se/windows/dl-" .. curl_version .. "/curl-" .. curl_version
if package:is_arch("x64", "x86_64") then
url_curl = url_curl .. "-win64-mingw.zip"
elseif package:is_arch("arm64") then
url_curl = url_curl .. "-win64a-mingw.zip"
else
url_curl = url_curl .. "-win32-mingw.zip"
end
local archive_7z = path.join(package:buildir(), "7z.zip")
local archive_curl = path.join(package:buildir(), "curl.zip")
local tmpdir_7z = path.join(package:buildir(), "7z")
local tmpdir_curl = path.join(package:buildir(), "curl")
local winenv_bindir = path.join(package:buildir(), "winenv", "bin")
os.mkdir(winenv_bindir)
http.download(url_7z, archive_7z, {insecure = global.get("insecure-ssl")})
archive.extract(archive_7z, tmpdir_7z)
os.cp(path.join(tmpdir_7z, "*"), winenv_bindir)
http.download(url_curl, archive_curl, {insecure = global.get("insecure-ssl")})
archive.extract(archive_curl, tmpdir_curl)
os.cp(path.join(tmpdir_curl, "*", "bin", "*.exe"), winenv_bindir)
os.cp(path.join(tmpdir_curl, "*", "bin", "*.crt"), winenv_bindir)
winenv = path.directory(winenv_bindir)
package:add("installfiles", path.join(winenv, "**"), {rootdir = path.directory(winenv)})
end
end
end)
xpack_component("LongPath")
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}]])
batchcmds:rawcmd("wix", [[
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Control\FileSystem">
<RegistryValue Type="integer" Name="LongPathsEnabled" Value="1" KeyPath="yes"/>
</RegistryKey>
]])
end)
xpack("xmakesrc")
set_homepage("https://xmake.io")
set_title("Xmake build utility ($(arch))")
set_description("A cross-platform build utility based on Lua.")
set_copyright("Copyright (C) 2015-present, TBOOX Open Source Group")
set_author("ruki <[email protected]>")
set_formats("srczip", "srctargz", "runself", "srpm", "deb")
set_basename("xmake-v$(version)")
set_prefixdir("xmake-$(version)")
set_license("Apache-2.0")
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/**|scripts/vsxmake/**"), 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_buildcmd(function (package, batchcmds)
local format = package:format()
if format == "srpm" or format == "deb" then
batchcmds:runv("./configure")
batchcmds:runv("make")
end
end)
on_installcmd(function (package, batchcmds)
local format = package:format()
if format == "runself" then
batchcmds:runv("./scripts/get.sh", {"__local__"})
elseif format == "srpm" or format == "deb" then
batchcmds:runv("make", {"install", path(package:install_rootdir(), function (p) return "PREFIX=" .. p end)})
end
end)
|
0 | repos/xmake | repos/xmake/core/xmake.sh | #!/bin/sh
set_project "xmake"
set_version "2.9.4" "%Y%m%d"
# set warning all
set_warnings "all"
# set language: c99
set_languages "c99"
# add definitions
add_defines "_GNU_SOURCE=1" "_FILE_OFFSET_BITS=64" "_LARGEFILE_SOURCE"
# disable some compiler errors
if is_plat "macosx"; then
add_cxflags "-Wno-error=deprecated-declarations" "-fno-strict-aliasing" "-Wno-error=nullability-completeness" "-Wno-error=parentheses-equality"
fi
# add build modes
if is_mode "debug"; then
set_symbols "debug"
set_optimizes "none"
else
set_strip "all"
if ! is_kind "shared"; then
set_symbols "hidden"
fi
set_optimizes "smallest"
fi
# the runtime option, lua or luajit
option "runtime" "Use luajit or lua runtime" "lua"
# always use external dependencies
option "external" "Always use external dependencies" false
# the readline option
option "readline"
add_links "readline"
add_cincludes "stdio.h" "readline/readline.h"
add_cfuncs "readline"
add_defines "XM_CONFIG_API_HAVE_READLINE"
option_end
# the curses option
option "curses"
add_cfuncs "initscr"
add_cincludes "curses.h"
add_defines "XM_CONFIG_API_HAVE_CURSES"
before_check "option_find_curses"
option_end
option_find_curses() {
local ncurses="ncurses"
if is_plat "mingw"; then
ncurses="ncursesw"
fi
local ncurses_ldflags=""
ncurses_ldflags=$(pkg-config --libs ${ncurses} 2>/dev/null)
option "curses"
if test_nz "${ncurses_ldflags}"; then
add_cflags `pkg-config --cflags ${ncurses} 2>/dev/null`
add_ldflags "${ncurses_ldflags}"
else
add_links "curses"
fi
option_end
}
# the atomic option
# @note some systems need link atomic, e.g. raspberrypi
option "atomic"
add_links "atomic"
add_csnippets "
void test() {\n
int v;\n
__atomic_load(&v,&v,0);\n
}"
option_end
# the lua option
option "lua"
add_cfuncs "lua_pushstring"
add_cincludes "lua.h" "lualib.h" "lauxlib.h"
add_defines "LUA_COMPAT_5_1" "LUA_COMPAT_5_2" "LUA_COMPAT_5_3"
before_check "option_find_lua"
option_end
option_find_lua() {
local ldflags=""
local cflags=""
option "lua"
# detect lua5.4 on debian
cflags=`pkg-config --cflags lua5.4 2>/dev/null`
ldflags=`pkg-config --libs lua5.4 2>/dev/null`
# detect it on fedora
if test_z "${cflags}"; then
cflags=`pkg-config --cflags lua 2>/dev/null`
fi
if test_z "${ldflags}"; then
ldflags=`pkg-config --libs lua 2>/dev/null`
fi
if test_z "${cflags}"; then
cflags="-I/usr/include/lua5.4"
fi
if test_z "${ldflags}"; then
ldflags="-llua5.4"
fi
add_cflags "${cflags}"
add_ldflags "${ldflags}"
option_end
}
# the luajit option
option "luajit"
add_cfuncs "lua_pushstring"
add_cincludes "lua.h" "lualib.h" "lauxlib.h"
add_defines "USE_LUAJIT"
before_check "option_find_luajit"
option_end
option_find_luajit() {
local ldflags=""
local cflags=""
option "luajit"
cflags=`pkg-config --cflags luajit 2>/dev/null`
ldflags=`pkg-config --libs luajit 2>/dev/null`
if test_z "${cflags}"; then
cflags="-I/usr/include/luajit-2.1"
fi
if test_z "${ldflags}"; then
ldflags="-lluajit"
fi
add_cflags "${cflags}"
add_ldflags "${ldflags}"
option_end
}
# the lz4 option
option "lz4"
add_cfuncs "LZ4F_compressFrame"
add_cincludes "lz4.h" "lz4frame.h"
before_check "option_find_lz4"
option_end
option_find_lz4() {
local ldflags=""
local cflags=""
option "lz4"
cflags=`pkg-config --cflags liblz4 2>/dev/null`
ldflags=`pkg-config --libs liblz4 2>/dev/null`
if test_z "${cflags}"; then
cflags="-I/usr/include"
fi
if test_z "${ldflags}"; then
ldflags="-llz4"
fi
add_cflags "${cflags}"
add_ldflags "${ldflags}"
option_end
}
# the sv option
option "sv"
add_cfuncs "semver_tryn"
add_cincludes "semver.h"
add_links "sv"
before_check "option_find_sv"
option_end
option_find_sv() {
local ldflags=""
local cflags=""
option "sv"
cflags=`pkg-config --cflags libsv 2>/dev/null`
ldflags=`pkg-config --libs libsv 2>/dev/null`
if test_z "${cflags}"; then
cflags="-I/usr/include"
fi
if test_z "${ldflags}"; then
ldflags="-lsv"
fi
add_cflags "${cflags}"
add_ldflags "${ldflags}"
option_end
}
# the tbox option
option "tbox"
add_cfuncs "tb_exit" "tb_md5_init" "tb_charset_conv_data"
add_cincludes "tbox/tbox.h"
add_links "tbox"
before_check "option_find_tbox"
option_end
option_find_tbox() {
local ldflags=""
local cflags=""
option "tbox"
cflags=`pkg-config --cflags libtbox 2>/dev/null`
ldflags=`pkg-config --libs libtbox 2>/dev/null`
if test_z "${cflags}"; then
cflags="-I/usr/include"
fi
if test_z "${ldflags}"; then
ldflags="-ltbox"
fi
add_cflags "${cflags}"
add_ldflags "${ldflags}"
# ubuntu armv7/armel maybe need it
if is_plat "linux" && is_arch "armv7" "arm"; then
add_ldflags "-latomic"
fi
option_end
}
# add projects
if ! has_config "external"; then
if is_config "runtime" "luajit"; then
includes "src/luajit"
else
includes "src/lua"
fi
includes "src/lua-cjson"
includes "src/lz4"
includes "src/sv"
includes "src/tbox"
fi
includes "src/xmake"
includes "src/demo"
|
0 | repos/xmake | repos/xmake/core/xmake.lua | -- project
set_project("xmake")
-- version
set_version("2.9.4", {build = "%Y%m%d"})
-- set xmake min version
set_xmakever("2.8.5")
-- set all warnings as errors
set_warnings("all", "error")
-- set language: c99, c++11
set_languages("c99", "cxx11")
-- add release and debug modes
add_rules("mode.release", "mode.debug")
if is_mode("release") then
set_optimize("smallest")
if is_plat("windows") then
add_ldflags("/LTCG")
end
end
-- disable some compiler errors
add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=nullability-completeness", "-Wno-error=parentheses-equality")
-- add definitions
add_defines("_GNU_SOURCE=1", "_FILE_OFFSET_BITS=64", "_LARGEFILE_SOURCE")
-- add vectorexts
--[[
if is_arch("x86", "x64", "i386", "x86_64") then
add_vectorexts("sse", "sse2", "sse3", "avx", "avx2")
elseif is_arch("arm.*") then
add_vectorexts("neon")
end]]
-- for the windows platform (msvc)
if is_plat("windows") then
set_runtimes("MT")
add_ldflags("-nodefaultlib:msvcrt.lib")
add_links("kernel32", "user32", "gdi32")
end
-- for mode coverage
if is_mode("coverage") then
add_ldflags("-coverage", "-fprofile-arcs", "-ftest-coverage")
end
-- set cosmocc toolchain, e.g. xmake f -p linux --cosmocc=y
if has_config("cosmocc") then
add_requires("cosmocc")
set_toolchains("@cosmocc")
set_policy("build.ccache", false)
end
-- use cosmocc toolchain
option("cosmocc", {default = false, description = "Use cosmocc toolchain to build once and run anywhere."})
-- embed all script files
option("embed", {default = false, description = "Embed all script files."})
-- the runtime option
option("runtime")
set_default("lua")
set_description("Use luajit or lua runtime")
set_values("luajit", "lua")
option_end()
-- the lua-cjson option
option("lua_cjson")
set_default(true)
set_description("Use lua-cjson as json parser")
option_end()
-- the readline option
option("readline")
set_description("Enable or disable readline library")
add_links("readline")
add_cincludes("stdio.h", "readline/readline.h")
add_cfuncs("readline")
add_defines("XM_CONFIG_API_HAVE_READLINE")
add_deps("cosmocc")
after_check(function (option)
if option:dep("cosmocc"):enabled() then
option:enable(false)
end
end)
option_end()
-- the curses option
option("curses")
set_description("Enable or disable curses library")
add_defines("XM_CONFIG_API_HAVE_CURSES")
add_deps("cosmocc")
before_check(function (option)
if is_plat("mingw") then
option:add("cincludes", "ncursesw/curses.h")
option:add("links", "ncursesw")
else
option:add("cincludes", "curses.h")
option:add("links", "curses")
end
end)
after_check(function (option)
if option:dep("cosmocc"):enabled() then
option:enable(false)
end
end)
option_end()
-- the pdcurses option
option("pdcurses")
set_default(true)
set_description("Enable or disable pdcurses library")
add_defines("PDCURSES")
add_defines("XM_CONFIG_API_HAVE_CURSES")
option_end()
-- only build xmake libraries for development?
option("onlylib")
set_default(false)
set_description("Only build xmake libraries for development")
option_end()
-- suppress warnings
if is_plat("windows") then
add_defines("_CRT_SECURE_NO_WARNINGS")
add_cxflags("/utf-8")
end
-- add projects
includes("src/sv", "src/lz4", "src/tbox", "src/xmake", "src/demo")
if has_config("lua_cjson") then
includes("src/lua-cjson")
end
if is_config("runtime", "luajit") then
includes("src/luajit")
else
includes("src/lua")
end
if is_plat("windows") then
includes("src/pdcurses")
end
-- add xpack
includes("@builtin/xpack")
if xpack then
includes("xpack.lua")
end
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.