Skip to content

Commit

Permalink
Load Diplomat and twiggy from cache; update diplomat (#974)
Browse files Browse the repository at this point in the history
* Update diplomat

* Add make tasks for updating diplomat

* Load Diplomat from cache

* Load twiggy from cache

* No need to sync anymore

* indent

* Include tool name in cache key name
  • Loading branch information
Manishearth authored Aug 24, 2021
1 parent 9b41685 commit b66b237
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 46 deletions.
95 changes: 82 additions & 13 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
key: ${{ runner.os }}-make-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
key: ${{ runner.os }}-make-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
key: ${{ runner.os }}-make-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
Expand All @@ -145,13 +145,27 @@ jobs:
packages: |
sphinx
sphinx-rtd-theme
- name: Get Diplomat version
id: diplomat-version
run: |
echo "::set-output name=rev::$(cargo make diplomat-get-rev --loglevel error | tr -d '[:space:]')"
shell: bash
- name: Attempt to load cached Diplomat
uses: actions/cache@v2
id: diplomat-cache
with:
path: |
~/.cargo/bin/diplomat-tool
~/.cargo/bin/diplomat-tool.exe
key: ${{ runner.os }}-diplomat-${{ steps.diplomat-version.outputs.rev }}

- name: Install Diplomat
if: steps.diplomat-cache.outputs.cache-hit != 'true'
uses: actions-rs/cargo@v1.0.1
with:
command: install
# Keep this in sync with ffi/capi/Cargo.toml
args: --git https://github.com/rust-diplomat/diplomat.git --rev 3ac8c3e8e31353a2f3eb02d015eb23a1feb84b4d diplomat-tool
args: --git https://github.com/rust-diplomat/diplomat.git --rev ${{ steps.diplomat-version.outputs.rev }} diplomat-tool

- name: Build
uses: actions-rs/cargo@v1.0.1
Expand Down Expand Up @@ -191,7 +205,7 @@ jobs:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
key: ${{ runner.os }}-make-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
Expand Down Expand Up @@ -219,7 +233,26 @@ jobs:
- name: Install WASM tools
run: |
sudo apt-get install wabt binaryen
cargo install twiggy
- name: Get twiggy version
id: twiggy-version
run: |
echo "::set-output name=hash::$(cargo search twiggy | grep '^twiggy =' | md5sum)"
shell: bash
- name: Attempt to load cached twiggy
uses: actions/cache@v2
id: twiggy-cache
with:
path: |
~/.cargo/bin/twiggy
~/.cargo/bin/twiggy.exe
key: ${{ runner.os }}-twiggy-${{ steps.twiggy-version.outputs.hash }}
- name: Install twiggy
if: steps.twiggy-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
with:
crate: twiggy
version: latest

- name: Get cargo-make version
id: cargo-make-version
Expand All @@ -233,19 +266,35 @@ jobs:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
key: ${{ runner.os }}-make-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
with:
crate: cargo-make
version: latest

- name: Get Diplomat version
id: diplomat-version
run: |
echo "::set-output name=rev::$(cargo make diplomat-get-rev --loglevel error | tr -d '[:space:]')"
shell: bash
- name: Attempt to load cached Diplomat
uses: actions/cache@v2
id: diplomat-cache
with:
path: |
~/.cargo/bin/diplomat-tool
~/.cargo/bin/diplomat-tool.exe
key: ${{ runner.os }}-diplomat-${{ steps.diplomat-version.outputs.rev }}

- name: Install Diplomat
if: steps.diplomat-cache.outputs.cache-hit != 'true'
uses: actions-rs/cargo@v1.0.1
with:
command: install
args: --git https://github.com/rust-diplomat/diplomat.git --rev 3ac8c3e8e31353a2f3eb02d015eb23a1feb84b4d diplomat-tool
# Keep this in sync with ffi/capi/Cargo.toml
args: --git https://github.com/rust-diplomat/diplomat.git --rev ${{ steps.diplomat-version.outputs.rev }} diplomat-tool

- name: Build
uses: actions-rs/cargo@v1.0.1
Expand Down Expand Up @@ -287,7 +336,7 @@ jobs:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
key: ${{ runner.os }}-make-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
Expand Down Expand Up @@ -324,7 +373,7 @@ jobs:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
key: ${{ runner.os }}-make-${{ steps.cargo-make-version.outputs.hash }}
- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
Expand All @@ -344,7 +393,7 @@ jobs:
path: |
~/.cargo/bin/cargo-readme
~/.cargo/bin/cargo-readme.exe
key: ${{ runner.os }}-${{ steps.cargo-readme-version.outputs.hash }}
key: ${{ runner.os }}-readme-${{ steps.cargo-readme-version.outputs.hash }}
- name: Install cargo-readme
if: steps.cargo-readme-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
Expand Down Expand Up @@ -645,7 +694,7 @@ jobs:
path: |
~/.cargo/bin/cargo-make
~/.cargo/bin/cargo-make.exe
key: ${{ runner.os }}-${{ steps.cargo-make-version.outputs.hash }}
key: ${{ runner.os }}-make-${{ steps.cargo-make-version.outputs.hash }}

- name: Install cargo-make
if: steps.cargo-make-cache.outputs.cache-hit != 'true'
Expand All @@ -654,14 +703,34 @@ jobs:
crate: cargo-make
version: latest

- name: Get twiggy version
id: twiggy-version
run: |
echo "::set-output name=hash::$(cargo search twiggy | grep '^twiggy =' | md5sum)"
shell: bash
- name: Attempt to load cached twiggy
uses: actions/cache@v2
id: twiggy-cache
with:
path: |
~/.cargo/bin/twiggy
~/.cargo/bin/twiggy.exe
key: ${{ runner.os }}-twiggy-${{ steps.twiggy-version.outputs.hash }}
- name: Install twiggy
if: steps.twiggy-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1.2
with:
crate: twiggy
version: latest

- name: Install prerequisites for wasm build
run: |
rustup component add rust-src
rustup toolchain list
rustup toolchain install nightly-2021-02-28
sudo npm install -g wasm-opt --unsafe-perm
sudo npm install -g wabt
cargo install twiggy
- name: Setup output data directory
run: mkdir -p benchmarks/binsize
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions ffi/capi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ icu_provider_blob = { path = "../../provider/blob" }
tinystr = { version = "0.4.10", features = ["alloc"], default-features = false }
writeable = { path = "../../utils/writeable/" }

# make sure to update GitHub actions to use the appropriate revision
diplomat = { git = "https://github.com/rust-diplomat/diplomat", rev = "3ac8c3e8e31353a2f3eb02d015eb23a1feb84b4d" }
diplomat-runtime = { git = "https://github.com/rust-diplomat/diplomat", rev = "3ac8c3e8e31353a2f3eb02d015eb23a1feb84b4d" }
# Run `cargo make diplomat-install` to get the right diplomat binary installed
diplomat = { git = "https://github.com/rust-diplomat/diplomat", rev = "38cffa9bc2ef21d0aba89ed7d76236de4153248a" }
diplomat-runtime = { git = "https://github.com/rust-diplomat/diplomat", rev = "38cffa9bc2ef21d0aba89ed7d76236de4153248a" }
icu_testdata = { version = "0.3", path = "../../provider/testdata", default-features = false, features = ["static"], optional = true }

# This cfg originates in dlmalloc/lib.rs
Expand Down
1 change: 0 additions & 1 deletion ffi/capi/include/result_void_ICU4XLocaleError.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ extern "C" {
#include "ICU4XLocaleError.h"
typedef struct locale_ffi_result_void_ICU4XLocaleError {
union {
uint8_t ok[0];
ICU4XLocaleError err;
};
bool is_ok;
Expand Down
4 changes: 0 additions & 4 deletions ffi/capi/include/result_void_void.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
extern "C" {
#endif
typedef struct decimal_ffi_result_void_void {
union {
uint8_t ok[0];
uint8_t err[0];
};
bool is_ok;
} decimal_ffi_result_void_void;
#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion ffi/cpp/include/ICU4XFixedDecimalFormatOptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ struct ICU4XFixedDecimalFormatOptions {

inline ICU4XFixedDecimalFormatOptions ICU4XFixedDecimalFormatOptions::default_() {
capi::ICU4XFixedDecimalFormatOptions diplomat_raw_struct_out_value = capi::ICU4XFixedDecimalFormatOptions_default();
return ICU4XFixedDecimalFormatOptions{ .grouping_strategy = std::move(ICU4XFixedDecimalGroupingStrategy{ diplomat_raw_struct_out_value.grouping_strategy }), .sign_display = std::move(ICU4XFixedDecimalSignDisplay{ diplomat_raw_struct_out_value.sign_display }) };
return ICU4XFixedDecimalFormatOptions{ .grouping_strategy = std::move(static_cast<ICU4XFixedDecimalGroupingStrategy>(diplomat_raw_struct_out_value.grouping_strategy)), .sign_display = std::move(static_cast<ICU4XFixedDecimalSignDisplay>(diplomat_raw_struct_out_value.sign_display)) };
}
#endif
24 changes: 12 additions & 12 deletions ffi/cpp/include/ICU4XLocale.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ template<typename W> inline diplomat::result<std::monostate, ICU4XLocaleError> I
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value;
}
Expand All @@ -83,7 +83,7 @@ inline diplomat::result<std::string, ICU4XLocaleError> ICU4XLocale::basename() {
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string));
}
Expand All @@ -93,7 +93,7 @@ template<typename W> inline diplomat::result<std::monostate, ICU4XLocaleError> I
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value;
}
Expand All @@ -104,7 +104,7 @@ inline diplomat::result<std::string, ICU4XLocaleError> ICU4XLocale::get_unicode_
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string));
}
Expand All @@ -114,7 +114,7 @@ template<typename W> inline diplomat::result<std::monostate, ICU4XLocaleError> I
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value;
}
Expand All @@ -125,7 +125,7 @@ inline diplomat::result<std::string, ICU4XLocaleError> ICU4XLocale::language() {
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string));
}
Expand All @@ -135,7 +135,7 @@ template<typename W> inline diplomat::result<std::monostate, ICU4XLocaleError> I
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value;
}
Expand All @@ -146,7 +146,7 @@ inline diplomat::result<std::string, ICU4XLocaleError> ICU4XLocale::region() {
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string));
}
Expand All @@ -156,7 +156,7 @@ template<typename W> inline diplomat::result<std::monostate, ICU4XLocaleError> I
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value;
}
Expand All @@ -167,7 +167,7 @@ inline diplomat::result<std::string, ICU4XLocaleError> ICU4XLocale::script() {
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string));
}
Expand All @@ -177,7 +177,7 @@ template<typename W> inline diplomat::result<std::monostate, ICU4XLocaleError> I
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value;
}
Expand All @@ -188,7 +188,7 @@ inline diplomat::result<std::string, ICU4XLocaleError> ICU4XLocale::tostring() {
diplomat::result<std::monostate, ICU4XLocaleError> diplomat_result_out_value(diplomat_result_raw_out_value.is_ok);
if (diplomat_result_raw_out_value.is_ok) {
} else {
diplomat_result_out_value.set_err((std::move(ICU4XLocaleError{ diplomat_result_raw_out_value.err })));
diplomat_result_out_value.set_err((std::move(static_cast<ICU4XLocaleError>(diplomat_result_raw_out_value.err))));
}
return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string));
}
Expand Down
6 changes: 3 additions & 3 deletions ffi/cpp/include/ICU4XLocaleCanonicalizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ inline std::optional<ICU4XLocaleCanonicalizer> ICU4XLocaleCanonicalizer::create(
return diplomat_optional_out_value;
}
inline ICU4XCanonicalizationResult ICU4XLocaleCanonicalizer::canonicalize(ICU4XLocale& locale) {
return ICU4XCanonicalizationResult{ capi::ICU4XLocaleCanonicalizer_canonicalize(this->inner.get(), locale.AsFFIMut()) };
return static_cast<ICU4XCanonicalizationResult>(capi::ICU4XLocaleCanonicalizer_canonicalize(this->inner.get(), locale.AsFFIMut()));
}
inline ICU4XCanonicalizationResult ICU4XLocaleCanonicalizer::maximize(ICU4XLocale& locale) {
return ICU4XCanonicalizationResult{ capi::ICU4XLocaleCanonicalizer_maximize(this->inner.get(), locale.AsFFIMut()) };
return static_cast<ICU4XCanonicalizationResult>(capi::ICU4XLocaleCanonicalizer_maximize(this->inner.get(), locale.AsFFIMut()));
}
inline ICU4XCanonicalizationResult ICU4XLocaleCanonicalizer::minimize(ICU4XLocale& locale) {
return ICU4XCanonicalizationResult{ capi::ICU4XLocaleCanonicalizer_minimize(this->inner.get(), locale.AsFFIMut()) };
return static_cast<ICU4XCanonicalizationResult>(capi::ICU4XLocaleCanonicalizer_minimize(this->inner.get(), locale.AsFFIMut()));
}
#endif
2 changes: 1 addition & 1 deletion ffi/cpp/include/ICU4XPluralRules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ inline ICU4XCreatePluralRulesResult ICU4XPluralRules::create(const ICU4XLocale&
return ICU4XCreatePluralRulesResult{ .rules = std::move(diplomat_optional_out_value_rules), .success = std::move(diplomat_raw_struct_out_value.success) };
}
inline ICU4XPluralCategory ICU4XPluralRules::select(const ICU4XPluralOperands& op) {
return ICU4XPluralCategory{ capi::ICU4XPluralRules_select(this->inner.get(), (capi::ICU4XPluralOperands*) &op) };
return static_cast<ICU4XPluralCategory>(capi::ICU4XPluralRules_select(this->inner.get(), (capi::ICU4XPluralOperands*) &op));
}
inline ICU4XPluralCategories ICU4XPluralRules::categories() {
capi::ICU4XPluralCategories diplomat_raw_struct_out_value = capi::ICU4XPluralRules_categories(this->inner.get());
Expand Down
Loading

0 comments on commit b66b237

Please sign in to comment.