How to share libraries in multi applications using rebar?

163 Views Asked by At

I have a project structure like this:

ROOT/
    apps/
        common_lib_1/
            src/*.erl
            include/*.hrl
        common_lib_2/
            src/*.erl
            include/*.hrl
        common_lib_3/
            src/*.erl
            include/*.hrl
        login_server/
            src/*.erl
        game_server
            src/*.erl
    rel/

I want to distribute game_server and login_server, game_server depends on common_lib_1 and common_lib_2, login_server depends on common_lib_1 and common_lib_3.

If execute rebar create-node nodeid=xxx in rel/game_server and rel/login_server, when I create distribute using rebar generate, many duplicated files will generated.

I want to distribute thems with a clean structure like this:

my_game/
    bin/
        game_server_region_1 # startup script of game server with region 1
        game_server_region_2 # startup script of game server with region 2
        login_server         # startup script of login server
        ...                  # other common files
    erts-5.10.3/
        bin/
    lib/
        stdlib-1.19.3/
        sasl-2.3.3/
        common_lib_1-1.0.0/
        common_lib_2-1.0.0/
        common_lib_3-1.0.0/
        game_server-1.0.0/
        login_server-1.0.0/
        ...                  # other shared libraries
    releases/
        1.0.0/
            game_server.boot
            game_server.rel
            game_server.script
            login_server.boot
            login_server.rel
            login_server.script
            game_server_region_1_vm.args
            game_server_region_1_sys.config
            game_server_region_1_vm.args
            game_server_region_1_sys.config
            login_server_vm.args
            login_server_sys.config
        RELEASES
        start_erl.data

I expect all applications shared libraries, they have own startup script, vm and sys config.

How to write a clean reltool.config to do this?

0

There are 0 best solutions below