Code Monkey home page Code Monkey logo

Comments (5)

tothlac avatar tothlac commented on June 25, 2024 1

So I have just tried it on our projects with a simple modification in katt's code. I've moved prv/katt_blueprint.peg => src/katt_blueprint.peg and added

{plugins, [
           rebar3_neotoma_plugin
          ]}.

{provider_hooks, [
                 {pre, [
                        {compile, {neotoma, compile}}
                       ]}
                 ]}.

to rebar.config and commented out

{post_hooks, [{compile, "./priv/compile-parser"}]}.

Actually now there is no need for priv/compile-parser anymore. Should I create a pull request?

from katt.

tothlac avatar tothlac commented on June 25, 2024

The problem is definitely with the current compile order in rebar3. Now the pre_hooks are called before the dependencies of the project are compiled which is wrong.

Fred Herbert mentioned me this neotoma plugin:

https://github.com/tsloughter/rebar3_neotoma_plugin

I've tried and it actually works, the only problem is that it does not support an src_dir parameter. This is a problem because katt_blueprint.peg is stored in the priv folder, and the plugin wants to compile .peg files stored only in the src directory.

Either katt_blueprint.peg should be moved into ./src or the plugin should be slightly modified. Can you see any other options?

from katt.

brucify avatar brucify commented on June 25, 2024

@tothlac I tried your https://github.com/tothlac/try_katt with a branch of katt using the rebar3_neotoma_plugin plugin:

               {katt,
                   {git,
                       "[email protected]:brucify/katt.git",
                       {branch,"use-rebar3-neotoma-plugin"}}}

With katt rebar.config:

{plugins, [rebar3_neotoma_plugin]}.
{provider_hooks, [{pre, [{compile, {neotoma, compile}}]}]}.

It seems that katt_blueprint.erl is still not generated:

✗ rebar3 eunit
...
===> Performing EUnit tests...
F
Failures:

  1) try_katt_test:katt_test/0: module 'try_katt_test'
     Failure/Error: {error,undef,
                        [{katt_blueprint,module_info,[],[]},
                         {try_katt_test,katt_test,0,
                             [{file,
                                  "/Users/bruce/git/try_katt/test/try_katt_test.erl"},
                              {line,6}]},
                         {try_katt_test,katt_test,0,[]}]}
     Output:

Finished in 0.063 seconds
1 tests, 1 failures
✗ ls -l _build/test/lib/katt/src
total 240
-rw-r--r--  1 bruce  staff   1140 Feb 16 17:47 katt.app.src
-rw-r--r--  1 bruce  staff  16572 Feb 16 17:47 katt.erl
-rw-r--r--  1 bruce  staff   4006 Feb 16 17:47 katt.hrl
-rw-r--r--  1 bruce  staff   2174 Feb 16 17:47 katt_blueprint_parse.erl
-rw-r--r--  1 bruce  staff  12642 Feb 16 17:47 katt_callbacks.erl
-rw-r--r--  1 bruce  staff   7407 Feb 16 17:47 katt_callbacks_json.erl
-rw-r--r--  1 bruce  staff   6989 Feb 16 17:47 katt_callbacks_wfu.erl
-rw-r--r--  1 bruce  staff   6140 Feb 16 17:47 katt_cli.erl
-rw-r--r--  1 bruce  staff   6766 Feb 16 17:47 katt_har_cli.erl
-rw-r--r--  1 bruce  staff   2341 Feb 16 17:47 katt_request.erl
-rw-r--r--  1 bruce  staff   2126 Feb 16 17:47 katt_response.erl
-rw-r--r--  1 bruce  staff  20030 Feb 16 17:47 katt_util.erl
-rw-r--r--  1 bruce  staff  11000 Feb 16 17:47 katt_validate_type.erl
✗ rebar3 version
rebar 3.18.0 on Erlang/OTP 22 Erts 10.6.1

However if I go into _build/test/lib/katt, change the rebar.config and compile, it correctly generates the katt_blueprint.erl file.

Did you get it to work?

Edit:
It seems I forgot to move priv/katt_blueprint.peg to src/katt_blueprint.peg. Everything works after I did that.

===> Performing EUnit tests...
.
Finished in 0.105 seconds
1 tests, 0 failures

✗ ls -l _build/test/lib/katt/src
total 320
...
-rw-r--r--  1 bruce  staff  26348 Feb 16 18:39 katt_blueprint.erl
-rw-r--r--  1 bruce  staff   8525 Feb 16 18:39 katt_blueprint.peg
...
✗ ls -l _build/test/lib/katt/ebin
total 328
...
-rw-r--r--  1 bruce  staff  46032 Feb 16 18:39 katt_blueprint.beam
...

This is probably because rebar3_neotoma_plugin only looks for and outputs .peg files in the src directory:

         SourceDir = filename:join(rebar_app_info:dir(AppInfo), "src"),
         CompileFun = fun(Source, Target, _Config) ->
                              OutDir = filename:dirname(Target),
                              neotoma:file(Source, [{output, OutDir}])
                      end,

         rebar_base_compiler:run(Opts, [], SourceDir, ".peg", SourceDir, ".erl", CompileFun, [{check_last_mod, true}])

from katt.

andreineculau avatar andreineculau commented on June 25, 2024

bump
Sorry for the silence. Before I jump into this, I wanted to check if you have reached a solution @brucify @tothlac .
Thanks for reporting!

from katt.

brucify avatar brucify commented on June 25, 2024

Sorry for a late response. I have a commit here that does what I mentioned above:

  • uses rebar3 plugin rebar3_neotoma_plugin
  • removes priv/compile-parser
  • moves priv/katt_blueprint.peg to src/katt_blueprint.peg

I can create a PR for this.

from katt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.