dotfiles/proto_compiler/lib/mix/tasks/compile.proto.ex
Nikos Papadakis 59c8c6ee23
Move Mix project to the root dir
This commit moves the mix.exs, mix.lock and priv directors that were
inside app/ to the root directory. Configuration tweaks with paths were
done for the asset building.

The priv/ directory had to be moved because mix by default symlinks it
inside the build output, and I couldn't find a configuration option to
have it live inside app/
2023-11-04 16:33:51 +02:00

34 lines
732 B
Elixir

defmodule Mix.Tasks.Compile.Proto do
use Mix.Task.Compiler
@manifest "compile.proto"
@impl true
def run(_args) do
output = "./app/lib/prymn_proto"
sources = Path.wildcard("proto/*.proto")
targets = Path.wildcard(output <> "/*.pb.ex")
if Mix.Utils.stale?(sources, targets) do
{_, 0} = do_protoc(sources, output)
end
:ok
end
@impl true
def manifests(), do: [manifest()]
defp manifest(), do: Path.join(Mix.Project.manifest_path(), @manifest)
defp do_protoc(sources, output) do
System.cmd(
"protoc",
[
"--elixir_out=plugins=grpc:" <> output,
"--elixir_opt=package_prefix=prymn_proto",
"-I",
"proto"
] ++ sources
)
end
end