Building C code in dep with rebar3: c_src not found

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Building C code in dep with rebar3: c_src not found

Igor Clark
Hi everyone,

I have an simple app which has a C port in it. I have a rebar.config from which it builds correctly when I run 'rebar3 compile' inside the app directory:

> { erl_opts, [debug_info] }.
> { deps, [] }.
>
> { plugins, [
> { pc, { git, "https://github.com/blt/port_compiler.git", { tag, "v1.10.1" } } }
> ] }.
>
> { provider_hooks, [
> { pre, [
> { compile, { pc, compile }},
> { clean, { pc, clean }}
> ] }
> ] }.
>
> { port_specs, [
> { "priv/bin/my_port_binary", [
> "c_src/my_c_file.1.c",
> "c_src/subdir/my_c_file_2.c"
> ] }
> ] }.
>
> { port_env, [
> { "CFLAGS", "$CFLAGS -Ic_src/ -g -Wall -Werror -O2" }
> ] }.


Compiling this works fine. The artifact is created in priv/bin, and running myapp:module_info() inside the shell shows the right details.

However, when I try to include this app as a dependency, I get this error:

> ===> Found no source files for:
> "c_src/my_c_file.1.c"
> ===> Found no source files for:
> "c_src/subdir/my_c_file_2.c"


I've included src, c_src and rebar.config in the 'files' entry in src/my_app.app.src.

I've also included a jiffy dep as a test to make sure C code gets built correctly, and that works fine, but I can't see what jiffy's config has that I don't.

Anyone know what I'm missing to make this work?

Thanks very much!
Igor
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Building C code in dep with rebar3: c_src not found

Igor Clark
Reading it back, I'm not sure if I made this very clear:

- project A is an OTP app containing C port code in c_src, and the above rebar.config with port compiler info
- project B is another OTP app referencing project A as a source dependency in project B's rebar config
- when I build project A in its own dir with 'rebar3 compile', it compiles the C code as expected
- when I build project B in its own dir with 'rebar3 compile', it recognises the port compiler dependency in project A's rebar.config, downloads and compiles it, but then fails to compile project A as a dep, saying "found no source files"

So I need some way for the port compiler, when running in the context of the parent app A, to know the proper path for 'c_src' inside the source dependency B. Can't see how it could be any problem with the port compiler, not least because jiffy uses it fine, so I must be missing something!

Incidentally I added CXXFLAGS to the port_env as well, but no difference, as expected. Clutching at straws somewhat there. ;-)

I also tried using a Makefile, which I guess is the intended rebar3 way, and that seems to work - but I'd love to know what's happening here.

Cheers,
Igor



On Wed, Jan 23, 2019 at 7:35 PM Igor Clark <[hidden email]> wrote:
Hi everyone,

I have an simple app which has a C port in it. I have a rebar.config from which it builds correctly when I run 'rebar3 compile' inside the app directory:

> { erl_opts, [debug_info] }.
> { deps, [] }.
>
> { plugins, [
>       { pc, { git, "https://github.com/blt/port_compiler.git", { tag, "v1.10.1" } } }
> ] }.
>
> { provider_hooks, [
>       { pre, [
>               { compile, { pc, compile }},
>               { clean, { pc, clean }}
>       ] }
> ] }.
>
> { port_specs, [
>       { "priv/bin/my_port_binary", [
>               "c_src/my_c_file.1.c",
>               "c_src/subdir/my_c_file_2.c"
>       ] }
> ] }.
>
> { port_env, [
>       { "CFLAGS", "$CFLAGS -Ic_src/ -g -Wall -Werror -O2" }
> ] }.


Compiling this works fine. The artifact is created in priv/bin, and running myapp:module_info() inside the shell shows the right details.

However, when I try to include this app as a dependency, I get this error:

> ===> Found no source files for:
> "c_src/my_c_file.1.c"
> ===> Found no source files for:
> "c_src/subdir/my_c_file_2.c"


I've included src, c_src and rebar.config in the 'files' entry in src/my_app.app.src.

I've also included a jiffy dep as a test to make sure C code gets built correctly, and that works fine, but I can't see what jiffy's config has that I don't.

Anyone know what I'm missing to make this work?

Thanks very much!
Igor

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Building C code in dep with rebar3: c_src not found

Bryan Paxton

 Hi,

 Is this a directory with a set of apps in it or is this an umbrella? (i.e., you have a top level rebar.config). AFAIK there's only two ways you can have local dependencies like this... in an umbrella or using checkout dependencies.

Either way could you share the rebar config for project B? In some loose form that is.

 I just made an umbrella using rebar3 and could not replicate the issue. Note that in an umbrella I must be top level when running rebar3 compile, etc.

--

Bryan


On 1/23/19 6:58 PM, Igor Clark wrote:
Reading it back, I'm not sure if I made this very clear:

- project A is an OTP app containing C port code in c_src, and the above rebar.config with port compiler info
- project B is another OTP app referencing project A as a source dependency in project B's rebar config
- when I build project A in its own dir with 'rebar3 compile', it compiles the C code as expected
- when I build project B in its own dir with 'rebar3 compile', it recognises the port compiler dependency in project A's rebar.config, downloads and compiles it, but then fails to compile project A as a dep, saying "found no source files"

So I need some way for the port compiler, when running in the context of the parent app A, to know the proper path for 'c_src' inside the source dependency B. Can't see how it could be any problem with the port compiler, not least because jiffy uses it fine, so I must be missing something!

Incidentally I added CXXFLAGS to the port_env as well, but no difference, as expected. Clutching at straws somewhat there. ;-)

