Skip to content

Commit

Permalink
Fix cpp formatter differences (#2773)
Browse files Browse the repository at this point in the history
* Part of #2647 

### What

For unknown reasons cpp formatter invoked via just file versus via
codegen yielded slightly different results. Tried various things but to
no avail. However, specifying some of the options in the clang format
file more explicitely solves the issue.

Plus, changed how header sorting is handled.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2773) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2773)
- [Docs
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp-codegen%2Ffix-formatter-differences/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp-codegen%2Ffix-formatter-differences/examples)
  • Loading branch information
Wumpf committed Jul 21, 2023
1 parent 90d8c39 commit 8baa1b6
Show file tree
Hide file tree
Showing 74 changed files with 189 additions and 154 deletions.
8 changes: 7 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BasedOnStyle: Google

# Make it slightly more similar to Rust.
# Based loosly on https://gist.github.com/YodaEmbedding/c2c77dc693d11f3734d78489f9a6eea4
# Based loosely on https://gist.github.com/YodaEmbedding/c2c77dc693d11f3734d78489f9a6eea4
AccessModifierOffset: -2
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
Expand All @@ -21,3 +21,9 @@ NamespaceIndentation: All
PointerAlignment: Left
SeparateDefinitionBlocks: Always
SpacesBeforeTrailingComments: 1
ReflowComments: true

# Don't change include blocks, we want to control this manually.
# Sorting headers however is allowed as all our headers should be standalone.
IncludeBlocks: Preserve
SortIncludes: CaseInsensitive
4 changes: 4 additions & 0 deletions crates/re_types/source_hash.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# This is a sha256 hash for all direct and indirect dependencies of this crate's build script.
# It can be safely removed at anytime to force the build script to run again.
# Check out build.rs to see how it's computed.
<<<<<<< HEAD
70102e74a219445db03e9e5d914687f1756e85b35d93e187dd3346d87b99f806
=======
b4f2c2b3b6518fd5c5b8fe2255952c6986895efe58cbc6ae0b56b0384a9ad930
>>>>>>> origin/main
7 changes: 5 additions & 2 deletions crates/re_types_builder/src/codegen/cpp/includes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ impl quote::ToTokens for Includes {
quote! { #hash include #name #NEWLINE_TOKEN }
});

// Put the local includes first. This is less common but makes it easier for us to early detect
// when a header relies on some system includes being present.
// (all our headers should be standalone, i.e. don't assume something else was included before them)
quote! {
#(#system)*
#NEWLINE_TOKEN
#(#local)*
#NEWLINE_TOKEN
#(#system)*
#NEWLINE_TOKEN
#NEWLINE_TOKEN
}
.to_tokens(tokens);
Expand Down
8 changes: 4 additions & 4 deletions rerun_cpp/src/archetypes/affix_fuzzer1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

#pragma once

#include <cstdint>
#include <optional>
#include <vector>

#include "../components/affix_fuzzer1.hpp"
#include "../components/affix_fuzzer10.hpp"
#include "../components/affix_fuzzer11.hpp"
Expand All @@ -27,6 +23,10 @@
#include "../components/affix_fuzzer8.hpp"
#include "../components/affix_fuzzer9.hpp"

#include <cstdint>
#include <optional>
#include <vector>

