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

[WIP] Expose import stack #1600

Closed
wants to merge 11 commits into from
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ ifeq (MinGW,$(UNAME))
LIB_SHARED = $(SASS_LIBSASS_PATH)/lib/libsass.dll
endif
else
CFLAGS += -fPIC
CXXFLAGS += -fPIC
LDFLAGS += -fPIC
ifneq (Cygwin,$(UNAME))
CFLAGS += -fPIC
CXXFLAGS += -fPIC
LDFLAGS += -fPIC
endif
endif

ifeq (MinGW,$(UNAME))
Expand All @@ -177,9 +179,11 @@ ifeq (MinGW,$(UNAME))
CXXFLAGS += -D ADD_EXPORTS
endif
else
CFLAGS += -fPIC
CXXFLAGS += -fPIC
LDFLAGS += -fPIC
ifneq (Cygwin,$(UNAME))
CFLAGS += -fPIC
CXXFLAGS += -fPIC
LDFLAGS += -fPIC
endif
endif

OBJECTS = $(addprefix src/,$(SOURCES:.cpp=.o))
Expand Down
8 changes: 4 additions & 4 deletions script/ci-build-libsass
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ if [ "x$AUTOTOOLS" == "xyes" ]; then
${SHARED_OPT}
echo -en 'travis_fold:end:configure\r'

make clean $MAKE_OPTS
make $MAKE_OPTS clean

# install to prefix directory
PREFIX="$PREFIX" make install
PREFIX="$PREFIX" make $MAKE_OPTS install

else

make clean $MAKE_OPTS
make $MAKE_OPTS clean

fi

# install to prefix directory
PREFIX="$PREFIX" make install
PREFIX="$PREFIX" make $MAKE_OPTS install

ls -la $PREFIX/*

Expand Down
12 changes: 6 additions & 6 deletions src/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1859,17 +1859,17 @@ namespace Sass {
// resolved color
std::string res_name = name;

double r = round(cap_channel<0xff>(r_));
double g = round(cap_channel<0xff>(g_));
double b = round(cap_channel<0xff>(b_));
double r = Sass::round(cap_channel<0xff>(r_));
double g = Sass::round(cap_channel<0xff>(g_));
double b = Sass::round(cap_channel<0xff>(b_));
double a = cap_channel<1> (a_);

// get color from given name (if one was given at all)
if (name != "" && name_to_color(name)) {
const Color* n = name_to_color(name);
r = round(cap_channel<0xff>(n->r()));
g = round(cap_channel<0xff>(n->g()));
b = round(cap_channel<0xff>(n->b()));
r = Sass::round(cap_channel<0xff>(n->r()));
g = Sass::round(cap_channel<0xff>(n->g()));
b = Sass::round(cap_channel<0xff>(n->b()));
a = cap_channel<1> (n->a());
}
// otherwise get the possible resolved color name
Expand Down
36 changes: 27 additions & 9 deletions src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ namespace Sass {
DECLARATION,
ASSIGNMENT,
IMPORT_STUB,
IMPORTED,
IMPORT,
COMMENT,
WARNING,
Expand Down Expand Up @@ -537,30 +538,47 @@ namespace Sass {
// necessary to store a list of each in an Import node.
////////////////////////////////////////////////////////////////////////////
class Import : public Statement {
std::vector<std::string> files_;
std::vector<Expression*> urls_;
ADD_PROPERTY(List*, media_queries);
std::vector<Expression*> urls_;
std::vector<Include> incs_;
ADD_PROPERTY(List*, media_queries);
public:
Import(ParserState pstate)
: Statement(pstate),
files_(std::vector<std::string>()),
urls_(std::vector<Expression*>()),
incs_(std::vector<Include>()),
media_queries_(0)
{ statement_type(IMPORT); }
std::vector<std::string>& files() { return files_; }
std::vector<Expression*>& urls() { return urls_; }
std::vector<Expression*>& urls() { return urls_; }
std::vector<Include>& incs() { return incs_; }
ATTACH_OPERATIONS()
};

// not yet resolved single import
// so far we only know requested name
class Import_Stub : public Statement {
ADD_PROPERTY(std::string, file_name)
Include resource_;
public:
Import_Stub(ParserState pstate, std::string f)
: Statement(pstate), file_name_(f)
std::string abs_path() { return resource_.abs_path; };
std::string imp_path() { return resource_.imp_path; };
Include resource() { return resource_; };

Import_Stub(ParserState pstate, Include res)
: Statement(pstate), resource_(res)
{ statement_type(IMPORT_STUB); }
ATTACH_OPERATIONS()
};

class Imported : public Has_Block {
ADD_PROPERTY(std::string, file_name)
ADD_PROPERTY(Import_Stub*, import_stub)
public:
Imported(Import_Stub* import_stub, Block* inner)
: Has_Block(import_stub->pstate(), inner),
import_stub_(import_stub)
{ statement_type(IMPORTED); }
ATTACH_OPERATIONS()
};

//////////////////////////////
// The Sass `@warn` directive.
//////////////////////////////
Expand Down
3 changes: 1 addition & 2 deletions src/ast_fwd_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
/////////////////////////////////////////////
namespace Sass {

enum Output_Style { NESTED, EXPANDED, COMPACT, COMPRESSED, FORMATTED };

class AST_Node;
// statements
class Statement;
Expand All @@ -23,6 +21,7 @@ namespace Sass {
class Declaration;
class Assignment;
class Import;
class Imported;
class Import_Stub;
class Warning;
class Error;
Expand Down
2 changes: 1 addition & 1 deletion src/backtrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Sass {
while (this_point->parent) {

// make path relative to the current directory
std::string rel_path(Sass::File::resolve_relative_path(this_point->pstate.path, cwd, cwd));
std::string rel_path(Sass::File::abs2rel(this_point->pstate.path, cwd, cwd));

if (warning) {
ss << std::endl
Expand Down
Loading