Skip to content

Commit 3c55d48

Browse files
authored
Merge pull request fbsamples#8 from fbsamples/carljparker/buck-cxx-20180328
Add C++ sample for Buck
2 parents 6a28c52 + 1ce896d commit 3c55d48

File tree

8 files changed

+87
-0
lines changed

8 files changed

+87
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ for more information.
1313

1414
* @Scale 2015 Cross Platform Demo: `cross-platform-scale-2015-demo`
1515
* Hello Buck for Java: `hello-buck-java`
16+
* Hello Buck for C++: `hello-buck-cxx`
17+

hello-buck-cxx/.buckconfig

Whitespace-only changes.

hello-buck-cxx/.buckversion

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
last

hello-buck-cxx/BUCK

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cxx_binary(
2+
name = 'main',
3+
srcs = [
4+
'hello-buck.cxx',
5+
],
6+
deps = [
7+
':hello_string',
8+
],
9+
)
10+
11+
cxx_library(
12+
name = 'hello_string',
13+
srcs = [
14+
'hello-string.cxx',
15+
],
16+
headers = [
17+
'hello-string.h',
18+
],
19+
)
20+

hello-buck-cxx/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
To build using buck:
3+
4+
buck build :main
5+
6+
The executable, `main` will be in `./buck-out/gen`.
7+
8+
You can also build any of the following flavors:
9+
10+
buck build :main#strip-debug
11+
buck build :main#strip-non-global
12+
buck build :main#strip-all
13+
14+
For a description of these flavors, see the Buck documentation at the following URL:
15+
16+
<https://buckbuild.com/rule/cxx_binary.html>
17+
18+
19+
**End of README.md**
20+

hello-buck-cxx/hello-buck.cxx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "stdio.h"
2+
#include "hello-string.h"
3+
4+
int main () {
5+
6+
hello_string * hello = new hello_string();
7+
8+
printf( "Hello, %s\n", hello -> get_string() );
9+
10+
return( 0 );
11+
12+
}
13+

hello-buck-cxx/hello-string.cxx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "stdio.h"
2+
#include "hello-string.h"
3+
4+
const char * hello_string::HELLO = "Buck";
5+
6+
hello_string::hello_string() {};
7+
8+
const char * hello_string::get_string() {
9+
10+
return( HELLO );
11+
12+
}
13+
14+
15+
// --- END ---
16+

hello-buck-cxx/hello-string.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class hello_string {
2+
3+
private:
4+
static const char * HELLO;
5+
6+
public:
7+
hello_string();
8+
9+
const char * get_string();
10+
11+
};
12+
13+
14+
// --- END ---
15+

0 commit comments

Comments
 (0)