Skip to content

Commit

Permalink
Add Buck sample. (buildfoundation#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zinnatullin authored Jan 19, 2017
1 parent f016b53 commit 5de51e2
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ before_install:
- ssh-keyscan -t rsa localhost > ~/.ssh/known_hosts
- chmod u+rw,go= ~/.ssh/known_hosts
# Install dependencies for sample projects.
## Gradle, Maven.
## Gradle, Maven, Buck.
- jdk_switcher use oraclejdk8
- java -version && javac -version
## Rust.
- sudo curl -sf -L https://static.rust-lang.org/rustup.sh | sh
## Go.
- sudo apt-get install golang --quiet --yes
- mv ~/.bashrc ~/.bashrc_original && echo -e "export GOROOT=$GOROOT\n" > ~/.bashrc && cat ~/.bashrc_original >> ~/.bashrc && rm ~/.bashrc_original
## Clang.
- sudo apt-get install clang --quiet --yes
## GCC.
Expand All @@ -32,6 +33,14 @@ before_install:
- eval $ANDROID_SDK_INSTALL_COMPONENT "build-tools-25.0.2"
- eval $ANDROID_SDK_INSTALL_COMPONENT "android-25"
- mv ~/.bashrc ~/.bashrc_original && echo -e "export ANDROID_HOME=$ANDROID_HOME\nJAVA_HOME=$JAVA_HOME" > ~/.bashrc && cat ~/.bashrc_original >> ~/.bashrc && rm ~/.bashrc_original
## Buck.
- sudo apt-get install ant python git
- git clone https://github.com/facebook/buck.git
- cd buck
- git checkout v2016.11.11.01
- ant
- mv ~/.bashrc ~/.bashrc_original && echo -e "export PATH=$PATH:`pwd`/bin\n" > ~/.bashrc && cat ~/.bashrc_original >> ~/.bashrc && rm ~/.bashrc_original
- cd ..

script:
- bash test/test.sh --run-samples
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ We have quite a bunch of samples showing off some practical applications.
* [Clang](samples/clang)
* [GCC](samples/gcc)
* [Maven](samples/mvn)
* [Buck](samples/buck)
* [Go](samples/go)

## Setup
Expand Down
4 changes: 4 additions & 0 deletions samples/buck/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[java]
src_roots = /src/main/java/
source_level = 6
target_level = 6
2 changes: 2 additions & 0 deletions samples/buck/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
buck-out
.buckd
1 change: 1 addition & 0 deletions samples/buck/.mainframer/config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
remote_machine=sample@remotebuildmachine
8 changes: 8 additions & 0 deletions samples/buck/.mainframer/ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# .buckd folder contains machine specific loc and bin files, no need to sync it between machines.
/.buckd

# Synching .git or other VCS folders is very bad idea, they are usually very heavy and not required for the build.
/.git

# Synching IDE specific folders is really not needed for remote build.
/.idea
2 changes: 2 additions & 0 deletions samples/buck/.mainframer/localignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Usually you don't need to sync buck-out folder to remote machine since it will have one as result of build.
/buck-out
2 changes: 2 additions & 0 deletions samples/buck/.mainframer/remoteignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Usually you don't need to sync sources back from remote to local machine.
/sample
18 changes: 18 additions & 0 deletions samples/buck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Sample Buck project

Most interesting for you here is not the source code, but configs in [`.mainframer`](.mainframer) folder.

This is a very common setup for basically any Buck project (including multimodule), but of course you might need to tune some ignore configs for your project.

### How to build

```bash
$ bash mainframer.sh buck build sample
```

Or any other Buck task you want, btw it integrates with IntelliJ pretty easily! TODO add link to docs.

### Requirements

* Buck installed on remote machine.
* JDK 8+ installed on remote machine.
10 changes: 10 additions & 0 deletions samples/buck/sample/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
java_binary(
name = "sample",
main_class = "com.gojuno.mainframer.Sample",
deps = [":main"]
)

java_library(
name = "main",
srcs = glob(["src/main/java/**/*.java"])
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.gojuno.mainframer;

class Sample {

public static void main(String[] args) {
System.out.println("Build me on remote machine!");
}
}
24 changes: 24 additions & 0 deletions test/sample_buck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -e

# You can run it from any directory.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Execute common pre-setup, include test functions.
source "$DIR/common.sh"

printTestStarted

# Copy Buck sample to build dir.
cp -a "$DIR/../samples/buck/." "$BUILD_DIR"

# Overwrite config to work with test remote machine.
setTestRemoteMachineInConfig

# Run mainframer.sh that builds Buck project.
bash "$REPO_DIR"/mainframer.sh 'buck clean && buck build sample'

# Run jar to ensure that it was built fine.
java -jar "$BUILD_DIR/buck-out/gen/sample/sample.jar"

printTestEnded

0 comments on commit 5de51e2

Please sign in to comment.