Add wasm sample for CI (#2372)

* Add wasm sample for CI

* Add wasm sample for CI

* Add wasm sample for CI
This commit is contained in:
Jonathan Turner
2020-08-19 07:34:05 +12:00
committed by GitHub
parent 738541f727
commit 43e061f8c6
17 changed files with 492 additions and 17 deletions

View File

@ -11,7 +11,6 @@ use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::collections::HashMap;
use std::error::Error;
use std::io::Read;
#[derive(Serialize, Deserialize, Debug)]
pub struct HtmlThemes {
@ -183,6 +182,7 @@ fn get_theme_from_asset_file(
Ok(convert_html_theme_to_hash_map(is_dark, th))
}
#[allow(unused_variables)]
fn get_asset_by_name_as_html_themes(
zip_name: &str,
json_name: &str,
@ -194,11 +194,20 @@ fn get_asset_by_name_as_html_themes(
Cow::Owned(bytes) => bytes,
};
let reader = std::io::Cursor::new(asset);
let mut archive = zip::ZipArchive::new(reader)?;
let mut zip_file = archive.by_name(json_name)?;
let mut contents = String::new();
zip_file.read_to_string(&mut contents)?;
Ok(serde_json::from_str(&contents)?)
#[cfg(feature = "zip")]
{
use std::io::Read;
let mut archive = zip::ZipArchive::new(reader)?;
let mut zip_file = archive.by_name(json_name)?;
let mut contents = String::new();
zip_file.read_to_string(&mut contents)?;
Ok(serde_json::from_str(&contents)?)
}
#[cfg(not(feature = "zip"))]
{
let th = HtmlThemes::default();
Ok(th)
}
}
None => {
let th = HtmlThemes::default();

View File

@ -76,6 +76,7 @@ impl Host for BasicHost {
}
}
#[allow(unused_variables)]
fn vars(&mut self) -> Vec<(String, String)> {
#[cfg(not(target_arch = "wasm32"))]
{
@ -88,6 +89,7 @@ impl Host for BasicHost {
}
}
#[allow(unused_variables)]
fn env_get(&mut self, key: OsString) -> Option<OsString> {
#[cfg(not(target_arch = "wasm32"))]
{
@ -99,6 +101,7 @@ impl Host for BasicHost {
}
}
#[allow(unused_variables)]
fn env_set(&mut self, key: OsString, value: OsString) {
#[cfg(not(target_arch = "wasm32"))]
{
@ -106,6 +109,7 @@ impl Host for BasicHost {
}
}
#[allow(unused_variables)]
fn env_rm(&mut self, key: OsString) {
#[cfg(not(target_arch = "wasm32"))]
{

View File

@ -261,7 +261,7 @@ fn is_executable(file: &DirEntry) -> bool {
}
#[cfg(target_arch = "wasm32")]
fn is_executable(file: &DirEntry) -> bool {
fn is_executable(_file: &DirEntry) -> bool {
false
}