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

Dramatically improving the build time of web-sys #2012

Merged
merged 38 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c3326d0
Pre-generating web-sys
Pauan Feb 23, 2020
ade831d
Fixing build errors
Pauan Feb 23, 2020
8cec24a
Minor refactor for the unit tests
Pauan Feb 23, 2020
a709ef6
Changing to generate #[wasm_bindgen} annotations
Pauan Feb 28, 2020
b8bca6e
Fixing code generation
Pauan Feb 28, 2020
48396f6
Adding in main bin to wasm-bindgen-webidl
Pauan Feb 28, 2020
1b58b99
Fixing more problems
Pauan Feb 28, 2020
f3c017b
Adding in support for unstable APIs
Pauan Feb 28, 2020
ceb00c2
Fixing bug with code generation
Pauan Feb 28, 2020
8f68e5a
More code generation fixes
Pauan Feb 28, 2020
52b7afd
Improving the webidl program
Pauan Feb 28, 2020
8fe9fe6
Removing unnecessary cfg from the generated code
Pauan Feb 28, 2020
28dc2c8
Splitting doc comments onto separate lines
Pauan Feb 28, 2020
7d74f92
Improving the generation for unstable features
Pauan Feb 28, 2020
c2899d5
Adding in support for string values in enums
Pauan Feb 28, 2020
304161f
Now runs rustfmt on the mod.rs file
Pauan Feb 28, 2020
e887214
Fixing codegen for constructors
Pauan Feb 28, 2020
48cf3f9
Fixing webidl-tests
Pauan Feb 29, 2020
731cdae
Fixing build errors
Pauan Feb 29, 2020
81437b5
Another fix for build errors
Pauan Feb 29, 2020
e03aab1
Renaming typescript_name to typescript_type
Pauan Feb 29, 2020
52c1e35
Adding in docs for typescript_type
Pauan Feb 29, 2020
8766dc9
Adding in CI script to verify that web-sys is up to date
Pauan Feb 29, 2020
7035cfb
Fixing CI script
Pauan Feb 29, 2020
6a0abe4
Fixing CI script
Pauan Feb 29, 2020
02fb6d5
Don't suppress git diff output
alexcrichton Mar 2, 2020
8e0aff6
Remove duplicate definitions of `Location`
alexcrichton Mar 2, 2020
737cf02
Regenerate webidl
alexcrichton Mar 2, 2020
7825911
Try to get the git diff command right
alexcrichton Mar 2, 2020
748be54
Handle named constructors in WebIDL
alexcrichton Mar 2, 2020
468e9d3
Remove stray rustfmt.toml
alexcrichton Mar 2, 2020
4d1cdd6
Add back NamedConstructorBar definition in tests
alexcrichton Mar 2, 2020
712ef70
Run stable rustfmt over everything
alexcrichton Mar 2, 2020
044f3cb
Don't run Cargo in a build script
alexcrichton Mar 2, 2020
6b3596f
Fixup generated code
alexcrichton Mar 2, 2020
9b01093
Running web-sys checks on stable
Pauan Mar 2, 2020
25f0fbc
Improving the code generation a little
Pauan Mar 2, 2020
36523ff
Running rustfmt
Pauan Mar 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ jobs:
env:
RUSTFLAGS: --cfg=web_sys_unstable_apis

- job: check_web_sys
displayName: "Verify that web-sys is compiled correctly"
steps:
- template: ci/azure-install-rust.yml
- script: cd crates/web-sys && cargo run --release --package wasm-bindgen-webidl webidls src/features
- script: git diff --exit-code

- job: test_js_sys
displayName: "Run js-sys crate tests"
steps:
Expand Down
72 changes: 13 additions & 59 deletions crates/backend/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@ pub struct Program {
pub enums: Vec<Enum>,
/// rust structs
pub structs: Vec<Struct>,
/// rust consts
pub consts: Vec<Const>,
/// "dictionaries", generated for WebIDL, which are basically just "typed
/// objects" in the sense that they represent a JS object with a particular
/// shape in JIT parlance.
pub dictionaries: Vec<Dictionary>,
/// custom typescript sections to be included in the definition file
pub typescript_custom_sections: Vec<String>,
/// Inline JS snippets
pub inline_js: Vec<String>,
}

impl Program {
/// Returns true if the Program is empty
pub fn is_empty(&self) -> bool {
self.exports.is_empty()
&& self.imports.is_empty()
&& self.enums.is_empty()
&& self.structs.is_empty()
&& self.typescript_custom_sections.is_empty()
&& self.inline_js.is_empty()
}
}

/// A rust to js interface. Allows interaction with rust objects/functions
/// from javascript.
#[cfg_attr(feature = "extra-traits", derive(Debug))]
Expand All @@ -51,8 +57,6 @@ pub struct Export {
/// Whether or not this function should be flagged as the wasm start
/// function.
pub start: bool,
/// Whether the API is unstable. This is only used internally.
pub unstable_api: bool,
}

/// The 3 types variations of `self`.
Expand All @@ -73,7 +77,6 @@ pub struct Import {
pub module: ImportModule,
pub js_namespace: Option<Ident>,
pub kind: ImportKind,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug))]
Expand Down Expand Up @@ -129,7 +132,6 @@ pub struct ImportFunction {
pub kind: ImportFunctionKind,
pub shim: Ident,
pub doc_comment: Option<String>,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
Expand Down Expand Up @@ -185,8 +187,7 @@ pub struct ImportType {
pub rust_name: Ident,
pub js_name: String,
pub attrs: Vec<syn::Attribute>,
pub typescript_name: Option<String>,
pub unstable_api: bool,
pub typescript_type: Option<String>,
pub doc_comment: Option<String>,
pub instanceof_shim: String,
pub is_type_of: Option<syn::Expr>,
Expand All @@ -207,8 +208,6 @@ pub struct ImportEnum {
pub variant_values: Vec<String>,
/// Attributes to apply to the Rust enum
pub rust_attrs: Vec<syn::Attribute>,
/// Whether the enum is part of an unstable WebIDL
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug))]
Expand Down Expand Up @@ -244,7 +243,6 @@ pub struct StructField {
pub getter: Ident,
pub setter: Ident,
pub comments: Vec<String>,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
Expand All @@ -254,7 +252,6 @@ pub struct Enum {
pub variants: Vec<Variant>,
pub comments: Vec<String>,
pub hole: u32,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
Expand All @@ -279,49 +276,6 @@ pub enum TypeLocation {
ExportRet,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq))]
#[derive(Clone)]
pub struct Const {
pub vis: syn::Visibility,
pub name: Ident,
pub class: Option<Ident>,
pub ty: syn::Type,
pub value: ConstValue,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq))]
#[derive(Clone)]
/// same as webidl::ast::ConstValue
pub enum ConstValue {
BooleanLiteral(bool),
FloatLiteral(f64),
SignedIntegerLiteral(i64),
UnsignedIntegerLiteral(u64),
Null,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
#[derive(Clone)]
pub struct Dictionary {
pub name: Ident,
pub fields: Vec<DictionaryField>,
pub ctor: bool,
pub doc_comment: Option<String>,
pub ctor_doc_comment: Option<String>,
pub unstable_api: bool,
}

#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
#[derive(Clone)]
pub struct DictionaryField {
pub rust_name: Ident,
pub js_name: String,
pub required: bool,
pub ty: syn::Type,
pub doc_comment: Option<String>,
}

impl Export {
/// Mangles a rust -> javascript export, so that the created Ident will be unique over function
/// name and class name, if the function belongs to a javascript class.
Expand Down
Loading