Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase facebook/buck 10/2020 #9

Merged
merged 38 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1c31c5b
Respect user input if abi_generation_mode is explicitly provided in j…
davidhao3300 Jun 25, 2020
da5384f
Automate publishing docs on CirclrCI (#2486)
Jun 29, 2020
3283f1c
Fixed git push access denied issue (#2487)
Jun 29, 2020
0aeb8be
handle bundling resources of static frameworks (Originally by rmaz) (…
Unknoob Jul 10, 2020
0299f0f
Add support for java 11 builds in jitpack (#2499)
kageiit Jul 20, 2020
888cae1
Fixed Unable to resolve dependency jdk8 (= 8.0.172) (#2492)
Jul 22, 2020
c29414a
CircleCI fix (#2495)
Jul 22, 2020
992456c
Added python3 to interpreter names (#2497)
Jul 22, 2020
c381e7c
Fixes for rust tests (#2503)
Jul 30, 2020
c30a8be
Add support for ANDROID_SDK_ROOT environment variable (#2507)
Jul 30, 2020
290308e
Fix for #2498 (#2504)
surapuramakhil Jul 30, 2020
c12ddfe
Set max store size bytes correctly so it is used by AbstractAsynchron…
raviagarwal7 Aug 3, 2020
7486182
CI rust test fixes (#2511)
Aug 5, 2020
d62d9b2
Fixed a phthon installation bug on CircleCI (#2509)
Aug 5, 2020
cac7c76
add Easynvest to buck showcases (#2514)
Lcsmarcal Aug 6, 2020
427f770
Make Python3 the first choice of python interpreter (#2512)
Aug 6, 2020
39a6610
Fixed a python3 compatible issue (#2517)
Aug 12, 2020
ff103fc
Added application_region and application_language properties to xcode…
Lcsmarcal Aug 12, 2020
d1717fd
Added Android NDK tests (#2515)
Aug 13, 2020
a68ef0d
Saifulriza (#2523)
saifulriza Aug 17, 2020
1c601fd
Add full kotlin configurations to kotlin rule (v2) (#2526)
tyvsmith Aug 25, 2020
d9d41a5
Fixing paths that fail during project generation (#2527)
tyvsmith Aug 25, 2020
ffa062a
(Rebase) Add snapshot_images_diff_path to apple_test (#2528)
Lcsmarcal Aug 25, 2020
7273a9d
Fixes for Windows tests (#2529)
Aug 28, 2020
6ce4daa
Added Flavors to docs (#2522)
Aug 28, 2020
2c78fcb
Added a kotlin tutorial for android (#2525)
Aug 31, 2020
6a45969
Prepare release v2020.09.01 (#2532)
Sep 1, 2020
b12b77f
Added dependency to pulbishing docs (#2534)
Sep 2, 2020
ff7c4cd
Fixed CircleCI tests (#2531)
Sep 2, 2020
cd9fbc8
Upgraded ruby syntax in replease process (#2533)
Sep 2, 2020
ffd2df6
Skip flaky tests on Windows platform (#2536)
Sep 9, 2020
682b0aa
Increased a timeout in Winddows test. (#2544)
Sep 22, 2020
2ab66a9
Fixed dlang installation error (#2543)
Sep 22, 2020
e5f9062
Install python2 from archive. (#2542)
Sep 22, 2020
a103d9b
Fixed a link (#2539)
Sep 22, 2020
ae8e8fc
Added a rust tutorial (#2540)
Oct 6, 2020
32440f9
Add support for async worker processes (#2547)
mikekap Oct 13, 2020
7b8881b
Merge branch 'facebook_master' into rebase-10-2020
Oct 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added a rust tutorial (facebook#2540)
Co-authored-by: v-jizhang <66389669+buck-bot@users.noreply.github.com>
  • Loading branch information
Jinlin Zhang and buck-bot authored Oct 6, 2020
commit ae8e8fc013413f0144b73971eceeff3fd6f51d6c
82 changes: 79 additions & 3 deletions docs/learning/tutorial.soy
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<td><span><strong>Platform:</strong></span></td>
<td>
<a href="javascript:void(0);" class="button-android" onclick="display('platform', 'android')">Android</a>
<a href="javascript:void(0);" class="button-macos" onclick="display('platform', 'macos')">MacOS</a>
<a href="javascript:void(0);" class="button-linuxos" onclick="display('platform', 'linuxos')">Linux</a>
</td>
</tr>
<tr>
Expand All @@ -61,12 +63,13 @@
<td>
<a href="javascript:void(0);" class="button-java" onclick="display('language', 'java')">Java</a>
<a href="javascript:void(0);" class="button-kotlin" onclick="display('language', 'kotlin')">Kotlin</a>
<a href="javascript:void(0);" class="button-rust" onclick="display('language', 'rust')">Rust</a>
</td>
</tr>
</table>
</div>

<span><block class="mac linux android java kotlin" /></span>
<span><block class="macos mac linuxos linux android java kotlin rust" /></span>
<h2>Path Setup</h2>

<p>
Expand All @@ -83,7 +86,7 @@ sudo ln -s ${PWD}/bin/buckd /usr/bin/buckd
<h2>Create Project</h2>

<p>
We are going to build a sample Android application. We should start our project in an empty directory, so create a new one and navigate to it:
We are going to build a sample application. We should start our project in an empty directory, so create a new one and navigate to it:
</p>

{literal}<pre>
Expand All @@ -99,8 +102,9 @@ cd ~/my-first-buck-project/

<h2>Compile Your Code</h2>

<span><block class="mac linux android java kotlin" /></span>
<p>
Android applications are typically written in Javai and kotlin, so the first thing we will do is to configure Buck to compile code against the Android API. To do so, Buck needs to know where your Android SDK is. Assuming that your Android SDK is installed in <code>~/android-sdk</code>, run the following command to set a <code>ANDROID_SDK</code> environment variable that tells Buck where to find your Android SDK:
Android applications are typically written in Java and kotlin, so the first thing we will do is to configure Buck to compile code against the Android API. To do so, Buck needs to know where your Android SDK is. Assuming that your Android SDK is installed in <code>~/android-sdk</code>, run the following command to set a <code>ANDROID_SDK</code> environment variable that tells Buck where to find your Android SDK:
</p>

{literal}<pre>
Expand Down Expand Up @@ -197,6 +201,78 @@ echo "android_library(
</blockquote>
</p>

<span><block class="mac linux linuxos macos kotlin rust " /></span>
<p>
First, we create rust source files and directories:
</p>
{literal}<pre>
mkdir -p src/front_of_house
echo "mod front_of_house;

pub use crate::front_of_house::hosting;
pub use crate::front_of_house::serving;

fn main() {
hosting::add_to_waitlist();
hosting::seat_at_table();
serving::take_order();
serving::serve_order();
serving::take_payment();
}" > src/main.rs

echo "pub mod hosting;
pub mod serving;" > src/front_of_house.rs

echo "pub fn add_to_waitlist() {
println!(\"Added to watinglist.\");
}

pub fn seat_at_table() {
println!(\"Seated at table.\");
}" > src/front_of_house/hosting.rs

echo "pub fn take_order() {
println!(\"Ordered.\");
}

pub fn serve_order() {
println!(\"Order served.\");
}

pub fn take_payment() {
println!(\"Payment done.\");
} > src/front_of_house/serving.rs
</pre>{/literal}

<p>
Now we need a build file that defines a build rule to compile this Java code, so we create an <code><a href="rule/rust_binary.html">rust_binary()</a></code> rule in <code>BUCK</code>:
{literal}<pre>
echo "rust_binary(
name = 'restaurant',
srcs = glob(
['src/**/*.rs'],
),
)" >BUCK
</pre>{/literal}
</p>

<p>
Now we can build our rust code using Buck:
</p>

<pre>buck build{sp}:restaurant</pre>

<p>
And run the sample:
</p>
<pre>buck run{sp}:restaurant</pre>

<p>
<blockquote>
Buck generates its output in the <code>buck-out</code> directory, so this is a good time to specify <code>buck-out</code> as something that should be ignored by your version control system.
</blockquote>
</p>

<span><block class="mac linux android java kotlin" /></span>
<h2>Package Resources</h2>

Expand Down
7 changes: 6 additions & 1 deletion docs/static/buck.css
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,11 @@ footer {
.disp-os-windows .toggler .button-windows,
.disp-platform-ios .toggler .button-ios,
.disp-platform-android .toggler .button-android,
.disp-platform-macos .toggler .button-macos,
.disp-platform-linuxos .toggler .button-linuxos,
.disp-language-java .toggler .button-java,
.disp-language-kotlin .toggler .button-kotlin {
.disp-language-kotlin .toggler .button-kotlin,
.disp-language-rust .toggler .button-rust {
background-color: #05A5D1;
color: white;
}
Expand All @@ -572,6 +575,8 @@ block {
.disp-platform-android.disp-os-linux.disp-language-java .android.linux.java,
.disp-platform-android.disp-os-mac.disp-language-kotlin .android.mac.kotlin,
.disp-platform-android.disp-os-linux.disp-language-kotlin .android.linux.kotlin,
.disp-platform-macos.disp-os-mac.disp-language-rust .macos.mac.rust,
.disp-platform-linuxos.disp-os-linux.disp-language-rust .linuxos.linux.rust,
.display-platform-ios.display-os-mac .ios.mac,
.display-platform-ios.display-os-linux .ios.linux,
.display-platform-ios.display-os-windows .ios.windows,
Expand Down