From dd8a1ace5e22996ed6869a4678ae15fffe1dad0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pontus=20=C3=96stlund?= <ponost@roxen.com> Date: Tue, 29 Nov 2016 15:56:15 +0100 Subject: [PATCH] Added some info methods about libsass version. Improved configure.in to check for features in libsass. --- .gitignore | 2 ++ Makefile.in | 2 +- config.h.in | 55 ++++++++++++++++++++++++++++++++++++ configure.in | 18 ++++++++++-- module.pmod.in | 11 +++++++- sass.cmod | 65 +++++++++++++++++++++++++++++++++++++------ simple-test/test.pike | 6 ++++ 7 files changed, 145 insertions(+), 14 deletions(-) create mode 100644 config.h.in diff --git a/.gitignore b/.gitignore index 7ae3835ea6..4792cb23aa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ configure config.cache config.log config.status +config.h make_variables modlist_segment module.pmod @@ -13,5 +14,6 @@ sass.c *.o plib/ refdoc/ +_build/ *.css *.map diff --git a/Makefile.in b/Makefile.in index 1bfea57ad3..df17043e5f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,6 +4,7 @@ VPATH=@srcdir@ MODNAME=Sass MODDIR=Tools.pmod/ MODULE_PMOD_IN=module.pmod.in +AUTODOC_SRC_IN=module.pmod.in sass.c MODULE_WRAPPER_PREFIX=_ MODULE_LDFLAGS=@LDFLAGS@ @LIBS@ @CMOD_LIBS@ MODULE_CFLAGS=@CMOD_CFLAGS@ @@ -14,4 +15,3 @@ OBJS=sass.o sass.o : $(SRCDIR)/sass.c @dependencies@ - diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000000..6df87f0373 --- /dev/null +++ b/config.h.in @@ -0,0 +1,55 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if libsass has sass_language_version() */ +#undef HAVE_LIBSASS_LANGUAGE_VERSION + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the <sass.h> header file. */ +#undef HAVE_SASS_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS diff --git a/configure.in b/configure.in index 2ac0a2eef3..4632b346e5 100644 --- a/configure.in +++ b/configure.in @@ -1,13 +1,25 @@ AC_INIT(sass.cmod) +AC_CONFIG_HEADERS(config.h) +# AC_ARG_WITH(sass, [ --with(out)-sass Support for SASS],[],[with_sass=yes]) AC_MODULE_INIT() +AH_TEMPLATE([HAVE_LIBSASS_LANGUAGE_VERSION], + [Define to 1 if libsass has sass_language_version()]) + CMOD_LIBS="-lsass" CMOD_CFLAGS="" +# AC_HAVE_HEADERS(sass.h) +AC_CHECK_HEADERS([sass.h]) + +# +# Check for features in libsass +# +AC_SEARCH_LIBS(sass_language_version, sass, + [ AC_DEFINE([HAVE_LIBSASS_LANGUAGE_VERSION], [1]) ]) + + AC_SUBST(CMOD_CFLAGS) AC_SUBST(CMOD_LIBS) -AC_HAVE_HEADERS(sass.h) -AC_CHECK_HEADERS(sass.h) - AC_OUTPUT(Makefile) diff --git a/module.pmod.in b/module.pmod.in index 6dd11947db..6c7288bcd1 100644 --- a/module.pmod.in +++ b/module.pmod.in @@ -18,7 +18,7 @@ class SCSS { inherit Tools@module@._Api; - //! Set options to the SASS compiler + //! Set options to the SASS compiler. @[opts] //! //! @param opts //! @mapping @@ -97,4 +97,13 @@ class SCSS } } } + + // //! Test if @[set_options()] will be linked to from @[a]? + // //! + // //! @param a + // //! Just a parameter + // void test_func(mapping a) + // { + // return a; + // } } diff --git a/sass.cmod b/sass.cmod index 961506097e..df763865e3 100644 --- a/sass.cmod +++ b/sass.cmod @@ -5,7 +5,7 @@ */ #include <sass.h> - +#include "config.h" #include "global.h" #include "interpret.h" #include "module.h" @@ -24,7 +24,8 @@ DECLARATIONS /*! @module Tools */ -/*! @module Sass +/*! @module _Sass + *! Low level module of @[Tools.Sass] */ // #define SASS_DEBUG @@ -79,6 +80,11 @@ void set_options (sass_opts *opts, struct Sass_Context *ctx) } } + +/*! @class _Api + *! + *! Base class and stuff + */ PIKECLASS _Api { // CVAR sass_object *sobj; @@ -86,10 +92,10 @@ PIKECLASS _Api /*! @decl void set_include_path(string path) *! - *! Set include path of @tt{@imports@} + *! Set include path of @tt{imports@} *! *! @seealso - *! get_include_path() + *! @[get_include_path()] *! *! @param path */ @@ -106,10 +112,10 @@ PIKECLASS _Api /*! @decl string get_include_path() *! - *! Get include path of @tt{@imports@} + *! Get include path of @tt{imports@} *! *! @seealso - *! set_include_path() + *! @[set_include_path()] */ PIKEFUN string get_include_path () { @@ -177,6 +183,7 @@ PIKECLASS _Api RETURN (THIS->options->comments); } + /*! @decl void set_source_map_file(string path) *! *! Path to source map file. Enables the source map generating. @@ -212,7 +219,7 @@ PIKECLASS _Api push_text (f); } else { - push_int (0); + push_undefined (); } } @@ -232,6 +239,7 @@ PIKECLASS _Api THIS->options->map_embed = embed; } + /*! @decl bool get_source_map_embed() *! *! Will a source map be embedded or not? @@ -274,7 +282,7 @@ PIKECLASS _Api push_text (THIS->options->map_root); } else { - push_int (0); + push_undefined (); } } @@ -312,7 +320,7 @@ PIKECLASS _Api /*! @decl void set_precision(int(0..) p) *! - *! Set the precision of fractional numbers. Default is @{5}. + *! Set the precision of fractional numbers. Default is @tt{5@}. *! *! @seealso *! @[get_precision()] @@ -480,11 +488,50 @@ PIKECLASS _Api free (THIS->options); } } +/*! @endclass */ + +/*! @decl string libsass_version() + *! + *! Returns the @tt{libsass@} version this module was compiled against + */ +PIKEFUN string libsass_version() +{ + const char* v = libsass_version(); + push_string (make_shared_string (v)); +} + +/*! @decl string sass2scss_version() + *! + *! Returns the @tt{sass2scss@} version this module was compiled against + */ +PIKEFUN string sass2scss_version() +{ + const char* v = sass2scss_version(); + push_string (make_shared_string (v)); +} + +#if HAVE_LIBSASS_LANGUAGE_VERSION +/* Returns the @tt{language@} version of Sass this module was compiled against +*/ +PIKEFUN string libsass_language_version() +{ + const char* v = libsass_language_version(); + push_string (make_shared_string (v)); +} +#endif PIKE_MODULE_INIT { add_string_constant ("LIBSASS_VERSION", LIBSASS_VERSION, 0); + /*! @decl constant STYLE_NESTED + *! @decl constant STYLE_EXPANDED + *! @decl constant STYLE_COMPACT + *! @decl constant STYLE_COMPRESSED + *! + *! Styling of output. Use as argument to @[set_output_style()] + */ + add_integer_constant ("STYLE_NESTED", SASS_STYLE_NESTED, 0); add_integer_constant ("STYLE_EXPANDED", SASS_STYLE_EXPANDED, 0); add_integer_constant ("STYLE_COMPACT", SASS_STYLE_COMPACT, 0); diff --git a/simple-test/test.pike b/simple-test/test.pike index 1c9d5ffd1a..64074c50fb 100644 --- a/simple-test/test.pike +++ b/simple-test/test.pike @@ -5,6 +5,12 @@ constant BASE = __DIR__; int main(int argc, array(string) argv) { + if (argc > 1 && argv[1] == "v") { + write("libsass version: %s\n", Tools.Sass.libsass_version()); + write("sass2scss version: %s\n", Tools.Sass.sass2scss_version()); + return 0; + } + compiler = Tools.Sass.SCSS(); compiler->set_options(([ "output_style" : Tools.Sass.STYLE_EXPANDED -- GitLab