Update README and remove unnecessary flags

This commit is contained in:
Taylor Cramer 2017-06-05 12:11:20 -07:00 коммит произвёл Ted Mielczarek
Родитель 17fb0dd018
Коммит 3da16a7c33
3 изменённых файлов: 19 добавлений и 27 удалений

Просмотреть файл

@ -3,7 +3,7 @@
sccache - Shared Compilation Cache
==================================
Sccache is a [ccache](https://ccache.samba.org/)-like tool. It is used as a compiler wrapper and avoids compilation when possible, storing a cache in a remote storage using the S3 API.
Sccache is a [ccache](https://ccache.samba.org/)-like tool. It is used as a compiler wrapper and avoids compilation when possible, storing a cache in a remote storage using the S3 API, the GCS API, or Redis.
Sccache now includes [experimental Rust support](docs/Rust.md).
@ -17,11 +17,11 @@ Build Requirements
sccache is a [Rust](https://www.rust-lang.org/) program. Building it requires `cargo` (and thus `rustc`). sccache currently requires **Rust 1.17**.
We recommend you install Rust via [Rustup](https://rustup.rs/). The generated binaries can be built so that they are very portable, see [scripts/build-release.sh](scripts/build-release.sh). By default `sccache` supports a local disk cache. To build `sccache` with support for `S3` and/or `Redis` cache backends, add `--features=all` or select a specific feature by passing `s3` and/or `redis`. Refer the [Cargo Documentation](http://doc.crates.io/manifest.html#the-features-section) for details.
We recommend you install Rust via [Rustup](https://rustup.rs/). The generated binaries can be built so that they are very portable, see [scripts/build-release.sh](scripts/build-release.sh). By default `sccache` supports a local disk cache. To build `sccache` with support for `S3` and/or `Redis` cache backends, add `--features=all` or select a specific feature by passing `s3`, `gcs`, and/or `redis`. Refer the [Cargo Documentation](http://doc.crates.io/manifest.html#the-features-section) for details.
## Build
> $ cargo build [--features=all|redis|s3] [--release]
> $ cargo build [--features=all|redis|s3|gcs] [--release]
## Installation
@ -51,6 +51,10 @@ If you want to use S3 storage for the sccache cache, you need to set the `SCCACH
Set `SCCACHE_REDIS` to a [Redis](https://redis.io/) url in format `redis://[:<passwd>@]<hostname>[:port][/<db>]` to store the cache in a Redis instance.
To use [GCS](https://cloud.google.com/storage/), you need to set the `SCCACHE_GCS_BUCKET` environment variable to the name of the GCS bucket.
If you're using authentication, set `SCCACHE_GCS_KEY_PATH` to the location of your JSON service account credentials.
By default, SCCACHE on GCS will be read-only. To change this, set `SCCACHE_GCS_RW_MODE` to either `READ_ONLY` or `READ_WRITE`.
*Important:* The environment variables are only taken into account when the server starts, so only on the first run.
Debugging

20
src/cache/cache.rs поставляемый
Просмотреть файл

@ -235,15 +235,6 @@ pub fn storage_from_environment(pool: &CpuPool, _handle: &Handle) -> Arc<Storage
debug!("Trying GCS bucket({})", bucket);
#[cfg(feature = "gcs")]
{
let base_url = match env::var("SSCACHE_GCS_BASE_URL") {
Ok(base_url) => base_url,
_ => {
let default = "https://www.googleapis.com";
warn!("No SCCACHE_GCS_BASE_URl specified, using default: {}", default);
default.to_owned()
}
};
let cred_path = match env::var("SCCACHE_GCS_KEY_PATH") {
Ok(cred_location) => Some(cred_location),
_ => {
@ -253,21 +244,22 @@ pub fn storage_from_environment(pool: &CpuPool, _handle: &Handle) -> Arc<Storage
}
};
let rw_mode = match env::var("SCCACHE_RW_MODE").as_ref().map(String::as_str) {
let rw_mode = match env::var("SCCACHE_GCS_RW_MODE").as_ref().map(String::as_str) {
Ok("READ_ONLY") => RWMode::ReadOnly,
Ok("READ_WRITE") => RWMode::ReadWrite,
Ok(_) => {
warn!("Invalid SCCACHE_RW_MODE-- defaulting to READ_ONLY.");
warn!("Invalid SCCACHE_GCS_RW_MODE-- defaulting to READ_ONLY.");
RWMode::ReadOnly
},
_ => {
warn!("No SCCACHE_RW_MODE specified-- defaulting to READ_ONLY.");
warn!("No SCCACHE_GCS_RW_MODE specified-- defaulting to READ_ONLY.");
RWMode::ReadOnly
}
};
let gcs_cred_provider = cred_path.map(|path| GCSCredentialProvider::new(rw_mode, path));
match GCSCache::new(bucket, base_url, gcs_cred_provider, rw_mode, _handle) {
let gcs_cred_provider =
cred_path.map(|path| GCSCredentialProvider::new(rw_mode, path));
match GCSCache::new(bucket, gcs_cred_provider, rw_mode, _handle) {
Ok(s) => {
trace!("Using GCSCache");
return Arc::new(s);

16
src/cache/gcs.rs поставляемый
Просмотреть файл

@ -48,28 +48,26 @@ type HyperClient = Client<HttpsConnector<HttpConnector>>;
/// A GCS bucket
struct Bucket {
name: String,
base_url: String,
client: HyperClient,
}
impl fmt::Display for Bucket {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Bucket(name={}, base_url={})", self.name, self.base_url)
write!(f, "Bucket(name={})", self.name)
}
}
impl Bucket {
pub fn new(name: String, base_url: String, handle: &Handle) -> Result<Bucket> {
pub fn new(name: String, handle: &Handle) -> Result<Bucket> {
let client = Client::configure()
.connector(HttpsConnector::new(1, handle)?)
.build(handle);
Ok(Bucket { name, base_url, client })
Ok(Bucket { name, client })
}
fn get(&self, key: &str, cred_provider: &Option<GCSCredentialProvider>) -> SFuture<Vec<u8>> {
let url = format!("{}/download/storage/v1/b/{}/o/{}?alt=media",
self.base_url,
let url = format!("https://www.googleapis.com/download/storage/v1/b/{}/o/{}?alt=media",
percent_encode(self.name.as_bytes(), PATH_SEGMENT_ENCODE_SET),
percent_encode(key.as_bytes(), PATH_SEGMENT_ENCODE_SET));
@ -107,8 +105,7 @@ impl Bucket {
}
fn put(&self, key: &str, content: Vec<u8>, cred_provider: &Option<GCSCredentialProvider>) -> SFuture<()> {
let url = format!("{}/upload/storage/v1/b/{}/o?name={}&uploadType=media",
self.base_url,
let url = format!("https://www.googleapis.com/upload/storage/v1/b/{}/o?name={}&uploadType=media",
percent_encode(self.name.as_bytes(), PATH_SEGMENT_ENCODE_SET),
percent_encode(key.as_bytes(), QUERY_ENCODE_SET));
@ -318,13 +315,12 @@ pub struct GCSCache {
impl GCSCache {
/// Create a new `GCSCache` storing data in `bucket`
pub fn new(bucket: String,
endpoint: String,
credential_provider: Option<GCSCredentialProvider>,
rw_mode: RWMode,
handle: &Handle) -> Result<GCSCache>
{
Ok(GCSCache {
bucket: Rc::new(Bucket::new(bucket, endpoint, handle)?),
bucket: Rc::new(Bucket::new(bucket, handle)?),
rw_mode: rw_mode,
credential_provider: credential_provider,
})