mirror of
https://github.com/WhatsApp/erlang-language-platform.git
synced 2025-12-23 12:26:48 +00:00
The internal and external repositories are out of sync. This Pull Request attempts to brings them back in sync by patching the GitHub repository. Please carefully review this patch. You must disable ShipIt for your project in order to merge this pull request. DO NOT IMPORT this pull request. Instead, merge it directly on GitHub using the MERGE BUTTON. Re-enable ShipIt after merging. fbshipit-source-id: 39bc64c1a96888b1034f7807ced9b7b2365df04e
78 lines
2.4 KiB
Text
78 lines
2.4 KiB
Text
load("@fbcode_macros//build_defs:native_rules.bzl", "buck_genrule")
|
|
|
|
oncall("vscode_erlang")
|
|
|
|
# Code generation rule - generates Erlang modules from template files
|
|
buck_genrule(
|
|
name = "example_service_types_erl",
|
|
srcs = [
|
|
"templates/example_service_types.erl",
|
|
],
|
|
outs = {
|
|
"example_service_types.erl": ["example_service_types.erl"],
|
|
},
|
|
bash = "cp $SRCDIR/templates/example_service_types.erl $OUT/example_service_types.erl",
|
|
cmd_exe = "copy %SRCDIR%\\templates\\example_service_types.erl %OUT%\\example_service_types.erl",
|
|
)
|
|
|
|
buck_genrule(
|
|
name = "example_service_client_erl",
|
|
srcs = [
|
|
"templates/example_service_client.erl",
|
|
],
|
|
outs = {
|
|
"example_service_client.erl": ["example_service_client.erl"],
|
|
},
|
|
bash = "cp $SRCDIR/templates/example_service_client.erl $OUT/example_service_client.erl",
|
|
cmd_exe = "copy %SRCDIR%\\templates\\example_service_client.erl %OUT%\\example_service_client.erl",
|
|
)
|
|
|
|
buck_genrule(
|
|
name = "example_service_types_hrl",
|
|
srcs = [
|
|
"templates/example_service_types.hrl",
|
|
],
|
|
outs = {
|
|
"example_service_types.hrl": ["example_service_types.hrl"],
|
|
},
|
|
bash = "cp $SRCDIR/templates/example_service_types.hrl $OUT/example_service_types.hrl",
|
|
cmd_exe = "copy %SRCDIR%\\templates\\example_service_types.hrl %OUT%\\example_service_types.hrl",
|
|
)
|
|
|
|
# Erlang library containing only the generated code
|
|
erlang_app(
|
|
name = "example_service_generated",
|
|
srcs = [
|
|
# Include generated Erlang modules from genrule output
|
|
":example_service_types_erl[example_service_types.erl]",
|
|
":example_service_client_erl[example_service_client.erl]",
|
|
],
|
|
includes = [
|
|
# Include generated header files from genrule output
|
|
":example_service_types_hrl[example_service_types.hrl]",
|
|
],
|
|
)
|
|
|
|
# Erlang application that uses the generated code (non-generated files only)
|
|
erlang_application(
|
|
name = "codegen_test_app",
|
|
srcs = glob(["app_a/src/*.erl"]),
|
|
app_name = "codegen_test",
|
|
app_src = "app_a/src/codegen_test.app.src",
|
|
applications = [
|
|
"kernel",
|
|
"stdlib",
|
|
":example_service_generated",
|
|
],
|
|
includes = glob(["app_a/include/*.hrl"]),
|
|
labels = ["user_application"],
|
|
version = "1.0.0",
|
|
)
|
|
|
|
# Test to verify the generated code works
|
|
erlang_tests(
|
|
suites = [
|
|
"app_a/test/codegen_test_SUITE.erl",
|
|
],
|
|
deps = [":codegen_test_app"],
|
|
)
|