From 33da73fefdaf6e0b73e695c1612d5b284b0466b2 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sun, 10 Jan 2016 23:24:02 +0100 Subject: [PATCH 1/5] Add common header for all compile units --- src/ast.cpp | 1 + src/base64vlq.cpp | 1 + src/bind.cpp | 1 + src/color_maps.cpp | 1 + src/constants.cpp | 1 + src/context.cpp | 1 + src/cssize.cpp | 1 + src/emitter.cpp | 1 + src/environment.cpp | 1 + src/error_handling.cpp | 1 + src/eval.cpp | 1 + src/expand.cpp | 1 + src/extend.cpp | 1 + src/file.cpp | 1 + src/functions.cpp | 1 + src/inspect.cpp | 1 + src/lexer.cpp | 1 + src/listize.cpp | 1 + src/memory_manager.cpp | 1 + src/node.cpp | 1 + src/output.cpp | 1 + src/parser.cpp | 1 + src/plugins.cpp | 1 + src/position.cpp | 1 + src/prelexer.cpp | 1 + src/remove_placeholders.cpp | 1 + src/sass.cpp | 1 + src/sass.hpp | 5 +++++ src/sass_context.cpp | 1 + src/sass_functions.cpp | 1 + src/sass_interface.cpp | 1 + src/sass_util.cpp | 1 + src/sass_values.cpp | 1 + src/source_map.cpp | 1 + src/to_c.cpp | 1 + src/to_string.cpp | 1 + src/to_value.cpp | 1 + src/units.cpp | 1 + src/utf8_string.cpp | 1 + src/util.cpp | 1 + src/values.cpp | 1 + win/libsass.vcxproj.filters | 12 +++++++++--- 42 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 src/sass.hpp diff --git a/src/ast.cpp b/src/ast.cpp index cd3bdf7672..82c769b49e 100644 --- a/src/ast.cpp +++ b/src/ast.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "ast.hpp" #include "context.hpp" #include "node.hpp" diff --git a/src/base64vlq.cpp b/src/base64vlq.cpp index 0d30c660f5..be2fb4926a 100644 --- a/src/base64vlq.cpp +++ b/src/base64vlq.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "base64vlq.hpp" namespace Sass { diff --git a/src/bind.cpp b/src/bind.cpp index 3ae725a3d5..44edb2e083 100644 --- a/src/bind.cpp +++ b/src/bind.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "bind.hpp" #include "ast.hpp" #include "context.hpp" diff --git a/src/color_maps.cpp b/src/color_maps.cpp index 948185860e..e520378069 100644 --- a/src/color_maps.cpp +++ b/src/color_maps.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "ast.hpp" #include "color_maps.hpp" diff --git a/src/constants.cpp b/src/constants.cpp index 1a2c6da00e..518324b4cb 100644 --- a/src/constants.cpp +++ b/src/constants.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "constants.hpp" namespace Sass { diff --git a/src/context.cpp b/src/context.cpp index d6d81e7c93..0b0f867841 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -4,6 +4,7 @@ #define PATH_SEP ':' #endif +#include "sass.hpp" #include #include #include diff --git a/src/cssize.cpp b/src/cssize.cpp index c689aeab8c..72a9cae7f8 100644 --- a/src/cssize.cpp +++ b/src/cssize.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/emitter.cpp b/src/emitter.cpp index 98a2b1d7b6..86b135aaa4 100644 --- a/src/emitter.cpp +++ b/src/emitter.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "util.hpp" #include "context.hpp" #include "output.hpp" diff --git a/src/environment.cpp b/src/environment.cpp index b311c68bc5..a8cbd52c51 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "ast.hpp" #include "environment.hpp" diff --git a/src/error_handling.cpp b/src/error_handling.cpp index 389939a815..01171c2834 100644 --- a/src/error_handling.cpp +++ b/src/error_handling.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "ast.hpp" #include "prelexer.hpp" #include "backtrace.hpp" diff --git a/src/eval.cpp b/src/eval.cpp index 38f8c4ce9b..41ca4d805b 100644 --- a/src/eval.cpp +++ b/src/eval.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/expand.cpp b/src/expand.cpp index cb385e54c6..06ec9496d3 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -2,6 +2,7 @@ #pragma warning(disable : 4503) #endif +#include "sass.hpp" #include #include diff --git a/src/extend.cpp b/src/extend.cpp index fb44317c2c..a3cce5d6a8 100644 --- a/src/extend.cpp +++ b/src/extend.cpp @@ -2,6 +2,7 @@ #pragma warning(disable : 4503) #endif +#include "sass.hpp" #include "extend.hpp" #include "context.hpp" #include "to_string.hpp" diff --git a/src/file.cpp b/src/file.cpp index 461e29556e..9751394c04 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -13,6 +13,7 @@ #define NOMINMAX #endif +#include "sass.hpp" #include #include #include diff --git a/src/functions.cpp b/src/functions.cpp index 109b57e70c..d96439e602 100644 --- a/src/functions.cpp +++ b/src/functions.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "functions.hpp" #include "ast.hpp" #include "context.hpp" diff --git a/src/inspect.cpp b/src/inspect.cpp index 6fbbbb04ef..0b183a0202 100644 --- a/src/inspect.cpp +++ b/src/inspect.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/lexer.cpp b/src/lexer.cpp index 12492d7ffa..14ad116639 100644 --- a/src/lexer.cpp +++ b/src/lexer.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/listize.cpp b/src/listize.cpp index a3d2d89e4e..8459c4d164 100644 --- a/src/listize.cpp +++ b/src/listize.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/memory_manager.cpp b/src/memory_manager.cpp index a89912b76d..fd7c5ec8b4 100644 --- a/src/memory_manager.cpp +++ b/src/memory_manager.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "ast.hpp" #include "memory_manager.hpp" diff --git a/src/node.cpp b/src/node.cpp index 2e63966370..6cc94b75e4 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include "node.hpp" diff --git a/src/output.cpp b/src/output.cpp index 2efcf623f2..0b25529e4f 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "ast.hpp" #include "output.hpp" #include "to_string.hpp" diff --git a/src/parser.cpp b/src/parser.cpp index c44b414b98..dc44fc629c 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/plugins.cpp b/src/plugins.cpp index 12efe9758d..bdd61a905d 100644 --- a/src/plugins.cpp +++ b/src/plugins.cpp @@ -7,6 +7,7 @@ #include #endif +#include "sass.hpp" #include #include "output.hpp" #include "plugins.hpp" diff --git a/src/position.cpp b/src/position.cpp index f9200bd41a..a8afe67d4e 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "position.hpp" namespace Sass { diff --git a/src/prelexer.cpp b/src/prelexer.cpp index bef6ba6ffb..d86df3f3d8 100644 --- a/src/prelexer.cpp +++ b/src/prelexer.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/remove_placeholders.cpp b/src/remove_placeholders.cpp index 2909eaa52b..5f6e5cc847 100644 --- a/src/remove_placeholders.cpp +++ b/src/remove_placeholders.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "remove_placeholders.hpp" #include "context.hpp" #include "inspect.hpp" diff --git a/src/sass.cpp b/src/sass.cpp index 5b8ece4e30..672e2dbfdc 100644 --- a/src/sass.cpp +++ b/src/sass.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/sass.hpp b/src/sass.hpp new file mode 100644 index 0000000000..d1cf42db87 --- /dev/null +++ b/src/sass.hpp @@ -0,0 +1,5 @@ +// must be the first include in all compile units +#ifndef SASS_SASS_H +#define SASS_SASS_H + +#endif diff --git a/src/sass_context.cpp b/src/sass_context.cpp index ab3b3f651c..6befdbe9a7 100644 --- a/src/sass_context.cpp +++ b/src/sass_context.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/sass_functions.cpp b/src/sass_functions.cpp index 1b328cb9b7..2373cea0c6 100644 --- a/src/sass_functions.cpp +++ b/src/sass_functions.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include "util.hpp" #include "context.hpp" diff --git a/src/sass_interface.cpp b/src/sass_interface.cpp index f38f0e98b7..1de738a308 100644 --- a/src/sass_interface.cpp +++ b/src/sass_interface.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/sass_util.cpp b/src/sass_util.cpp index ce49cae8b9..5a770effb8 100644 --- a/src/sass_util.cpp +++ b/src/sass_util.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "node.hpp" #include "to_string.hpp" diff --git a/src/sass_values.cpp b/src/sass_values.cpp index 767f2af1fb..4ce2d601e6 100644 --- a/src/sass_values.cpp +++ b/src/sass_values.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include "util.hpp" diff --git a/src/source_map.cpp b/src/source_map.cpp index 20e81b7603..44f8defe01 100644 --- a/src/source_map.cpp +++ b/src/source_map.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/to_c.cpp b/src/to_c.cpp index 8cb87654bb..5dd3a194fe 100644 --- a/src/to_c.cpp +++ b/src/to_c.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "to_c.hpp" #include "ast.hpp" diff --git a/src/to_string.cpp b/src/to_string.cpp index 4fd33291fa..69b4c3dfbc 100644 --- a/src/to_string.cpp +++ b/src/to_string.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/to_value.cpp b/src/to_value.cpp index 01cbae1bb6..c6635fa85e 100644 --- a/src/to_value.cpp +++ b/src/to_value.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "ast.hpp" #include "to_value.hpp" #include "to_string.hpp" diff --git a/src/units.cpp b/src/units.cpp index 48acab9638..33dccd65e8 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include "units.hpp" diff --git a/src/utf8_string.cpp b/src/utf8_string.cpp index c267ca9e1b..60efc3fc4c 100644 --- a/src/utf8_string.cpp +++ b/src/utf8_string.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include #include #include diff --git a/src/util.cpp b/src/util.cpp index 6d9157ca0a..f32c324590 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "sass.h" #include "ast.hpp" #include "util.hpp" diff --git a/src/values.cpp b/src/values.cpp index 71a4a54262..738a56bb15 100644 --- a/src/values.cpp +++ b/src/values.cpp @@ -1,3 +1,4 @@ +#include "sass.hpp" #include "sass.h" #include "values.hpp" diff --git a/win/libsass.vcxproj.filters b/win/libsass.vcxproj.filters index a6759842fe..acef223e13 100644 --- a/win/libsass.vcxproj.filters +++ b/win/libsass.vcxproj.filters @@ -27,9 +27,6 @@ Header Files - - Header Files - Header Files @@ -177,6 +174,12 @@ Header Files + + Header Files + + + Header Files + @@ -308,5 +311,8 @@ Source Files + + Source Files + From cc254606f5179f6212437009547853324165e67a Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sun, 10 Jan 2016 23:24:39 +0100 Subject: [PATCH 2/5] Undefine `__EXTENSIONS__` to fix compilation on smartos Removed `#undef` occurrences that are no longer needed --- Makefile | 4 ++-- src/sass.hpp | 5 +++++ src/units.cpp | 4 ---- src/units.hpp | 1 - 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index cfc63b6632..a7deb27e64 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,8 @@ MKDIR ?= mkdir RMDIR ?= rmdir WINDRES ?= windres ifeq ($(OS),SunOS) # Solaris/Illumos flavors -INSTALL = ginstall -PREFIX = /opt/local +INSTALL ?= ginstall +PREFIX ?= /opt/local endif INSTALL ?= install CFLAGS ?= -Wall diff --git a/src/sass.hpp b/src/sass.hpp index d1cf42db87..e5f1ae384a 100644 --- a/src/sass.hpp +++ b/src/sass.hpp @@ -2,4 +2,9 @@ #ifndef SASS_SASS_H #define SASS_SASS_H +// undefine extensions macro to tell sys includes +// that we do not want any macros to be exported +// this mainly fixes issues on smartos (SEC) +#undef __EXTENSIONS__ + #endif diff --git a/src/units.cpp b/src/units.cpp index 33dccd65e8..6c4d7fe105 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -2,10 +2,6 @@ #include #include "units.hpp" -#ifdef IN -#undef IN -#endif - namespace Sass { /* the conversion matrix can be readed the following way */ diff --git a/src/units.hpp b/src/units.hpp index 480297280e..ecfa12bb11 100644 --- a/src/units.hpp +++ b/src/units.hpp @@ -1,6 +1,5 @@ #ifndef SASS_UNITS_H #define SASS_UNITS_H -#undef SEC #include #include From 678cc3da385c63fee4f7cbaea4adcc494aa96d35 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Mon, 11 Jan 2016 01:21:37 +0100 Subject: [PATCH 3/5] Rename `Sass::SassUnit` to `Sass::UnitType` Rename `Sass::SassUnitType` to `Sass::UnitClass` --- src/units.cpp | 108 +++++++++++++++++++++++++------------------------- src/units.hpp | 14 +++---- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/units.cpp b/src/units.cpp index 6c4d7fe105..184529412f 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -49,72 +49,72 @@ namespace Sass { /* dppx */ { 1/96.0, 2.54/96, 1 } }; - SassUnitType get_unit_type(SassUnit unit) + UnitClass get_unit_type(UnitType unit) { switch (unit & 0xFF00) { - case SassUnitType::LENGTH: return SassUnitType::LENGTH; break; - case SassUnitType::ANGLE: return SassUnitType::ANGLE; break; - case SassUnitType::TIME: return SassUnitType::TIME; break; - case SassUnitType::FREQUENCY: return SassUnitType::FREQUENCY; break; - case SassUnitType::RESOLUTION: return SassUnitType::RESOLUTION; break; - default: return SassUnitType::INCOMMENSURABLE; break; + case UnitClass::LENGTH: return UnitClass::LENGTH; break; + case UnitClass::ANGLE: return UnitClass::ANGLE; break; + case UnitClass::TIME: return UnitClass::TIME; break; + case UnitClass::FREQUENCY: return UnitClass::FREQUENCY; break; + case UnitClass::RESOLUTION: return UnitClass::RESOLUTION; break; + default: return UnitClass::INCOMMENSURABLE; break; } }; - SassUnit string_to_unit(const std::string& s) + UnitType string_to_unit(const std::string& s) { // size units - if (s == "px") return SassUnit::PX; - else if (s == "pt") return SassUnit::PT; - else if (s == "pc") return SassUnit::PC; - else if (s == "mm") return SassUnit::MM; - else if (s == "cm") return SassUnit::CM; - else if (s == "in") return SassUnit::IN; + if (s == "px") return UnitType::PX; + else if (s == "pt") return UnitType::PT; + else if (s == "pc") return UnitType::PC; + else if (s == "mm") return UnitType::MM; + else if (s == "cm") return UnitType::CM; + else if (s == "in") return UnitType::IN; // angle units - else if (s == "deg") return SassUnit::DEG; - else if (s == "grad") return SassUnit::GRAD; - else if (s == "rad") return SassUnit::RAD; - else if (s == "turn") return SassUnit::TURN; + else if (s == "deg") return UnitType::DEG; + else if (s == "grad") return UnitType::GRAD; + else if (s == "rad") return UnitType::RAD; + else if (s == "turn") return UnitType::TURN; // time units - else if (s == "s") return SassUnit::SEC; - else if (s == "ms") return SassUnit::MSEC; + else if (s == "s") return UnitType::SEC; + else if (s == "ms") return UnitType::MSEC; // frequency units - else if (s == "Hz") return SassUnit::HERTZ; - else if (s == "kHz") return SassUnit::KHERTZ; + else if (s == "Hz") return UnitType::HERTZ; + else if (s == "kHz") return UnitType::KHERTZ; // resolutions units - else if (s == "dpi") return SassUnit::DPI; - else if (s == "dpcm") return SassUnit::DPCM; - else if (s == "dppx") return SassUnit::DPPX; + else if (s == "dpi") return UnitType::DPI; + else if (s == "dpcm") return UnitType::DPCM; + else if (s == "dppx") return UnitType::DPPX; // for unknown units - else return SassUnit::UNKNOWN; + else return UnitType::UNKNOWN; } - const char* unit_to_string(SassUnit unit) + const char* unit_to_string(UnitType unit) { switch (unit) { // size units - case SassUnit::PX: return "px"; break; - case SassUnit::PT: return "pt"; break; - case SassUnit::PC: return "pc"; break; - case SassUnit::MM: return "mm"; break; - case SassUnit::CM: return "cm"; break; - case SassUnit::IN: return "in"; break; + case UnitType::PX: return "px"; break; + case UnitType::PT: return "pt"; break; + case UnitType::PC: return "pc"; break; + case UnitType::MM: return "mm"; break; + case UnitType::CM: return "cm"; break; + case UnitType::IN: return "in"; break; // angle units - case SassUnit::DEG: return "deg"; break; - case SassUnit::GRAD: return "grad"; break; - case SassUnit::RAD: return "rad"; break; - case SassUnit::TURN: return "turn"; break; + case UnitType::DEG: return "deg"; break; + case UnitType::GRAD: return "grad"; break; + case UnitType::RAD: return "rad"; break; + case UnitType::TURN: return "turn"; break; // time units - case SassUnit::SEC: return "s"; break; - case SassUnit::MSEC: return "ms"; break; + case UnitType::SEC: return "s"; break; + case UnitType::MSEC: return "ms"; break; // frequency units - case SassUnit::HERTZ: return "Hz"; break; - case SassUnit::KHERTZ: return "kHz"; break; + case UnitType::HERTZ: return "Hz"; break; + case UnitType::KHERTZ: return "kHz"; break; // resolutions units - case SassUnit::DPI: return "dpi"; break; - case SassUnit::DPCM: return "dpcm"; break; - case SassUnit::DPPX: return "dppx"; break; + case UnitType::DPI: return "dpi"; break; + case UnitType::DPCM: return "dpcm"; break; + case UnitType::DPPX: return "dppx"; break; // for unknown units default: return ""; break; } @@ -126,11 +126,11 @@ namespace Sass { // assert for same units if (s1 == s2) return 1; // get unit enum from string - SassUnit u1 = string_to_unit(s1); - SassUnit u2 = string_to_unit(s2); + UnitType u1 = string_to_unit(s1); + UnitType u2 = string_to_unit(s2); // query unit group types - SassUnitType t1 = get_unit_type(u1); - SassUnitType t2 = get_unit_type(u2); + UnitClass t1 = get_unit_type(u1); + UnitClass t2 = get_unit_type(u2); // get absolute offset // used for array acces size_t i1 = u1 - t1; @@ -141,13 +141,13 @@ namespace Sass { // only process known units if (u1 != UNKNOWN && u2 != UNKNOWN) { switch (t1) { - case SassUnitType::LENGTH: return size_conversion_factors[i1][i2]; break; - case SassUnitType::ANGLE: return angle_conversion_factors[i1][i2]; break; - case SassUnitType::TIME: return time_conversion_factors[i1][i2]; break; - case SassUnitType::FREQUENCY: return frequency_conversion_factors[i1][i2]; break; - case SassUnitType::RESOLUTION: return resolution_conversion_factors[i1][i2]; break; + case UnitClass::LENGTH: return size_conversion_factors[i1][i2]; break; + case UnitClass::ANGLE: return angle_conversion_factors[i1][i2]; break; + case UnitClass::TIME: return time_conversion_factors[i1][i2]; break; + case UnitClass::FREQUENCY: return frequency_conversion_factors[i1][i2]; break; + case UnitClass::RESOLUTION: return resolution_conversion_factors[i1][i2]; break; // ToDo: should we throw error here? - case SassUnitType::INCOMMENSURABLE: return 0; break; + case UnitClass::INCOMMENSURABLE: return 0; break; } } // fallback diff --git a/src/units.hpp b/src/units.hpp index ecfa12bb11..187c5d3fb8 100644 --- a/src/units.hpp +++ b/src/units.hpp @@ -9,7 +9,7 @@ namespace Sass { const double PI = std::acos(-1); - enum SassUnitType { + enum UnitClass { LENGTH = 0x000, ANGLE = 0x100, TIME = 0x200, @@ -18,10 +18,10 @@ namespace Sass { INCOMMENSURABLE = 0x500 }; - enum SassUnit { + enum UnitType { // size units - IN = SassUnitType::LENGTH, + IN = UnitClass::LENGTH, CM, PC, MM, @@ -58,9 +58,9 @@ namespace Sass { extern const double frequency_conversion_factors[2][2]; extern const double resolution_conversion_factors[3][3]; - enum Sass::SassUnit string_to_unit(const std::string&); - const char* unit_to_string(Sass::SassUnit unit); - enum Sass::SassUnitType get_unit_type(Sass::SassUnit unit); + enum Sass::UnitType string_to_unit(const std::string&); + const char* unit_to_string(Sass::UnitType unit); + enum Sass::UnitClass get_unit_type(Sass::UnitType unit); // throws incompatibleUnits exceptions double conversion_factor(const std::string&, const std::string&, bool = true); @@ -68,7 +68,7 @@ namespace Sass { { public: const char* msg; - incompatibleUnits(Sass::SassUnit a, Sass::SassUnit b) + incompatibleUnits(Sass::UnitType a, Sass::UnitType b) : exception() { std::stringstream ss; From 683e81c75ce8c56ee2f86aca709c29c6413fc1a7 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Mon, 11 Jan 2016 02:26:45 +0100 Subject: [PATCH 4/5] Move compiler flags and macros to main sass header --- src/context.cpp | 6 ------ src/expand.cpp | 4 ---- src/extend.cpp | 4 ---- src/file.cpp | 38 +++++++++++++------------------------- src/parser.cpp | 24 ++++++++++++------------ src/sass.hpp | 33 ++++++++++++++++++++++++++++++++- 6 files changed, 57 insertions(+), 52 deletions(-) diff --git a/src/context.cpp b/src/context.cpp index 0b0f867841..d9600ecdcc 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -1,9 +1,3 @@ -#ifdef _WIN32 -#define PATH_SEP ';' -#else -#define PATH_SEP ':' -#endif - #include "sass.hpp" #include #include diff --git a/src/expand.cpp b/src/expand.cpp index 06ec9496d3..cf3bfcbe5e 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -1,7 +1,3 @@ -#ifdef _MSC_VER -#pragma warning(disable : 4503) -#endif - #include "sass.hpp" #include #include diff --git a/src/extend.cpp b/src/extend.cpp index a3cce5d6a8..78184680a0 100644 --- a/src/extend.cpp +++ b/src/extend.cpp @@ -1,7 +1,3 @@ -#ifdef _MSC_VER -#pragma warning(disable : 4503) -#endif - #include "sass.hpp" #include "extend.hpp" #include "context.hpp" diff --git a/src/file.cpp b/src/file.cpp index 9751394c04..3a5b0249ad 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1,18 +1,14 @@ #ifdef _WIN32 -#ifdef __MINGW32__ -#ifndef off64_t -#define off64_t _off64_t /* Workaround for http://sourceforge.net/p/mingw/bugs/2024/ */ -#endif -#endif -#include -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +# ifdef __MINGW32__ +# ifndef off64_t +# define off64_t _off64_t /* Workaround for http://sourceforge.net/p/mingw/bugs/2024/ */ +# endif +# endif +# include +# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) #else -#include -#endif -#ifdef _MSC_VER -#define NOMINMAX +# include #endif - #include "sass.hpp" #include #include @@ -27,16 +23,16 @@ #include "sass2scss.h" #ifdef _WIN32 -#include +# include -#ifdef _MSC_VER -#include +# ifdef _MSC_VER +# include inline static std::string wstring_to_string(const std::wstring& wstr) { std::wstring_convert, wchar_t> wchar_converter; return wchar_converter.to_bytes(wstr); } -#else // mingw(/gcc) does not support C++11's codecvt yet. +# else // mingw(/gcc) does not support C++11's codecvt yet. inline static std::string wstring_to_string(const std::wstring &wstr) { int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); @@ -44,15 +40,7 @@ inline static std::string wstring_to_string(const std::wstring &wstr) WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL); return strTo; } -#endif -#endif - -#ifndef FS_CASE_SENSITIVE -#ifdef _WIN32 -#define FS_CASE_SENSITIVE 0 -#else -#define FS_CASE_SENSITIVE 1 -#endif +# endif #endif namespace Sass { diff --git a/src/parser.cpp b/src/parser.cpp index dc44fc629c..815f84ae30 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1199,7 +1199,7 @@ namespace Sass { > >(position))) { return lhs; } // parse the operator - bool left_ws = peek < css_comments >(); + const char* left_ws = peek < css_comments >(); // parse the operator enum Sass_OP op = lex() ? Sass_OP::EQ @@ -1211,11 +1211,11 @@ namespace Sass { // we checked the possibilites on top of fn : Sass_OP::EQ; // parse the right hand side expression - bool right_ws = peek < css_comments >(); + const char* right_ws = peek < css_comments >(); // parse the right hand side expression Expression* rhs = parse_expression(); // return binary expression with a left and a right hand side - return SASS_MEMORY_NEW(ctx.mem, Binary_Expression, lhs->pstate(), { op, left_ws, right_ws }, lhs, rhs); + return SASS_MEMORY_NEW(ctx.mem, Binary_Expression, lhs->pstate(), { op, left_ws != 0, right_ws != 0 }, lhs, rhs); } // parse_relation @@ -1237,10 +1237,10 @@ namespace Sass { std::vector operands; std::vector operators; - bool left_ws = peek < css_comments >(); + const char* left_ws = peek < css_comments >(); while (lex_css< exactly<'+'> >() || lex< sequence< negate< digit >, exactly<'-'> > >()) { - bool right_ws = peek < css_comments >(); - operators.push_back({ lexed.to_string() == "+" ? Sass_OP::ADD : Sass_OP::SUB, left_ws, right_ws }); + const char* right_ws = peek < css_comments >(); + operators.push_back({ lexed.to_string() == "+" ? Sass_OP::ADD : Sass_OP::SUB, left_ws != 0, right_ws != 0 }); operands.push_back(parse_operators()); left_ws = peek < css_comments >(); } @@ -1259,13 +1259,13 @@ namespace Sass { std::vector operands; // factors std::vector operators; // ops // lex operations to apply to lhs - bool left_ws = peek < css_comments >(); + const char* left_ws = peek < css_comments >(); while (lex_css< class_char< static_ops > >()) { - bool right_ws = peek < css_comments >(); + const char* right_ws = peek < css_comments >(); switch(*lexed.begin) { - case '*': operators.push_back({ Sass_OP::MUL, left_ws, right_ws }); break; - case '/': operators.push_back({ Sass_OP::DIV, left_ws, right_ws }); break; - case '%': operators.push_back({ Sass_OP::MOD, left_ws, right_ws }); break; + case '*': operators.push_back({ Sass_OP::MUL, left_ws != 0, right_ws != 0 }); break; + case '/': operators.push_back({ Sass_OP::DIV, left_ws != 0, right_ws != 0 }); break; + case '%': operators.push_back({ Sass_OP::MOD, left_ws != 0, right_ws != 0 }); break; default: throw std::runtime_error("unknown static op parsed"); break; } operands.push_back(parse_factor()); @@ -1903,7 +1903,7 @@ namespace Sass { call->predicate(predicate); // parse mandatory block call->block(parse_block()); - // remove from stack + // return ast node stack.pop_back(); // return ast node return call; diff --git a/src/sass.hpp b/src/sass.hpp index e5f1ae384a..1d896a74eb 100644 --- a/src/sass.hpp +++ b/src/sass.hpp @@ -4,7 +4,38 @@ // undefine extensions macro to tell sys includes // that we do not want any macros to be exported -// this mainly fixes issues on smartos (SEC) +// mainly fixes an issue on SmartOS (SEC macro) #undef __EXTENSIONS__ +#ifdef _MSC_VER +#pragma warning(disable : 4005) +#endif + +// aplies to MSVC and MinGW +#ifdef _WIN32 +// we do not want the ERROR macro +# define NOGDI +// we do not want the min/max macro +# define NOMINMAX +#endif + +// should we be case insensitive +// when dealing with files or paths +#ifndef FS_CASE_SENSITIVE +# ifdef _WIN32 +# define FS_CASE_SENSITIVE 0 +# else +# define FS_CASE_SENSITIVE 1 +# endif +#endif + +// path separation char +#ifndef PATH_SEP +# ifdef _WIN32 +# define PATH_SEP ';' +# else +# define PATH_SEP ':' +# endif +#endif + #endif From 7b670e4d152dfac7732cede32b7abc38bf5e9a99 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Mon, 11 Jan 2016 01:07:03 +0100 Subject: [PATCH 5/5] Improve SunOS Makefile specifics and add documentation --- Makefile | 11 ++++++++--- docs/build-with-autotools.md | 10 ++++++++++ docs/build-with-makefiles.md | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a7deb27e64..c0aa66169b 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,10 @@ CP ?= cp -a MKDIR ?= mkdir RMDIR ?= rmdir WINDRES ?= windres -ifeq ($(OS),SunOS) # Solaris/Illumos flavors +# Solaris/Illumos flavors +# ginstall from coreutils +ifeq ($(OS),SunOS) INSTALL ?= ginstall -PREFIX ?= /opt/local endif INSTALL ?= install CFLAGS ?= -Wall @@ -134,7 +135,11 @@ ifneq ($(BUILD),shared) endif ifeq (,$(TRAVIS_BUILD_DIR)) - PREFIX ?= /usr/local + ifeq ($(OS),SunOS) + PREFIX ?= /opt/local + else + PREFIX ?= /usr/local + endif else PREFIX ?= $(TRAVIS_BUILD_DIR) endif diff --git a/docs/build-with-autotools.md b/docs/build-with-autotools.md index fa1c1a8555..a48ed18aa2 100644 --- a/docs/build-with-autotools.md +++ b/docs/build-with-autotools.md @@ -7,6 +7,16 @@ git clone https://github.com/sass/sassc.git libsass/sassc git clone https://github.com/sass/sass-spec.git libsass/sass-spec ``` +### Prerequisites + +In order to run autotools you need a few tools installed on your system. +```bash +yum install automake libtool # RedHat Linux +emerge -a automake libtool # Gentoo Linux +pkgin install automake libtool # SmartOS +``` + + ### Create configure script ```bash cd libsass diff --git a/docs/build-with-makefiles.md b/docs/build-with-makefiles.md index 41eb4edebe..7ae2e33d62 100644 --- a/docs/build-with-makefiles.md +++ b/docs/build-with-makefiles.md @@ -32,6 +32,24 @@ $ ls libsass/lib libsass.a libsass.so ``` +### Install onto the system + +We recommend to use [autotools to install](build-with-autotools.md) libsass onto the +system, since that brings all the benefits of using libtools as the main install method. +If you still want to install libsass via the makefile, you need to make sure that gnu +`install` utility (or compatible) is installed on your system. +```bash +yum install coreutils # RedHat Linux +emerge -a coreutils # Gentoo Linux +pkgin install coreutils # SmartOS +``` + +You can set the install location by setting `PREFIX` +```bash +PREFIX="/opt/local" make install +``` + + ### Compling sassc ```bash