From 7e639a1a9db7165a0be3f7981956b3b630d33644 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Fri, 29 Mar 2024 20:27:21 -0500 Subject: [PATCH] Add bin/physical.sh (#4997) --- bin/physical.sh | 218 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100755 bin/physical.sh diff --git a/bin/physical.sh b/bin/physical.sh new file mode 100755 index 000000000..c2c5aad68 --- /dev/null +++ b/bin/physical.sh @@ -0,0 +1,218 @@ +#!/bin/bash + +set -o errexit + +marker_base=985c80fbc6131f3a8cedd0da7e8af98dfceb13c7 +marker_commit=${1:-${marker_base}} + +if [ $(git merge-base ${marker_commit} ${marker_base}) != ${marker_base} ]; then + echo "first marker commit not an ancestor: ${marker_commit}" + exit 1 +fi + +if [ $(git merge-base ${marker_commit} HEAD) != $(git rev-parse --verify ${marker_commit}) ]; then + echo "given marker commit not an ancestor: ${marker_commit}" + exit 1 +fi + +if [ -e Builds/CMake ]; then + echo move CMake + git mv Builds/CMake cmake + git add --update . + git commit -m 'Move CMake directory' --author 'Pretty Printer ' +fi + +if [ -e src/ripple ]; then + + echo move protocol buffers + mkdir -p include/xrpl + if [ -e src/ripple/proto ]; then + git mv src/ripple/proto include/xrpl + fi + + extract_list() { + git show ${marker_commit}:Builds/CMake/RippledCore.cmake | \ + awk "/END ${1}/ { p = 0 } p && /src\/ripple/; /BEGIN ${1}/ { p = 1 }" | \ + sed -e 's#src/ripple/##' -e 's#[^a-z]\+$##' + } + + move_files() { + oldroot="$1"; shift + newroot="$1"; shift + detail="$1"; shift + files=("$@") + for file in ${files[@]}; do + if [ ! -e ${oldroot}/${file} ]; then + continue + fi + dir=$(dirname ${file}) + if [ $(basename ${dir}) == 'details' ]; then + dir=$(dirname ${dir}) + fi + if [ $(basename ${dir}) == 'impl' ]; then + dir="$(dirname ${dir})/${detail}" + fi + mkdir -p ${newroot}/${dir} + git mv ${oldroot}/${file} ${newroot}/${dir} + done + } + + echo move libxrpl headers + files=$(extract_list 'LIBXRPL HEADERS') + files+=( + basics/SlabAllocator.h + + beast/asio/io_latency_probe.h + beast/container/aged_container.h + beast/container/aged_container_utility.h + beast/container/aged_map.h + beast/container/aged_multimap.h + beast/container/aged_multiset.h + beast/container/aged_set.h + beast/container/aged_unordered_map.h + beast/container/aged_unordered_multimap.h + beast/container/aged_unordered_multiset.h + beast/container/aged_unordered_set.h + beast/container/detail/aged_associative_container.h + beast/container/detail/aged_container_iterator.h + beast/container/detail/aged_ordered_container.h + beast/container/detail/aged_unordered_container.h + beast/container/detail/empty_base_optimization.h + beast/core/LockFreeStack.h + beast/insight/Collector.h + beast/insight/Counter.h + beast/insight/CounterImpl.h + beast/insight/Event.h + beast/insight/EventImpl.h + beast/insight/Gauge.h + beast/insight/GaugeImpl.h + beast/insight/Group.h + beast/insight/Groups.h + beast/insight/Hook.h + beast/insight/HookImpl.h + beast/insight/Insight.h + beast/insight/Meter.h + beast/insight/MeterImpl.h + beast/insight/NullCollector.h + beast/insight/StatsDCollector.h + beast/test/fail_counter.h + beast/test/fail_stream.h + beast/test/pipe_stream.h + beast/test/sig_wait.h + beast/test/string_iostream.h + beast/test/string_istream.h + beast/test/string_ostream.h + beast/test/test_allocator.h + beast/test/yield_to.h + beast/utility/hash_pair.h + beast/utility/maybe_const.h + beast/utility/temp_dir.h + + # included by only json/impl/json_assert.h + json/json_errors.h + + protocol/PayChan.h + protocol/RippleLedgerHash.h + protocol/messages.h + protocol/st.h + ) + files+=( + basics/README.md + crypto/README.md + json/README.md + protocol/README.md + resource/README.md + ) + move_files src/ripple include/xrpl detail ${files[@]} + + echo move libxrpl sources + files=$(extract_list 'LIBXRPL SOURCES') + move_files src/ripple src/libxrpl "" ${files[@]} + + echo check leftovers + dirs=$(cd include/xrpl; ls -d */) + dirs=$(cd src/ripple; ls -d ${dirs} 2>/dev/null || true) + files="$(cd src/ripple; find ${dirs} -type f)" + if [ -n "${files}" ]; then + echo "leftover files:" + echo ${files} + exit + fi + + echo remove empty directories + empty_dirs="$(cd src/ripple; find ${dirs} -depth -type d)" + for dir in ${empty_dirs[@]}; do + if [ -e ${dir} ]; then + rmdir ${dir} + fi + done + + echo move xrpld sources + files=$( + extract_list 'XRPLD SOURCES' + cd src/ripple + find * -regex '.*\.\(h\|ipp\|md\|pu\|uml\|png\)' + ) + move_files src/ripple src/xrpld detail ${files[@]} + + files="$(cd src/ripple; find . -type f)" + if [ -n "${files}" ]; then + echo "leftover files:" + echo ${files} + exit + fi + +fi + +rm -rf src/ripple + +echo rename .hpp to .h +find include src -name '*.hpp' -exec bash -c 'f="{}"; git mv "${f}" "${f%hpp}h"' \; + +echo move PerfLog.h +if [ -e include/xrpl/basics/PerfLog.h ]; then + git mv include/xrpl/basics/PerfLog.h src/xrpld/perflog +fi + +# Make sure all protobuf includes have the correct prefix. +protobuf_replace='s:^#include\s*["<].*org/xrpl\([^">]\+\)[">]:#include :' +# Make sure first-party includes use angle brackets and .h extension. +ripple_replace='s:include\s*["<]ripple/\(.*\)\.h\(pp\)\?[">]:include :' +beast_replace='s:include\s*:#include :" \ + -e "s:^#include ' +find include src -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -exec clang-format-10 -i {} + +git add --update . +git commit -m 'Rewrite includes' --author 'Pretty Printer ' +./Builds/levelization/levelization.sh +git add --update . +git commit -m 'Recompute loops' --author 'Pretty Printer '