diff --git a/.travis.yml b/.travis.yml index aaa2cb96..8c93d3f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,9 @@ matrix: apt: sources: - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-5.0 packages: - - clang-format-3.9 + - clang-format-5.0 - g++-6 install: - export CC=gcc-6 diff --git a/Makefile b/Makefile index ade52c52..8b34ba48 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ -CLANG_FORMAT ?= clang-format-3.9 +CLANG_FORMAT ?= clang-format-5.0 +PYTHON_FORMAT ?= yapf +TCL_FORMAT ?= utils//tcl-reformat.sh .PHONY: database format clean env +IN_ENV = if [ -e env/bin/activate ]; then . env/bin/activate; fi; env: virtualenv --python=python3 env . env/bin/activate; pip install -r requirements.txt @@ -15,11 +18,13 @@ build: database: build $(MAKE) -C $@ +FORMAT_EXCLUDE = third_party git env build +FIND_EXCLUDE = $(foreach x,$(FORMAT_EXCLUDE),-and -not -path './$(x)/*') format: - find . -name \*.cc -and -not -path './third_party/*' -and -not -path './.git/*' -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i - find . -name \*.h -and -not -path './third_party/*' -and -not -path './.git/*' -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i - find . -name \*.py -and -not -path './third_party/*' -and -not -path './.git/*' -print0 | xargs -0 -P $$(nproc) yapf -p -i - find . -name \*.tcl -and -not -path './third_party/*' -and -not -path './.git/*' -print0 | xargs -0 -P $$(nproc) -n 1 ${XRAY_TCL_REFORMAT} 2>/dev/null + find . -name \*.cc $(FIND_EXCLUDE) -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i + find . -name \*.h $(FIND_EXCLUDE) -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i + $(IN_ENV) find . -name \*.py $(FIND_EXCLUDE) -print0 | xargs -0 -P $$(nproc) yapf -p -i + find . -name \*.tcl $(FIND_EXCLUDE) -print0 | xargs -0 -P $$(nproc) -n 1 $(TCL_FORMAT) clean: $(MAKE) -C database clean diff --git a/lib/include/prjxray/xilinx/xc7series/configuration_bus.h b/lib/include/prjxray/xilinx/xc7series/configuration_bus.h index 06ab3454..8b3e9bdf 100644 --- a/lib/include/prjxray/xilinx/xc7series/configuration_bus.h +++ b/lib/include/prjxray/xilinx/xc7series/configuration_bus.h @@ -60,7 +60,7 @@ ConfigurationBus::ConfigurationBus(T first, T last) { std::sort(first, last, [](const FrameAddress& lhs, const FrameAddress& rhs) { return lhs.column() < rhs.column(); - }); + }); for (auto col_first = first; col_first != last;) { auto col_last = std::upper_bound( diff --git a/lib/include/prjxray/xilinx/xc7series/global_clock_region.h b/lib/include/prjxray/xilinx/xc7series/global_clock_region.h index 9372948a..39747f3b 100644 --- a/lib/include/prjxray/xilinx/xc7series/global_clock_region.h +++ b/lib/include/prjxray/xilinx/xc7series/global_clock_region.h @@ -61,7 +61,7 @@ GlobalClockRegion::GlobalClockRegion(T first, T last) { std::sort(first, last, [](const FrameAddress& lhs, const FrameAddress& rhs) { return lhs.row() < rhs.row(); - }); + }); for (auto row_first = first; row_first != last;) { auto row_last = std::upper_bound( diff --git a/lib/include/prjxray/xilinx/xc7series/row.h b/lib/include/prjxray/xilinx/xc7series/row.h index d5b30215..8dd8d9cc 100644 --- a/lib/include/prjxray/xilinx/xc7series/row.h +++ b/lib/include/prjxray/xilinx/xc7series/row.h @@ -58,7 +58,7 @@ Row::Row(T first, T last) { std::sort(first, last, [](const FrameAddress& lhs, const FrameAddress& rhs) { return lhs.block_type() < rhs.block_type(); - }); + }); for (auto bus_first = first; bus_first != last;) { auto bus_last = std::upper_bound( diff --git a/lib/xilinx/xc7series/configuration_test.cc b/lib/xilinx/xc7series/configuration_test.cc index 914b42fe..4b94e583 100644 --- a/lib/xilinx/xc7series/configuration_test.cc +++ b/lib/xilinx/xc7series/configuration_test.cc @@ -43,12 +43,14 @@ TEST(ConfigurationTest, ConstructFromPacketsWithSingleFrame) { { static_cast(0x1), xc7series::ConfigurationPacket::Opcode::Write, - xc7series::ConfigurationRegister::CMD, absl::MakeSpan(cmd), + xc7series::ConfigurationRegister::CMD, + absl::MakeSpan(cmd), }, { static_cast(0x1), xc7series::ConfigurationPacket::Opcode::Write, - xc7series::ConfigurationRegister::FDRI, absl::MakeSpan(frame), + xc7series::ConfigurationRegister::FDRI, + absl::MakeSpan(frame), }, }; @@ -94,12 +96,14 @@ TEST(ConfigurationTest, ConstructFromPacketsWithAutoincrement) { { static_cast(0x1), xc7series::ConfigurationPacket::Opcode::Write, - xc7series::ConfigurationRegister::CMD, absl::MakeSpan(cmd), + xc7series::ConfigurationRegister::CMD, + absl::MakeSpan(cmd), }, { static_cast(0x1), xc7series::ConfigurationPacket::Opcode::Write, - xc7series::ConfigurationRegister::FDRI, absl::MakeSpan(frame), + xc7series::ConfigurationRegister::FDRI, + absl::MakeSpan(frame), }, }; diff --git a/tools/xc7patch.cc b/tools/xc7patch.cc index 318b193f..d82b2869 100644 --- a/tools/xc7patch.cc +++ b/tools/xc7patch.cc @@ -84,7 +84,7 @@ int patch_frames( frame_data_strings.end(), frame_data.begin(), [](const std::string& val) -> uint32_t { return std::stoul(val, nullptr, 16); - }); + }); uint32_t ecc = 0; for (size_t ii = 0; ii < frame_data.size(); ++ii) { diff --git a/utils/environment.sh b/utils/environment.sh index 73cc2a0a..7f773271 100644 --- a/utils/environment.sh +++ b/utils/environment.sh @@ -27,6 +27,5 @@ export XRAY_FASM2FRAMES="python3 ${XRAY_UTILS_DIR}/fasm2frames.py" export XRAY_BITTOOL="${XRAY_TOOLS_DIR}/bittool" export XRAY_BLOCKWIDTH="python3 ${XRAY_UTILS_DIR}/blockwidth.py" export XRAY_PARSEDB="python3 ${XRAY_UTILS_DIR}/parsedb.py" -export XRAY_REFORMAT_TCL="${XRAY_DIR}/third_party/reformat.tcl" export XRAY_TCL_REFORMAT="${XRAY_UTILS_DIR}/tcl-reformat.sh" diff --git a/utils/tcl-reformat.sh b/utils/tcl-reformat.sh index 63624a61..3cf35874 100755 --- a/utils/tcl-reformat.sh +++ b/utils/tcl-reformat.sh @@ -4,7 +4,7 @@ fn=$1 -$XRAY_REFORMAT_TCL $fn >/dev/null +third_party/reformat.tcl $fn >/dev/null # Always puts a newline at the end, even if there was one before # remove duplicates, but keep at least one printf "%s\n" "$(< $fn)" >$fn.tmp