diff options
| author | Ângelo Andrade Cirino <[email protected]> | 2021-08-05 17:06:44 -0300 |
|---|---|---|
| committer | Ângelo Andrade Cirino <[email protected]> | 2021-08-05 17:06:44 -0300 |
| commit | 286ba62b6189953f8a0c255053ca3c3f7f1e5693 (patch) | |
| tree | 7d0671f7a57ea8ae102be3454d956848eb8b0b5c /tests | |
| parent | 81ad292ea67f82d88d785a37d23b1f1603996da1 (diff) | |
| parent | a959af20d2a34038efb13053c112ef1d55084081 (diff) | |
Merge branch 'master' of https://github.com/xmake-io/xmake
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/apis/add_allowedxxx/.gitignore | 8 | ||||
| -rw-r--r-- | tests/apis/add_allowedxxx/src/main.cpp | 9 | ||||
| -rw-r--r-- | tests/apis/add_allowedxxx/xmake.lua | 83 | ||||
| -rw-r--r-- | tests/projects/other/autogen_code/.gitignore | 8 | ||||
| -rw-r--r-- | tests/projects/other/autogen_code/test.lua | 3 | ||||
| -rw-r--r-- | tests/projects/other/autogen_code/xmake.lua | 20 | ||||
| -rw-r--r-- | tests/projects/other/bin2c/.gitignore | 8 | ||||
| -rw-r--r-- | tests/projects/other/bin2c/src/data.bin | 1 | ||||
| -rw-r--r-- | tests/projects/other/bin2c/src/image.png | 1 | ||||
| -rw-r--r-- | tests/projects/other/bin2c/src/main.c | 16 | ||||
| -rw-r--r-- | tests/projects/other/bin2c/test.lua | 3 | ||||
| -rw-r--r-- | tests/projects/other/bin2c/xmake.lua | 10 | ||||
| -rw-r--r-- | tests/projects/vala/lua/src/main.vala | 21 | ||||
| -rw-r--r-- | tests/projects/vala/lua/xmake.lua | 10 |
14 files changed, 201 insertions, 0 deletions
diff --git a/tests/apis/add_allowedxxx/.gitignore b/tests/apis/add_allowedxxx/.gitignore new file mode 100644 index 000000000..152105761 --- /dev/null +++ b/tests/apis/add_allowedxxx/.gitignore @@ -0,0 +1,8 @@ +# Xmake cache +.xmake/ +build/ + +# MacOS Cache +.DS_Store + + diff --git a/tests/apis/add_allowedxxx/src/main.cpp b/tests/apis/add_allowedxxx/src/main.cpp new file mode 100644 index 000000000..7c435d251 --- /dev/null +++ b/tests/apis/add_allowedxxx/src/main.cpp @@ -0,0 +1,9 @@ +#include <iostream> + +using namespace std; + +int main(int argc, char** argv) +{ + cout << "hello world!" << endl; + return 0; +} diff --git a/tests/apis/add_allowedxxx/xmake.lua b/tests/apis/add_allowedxxx/xmake.lua new file mode 100644 index 000000000..e2f1f1ad9 --- /dev/null +++ b/tests/apis/add_allowedxxx/xmake.lua @@ -0,0 +1,83 @@ +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 defination +-- add_defines("NDEBUG", "_GNU_SOURCE=1") +-- +-- -- set warning all as error +-- 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 +-- + diff --git a/tests/projects/other/autogen_code/.gitignore b/tests/projects/other/autogen_code/.gitignore new file mode 100644 index 000000000..152105761 --- /dev/null +++ b/tests/projects/other/autogen_code/.gitignore @@ -0,0 +1,8 @@ +# Xmake cache +.xmake/ +build/ + +# MacOS Cache +.DS_Store + + diff --git a/tests/projects/other/autogen_code/test.lua b/tests/projects/other/autogen_code/test.lua new file mode 100644 index 000000000..b57362078 --- /dev/null +++ b/tests/projects/other/autogen_code/test.lua @@ -0,0 +1,3 @@ +function main(t) + t:build() +end diff --git a/tests/projects/other/autogen_code/xmake.lua b/tests/projects/other/autogen_code/xmake.lua new file mode 100644 index 000000000..fb40d8e9c --- /dev/null +++ b/tests/projects/other/autogen_code/xmake.lua @@ -0,0 +1,20 @@ +add_rules("mode.debug", "mode.release") + +target("autogen_code") + set_kind("binary") + add_files("$(buildir)/autogen.cpp", {always_added = true}) + before_build(function (target) + io.writefile("$(buildir)/autogen.cpp", [[ +#include <iostream> + +using namespace std; + +int main(int argc, char** argv) +{ + cout << "hello world!" << endl; + return 0; +} + ]]) + end) + + diff --git a/tests/projects/other/bin2c/.gitignore b/tests/projects/other/bin2c/.gitignore new file mode 100644 index 000000000..152105761 --- /dev/null +++ b/tests/projects/other/bin2c/.gitignore @@ -0,0 +1,8 @@ +# Xmake cache +.xmake/ +build/ + +# MacOS Cache +.DS_Store + + diff --git a/tests/projects/other/bin2c/src/data.bin b/tests/projects/other/bin2c/src/data.bin new file mode 100644 index 000000000..5d26814ee --- /dev/null +++ b/tests/projects/other/bin2c/src/data.bin @@ -0,0 +1 @@ +hello xmake! diff --git a/tests/projects/other/bin2c/src/image.png b/tests/projects/other/bin2c/src/image.png new file mode 100644 index 000000000..d2c2e1ac6 --- /dev/null +++ b/tests/projects/other/bin2c/src/image.png @@ -0,0 +1 @@ +fake image diff --git a/tests/projects/other/bin2c/src/main.c b/tests/projects/other/bin2c/src/main.c new file mode 100644 index 000000000..31e416157 --- /dev/null +++ b/tests/projects/other/bin2c/src/main.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +static unsigned char g_bin_data[] = { + #include "data.bin.h" +}; + +static unsigned char g_png_data[] = { + #include "image.png.h" +}; + +int main(int argc, char** argv) +{ + printf("data.bin: %s, size: %d\n", g_bin_data, (int)sizeof(g_bin_data)); + printf("image.png: %s, size: %d\n", g_png_data, (int)sizeof(g_png_data)); + return 0; +} diff --git a/tests/projects/other/bin2c/test.lua b/tests/projects/other/bin2c/test.lua new file mode 100644 index 000000000..b57362078 --- /dev/null +++ b/tests/projects/other/bin2c/test.lua @@ -0,0 +1,3 @@ +function main(t) + t:build() +end diff --git a/tests/projects/other/bin2c/xmake.lua b/tests/projects/other/bin2c/xmake.lua new file mode 100644 index 000000000..b5517a54e --- /dev/null +++ b/tests/projects/other/bin2c/xmake.lua @@ -0,0 +1,10 @@ +add_rules("mode.debug", "mode.release") + +target("test") + set_kind("binary") + add_rules("utils.bin2c", {linewidth = 16}) + add_files("src/*.c") + add_files("src/*.bin") + add_files("src/*.png", {rules = "utils.bin2c"}) + + diff --git a/tests/projects/vala/lua/src/main.vala b/tests/projects/vala/lua/src/main.vala new file mode 100644 index 000000000..8e8a32da0 --- /dev/null +++ b/tests/projects/vala/lua/src/main.vala @@ -0,0 +1,21 @@ +using Lua; + +static int my_func (LuaVM vm) { + stdout.printf ("Vala Code From Lua Code! (%f)\n", vm.to_number (1)); + return 1; +} + +static int main (string[] args) { + + string code = """ + print "Lua Code From Vala Code!" + my_func(33) + """; + + var vm = new LuaVM (); + vm.open_libs (); + vm.register ("my_func", my_func); + vm.do_string (code); + + return 0; +} diff --git a/tests/projects/vala/lua/xmake.lua b/tests/projects/vala/lua/xmake.lua new file mode 100644 index 000000000..df0cbeb89 --- /dev/null +++ b/tests/projects/vala/lua/xmake.lua @@ -0,0 +1,10 @@ +add_rules("mode.release", "mode.debug") + +add_requires("lua", "glib") + +target("test") + set_kind("binary") + add_rules("vala") + add_files("src/*.vala") + add_packages("lua", "glib") + add_values("vala.packages", "lua") |
