aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-09-20 06:37:59 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-09-20 06:40:28 +0200
commit194a5708f3a42c6254cf99d8e03b5c8c60224feb (patch)
tree650a6427b438f5ebdbc31746e5d8e5b5debef7ff /tests
parentce415d8b76e355c34dc42b68c4da5a69b2c392b8 (diff)
Initial commit, works to create ninja file
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
new file mode 100644
index 0000000..9af7241
--- /dev/null
+++ b/tests/main.cpp
@@ -0,0 +1,37 @@
+#include <cstdio>
+#include <ninja/Ninja.hpp>
+
+using namespace ninja;
+
+int main(int argc, char **argv)
+{
+ NinjaBuildFile ninjaBuildFile;
+ ninjaBuildFile.defineGlobalVariable("globalIncDir", "'-I/home/dec05eba/git/libninja/include'");
+
+ NinjaVariable argsVar = { "ARGS" };
+ NinjaVariable linkArgsVar = { "LINK_ARGS" };
+
+ NinjaRule *compileCppRule = ninjaBuildFile.createRule("cpp_COMPILER",
+ { NinjaArg("c++"), NinjaArg(argsVar), NinjaArg("-c"), NinjaArg("$in"), NinjaArg("-o"), NinjaArg("$out") });
+ compileCppRule->depFile = "$out.d";
+
+ NinjaRule *buildExeRule = ninjaBuildFile.createRule("BUILD_EXEC",
+ { NinjaArg("c++"), NinjaArg(argsVar), NinjaArg("-o"), NinjaArg("$out"), NinjaArg("$in"), NinjaArg(linkArgsVar), NinjaArg("$aliasing") });
+ buildExeRule->depFile = "$out.d";
+
+ NinjaRule *compileCRule = ninjaBuildFile.createRule("c_COMPILER",
+ { NinjaArg("cc"), NinjaArg(argsVar), NinjaArg("-c"), NinjaArg("$in"), NinjaArg("-o"), NinjaArg("$out") });
+ buildExeRule->depFile = "$out.d";
+
+
+ NinjaArgValue argsValue = { argsVar, "$globalIncDir -std=c++14 -pedantic -fpie -MMD -MP '-Itest@exe' '-I..' -Wall -Wextra -Werror=return-type -fdiagnostics-show-option '-fdiagnostics-color=always' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Winvalid-pch' -fstack-protector '-Og' -fexceptions -Wnon-virtual-dtor -g3 -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -fasynchronous-unwind-tables" };
+ compileCppRule->build("../../main.cpp", "test@exe/main.cpp.o", { argsValue });
+
+ NinjaArgValue linkArgsValue = { linkArgsVar, "-Wl,--no-undefined,--as-needed -ldl -lm -pthread -pthread \"/home/dec05eba/git/libninja/sibs-build/debug/liblibninja.so\"" };
+ buildExeRule->build("test@exe/main.cpp.o", "test", { argsValue });
+
+ std::string generatedNinjaFile = ninjaBuildFile.generate();
+
+ printf("%s\n", generatedNinjaFile.c_str());
+ return 0;
+}