leo-project / erocksdb

Erlang bindings to RocksDB datastore
68 stars 15 forks source link

Build erocksdb using rebar #21

Closed sthadka closed 8 years ago

sthadka commented 8 years ago

PR to fix building of erocksdb using rebar. This allows us to add the project as a dependency and build it via rebar.

mocchira commented 8 years ago

@sthadka Thank you for the PR.

There is a PR which also try to solve the same problem. https://github.com/leo-project/erocksdb/pull/16

As described the above, Some hacks is needed in order to pass environment variables to rebar.

For now https://github.com/project-fifo/erocksdb/blob/r3/rebar.config.script seems to be the most promising way. please consider integrating the above hack into your PR.

mocchira commented 8 years ago

https://github.com/leo-project/erocksdb/pull/21/commits/87e94a2bfb8bc93ede88d0469aeb838cb7e25418 seems not to solve the problem on my dev env and also travis CI. ( PLATFORM_LDFLAGS is still not passed to rebar with this commit )

you can confirm the environment variables passed to rebar by adding -vvv as below.

./rebar -vvv compile

## The below line is outputted to STDOUT when PLATFORM_LDFLAGS is passed properly
{"PLATFORM_LDFLAGS"," -lpthread -lrt  -lz -lbz2"},
sthadka commented 8 years ago

That is correct. The earlier commit you mentioned also does not work as the sequence seems to be

  1. rebar script is called
  2. pre_hooks are called
  3. rebar step (get-deps, compile etc.) is called

When the rebar script is called, the make_config.mk file doesn't still exist, so the script in itself doesn't work. I am trying to figure out a way to do it between steps 2, 3 so that the PLATFORM_LDFLAGS is present by then. Thanks for the tips, I'll try some more ideas around it.

Licenser commented 8 years ago

The .script works because it does not resolve the content until gcc is called, notice the $(..) inside this is a sub shell elected when the command is run just as $VARIABLES get only resolved when the command is run.

sthadka commented 8 years ago

I did try your solution and moved c_src/build_deps.sh from the Makefie to rebar.config as a pre-hook.

The issue was the port_spec stripped out the $ from the awk command in the rebar.config.script and it failed to run.

sthadka commented 8 years ago

@Licenser Testimony to the saying that "thinking out loud helps"!. Replaced the awk with cut command and it now works.

@mocchira Finally got the green from travis.

Licenser commented 8 years ago

Huzza! I guess the stripping of $ must be a rebar2/3 difference :(

mocchira commented 8 years ago

@sthadka @Licenser good catch! thanks for your contribution.