xdrgen
is a code generator that takes XDR IDL files (.x
files) as specified
in RFC 4506 and spits code out in
various languages.
xdrgen
requires ruby 2.1 or later to run.
Xdrgen is a very early project. Aside from the test fixtures in spec/fixtures, the only .x files that have been thrown at it are the .x files used for the stellar-core project.
Xdrgen presently supports these output languages: ruby, javacript, java, golang, elixir and Python:
Testing is very sparse, but will improve over time.
Xdrgen is a rubygem, compatible with ruby 2.1 or higher
$ gem install xdrgen
The command line:
xdrgen [-o OUTPUT_DIR] [-l LANGUAGE] [-n NAMESPACE] [INPUT_FILES ...]
--rust-types-custom-str-impl
: Used to specify a comma-separated list of type names that should not have string conversion code generated as it will be provided by custom implementations provided by the developer using the generated code.
Add this line to your application's Gemfile:
gem 'xdrgen'
And then execute:
$ bundle
Example usage:
require 'xdrgen'
# create a compilation object, specifying your options
c = Xdrgen::Compilation.new(
["MyProgram.x"],
output_dir:"src/generated",
language: :ruby,
namespace: "MyProgram::XDR",
options: {
rust_types_custom_str_impl: [],
rust_types_custom_jsonschema_impl: [],
},
)
# then run compile
c.compile
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)