Building in Android
๋ ๊ฐ์ genrule์ ๋ง๋ญ๋๋ค. ํ๋๋ CXX ํค๋๋ฅผ ์์ฑํ๊ณ ๋ค๋ฅธ ํ๋๋ CXX ์์ค ํ์ผ์ ์์ฑํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ cc_library_static
์ ๋ํ ์
๋ ฅ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค.
// lib.rs์ Rust ๋ด๋ณด๋ด๊ธฐ ํจ์์ ๋ํ
// C++ ๋ฐ์ธ๋ฉ์ด ํฌํจ๋ C++ ํค๋๋ฅผ ์์ฑํฉ๋๋ค.
genrule {
name: "libcxx_test_bridge_header",
tools: ["cxxbridge"],
cmd: "$(location cxxbridge) $(in) --header > $(out)",
srcs: ["lib.rs"],
out: ["lib.rs.h"],
}
// Rust๊ฐ ํธ์ถํ๋ C++ ์ฝ๋๋ฅผ ์์ฑํฉ๋๋ค.
genrule {
name: "libcxx_test_bridge_code",
tools: ["cxxbridge"],
cmd: "$(location cxxbridge) $(in) > $(out)",
srcs: ["lib.rs"],
out: ["lib.rs.cc"],
}
cxxbridge
๋๊ตฌ๋ C++ ์ธก์ ๋ธ๋ฆฌ์ง ๋ชจ๋์ ์์ฑํ๋ ๋ ๋ฆฝํ ๋๊ตฌ์ ๋๋ค. ์ด ๋๊ตฌ๋ Android์ ํฌํจ๋์ด ์์ผ๋ฉฐ Soong ๋๊ตฌ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.- ์ผ๋ฐ์ ์ผ๋ก Rust ์์ค ํ์ผ์ด
lib.rs
์ธ ๊ฒฝ์ฐ ํค๋ ํ์ผ์ ์ด๋ฆ์lib.rs.h
์ด๊ณ ์์ค ํ์ผ์ ์ด๋ฆ์lib.rs.cc
๊ฐ ๋ฉ๋๋ค. ๊ทธ๋ฌ๋ ์ด ์ด๋ฆ ์ง์ ๊ท์น์ ๊ฐ์ ๋์ง ์์ต๋๋ค.