namespace rr {
namespace archetypes {
struct AffixFuzzer1 {
Expand Down
8 changes: 4 additions & 4 deletions rerun_cpp/src/archetypes/points2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

#pragma once

#include <cstdint>
#include <optional>
#include <vector>

#include "../components/class_id.hpp"
#include "../components/color.hpp"
#include "../components/draw_order.hpp"
Expand All @@ -16,6 +12,10 @@
#include "../components/point2d.hpp"
#include "../components/radius.hpp"

#include <cstdint>
#include <optional>
#include <vector>

namespace rr {
namespace archetypes {
/// A 2D point cloud with positions and optional colors, radii, labels, etc.
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/archetypes/transform3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

#pragma once

#include "../components/transform3d.hpp"

#include <cstdint>
#include <utility>

#include "../components/transform3d.hpp"

namespace rr {
namespace archetypes {
/// A 3D transform.
Expand Down
5 changes: 3 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer1.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>
#include "affix_fuzzer1.hpp"

#include "../datatypes/affix_fuzzer1.hpp"
#include "affix_fuzzer1.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

#pragma once

#include "../datatypes/affix_fuzzer1.hpp"

#include <cstdint>
#include <memory>
#include <utility>

#include "../datatypes/affix_fuzzer1.hpp"

namespace arrow {
class DataType;
}
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer10.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>

#include "affix_fuzzer10.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
std::shared_ptr<arrow::DataType> AffixFuzzer10::to_arrow_datatype() {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer11.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>

#include "affix_fuzzer11.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
std::shared_ptr<arrow::DataType> AffixFuzzer11::to_arrow_datatype() {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer12.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>

#include "affix_fuzzer12.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
std::shared_ptr<arrow::DataType> AffixFuzzer12::to_arrow_datatype() {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer13.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>

#include "affix_fuzzer13.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
std::shared_ptr<arrow::DataType> AffixFuzzer13::to_arrow_datatype() {
Expand Down
5 changes: 3 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer14.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>
#include "affix_fuzzer14.hpp"

#include "../datatypes/affix_fuzzer1.hpp"
#include "affix_fuzzer14.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer14.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

#pragma once

#include "../datatypes/affix_fuzzer3.hpp"

#include <cstdint>
#include <memory>
#include <utility>

#include "../datatypes/affix_fuzzer3.hpp"

namespace arrow {
class DataType;
}
Expand Down
5 changes: 3 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer15.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>
#include "affix_fuzzer15.hpp"

#include "../datatypes/affix_fuzzer1.hpp"
#include "affix_fuzzer15.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer15.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#pragma once

#include "../datatypes/affix_fuzzer3.hpp"

#include <cstdint>
#include <memory>
#include <optional>
#include <utility>

#include "../datatypes/affix_fuzzer3.hpp"

namespace arrow {
class DataType;
}
Expand Down
5 changes: 3 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer16.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>
#include "affix_fuzzer16.hpp"

#include "../datatypes/affix_fuzzer1.hpp"
#include "affix_fuzzer16.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer16.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#pragma once

#include "../datatypes/affix_fuzzer3.hpp"

#include <cstdint>
#include <memory>
#include <utility>
#include <vector>

#include "../datatypes/affix_fuzzer3.hpp"

namespace arrow {
class DataType;
}
Expand Down
5 changes: 3 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer17.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>
#include "affix_fuzzer17.hpp"

#include "../datatypes/affix_fuzzer1.hpp"
#include "affix_fuzzer17.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer17.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

#pragma once

#include "../datatypes/affix_fuzzer3.hpp"

#include <cstdint>
#include <memory>
#include <optional>
#include <utility>
#include <vector>

#include "../datatypes/affix_fuzzer3.hpp"

namespace arrow {
class DataType;
}
Expand Down
5 changes: 3 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer18.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>
#include "affix_fuzzer18.hpp"

#include "../datatypes/affix_fuzzer1.hpp"
#include "affix_fuzzer18.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer18.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

#pragma once

#include "../datatypes/affix_fuzzer4.hpp"

#include <cstdint>
#include <memory>
#include <optional>
#include <utility>
#include <vector>

#include "../datatypes/affix_fuzzer4.hpp"

namespace arrow {
class DataType;
}
Expand Down
5 changes: 3 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer19.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>
#include "affix_fuzzer19.hpp"

#include "../datatypes/affix_fuzzer5.hpp"
#include "affix_fuzzer19.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer19.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

#pragma once

#include "../datatypes/affix_fuzzer5.hpp"

#include <cstdint>
#include <memory>
#include <utility>

#include "../datatypes/affix_fuzzer5.hpp"

namespace arrow {
class DataType;
}
Expand Down
5 changes: 3 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer2.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// NOTE: This file was autogenerated by re_types_builder; DO NOT EDIT.
// Based on "crates/re_types/definitions/rerun/testing/components/fuzzy.fbs"

#include <arrow/api.h>
#include "affix_fuzzer2.hpp"

#include "../datatypes/affix_fuzzer1.hpp"
#include "affix_fuzzer2.hpp"

#include <arrow/api.h>

namespace rr {
namespace components {
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/src/components/affix_fuzzer2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

#pragma once

#include "../datatypes/affix_fuzzer1.hpp"

#include <cstdint>
#include <memory>
#include <utility>

#include "../datatypes/affix_fuzzer1.hpp"

namespace arrow {
class DataType;
}
Expand Down
Loading

0 comments on commit 8baa1b6

Please sign in to comment.