Skip to content

Commit 60589d6

Browse files
authored
Update Buck C++ sample to demonstrate multiple "platforms" in .buckconfig (fbsamples#10)
* Demonstrate user-defined platform flavors with a platform called `other_platform` * Add a `.gitignore` that includes Buck artifacts to ignore * Update README to use `--show-output` instead of explicitly stating the path to the output
1 parent 3c55d48 commit 60589d6

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Buck
2+
buck-out
3+
.buckconfig.local
4+
.buckd

hello-buck-cxx/.buckconfig

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
[cxx]
3+
cxxppflags="-D HELLOSTRING=\"Buck\""
4+
5+
[cxx#other_platform]
6+
cxxppflags="-D HELLOSTRING=\"Chuck\""
7+

hello-buck-cxx/README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11

22
To build using buck:
33

4-
buck build :main
4+
buck build --show-output :main
55

6-
The executable, `main` will be in `./buck-out/gen`.
6+
The `--show-output` option shows the path to the output from the build.
7+
8+
To build and run using buck:
9+
10+
buck run :main
11+
12+
To build and run using the alternative `#other_platform` platform
13+
defined in `.buckconfig`:
14+
15+
buck run :main#other_platform
716

817
You can also build any of the following flavors:
918

1019
buck build :main#strip-debug
1120
buck build :main#strip-non-global
1221
buck build :main#strip-all
1322

14-
For a description of these flavors, see the Buck documentation at the following URL:
23+
For a description of these flavors, see the Buck documentation at the
24+
following URL:
1525

16-
<https://buckbuild.com/rule/cxx_binary.html>
26+
> <https://buckbuild.com/rule/cxx_binary.html>
1727
1828

1929
**End of README.md**

hello-buck-cxx/hello-string.cxx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#include "stdio.h"
22
#include "hello-string.h"
33

4-
const char * hello_string::HELLO = "Buck";
4+
//
5+
// HELLOSTRING is defined in .buckconfig
6+
//
7+
const char * hello_string::HELLO = HELLOSTRING;
58

69
hello_string::hello_string() {};
710

0 commit comments

Comments
 (0)