Fix for unusual source code locations relative to the include directory. #3

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
@jamesleegwu

This fixes compilation for cases when the include directory is not just one directory up from the source code location. For example, if I have a project set up like

/project/foo/ebin/foo.beam
/project/foo/include/foo.hrl
/project/foo/src/web/foo.erl

Then it was compiled like:

erlc -o ebin -I include src/web/foo.erl

and foo:module_info() contains

{options, [{i, "include"}]} (among other things)

Before this change, sync would modify the include directory based on the source file location like:

/project/foo/src/web/../include

Instead, we need to use include relative to the base directory. In this case, we can find it between the source code and the beam file:

"/project/foo" = find_basedir("/project/foo/ebin/foo.beam", "/project/foo/src/web/foo.erl").

James Lee added some commits Feb 19, 2011

James Lee
Fix issue where source code is not just one directory down from the i…
…nclude directory. This change finds the base directory of where the source and beam file are located, and uses that to find the include directory.
@jamesleegwu

This comment has been minimized.

Show comment Hide comment
@jamesleegwu

jamesleegwu Feb 19, 2011

Well, this isn't completely perfect. If there are no directories in common, then the code crashes when trying to join an empty list:

=ERROR REPORT==== 19-Feb-2011::01:27:53 ===
** Generic server sync_worker terminating 
** Last message in was {'$gen_cast',recompile}
** When Server state == {state}
** Reason for termination == 
** {function_clause,[{filename,join,[[]]},
                     {sync_worker,transform_options,3},
                     {sync_worker,possibly_compile,1},
                     {sync_worker,'-recompile/1-lc$^0/1-0-',1},
                     {sync_worker,recompile,1},
                     {sync_worker,handle_cast,2},
                     {gen_server,handle_msg,5},
                     {proc_lib,init_p_do_apply,3}]}

My solution is in jamesleegwu/sync@b36ce77, but there may be a better one.

Well, this isn't completely perfect. If there are no directories in common, then the code crashes when trying to join an empty list:

=ERROR REPORT==== 19-Feb-2011::01:27:53 ===
** Generic server sync_worker terminating 
** Last message in was {'$gen_cast',recompile}
** When Server state == {state}
** Reason for termination == 
** {function_clause,[{filename,join,[[]]},
                     {sync_worker,transform_options,3},
                     {sync_worker,possibly_compile,1},
                     {sync_worker,'-recompile/1-lc$^0/1-0-',1},
                     {sync_worker,recompile,1},
                     {sync_worker,handle_cast,2},
                     {gen_server,handle_msg,5},
                     {proc_lib,init_p_do_apply,3}]}

My solution is in jamesleegwu/sync@b36ce77, but there may be a better one.

@choptastic

This comment has been minimized.

Show comment Hide comment
@choptastic

choptastic Mar 12, 2014

Collaborator

This should be resolved. If it's not, could you re-implement the Pull request from the current HEAD so that it merges cleanly?

Collaborator

choptastic commented Mar 12, 2014

This should be resolved. If it's not, could you re-implement the Pull request from the current HEAD so that it merges cleanly?

@choptastic choptastic closed this Mar 12, 2014

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