From eb649ff736e101e49afacb31d580741851375e69 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 21 Jan 2016 11:08:37 +0200 Subject: Basic "Hello World" C++ program with build2 --- .gitignore | 6 ++++++ build/.gitignore | 1 + build/bootstrap.build | 15 +++++++++++++++ build/root.build | 5 +++++ buildfile | 7 +++++++ hello.cxx | 22 ++++++++++++++++++++++ manifest | 15 +++++++++++++++ test.out | 2 ++ version | 1 + 9 files changed, 74 insertions(+) create mode 100644 .gitignore create mode 100644 build/.gitignore create mode 100644 build/bootstrap.build create mode 100644 build/root.build create mode 100644 buildfile create mode 100644 hello.cxx create mode 100644 manifest create mode 100644 test.out create mode 100644 version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e598bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.o +*.so +*.a +core + +hello diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 0000000..225c27f --- /dev/null +++ b/build/.gitignore @@ -0,0 +1 @@ +config.build diff --git a/build/bootstrap.build b/build/bootstrap.build new file mode 100644 index 0000000..20e3dbe --- /dev/null +++ b/build/bootstrap.build @@ -0,0 +1,15 @@ +project = hello +version = 1.0.0 +revision = 0 + +using config +using dist +using test +using install + +dist.package = $project-$version + +if ($revision != 0) +{ + dist.package += +$revision +} diff --git a/build/root.build b/build/root.build new file mode 100644 index 0000000..7b1aac4 --- /dev/null +++ b/build/root.build @@ -0,0 +1,5 @@ +using cxx + +cxx{*}: extension = cxx + +cxx.std = 11 diff --git a/buildfile b/buildfile new file mode 100644 index 0000000..0f35aef --- /dev/null +++ b/buildfile @@ -0,0 +1,7 @@ +import libs = libhello%lib{hello} + +exe{hello}: cxx{hello} $libs +exe{hello}: test.arguments = World "Planet #345732" +exe{hello}: test.output = test.out + +./: exe{hello} doc{version} file{manifest} diff --git a/hello.cxx b/hello.cxx new file mode 100644 index 0000000..c105d17 --- /dev/null +++ b/hello.cxx @@ -0,0 +1,22 @@ +// file: hello.cxx -*- C++ -*- + +#include + +#include + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc < 2) + { + cerr << "usage: hello ..." << endl; + return 1; + } + + using hello::say; + + for (int i (1); i != argc; ++i) + say (argv[i]); +} diff --git a/manifest b/manifest new file mode 100644 index 0000000..27c1158 --- /dev/null +++ b/manifest @@ -0,0 +1,15 @@ +: 1 +name: hello +version: 1.0.0 +summary: The "Hello World" example program +license: MIT +tags: c++, hello, world, example +description: \ +A simple program that implements the "Hello World" example in C++ using the +libhello library. Its primary goal is to show a canonical build2/bpkg +project/package. +\ +url: http://www.example.org/hello +email: hello-users@example.org +requires: c++11 +depends: libhello [1.0.0 2.0.0-); compatible with libhello-1.X.Y diff --git a/test.out b/test.out new file mode 100644 index 0000000..275233c --- /dev/null +++ b/test.out @@ -0,0 +1,2 @@ +Hello, World! +Hello, Planet #345732! diff --git a/version b/version new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/version @@ -0,0 +1 @@ +1.0.0 -- cgit v1.1