Skip to content

Commit

Permalink
Add makefile rules for regenerating from a local xdrgen (#221)
Browse files Browse the repository at this point in the history
* Add makefile rules for regenerating from a local xdrgen

* Run bundle install in deployment mode so that gems are installed in the working directory as a cheap hack to reuse them across runs

Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
  • Loading branch information
brson and leighmcculloch authored Dec 10, 2022
1 parent 2ee97b1 commit 4bad637
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,37 @@ generate: src/curr/generated.rs xdr/curr-version src/next/generated.rs xdr/next-

src/curr/generated.rs: $(sort $(wildcard xdr/curr/*.x))
> $@
ifeq ($(LOCAL_XDRGEN),)
docker run -i --rm -v $$PWD:/wd -w /wd docker.io/library/ruby:latest /bin/bash -c '\
gem install specific_install -v 0.3.7 && \
gem specific_install https://github.com/stellar/xdrgen.git -b $(XDRGEN_VERSION) && \
xdrgen --language rust --namespace generated --output src/curr $^ \
'
else
docker run -i --rm -v $$PWD/../xdrgen:/xdrgen -v $$PWD:/wd -w /wd docker.io/library/ruby:latest /bin/bash -c '\
pushd /xdrgen && bundle install --deployment && rake install && popd && \
xdrgen --language rust --namespace generated --output src/curr $^ \
'
endif
rustfmt $@

xdr/curr-version: $(wildcard .git/modules/xdr/curr/**/*) $(wildcard xdr/curr/*.x)
git submodule status -- xdr/curr | sed 's/^ *//g' | cut -f 1 -d " " | tr -d '\n' > xdr/curr-version

src/next/generated.rs: $(sort $(wildcard xdr/next/*.x))
> $@
ifeq ($(LOCAL_XDRGEN),)
docker run -i --rm -v $$PWD:/wd -w /wd docker.io/library/ruby:latest /bin/bash -c '\
gem install specific_install -v 0.3.7 && \
gem specific_install https://github.com/stellar/xdrgen.git -b $(XDRGEN_VERSION) && \
xdrgen --language rust --namespace generated --output src/next $^ \
'
else
docker run -i --rm -v $$PWD/../xdrgen:/xdrgen -v $$PWD:/wd -w /wd docker.io/library/ruby:latest /bin/bash -c '\
pushd /xdrgen && bundle install --deployment && rake install && popd && \
xdrgen --language rust --namespace generated --output src/next $^ \
'
endif
rustfmt $@

xdr/next-version: $(wildcard .git/modules/xdr/next/**/*) $(wildcard xdr/next/*.x)
Expand Down

0 comments on commit 4bad637

Please sign in to comment.