I also tried using a Makefile, which I guess is the intended rebar3 way, and that seems to work - but I'd love to know what's happening here.

Cheers,
Igor



On Wed, Jan 23, 2019 at 7:35 PM Igor Clark <[hidden email]> wrote:
Hi everyone,

I have an simple app which has a C port in it. I have a rebar.config from which it builds correctly when I run 'rebar3 compile' inside the app directory:

> { erl_opts, [debug_info] }.
> { deps, [] }.
>
> { plugins, [
>       { pc, { git, "https://github.com/blt/port_compiler.git", { tag, "v1.10.1" } } }
> ] }.
>
> { provider_hooks, [
>       { pre, [
>               { compile, { pc, compile }},
>               { clean, { pc, clean }}
>       ] }
> ] }.
>
> { port_specs, [
>       { "priv/bin/my_port_binary", [
>               "c_src/my_c_file.1.c",
>               "c_src/subdir/my_c_file_2.c"
>       ] }
> ] }.
>
> { port_env, [
>       { "CFLAGS", "$CFLAGS -Ic_src/ -g -Wall -Werror -O2" }
> ] }.


Compiling this works fine. The artifact is created in priv/bin, and running myapp:module_info() inside the shell shows the right details.

However, when I try to include this app as a dependency, I get this error:

> ===> Found no source files for:
> "c_src/my_c_file.1.c"
> ===> Found no source files for:
> "c_src/subdir/my_c_file_2.c"


I've included src, c_src and rebar.config in the 'files' entry in src/my_app.app.src.

I've also included a jiffy dep as a test to make sure C code gets built correctly, and that works fine, but I can't see what jiffy's config has that I don't.

Anyone know what I'm missing to make this work?

Thanks very much!
Igor

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Building C code in dep with rebar3: c_src not found

Igor Clark
Hi Bryan! Thanks for getting back to me.

Turns out this only happens with the latest version 1.10.1 of the port compiler - I tried older versions and everything works out as expected. Seems I'm not the only one who's seen this either. I'm going to pin pc to 1.9.1 in my project A, as everything works as I thought it should with that version.

Just to tidy up, to answer your question, yes it's an umbrella app - the 'parent' app B is one that I made with "rebar3 new release", and then added project A as a remote source dependency, i.e. from a git repo, into 'deps' in project B's rebar.config. I'm running rebar3 commands from top level in project B.

Appreciate your time!

best,
i

On 24 Jan 2019, at 05:18, Bryan Paxton <[hidden email]> wrote:

 Hi,

 Is this a directory with a set of apps in it or is this an umbrella? (i.e., you have a top level rebar.config). AFAIK there's only two ways you can have local dependencies like this... in an umbrella or using checkout dependencies.

Either way could you share the rebar config for project B? In some loose form that is.

 I just made an umbrella using rebar3 and could not replicate the issue. Note that in an umbrella I must be top level when running rebar3 compile, etc.

--

Bryan


On 1/23/19 6:58 PM, Igor Clark wrote:
Reading it back, I'm not sure if I made this very clear:

- project A is an OTP app containing C port code in c_src, and the above rebar.config with port compiler info
- project B is another OTP app referencing project A as a source dependency in project B's rebar config
- when I build project A in its own dir with 'rebar3 compile', it compiles the C code as expected
- when I build project B in its own dir with 'rebar3 compile', it recognises the port compiler dependency in project A's rebar.config, downloads and compiles it, but then fails to compile project A as a dep, saying "found no source files"

So I need some way for the port compiler, when running in the context of the parent app A, to know the proper path for 'c_src' inside the source dependency B. Can't see how it could be any problem with the port compiler, not least because jiffy uses it fine, so I must be missing something!

Incidentally I added CXXFLAGS to the port_env as well, but no difference, as expected. Clutching at straws somewhat there. ;-)

I also tried using a Makefile, which I guess is the intended rebar3 way, and that seems to work - but I'd love to know what's happening here.

Cheers,
Igor



On Wed, Jan 23, 2019 at 7:35 PM Igor Clark <[hidden email]> wrote:
Hi everyone,

I have an simple app which has a C port in it. I have a rebar.config from which it builds correctly when I run 'rebar3 compile' inside the app directory:

> { erl_opts, [debug_info] }.
> { deps, [] }.
>
> { plugins, [
>       { pc, { git, "https://github.com/blt/port_compiler.git", { tag, "v1.10.1" } } }
> ] }.
>
> { provider_hooks, [
>       { pre, [
>               { compile, { pc, compile }},
>               { clean, { pc, clean }}
>       ] }
> ] }.
>
> { port_specs, [
>       { "priv/bin/my_port_binary", [
>               "c_src/my_c_file.1.c",
>               "c_src/subdir/my_c_file_2.c"
>       ] }
> ] }.
>
> { port_env, [
>       { "CFLAGS", "$CFLAGS -Ic_src/ -g -Wall -Werror -O2" }
> ] }.


Compiling this works fine. The artifact is created in priv/bin, and running myapp:module_info() inside the shell shows the right details.

However, when I try to include this app as a dependency, I get this error:

> ===> Found no source files for:
> "c_src/my_c_file.1.c"
> ===> Found no source files for:
> "c_src/subdir/my_c_file_2.c"


I've included src, c_src and rebar.config in the 'files' entry in src/my_app.app.src.

I've also included a jiffy dep as a test to make sure C code gets built correctly, and that works fine, but I can't see what jiffy's config has that I don't.

Anyone know what I'm missing to make this work?

Thanks very much!
Igor

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions