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

Fix sass_option_push_include_path / sass_option_push_plugin_path #1974

Merged
merged 1 commit into from
Apr 11, 2016

Conversation

xoofx
Copy link
Contributor

@xoofx xoofx commented Apr 4, 2016

This is a fix for #1871

Trying to use sass_option_push_include_path / sass_option_push_plugin_path I discovered that they were completely unplugged, while these APIs are useful to push path when the list is already prepared on the user side and we don't want to concatenate the includes (that will be splitted anyway by libsass)

collect_include_paths(paths_array[i]);
}

while (paths_array)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation looks off

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be that you're using tabs?

@xzyfer
Copy link
Contributor

xzyfer commented Apr 4, 2016

@xoofx thanks for this. My gut tells me we may need both implementations for the sake of upstreams that already implement the old char interface.

Could you also please PR how this would look with SassC?

@xoofx xoofx force-pushed the fix_sass_option_push_include_path branch from e676e1a to 158f144 Compare April 4, 2016 08:56
@xzyfer
Copy link
Contributor

xzyfer commented Apr 4, 2016

@xoofx never mind my previous comment, I'm hungry.

@am11 PTAL?

@xoofx
Copy link
Contributor Author

xoofx commented Apr 4, 2016

@xoofx never mind my previous comment, I'm hungry.

No, I did a fix and push force in the meantime ;)

You can see above a PR for sassc using this API.

@am11
Copy link
Contributor

am11 commented Apr 4, 2016

@xzyfer, I remember chatting about it with @mgreter on Slack that while include_path a string is functional, include_paths (plural) string array is not and has no affect on the output. By it looks, this change fixes that issue (I haven't tested it).

@mgreter
Copy link
Contributor

mgreter commented Apr 5, 2016

I think there was a compelling reason I disabled these, but I can't remember exactly what it was. @xoofx can you say how widely you tested it? We need to make sure it works with both APIs and preferably doesn't break if someone is funky enough to use both (IMO that we have a fixed order here is fine as doing so should not be encouraged anyway).

Other than that LGTM!

@xzyfer
Copy link
Contributor

xzyfer commented Apr 5, 2016

We have scheduled breaking API changes for 4.0 so I'm 👍 to shipping this and getting userland feedback.

@xzyfer
Copy link
Contributor

xzyfer commented Apr 5, 2016

I'm going to be AFK for the next week. @mgreter please ship this if you have no objections.

@mgreter
Copy link
Contributor

mgreter commented Apr 5, 2016

I don't even consider this one a breaking change but additional feature? But need to test this first. I hope I have some unit tests in perl-libsass for this. Maybe you can see and give feedback if node-sass is happy with the changes?

BTW. I was under the impression we make another iteration with the C-API in 3.4 (which might could be a rc for 4.0 IMO). I also would like to get rid of the obsolete C interface in 3.4. But there are a few todos open before that (access to current file, import stack etc.).

@xzyfer
Copy link
Contributor

xzyfer commented Apr 5, 2016

I won't have time this week, maybe @saper will. The SassC change looks promising (https://github.com/sass/sassc/pull/166/files)

@xoofx
Copy link
Contributor Author

xoofx commented Apr 5, 2016

@mgreter I tested it only on my wrapper and in the sassc branch. I have checked that using sass_option_set_include_path together with sass_option_push_include_path was correctly appending paths. It is not really a breaking change nor an additional feature but really just a bug fix. Previous API were just no-op.

@@ -185,11 +185,14 @@ namespace Sass {
}
}

void Context::collect_include_paths(const char** paths_array)
void Context::collect_include_paths(string_list* paths_array)
{
if (!paths_array) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if would no longer be needed (same while clause below)

@xoofx xoofx force-pushed the fix_sass_option_push_include_path branch from 158f144 to 7b9065f Compare April 6, 2016 01:16
// free intermediate data
free(include_paths);
free(plugin_paths);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you konw/can explain why this is no longer needed?
I'm also a bit worried about #1871 (comment)
Last check should be if there are any memory leaks.
But it doesn't break perl-libsass, so LGTM so far.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the previous code was basically a no-op (filling include_paths and then after freeing it).
That being said, there is a slight issue with c_ctx->include_paths that will not be released.

But I'm really not enough sure how ownership is currently working in libsass, if you could enlighten me. Looking at the code, I would assume that include_paths should be free in the sass_clear_context. Is it correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, actually, https://github.com/sass/libsass/blob/master/src/sass_context.cpp#L527 seems to release things, should be ok then? 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well there is std::vector<std::string> plugin_paths in context.hpp and struct string_list* plugin_paths in sass_context.hpp. But yes, normally we can expect memory to be alive until the main context is freed. There were also a lot of refactorings in the C++ part to re-use more of the C structs directly.

@mgreter
Copy link
Contributor

mgreter commented Apr 6, 2016

Sorry to be a bit nitpicky @xoofx. Any chance you have made an "end to end" test with sassc that requres the include path via cmd line?

@xoofx
Copy link
Contributor Author

xoofx commented Apr 6, 2016

I have tested it on the command line (only on Windows), so yes, I made a test, though quite basic. I was assuming also that there are some unit test using it?

@mgreter
Copy link
Contributor

mgreter commented Apr 6, 2016

Would like to wait for feedback from node-sass before merging (//CC @xzyfer, @am11, @saper) if their tests still pass. Other than that I don't see a reason we cannot give it a spin in 3.3.5 as incubating feature.

@mgreter
Copy link
Contributor

mgreter commented Apr 8, 2016

@xoofx can you rebase this to latest master so CI passes. Thanks!

@xoofx xoofx force-pushed the fix_sass_option_push_include_path branch from 7b9065f to bf471e2 Compare April 8, 2016 12:28
@xoofx
Copy link
Contributor Author

xoofx commented Apr 8, 2016

@xoofx can you rebase this to latest master so CI passes. Thanks!

done

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 78.013% when pulling bf471e2 on xoofx:fix_sass_option_push_include_path into aa8aa2d on sass:master.

@xzyfer
Copy link
Contributor

xzyfer commented Apr 10, 2016

@mgreter I've updated node-sass to LibSass master + this patch. Test pass. I am not using the updated interface however because include paths as a delimited string is much cleaner for us.

@xzyfer
Copy link
Contributor

xzyfer commented Apr 10, 2016

I'm happy to merge this and ship 3.3.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants