Skip to content

Commit

Permalink
xdr: add instructions for generating xdr (#4280)
Browse files Browse the repository at this point in the history
Add a readme for the xdr package describing how to generate xdr.

I frequently forget and have to figure it out each time. This might help someone else too.

The examples use docker so that it is a quick copy/paste for most people. We use docker frequently so most of us have docker. There's a good chance that less of us have ruby setup in a good state locally.

I also added the ref to the Rakefile because I also forget how to specify a different source location for downloading XDR and if the ref was always specified it would be easier to just edit it.
  • Loading branch information
leighmcculloch authored Mar 15, 2022
1 parent 9b3cb40 commit 3d935af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace :xdr do

HAYASHI_XDR.each do |src|
local_path = "xdr/" + File.basename(src)
encoded = client.contents("stellar/stellar-core", path: src).content
encoded = client.contents("stellar/stellar-core", query: {ref: "master"}, path: src).content
decoded = Base64.decode64 encoded

IO.write(local_path, decoded)
Expand Down
21 changes: 21 additions & 0 deletions xdr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# xdr

The xdr package contains encoding/decoding of Stellar XDR types.

## Code Generate

Most of the code this package is generated.

To download new XDR for code generation:

```
docker run --platform linux/amd64 -it --rm -v $PWD:/wd -w /wd ruby /bin/bash -c 'bundle install && bundle exec rake xdr:download'
```

To regenerate the code from the local XDR:

```
docker run --platform linux/amd64 -it --rm -v $PWD:/wd -w /wd ruby /bin/bash -c 'bundle install && bundle exec rake xdr:generate' && go fmt ./xdr
```

To download XDR for a different branch of stellar-core, modify `Rakefile` in the root.

0 comments on commit 3d935af

Please sign in to comment.