diff --git a/Cargo.toml b/Cargo.toml index fdbaabd..3f875f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,47 +1,9 @@ -[package] -name = "grass" -version = "0.12.1" -description = "A Sass compiler written purely in Rust" -readme = "README.md" -license = "MIT" -categories = ["command-line-utilities", "web-programming"] -keywords = ["scss", "sass", "css", "web"] -repository = "https://github.com/connorskees/grass" -authors = ["ConnorSkees <39542938+ConnorSkees@users.noreply.github.com>"] -edition = "2021" -include = ["src", "Cargo.toml", "README.md", "CHANGELOG.md", "Cargo.lock", "LICENSE"] -default-run = "grass" - -[[bin]] -name = "grass" -path = "src/main.rs" -required-features = ["commandline"] - -[lib] -name = "grass" -path = "src/lib.rs" -# crate-type = ["cdylib", "rlib"] -bench = false - -[dependencies] -grass_internal = { path = "./grass_internal", version = "0.12.1" } -include_sass = { path = "./include_sass", version = "0.12.1", optional = true } -clap = { version = "2.34.0", optional = true } - -[features] -# todo: no commandline by default -default = ["commandline", "random"] -# Option (enabled by default): build a binary using clap -commandline = ["clap"] -random = ["grass_internal/random"] -wasm-exports = ["grass_internal/wasm-exports"] -# Option: include the proc macro `include_sass!` -macro = ["include_sass"] -nightly = ["include_sass/nightly"] - -[dev-dependencies] -tempfile = "3.3.0" -paste = "1.0.3" +[workspace] +members = [ + "crates/compiler", + "crates/include_sass", + "crates/lib", +] [profile.release] debug = true diff --git a/grass_internal/Cargo.toml b/crates/compiler/Cargo.toml similarity index 95% rename from grass_internal/Cargo.toml rename to crates/compiler/Cargo.toml index b2e115f..05098ad 100644 --- a/grass_internal/Cargo.toml +++ b/crates/compiler/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "grass_internal" +name = "compiler" version = "0.12.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -name = "grass_internal" +name = "compiler" path = "src/lib.rs" # crate-type = ["cdylib", "rlib"] bench = false diff --git a/crates/compiler/input.scss b/crates/compiler/input.scss new file mode 100644 index 0000000..0ac7fce --- /dev/null +++ b/crates/compiler/input.scss @@ -0,0 +1,3 @@ +a { + color: red; +} \ No newline at end of file diff --git a/grass_internal/src/ast/args.rs b/crates/compiler/src/ast/args.rs similarity index 100% rename from grass_internal/src/ast/args.rs rename to crates/compiler/src/ast/args.rs diff --git a/grass_internal/src/ast/css.rs b/crates/compiler/src/ast/css.rs similarity index 100% rename from grass_internal/src/ast/css.rs rename to crates/compiler/src/ast/css.rs diff --git a/grass_internal/src/ast/expr.rs b/crates/compiler/src/ast/expr.rs similarity index 100% rename from grass_internal/src/ast/expr.rs rename to crates/compiler/src/ast/expr.rs diff --git a/grass_internal/src/ast/interpolation.rs b/crates/compiler/src/ast/interpolation.rs similarity index 100% rename from grass_internal/src/ast/interpolation.rs rename to crates/compiler/src/ast/interpolation.rs diff --git a/grass_internal/src/ast/media.rs b/crates/compiler/src/ast/media.rs similarity index 100% rename from grass_internal/src/ast/media.rs rename to crates/compiler/src/ast/media.rs diff --git a/grass_internal/src/ast/mixin.rs b/crates/compiler/src/ast/mixin.rs similarity index 100% rename from grass_internal/src/ast/mixin.rs rename to crates/compiler/src/ast/mixin.rs diff --git a/grass_internal/src/ast/mod.rs b/crates/compiler/src/ast/mod.rs similarity index 100% rename from grass_internal/src/ast/mod.rs rename to crates/compiler/src/ast/mod.rs diff --git a/grass_internal/src/ast/stmt.rs b/crates/compiler/src/ast/stmt.rs similarity index 100% rename from grass_internal/src/ast/stmt.rs rename to crates/compiler/src/ast/stmt.rs diff --git a/grass_internal/src/ast/style.rs b/crates/compiler/src/ast/style.rs similarity index 100% rename from grass_internal/src/ast/style.rs rename to crates/compiler/src/ast/style.rs diff --git a/grass_internal/src/ast/unknown.rs b/crates/compiler/src/ast/unknown.rs similarity index 100% rename from grass_internal/src/ast/unknown.rs rename to crates/compiler/src/ast/unknown.rs diff --git a/grass_internal/src/builtin/functions/color/hsl.rs b/crates/compiler/src/builtin/functions/color/hsl.rs similarity index 100% rename from grass_internal/src/builtin/functions/color/hsl.rs rename to crates/compiler/src/builtin/functions/color/hsl.rs diff --git a/grass_internal/src/builtin/functions/color/hwb.rs b/crates/compiler/src/builtin/functions/color/hwb.rs similarity index 100% rename from grass_internal/src/builtin/functions/color/hwb.rs rename to crates/compiler/src/builtin/functions/color/hwb.rs diff --git a/grass_internal/src/builtin/functions/color/mod.rs b/crates/compiler/src/builtin/functions/color/mod.rs similarity index 100% rename from grass_internal/src/builtin/functions/color/mod.rs rename to crates/compiler/src/builtin/functions/color/mod.rs diff --git a/grass_internal/src/builtin/functions/color/opacity.rs b/crates/compiler/src/builtin/functions/color/opacity.rs similarity index 100% rename from grass_internal/src/builtin/functions/color/opacity.rs rename to crates/compiler/src/builtin/functions/color/opacity.rs diff --git a/grass_internal/src/builtin/functions/color/other.rs b/crates/compiler/src/builtin/functions/color/other.rs similarity index 100% rename from grass_internal/src/builtin/functions/color/other.rs rename to crates/compiler/src/builtin/functions/color/other.rs diff --git a/grass_internal/src/builtin/functions/color/rgb.rs b/crates/compiler/src/builtin/functions/color/rgb.rs similarity index 100% rename from grass_internal/src/builtin/functions/color/rgb.rs rename to crates/compiler/src/builtin/functions/color/rgb.rs diff --git a/grass_internal/src/builtin/functions/list.rs b/crates/compiler/src/builtin/functions/list.rs similarity index 100% rename from grass_internal/src/builtin/functions/list.rs rename to crates/compiler/src/builtin/functions/list.rs diff --git a/grass_internal/src/builtin/functions/macros.rs b/crates/compiler/src/builtin/functions/macros.rs similarity index 100% rename from grass_internal/src/builtin/functions/macros.rs rename to crates/compiler/src/builtin/functions/macros.rs diff --git a/grass_internal/src/builtin/functions/map.rs b/crates/compiler/src/builtin/functions/map.rs similarity index 100% rename from grass_internal/src/builtin/functions/map.rs rename to crates/compiler/src/builtin/functions/map.rs diff --git a/grass_internal/src/builtin/functions/math.rs b/crates/compiler/src/builtin/functions/math.rs similarity index 100% rename from grass_internal/src/builtin/functions/math.rs rename to crates/compiler/src/builtin/functions/math.rs diff --git a/grass_internal/src/builtin/functions/meta.rs b/crates/compiler/src/builtin/functions/meta.rs similarity index 100% rename from grass_internal/src/builtin/functions/meta.rs rename to crates/compiler/src/builtin/functions/meta.rs diff --git a/grass_internal/src/builtin/functions/mod.rs b/crates/compiler/src/builtin/functions/mod.rs similarity index 100% rename from grass_internal/src/builtin/functions/mod.rs rename to crates/compiler/src/builtin/functions/mod.rs diff --git a/grass_internal/src/builtin/functions/selector.rs b/crates/compiler/src/builtin/functions/selector.rs similarity index 100% rename from grass_internal/src/builtin/functions/selector.rs rename to crates/compiler/src/builtin/functions/selector.rs diff --git a/grass_internal/src/builtin/functions/string.rs b/crates/compiler/src/builtin/functions/string.rs similarity index 100% rename from grass_internal/src/builtin/functions/string.rs rename to crates/compiler/src/builtin/functions/string.rs diff --git a/grass_internal/src/builtin/mod.rs b/crates/compiler/src/builtin/mod.rs similarity index 100% rename from grass_internal/src/builtin/mod.rs rename to crates/compiler/src/builtin/mod.rs diff --git a/grass_internal/src/builtin/modules/color.rs b/crates/compiler/src/builtin/modules/color.rs similarity index 100% rename from grass_internal/src/builtin/modules/color.rs rename to crates/compiler/src/builtin/modules/color.rs diff --git a/grass_internal/src/builtin/modules/list.rs b/crates/compiler/src/builtin/modules/list.rs similarity index 100% rename from grass_internal/src/builtin/modules/list.rs rename to crates/compiler/src/builtin/modules/list.rs diff --git a/grass_internal/src/builtin/modules/map.rs b/crates/compiler/src/builtin/modules/map.rs similarity index 100% rename from grass_internal/src/builtin/modules/map.rs rename to crates/compiler/src/builtin/modules/map.rs diff --git a/grass_internal/src/builtin/modules/math.rs b/crates/compiler/src/builtin/modules/math.rs similarity index 100% rename from grass_internal/src/builtin/modules/math.rs rename to crates/compiler/src/builtin/modules/math.rs diff --git a/grass_internal/src/builtin/modules/meta.rs b/crates/compiler/src/builtin/modules/meta.rs similarity index 100% rename from grass_internal/src/builtin/modules/meta.rs rename to crates/compiler/src/builtin/modules/meta.rs diff --git a/grass_internal/src/builtin/modules/mod.rs b/crates/compiler/src/builtin/modules/mod.rs similarity index 100% rename from grass_internal/src/builtin/modules/mod.rs rename to crates/compiler/src/builtin/modules/mod.rs diff --git a/grass_internal/src/builtin/modules/selector.rs b/crates/compiler/src/builtin/modules/selector.rs similarity index 100% rename from grass_internal/src/builtin/modules/selector.rs rename to crates/compiler/src/builtin/modules/selector.rs diff --git a/grass_internal/src/builtin/modules/string.rs b/crates/compiler/src/builtin/modules/string.rs similarity index 100% rename from grass_internal/src/builtin/modules/string.rs rename to crates/compiler/src/builtin/modules/string.rs diff --git a/grass_internal/src/color/mod.rs b/crates/compiler/src/color/mod.rs similarity index 100% rename from grass_internal/src/color/mod.rs rename to crates/compiler/src/color/mod.rs diff --git a/grass_internal/src/color/name.rs b/crates/compiler/src/color/name.rs similarity index 100% rename from grass_internal/src/color/name.rs rename to crates/compiler/src/color/name.rs diff --git a/grass_internal/src/common.rs b/crates/compiler/src/common.rs similarity index 100% rename from grass_internal/src/common.rs rename to crates/compiler/src/common.rs diff --git a/grass_internal/src/context_flags.rs b/crates/compiler/src/context_flags.rs similarity index 100% rename from grass_internal/src/context_flags.rs rename to crates/compiler/src/context_flags.rs diff --git a/grass_internal/src/error.rs b/crates/compiler/src/error.rs similarity index 100% rename from grass_internal/src/error.rs rename to crates/compiler/src/error.rs diff --git a/grass_internal/src/evaluate/bin_op.rs b/crates/compiler/src/evaluate/bin_op.rs similarity index 100% rename from grass_internal/src/evaluate/bin_op.rs rename to crates/compiler/src/evaluate/bin_op.rs diff --git a/grass_internal/src/evaluate/css_tree.rs b/crates/compiler/src/evaluate/css_tree.rs similarity index 100% rename from grass_internal/src/evaluate/css_tree.rs rename to crates/compiler/src/evaluate/css_tree.rs diff --git a/grass_internal/src/evaluate/env.rs b/crates/compiler/src/evaluate/env.rs similarity index 100% rename from grass_internal/src/evaluate/env.rs rename to crates/compiler/src/evaluate/env.rs diff --git a/grass_internal/src/evaluate/mod.rs b/crates/compiler/src/evaluate/mod.rs similarity index 100% rename from grass_internal/src/evaluate/mod.rs rename to crates/compiler/src/evaluate/mod.rs diff --git a/grass_internal/src/evaluate/scope.rs b/crates/compiler/src/evaluate/scope.rs similarity index 100% rename from grass_internal/src/evaluate/scope.rs rename to crates/compiler/src/evaluate/scope.rs diff --git a/grass_internal/src/evaluate/visitor.rs b/crates/compiler/src/evaluate/visitor.rs similarity index 100% rename from grass_internal/src/evaluate/visitor.rs rename to crates/compiler/src/evaluate/visitor.rs diff --git a/grass_internal/src/fs.rs b/crates/compiler/src/fs.rs similarity index 100% rename from grass_internal/src/fs.rs rename to crates/compiler/src/fs.rs diff --git a/grass_internal/src/interner.rs b/crates/compiler/src/interner.rs similarity index 100% rename from grass_internal/src/interner.rs rename to crates/compiler/src/interner.rs diff --git a/grass_internal/src/lexer.rs b/crates/compiler/src/lexer.rs similarity index 100% rename from grass_internal/src/lexer.rs rename to crates/compiler/src/lexer.rs diff --git a/grass_internal/src/lib.rs b/crates/compiler/src/lib.rs similarity index 98% rename from grass_internal/src/lib.rs rename to crates/compiler/src/lib.rs index a420266..fc247bc 100644 --- a/grass_internal/src/lib.rs +++ b/crates/compiler/src/lib.rs @@ -14,6 +14,7 @@ implementation. ## Use as library ``` +# use compiler as grass; fn main() -> Result<(), Box> { let css = grass::from_string( "a { b { color: &; } }".to_owned(), @@ -186,6 +187,7 @@ fn from_string_with_file_name>( /// n.b. `grass` does not currently support files or paths that are not valid UTF-8 /// /// ``` +/// # use compiler as grass; /// fn main() -> Result<(), Box> { /// let css = grass::from_path("input.scss", &grass::Options::default())?; /// Ok(()) @@ -199,6 +201,7 @@ pub fn from_path>(p: P, options: &Options) -> Result { /// Compile CSS from a string /// /// ``` +/// # use compiler as grass; /// fn main() -> Result<(), Box> { /// let css = grass::from_string("a { b { color: &; } }".to_string(), &grass::Options::default())?; /// assert_eq!(css, "a b {\n color: a b;\n}\n"); diff --git a/grass_internal/src/options.rs b/crates/compiler/src/options.rs similarity index 100% rename from grass_internal/src/options.rs rename to crates/compiler/src/options.rs diff --git a/grass_internal/src/parse/at_root_query.rs b/crates/compiler/src/parse/at_root_query.rs similarity index 100% rename from grass_internal/src/parse/at_root_query.rs rename to crates/compiler/src/parse/at_root_query.rs diff --git a/grass_internal/src/parse/base.rs b/crates/compiler/src/parse/base.rs similarity index 100% rename from grass_internal/src/parse/base.rs rename to crates/compiler/src/parse/base.rs diff --git a/grass_internal/src/parse/css.rs b/crates/compiler/src/parse/css.rs similarity index 100% rename from grass_internal/src/parse/css.rs rename to crates/compiler/src/parse/css.rs diff --git a/grass_internal/src/parse/keyframes.rs b/crates/compiler/src/parse/keyframes.rs similarity index 100% rename from grass_internal/src/parse/keyframes.rs rename to crates/compiler/src/parse/keyframes.rs diff --git a/grass_internal/src/parse/media_query.rs b/crates/compiler/src/parse/media_query.rs similarity index 100% rename from grass_internal/src/parse/media_query.rs rename to crates/compiler/src/parse/media_query.rs diff --git a/grass_internal/src/parse/mod.rs b/crates/compiler/src/parse/mod.rs similarity index 100% rename from grass_internal/src/parse/mod.rs rename to crates/compiler/src/parse/mod.rs diff --git a/grass_internal/src/parse/sass.rs b/crates/compiler/src/parse/sass.rs similarity index 100% rename from grass_internal/src/parse/sass.rs rename to crates/compiler/src/parse/sass.rs diff --git a/grass_internal/src/parse/scss.rs b/crates/compiler/src/parse/scss.rs similarity index 100% rename from grass_internal/src/parse/scss.rs rename to crates/compiler/src/parse/scss.rs diff --git a/grass_internal/src/parse/stylesheet.rs b/crates/compiler/src/parse/stylesheet.rs similarity index 100% rename from grass_internal/src/parse/stylesheet.rs rename to crates/compiler/src/parse/stylesheet.rs diff --git a/grass_internal/src/parse/value.rs b/crates/compiler/src/parse/value.rs similarity index 100% rename from grass_internal/src/parse/value.rs rename to crates/compiler/src/parse/value.rs diff --git a/grass_internal/src/selector/attribute.rs b/crates/compiler/src/selector/attribute.rs similarity index 100% rename from grass_internal/src/selector/attribute.rs rename to crates/compiler/src/selector/attribute.rs diff --git a/grass_internal/src/selector/common.rs b/crates/compiler/src/selector/common.rs similarity index 100% rename from grass_internal/src/selector/common.rs rename to crates/compiler/src/selector/common.rs diff --git a/grass_internal/src/selector/complex.rs b/crates/compiler/src/selector/complex.rs similarity index 100% rename from grass_internal/src/selector/complex.rs rename to crates/compiler/src/selector/complex.rs diff --git a/grass_internal/src/selector/compound.rs b/crates/compiler/src/selector/compound.rs similarity index 100% rename from grass_internal/src/selector/compound.rs rename to crates/compiler/src/selector/compound.rs diff --git a/grass_internal/src/selector/extend/extended_selector.rs b/crates/compiler/src/selector/extend/extended_selector.rs similarity index 100% rename from grass_internal/src/selector/extend/extended_selector.rs rename to crates/compiler/src/selector/extend/extended_selector.rs diff --git a/grass_internal/src/selector/extend/extension.rs b/crates/compiler/src/selector/extend/extension.rs similarity index 100% rename from grass_internal/src/selector/extend/extension.rs rename to crates/compiler/src/selector/extend/extension.rs diff --git a/grass_internal/src/selector/extend/functions.rs b/crates/compiler/src/selector/extend/functions.rs similarity index 100% rename from grass_internal/src/selector/extend/functions.rs rename to crates/compiler/src/selector/extend/functions.rs diff --git a/grass_internal/src/selector/extend/merged.rs b/crates/compiler/src/selector/extend/merged.rs similarity index 100% rename from grass_internal/src/selector/extend/merged.rs rename to crates/compiler/src/selector/extend/merged.rs diff --git a/grass_internal/src/selector/extend/mod.rs b/crates/compiler/src/selector/extend/mod.rs similarity index 100% rename from grass_internal/src/selector/extend/mod.rs rename to crates/compiler/src/selector/extend/mod.rs diff --git a/grass_internal/src/selector/extend/rule.rs b/crates/compiler/src/selector/extend/rule.rs similarity index 100% rename from grass_internal/src/selector/extend/rule.rs rename to crates/compiler/src/selector/extend/rule.rs diff --git a/grass_internal/src/selector/list.rs b/crates/compiler/src/selector/list.rs similarity index 100% rename from grass_internal/src/selector/list.rs rename to crates/compiler/src/selector/list.rs diff --git a/grass_internal/src/selector/mod.rs b/crates/compiler/src/selector/mod.rs similarity index 100% rename from grass_internal/src/selector/mod.rs rename to crates/compiler/src/selector/mod.rs diff --git a/grass_internal/src/selector/parse.rs b/crates/compiler/src/selector/parse.rs similarity index 100% rename from grass_internal/src/selector/parse.rs rename to crates/compiler/src/selector/parse.rs diff --git a/grass_internal/src/selector/simple.rs b/crates/compiler/src/selector/simple.rs similarity index 100% rename from grass_internal/src/selector/simple.rs rename to crates/compiler/src/selector/simple.rs diff --git a/grass_internal/src/serializer.rs b/crates/compiler/src/serializer.rs similarity index 100% rename from grass_internal/src/serializer.rs rename to crates/compiler/src/serializer.rs diff --git a/grass_internal/src/unit/conversion.rs b/crates/compiler/src/unit/conversion.rs similarity index 100% rename from grass_internal/src/unit/conversion.rs rename to crates/compiler/src/unit/conversion.rs diff --git a/grass_internal/src/unit/mod.rs b/crates/compiler/src/unit/mod.rs similarity index 100% rename from grass_internal/src/unit/mod.rs rename to crates/compiler/src/unit/mod.rs diff --git a/grass_internal/src/utils/chars.rs b/crates/compiler/src/utils/chars.rs similarity index 100% rename from grass_internal/src/utils/chars.rs rename to crates/compiler/src/utils/chars.rs diff --git a/grass_internal/src/utils/map_view.rs b/crates/compiler/src/utils/map_view.rs similarity index 100% rename from grass_internal/src/utils/map_view.rs rename to crates/compiler/src/utils/map_view.rs diff --git a/grass_internal/src/utils/mod.rs b/crates/compiler/src/utils/mod.rs similarity index 100% rename from grass_internal/src/utils/mod.rs rename to crates/compiler/src/utils/mod.rs diff --git a/grass_internal/src/utils/strings.rs b/crates/compiler/src/utils/strings.rs similarity index 100% rename from grass_internal/src/utils/strings.rs rename to crates/compiler/src/utils/strings.rs diff --git a/grass_internal/src/value/arglist.rs b/crates/compiler/src/value/arglist.rs similarity index 100% rename from grass_internal/src/value/arglist.rs rename to crates/compiler/src/value/arglist.rs diff --git a/grass_internal/src/value/calculation.rs b/crates/compiler/src/value/calculation.rs similarity index 100% rename from grass_internal/src/value/calculation.rs rename to crates/compiler/src/value/calculation.rs diff --git a/grass_internal/src/value/map.rs b/crates/compiler/src/value/map.rs similarity index 100% rename from grass_internal/src/value/map.rs rename to crates/compiler/src/value/map.rs diff --git a/grass_internal/src/value/mod.rs b/crates/compiler/src/value/mod.rs similarity index 100% rename from grass_internal/src/value/mod.rs rename to crates/compiler/src/value/mod.rs diff --git a/grass_internal/src/value/number.rs b/crates/compiler/src/value/number.rs similarity index 100% rename from grass_internal/src/value/number.rs rename to crates/compiler/src/value/number.rs diff --git a/grass_internal/src/value/sass_function.rs b/crates/compiler/src/value/sass_function.rs similarity index 100% rename from grass_internal/src/value/sass_function.rs rename to crates/compiler/src/value/sass_function.rs diff --git a/grass_internal/src/value/sass_number.rs b/crates/compiler/src/value/sass_number.rs similarity index 100% rename from grass_internal/src/value/sass_number.rs rename to crates/compiler/src/value/sass_number.rs diff --git a/include_sass/Cargo.toml b/crates/include_sass/Cargo.toml similarity index 83% rename from include_sass/Cargo.toml rename to crates/include_sass/Cargo.toml index 10bb742..69c89a8 100644 --- a/include_sass/Cargo.toml +++ b/crates/include_sass/Cargo.toml @@ -8,7 +8,7 @@ proc-macro = true [dependencies] syn = { version = "1.0.103", default-features = false } -grass_internal = { path = "../grass_internal" } +compiler = { path = "../compiler" } quote = { version = "1.0.23", default-features = false } [features] diff --git a/include_sass/src/lib.rs b/crates/include_sass/src/lib.rs similarity index 89% rename from include_sass/src/lib.rs rename to crates/include_sass/src/lib.rs index ca83277..7274b95 100644 --- a/include_sass/src/lib.rs +++ b/crates/include_sass/src/lib.rs @@ -2,7 +2,7 @@ use std::{cell::RefCell, collections::HashSet, path::PathBuf}; -use grass_internal::StdFs; +use compiler::StdFs; use proc_macro::TokenStream; use quote::format_ident; use syn::{parse_macro_input, LitStr}; @@ -12,10 +12,10 @@ use quote::__private::TokenStream as TokenStream2; #[derive(Debug)] struct FileTracker<'a> { files: RefCell>, - fs: &'a dyn grass_internal::Fs, + fs: &'a dyn compiler::Fs, } -impl<'a> grass_internal::Fs for FileTracker<'a> { +impl<'a> compiler::Fs for FileTracker<'a> { fn is_dir(&self, path: &std::path::Path) -> bool { #[cfg(feature = "nightly")] if let Ok(p) = std::fs::canonicalize(path) { @@ -88,7 +88,7 @@ fn finish(css: String, files: &HashSet) -> TokenStream { pub fn include_sass(item: TokenStream) -> TokenStream { let input = parse_macro_input!(item as LitStr); - let options = grass_internal::Options::default(); + let options = compiler::Options::default(); let fs = FileTracker { files: RefCell::new(HashSet::new()), @@ -97,11 +97,9 @@ pub fn include_sass(item: TokenStream) -> TokenStream { let value = input.value(); - let css = match grass_internal::from_path( + let css = match compiler::from_path( value, - &options - .fs(&fs) - .style(grass_internal::OutputStyle::Compressed), + &options.fs(&fs).style(compiler::OutputStyle::Compressed), ) { Ok(css) => css, Err(e) => { diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml new file mode 100644 index 0000000..2376d7f --- /dev/null +++ b/crates/lib/Cargo.toml @@ -0,0 +1,50 @@ +[package] +name = "grass" +version = "0.12.1" +description = "A Sass compiler written purely in Rust" +readme = "README.md" +license = "MIT" +categories = ["command-line-utilities", "web-programming"] +keywords = ["scss", "sass", "css", "web"] +repository = "https://github.com/connorskees/grass" +authors = ["ConnorSkees <39542938+ConnorSkees@users.noreply.github.com>"] +edition = "2021" +include = ["src", "Cargo.toml", "README.md", "CHANGELOG.md", "Cargo.lock", "LICENSE"] +default-run = "grass" + +[[bin]] +name = "grass" +path = "src/main.rs" +required-features = ["commandline"] + +[lib] +name = "grass" +path = "src/lib.rs" +# crate-type = ["cdylib", "rlib"] +bench = false + +[dependencies] +compiler = { path = "../compiler", version = "0.12.1" } +include_sass = { path = "../include_sass", version = "0.12.1", optional = true } +clap = { version = "2.34.0", optional = true } + +[features] +# todo: no commandline by default +default = ["commandline", "random"] +# Option (enabled by default): build a binary using clap +commandline = ["clap"] +random = ["compiler/random"] +wasm-exports = ["compiler/wasm-exports"] +# Option: include the proc macro `include_sass!` +macro = ["include_sass"] +nightly = ["include_sass/nightly"] + +[dev-dependencies] +tempfile = "3.3.0" +paste = "1.0.3" + +# [profile.release] +# debug = true +# panic = "abort" +# lto = true +# codegen-units = 1 diff --git a/src/lib.rs b/crates/lib/src/lib.rs similarity index 98% rename from src/lib.rs rename to crates/lib/src/lib.rs index 9cceb03..130cdf1 100644 --- a/src/lib.rs +++ b/crates/lib/src/lib.rs @@ -80,11 +80,11 @@ grass input.scss unknown_lints, )] -pub use grass_internal::*; +pub use compiler::*; /// Include CSS in your binary at compile time from a Sass source file /// -/// ```ignore +/// ``` /// static CSS: &str = grass::include!("../static/_main.scss"); /// ``` /// diff --git a/src/main.rs b/crates/lib/src/main.rs similarity index 100% rename from src/main.rs rename to crates/lib/src/main.rs diff --git a/tests/addition.rs b/crates/lib/tests/addition.rs similarity index 100% rename from tests/addition.rs rename to crates/lib/tests/addition.rs diff --git a/tests/and.rs b/crates/lib/tests/and.rs similarity index 100% rename from tests/and.rs rename to crates/lib/tests/and.rs diff --git a/tests/arglist.rs b/crates/lib/tests/arglist.rs similarity index 100% rename from tests/arglist.rs rename to crates/lib/tests/arglist.rs diff --git a/tests/args.rs b/crates/lib/tests/args.rs similarity index 100% rename from tests/args.rs rename to crates/lib/tests/args.rs diff --git a/tests/at-error.rs b/crates/lib/tests/at-error.rs similarity index 100% rename from tests/at-error.rs rename to crates/lib/tests/at-error.rs diff --git a/tests/at-root.rs b/crates/lib/tests/at-root.rs similarity index 100% rename from tests/at-root.rs rename to crates/lib/tests/at-root.rs diff --git a/tests/calc_args.rs b/crates/lib/tests/calc_args.rs similarity index 100% rename from tests/calc_args.rs rename to crates/lib/tests/calc_args.rs diff --git a/tests/charset.rs b/crates/lib/tests/charset.rs similarity index 100% rename from tests/charset.rs rename to crates/lib/tests/charset.rs diff --git a/tests/clamp.rs b/crates/lib/tests/clamp.rs similarity index 100% rename from tests/clamp.rs rename to crates/lib/tests/clamp.rs diff --git a/tests/color.rs b/crates/lib/tests/color.rs similarity index 100% rename from tests/color.rs rename to crates/lib/tests/color.rs diff --git a/tests/color_hsl.rs b/crates/lib/tests/color_hsl.rs similarity index 100% rename from tests/color_hsl.rs rename to crates/lib/tests/color_hsl.rs diff --git a/tests/color_hwb.rs b/crates/lib/tests/color_hwb.rs similarity index 100% rename from tests/color_hwb.rs rename to crates/lib/tests/color_hwb.rs diff --git a/tests/comments.rs b/crates/lib/tests/comments.rs similarity index 100% rename from tests/comments.rs rename to crates/lib/tests/comments.rs diff --git a/tests/compressed.rs b/crates/lib/tests/compressed.rs similarity index 100% rename from tests/compressed.rs rename to crates/lib/tests/compressed.rs diff --git a/tests/content-exists.rs b/crates/lib/tests/content-exists.rs similarity index 100% rename from tests/content-exists.rs rename to crates/lib/tests/content-exists.rs diff --git a/tests/custom-property.rs b/crates/lib/tests/custom-property.rs similarity index 100% rename from tests/custom-property.rs rename to crates/lib/tests/custom-property.rs diff --git a/tests/debug.rs b/crates/lib/tests/debug.rs similarity index 100% rename from tests/debug.rs rename to crates/lib/tests/debug.rs diff --git a/tests/division.rs b/crates/lib/tests/division.rs similarity index 100% rename from tests/division.rs rename to crates/lib/tests/division.rs diff --git a/tests/each.rs b/crates/lib/tests/each.rs similarity index 100% rename from tests/each.rs rename to crates/lib/tests/each.rs diff --git a/tests/equality.rs b/crates/lib/tests/equality.rs similarity index 100% rename from tests/equality.rs rename to crates/lib/tests/equality.rs diff --git a/tests/error.rs b/crates/lib/tests/error.rs similarity index 100% rename from tests/error.rs rename to crates/lib/tests/error.rs diff --git a/tests/extend.rs b/crates/lib/tests/extend.rs similarity index 100% rename from tests/extend.rs rename to crates/lib/tests/extend.rs diff --git a/tests/for.rs b/crates/lib/tests/for.rs similarity index 100% rename from tests/for.rs rename to crates/lib/tests/for.rs diff --git a/tests/forward.rs b/crates/lib/tests/forward.rs similarity index 100% rename from tests/forward.rs rename to crates/lib/tests/forward.rs diff --git a/tests/functions.rs b/crates/lib/tests/functions.rs similarity index 100% rename from tests/functions.rs rename to crates/lib/tests/functions.rs diff --git a/tests/get-function.rs b/crates/lib/tests/get-function.rs similarity index 100% rename from tests/get-function.rs rename to crates/lib/tests/get-function.rs diff --git a/tests/if.rs b/crates/lib/tests/if.rs similarity index 100% rename from tests/if.rs rename to crates/lib/tests/if.rs diff --git a/tests/important.rs b/crates/lib/tests/important.rs similarity index 100% rename from tests/important.rs rename to crates/lib/tests/important.rs diff --git a/tests/imports.rs b/crates/lib/tests/imports.rs similarity index 100% rename from tests/imports.rs rename to crates/lib/tests/imports.rs diff --git a/tests/include_sass.rs b/crates/lib/tests/include_sass.rs similarity index 100% rename from tests/include_sass.rs rename to crates/lib/tests/include_sass.rs diff --git a/tests/inspect.rs b/crates/lib/tests/inspect.rs similarity index 100% rename from tests/inspect.rs rename to crates/lib/tests/inspect.rs diff --git a/tests/interpolation.rs b/crates/lib/tests/interpolation.rs similarity index 100% rename from tests/interpolation.rs rename to crates/lib/tests/interpolation.rs diff --git a/tests/is-superselector.rs b/crates/lib/tests/is-superselector.rs similarity index 100% rename from tests/is-superselector.rs rename to crates/lib/tests/is-superselector.rs diff --git a/tests/keyframes.rs b/crates/lib/tests/keyframes.rs similarity index 100% rename from tests/keyframes.rs rename to crates/lib/tests/keyframes.rs diff --git a/tests/keywords.rs b/crates/lib/tests/keywords.rs similarity index 100% rename from tests/keywords.rs rename to crates/lib/tests/keywords.rs diff --git a/tests/large.rs b/crates/lib/tests/large.rs similarity index 100% rename from tests/large.rs rename to crates/lib/tests/large.rs diff --git a/tests/list.rs b/crates/lib/tests/list.rs similarity index 100% rename from tests/list.rs rename to crates/lib/tests/list.rs diff --git a/tests/macros.rs b/crates/lib/tests/macros.rs similarity index 100% rename from tests/macros.rs rename to crates/lib/tests/macros.rs diff --git a/tests/map.rs b/crates/lib/tests/map.rs similarity index 100% rename from tests/map.rs rename to crates/lib/tests/map.rs diff --git a/tests/math-module.rs b/crates/lib/tests/math-module.rs similarity index 100% rename from tests/math-module.rs rename to crates/lib/tests/math-module.rs diff --git a/tests/math.rs b/crates/lib/tests/math.rs similarity index 100% rename from tests/math.rs rename to crates/lib/tests/math.rs diff --git a/tests/media.rs b/crates/lib/tests/media.rs similarity index 100% rename from tests/media.rs rename to crates/lib/tests/media.rs diff --git a/tests/meta-module.rs b/crates/lib/tests/meta-module.rs similarity index 100% rename from tests/meta-module.rs rename to crates/lib/tests/meta-module.rs diff --git a/tests/meta.rs b/crates/lib/tests/meta.rs similarity index 100% rename from tests/meta.rs rename to crates/lib/tests/meta.rs diff --git a/tests/min-max.rs b/crates/lib/tests/min-max.rs similarity index 100% rename from tests/min-max.rs rename to crates/lib/tests/min-max.rs diff --git a/tests/misc.rs b/crates/lib/tests/misc.rs similarity index 100% rename from tests/misc.rs rename to crates/lib/tests/misc.rs diff --git a/tests/mixins.rs b/crates/lib/tests/mixins.rs similarity index 100% rename from tests/mixins.rs rename to crates/lib/tests/mixins.rs diff --git a/tests/modulo.rs b/crates/lib/tests/modulo.rs similarity index 100% rename from tests/modulo.rs rename to crates/lib/tests/modulo.rs diff --git a/tests/multiplication.rs b/crates/lib/tests/multiplication.rs similarity index 100% rename from tests/multiplication.rs rename to crates/lib/tests/multiplication.rs diff --git a/tests/nan.rs b/crates/lib/tests/nan.rs similarity index 100% rename from tests/nan.rs rename to crates/lib/tests/nan.rs diff --git a/tests/not.rs b/crates/lib/tests/not.rs similarity index 100% rename from tests/not.rs rename to crates/lib/tests/not.rs diff --git a/tests/null.rs b/crates/lib/tests/null.rs similarity index 100% rename from tests/null.rs rename to crates/lib/tests/null.rs diff --git a/tests/number.rs b/crates/lib/tests/number.rs similarity index 100% rename from tests/number.rs rename to crates/lib/tests/number.rs diff --git a/tests/or.rs b/crates/lib/tests/or.rs similarity index 100% rename from tests/or.rs rename to crates/lib/tests/or.rs diff --git a/tests/order-of-operations.rs b/crates/lib/tests/order-of-operations.rs similarity index 100% rename from tests/order-of-operations.rs rename to crates/lib/tests/order-of-operations.rs diff --git a/tests/ordering.rs b/crates/lib/tests/ordering.rs similarity index 100% rename from tests/ordering.rs rename to crates/lib/tests/ordering.rs diff --git a/tests/plain-css-fn.rs b/crates/lib/tests/plain-css-fn.rs similarity index 100% rename from tests/plain-css-fn.rs rename to crates/lib/tests/plain-css-fn.rs diff --git a/tests/plain-css.rs b/crates/lib/tests/plain-css.rs similarity index 100% rename from tests/plain-css.rs rename to crates/lib/tests/plain-css.rs diff --git a/tests/sass.rs b/crates/lib/tests/sass.rs similarity index 100% rename from tests/sass.rs rename to crates/lib/tests/sass.rs diff --git a/tests/scope.rs b/crates/lib/tests/scope.rs similarity index 100% rename from tests/scope.rs rename to crates/lib/tests/scope.rs diff --git a/tests/selector-append.rs b/crates/lib/tests/selector-append.rs similarity index 100% rename from tests/selector-append.rs rename to crates/lib/tests/selector-append.rs diff --git a/tests/selector-extend.rs b/crates/lib/tests/selector-extend.rs similarity index 100% rename from tests/selector-extend.rs rename to crates/lib/tests/selector-extend.rs diff --git a/tests/selector-nest.rs b/crates/lib/tests/selector-nest.rs similarity index 100% rename from tests/selector-nest.rs rename to crates/lib/tests/selector-nest.rs diff --git a/tests/selector-parse.rs b/crates/lib/tests/selector-parse.rs similarity index 100% rename from tests/selector-parse.rs rename to crates/lib/tests/selector-parse.rs diff --git a/tests/selector-replace.rs b/crates/lib/tests/selector-replace.rs similarity index 100% rename from tests/selector-replace.rs rename to crates/lib/tests/selector-replace.rs diff --git a/tests/selector-unify.rs b/crates/lib/tests/selector-unify.rs similarity index 100% rename from tests/selector-unify.rs rename to crates/lib/tests/selector-unify.rs diff --git a/tests/selectors.rs b/crates/lib/tests/selectors.rs similarity index 100% rename from tests/selectors.rs rename to crates/lib/tests/selectors.rs diff --git a/tests/simple-selectors.rs b/crates/lib/tests/simple-selectors.rs similarity index 100% rename from tests/simple-selectors.rs rename to crates/lib/tests/simple-selectors.rs diff --git a/tests/special-functions.rs b/crates/lib/tests/special-functions.rs similarity index 100% rename from tests/special-functions.rs rename to crates/lib/tests/special-functions.rs diff --git a/tests/splat.rs b/crates/lib/tests/splat.rs similarity index 100% rename from tests/splat.rs rename to crates/lib/tests/splat.rs diff --git a/tests/str-escape.rs b/crates/lib/tests/str-escape.rs similarity index 100% rename from tests/str-escape.rs rename to crates/lib/tests/str-escape.rs diff --git a/tests/strings.rs b/crates/lib/tests/strings.rs similarity index 100% rename from tests/strings.rs rename to crates/lib/tests/strings.rs diff --git a/tests/styles.rs b/crates/lib/tests/styles.rs similarity index 100% rename from tests/styles.rs rename to crates/lib/tests/styles.rs diff --git a/tests/subtraction.rs b/crates/lib/tests/subtraction.rs similarity index 100% rename from tests/subtraction.rs rename to crates/lib/tests/subtraction.rs diff --git a/tests/supports.rs b/crates/lib/tests/supports.rs similarity index 100% rename from tests/supports.rs rename to crates/lib/tests/supports.rs diff --git a/tests/unary.rs b/crates/lib/tests/unary.rs similarity index 100% rename from tests/unary.rs rename to crates/lib/tests/unary.rs diff --git a/tests/unicode-range.rs b/crates/lib/tests/unicode-range.rs similarity index 100% rename from tests/unicode-range.rs rename to crates/lib/tests/unicode-range.rs diff --git a/tests/units.rs b/crates/lib/tests/units.rs similarity index 100% rename from tests/units.rs rename to crates/lib/tests/units.rs diff --git a/tests/unknown-at-rule.rs b/crates/lib/tests/unknown-at-rule.rs similarity index 100% rename from tests/unknown-at-rule.rs rename to crates/lib/tests/unknown-at-rule.rs diff --git a/tests/url.rs b/crates/lib/tests/url.rs similarity index 100% rename from tests/url.rs rename to crates/lib/tests/url.rs diff --git a/tests/use.rs b/crates/lib/tests/use.rs similarity index 100% rename from tests/use.rs rename to crates/lib/tests/use.rs diff --git a/tests/values.rs b/crates/lib/tests/values.rs similarity index 100% rename from tests/values.rs rename to crates/lib/tests/values.rs diff --git a/tests/variables.rs b/crates/lib/tests/variables.rs similarity index 100% rename from tests/variables.rs rename to crates/lib/tests/variables.rs diff --git a/tests/warn.rs b/crates/lib/tests/warn.rs similarity index 100% rename from tests/warn.rs rename to crates/lib/tests/warn.rs diff --git a/tests/while.rs b/crates/lib/tests/while.rs similarity index 100% rename from tests/while.rs rename to crates/lib/tests/while.rs diff --git a/tests/whitespace.rs b/crates/lib/tests/whitespace.rs similarity index 100% rename from tests/whitespace.rs rename to crates/lib/tests/whitespace.rs