diff options
Diffstat (limited to 'tutorial/chapter-2')
-rw-r--r-- | tutorial/chapter-2/app/app.qbs | 11 | ||||
-rw-r--r-- | tutorial/chapter-2/app/main.c | 10 | ||||
-rw-r--r-- | tutorial/chapter-2/lib/lib.c | 15 | ||||
-rw-r--r-- | tutorial/chapter-2/lib/lib.h | 11 | ||||
-rw-r--r-- | tutorial/chapter-2/lib/lib.qbs | 28 | ||||
-rw-r--r-- | tutorial/chapter-2/myproject.qbs | 10 |
6 files changed, 85 insertions, 0 deletions
diff --git a/tutorial/chapter-2/app/app.qbs b/tutorial/chapter-2/app/app.qbs new file mode 100644 index 000000000..a3ee757ab --- /dev/null +++ b/tutorial/chapter-2/app/app.qbs @@ -0,0 +1,11 @@ +CppApplication { + Depends { name: "mylib" } + name: "My Application" + targetName: "myapp" + files: "main.c" + version: "1.0.0" + + consoleApplication: true + install: true + installDebugInformation: true +} diff --git a/tutorial/chapter-2/app/main.c b/tutorial/chapter-2/app/main.c new file mode 100644 index 000000000..a560d1ba1 --- /dev/null +++ b/tutorial/chapter-2/app/main.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#include "lib.h" + +int main() +{ + printf("Hello, world\n"); + printf("%s\n", get_string()); + return 0; +} diff --git a/tutorial/chapter-2/lib/lib.c b/tutorial/chapter-2/lib/lib.c new file mode 100644 index 000000000..9fe020ba2 --- /dev/null +++ b/tutorial/chapter-2/lib/lib.c @@ -0,0 +1,15 @@ +//! [0] + +// lib/lib.cpp +#include "lib.h" + +#ifndef CRUCIAL_DEFINE +# error CRUCIAL_DEFINE not defined +#endif + +const char *get_string() +{ + return "Hello from library"; +} + +//! [0] diff --git a/tutorial/chapter-2/lib/lib.h b/tutorial/chapter-2/lib/lib.h new file mode 100644 index 000000000..efc56ae0b --- /dev/null +++ b/tutorial/chapter-2/lib/lib.h @@ -0,0 +1,11 @@ +//! [0] + +// lib/lib.h +#ifndef LIB_H +#define LIB_H + +const char *get_string(); + +#endif // LIB_H + +//! [0] diff --git a/tutorial/chapter-2/lib/lib.qbs b/tutorial/chapter-2/lib/lib.qbs new file mode 100644 index 000000000..378d855a6 --- /dev/null +++ b/tutorial/chapter-2/lib/lib.qbs @@ -0,0 +1,28 @@ +//! [0] +StaticLibrary { + name: "mylib" + files: [ + "lib.c", + "lib.h", + ] + version: "1.0.0" + install: true + + //! [1] + Depends { name: 'cpp' } + cpp.defines: ['CRUCIAL_DEFINE'] + //! [1] + + //! [2] + Export { + Depends { name: "cpp" } + cpp.includePaths: [exportingProduct.sourceDirectory] + } + //! [2] + + //! [3] + Depends { name: 'bundle' } + bundle.isBundle: false + //! [3] +} +//! [0] diff --git a/tutorial/chapter-2/myproject.qbs b/tutorial/chapter-2/myproject.qbs new file mode 100644 index 000000000..17ef04ac9 --- /dev/null +++ b/tutorial/chapter-2/myproject.qbs @@ -0,0 +1,10 @@ +//! [0] +Project { + name: "My Project" + minimumQbsVersion: "2.0" + references: [ + "app/app.qbs", + "lib/lib.qbs" + ] +} +//! [0] |