Closed zmstone closed 9 years ago
You can include options to smother:compile("someerl.erl",[{i,"my/dir/include"}]) but it is supposed to include the original directory, so if it was in the same folder it would still be included...
BTW: no, it would not be fun to run it on itself - some of the patterns for the AST are horrible :)
I was using escriptized smother, perhaps i missed something, is there a way to pass options to the script?
Again, perhaps I missed something, but smother:compile/2 doesn't work either, at least not in OTP17. Not digging deeper, but epp:parse_file/3 (called in smother:compile/2) is perhaps broken in OTP17, If i switch to epp:parse_file(FileName, [{includes, IncludePath}, {macros, PredefMacros}]). it works with "-include(...)"
So there is a file under test called include_test.erl that includes two different header files. Travis-ci shows that working in OTP 17 and 17.3. There was something in 17.2 that broken everything, but whatever it was it was corrected in 17.3 and later.
If you can get include_test.erl to work but not your file thne please can you identify whats different?
include_test.erl doesn't compile unless make below change in smother.erl (master branch)
diff --git a/src/smother.erl b/src/smother.erl
index 5d2f083..02ecb95 100644
--- a/src/smother.erl
+++ b/src/smother.erl
@@ -58,7 +58,7 @@ compile(Filename,Options) ->
filename:join([CWD,SrcDir])
end,
TmpFile = smother_annotater:make_tmp_file(ModName,Code),
- {ok,Forms} = epp:parse_file(TmpFile,[{i,SourceDir}|Includes],[{'TEST', true}]),
+ {ok,Forms} = epp:parse_file(TmpFile,[SourceDir | Includes],[{'TEST', true}]),
smother_server:store_zero(),
I was wrong about epp:parse_file/3 bing broken. epp:parse_file/3 works fine with this change.
You know that moment when you read some code, then you read the docs, then you wonder how much you had drunk when you were writing that code... :)
Fixed in the latest push.
Failed with error: can't find include file "somehrl.hrl", i think such hrl files should be copied to e.g. /tmp before compile or ?
BTW, it would be fun to see the analyzing result of Smother itself. :)