Skip to content

Commit

Permalink
Set rebar.config "lib_dirs" to the built CouchDB location
Browse files Browse the repository at this point in the history
  • Loading branch information
jhs committed Nov 25, 2012
1 parent a0e6bfa commit 624377d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
27 changes: 27 additions & 0 deletions lib/templates/rebar.config.script
@@ -0,0 +1,27 @@
Add = fun(Dirs, Dir) -> ok
, case lists:member(Dir, Dirs)
of true -> Dirs
; _ -> Dirs ++ [Dir]
end
end
.

case os:getenv("COUCHDB_DEP")
of false -> CONFIG % env var not defined
; "" -> CONFIG % env var set to empty string
; Dir -> ok
% Always replace the library path given. This guarantees the most isolation and portability of the plugin. However, it may
% make things brittle.
, Dirs = case lists:keyfind(lib_dirs, 1, CONFIG)
of false -> ok
, []
; {lib_dirs, Lib_dirs} -> ok
%, Lib_dirs % Nope
, []
end
, New_dirs = Add(Dirs, Dir)
, Result = lists:keystore(lib_dirs, 1, CONFIG, {lib_dirs, New_dirs})
, io:format(standard_error, "Rebar config:\n~p\n", [Result])
, Result
end
.
12 changes: 11 additions & 1 deletion tasks/couchdb.rake
Expand Up @@ -147,13 +147,23 @@ namespace :couchdb do
gmake "COUCH_SRC='#{COUCH_SOURCE}/src/couchdb' clean"
gmake "COUCH_SRC='#{COUCH_SOURCE}/src/couchdb'"
elsif File.exists? 'rebar'
make_script = false
begin
ENV['ERL_COMPILER_OPTIONS'] = "[{i, \"#{COUCH_SOURCE}/src/couchdb\"}]"
if File.exists?("rebar.config") && !File.exists?("rebar.config.script")
make_script = true
ENV['COUCHDB_DEP'] = "#{COUCH_BUILD}/lib/couchdb/erlang/lib"
sh "cp", "-n", "#{HERE}/lib/templates/rebar.config.script", "." # noclobber
else
ENV['ERL_COMPILER_OPTIONS'] = "[{i, \"#{COUCH_SOURCE}/src/couchdb\"}]"
end

sh "./rebar clean"
sh "./rebar get-deps" unless ENV['skip_deps']
sh "./rebar compile"
ensure
ENV.delete('ERL_COMPILER_OPTIONS')
ENV.delete('COUCHDB_DEP')
sh "rm", "-f", "rebar.config.script" if make_script
end
else
raise "I do not know how to build this plugin: #{source}"
Expand Down

0 comments on commit 624377d

Please sign in to comment.