3DBAG / roofer

Automatic LoD2.2 building reconstruction
https://3dbag.github.io/roofer/
GNU General Public License v3.0
11 stars 2 forks source link

Refactor the project layout #18

Closed balazsdukai closed 4 months ago

balazsdukai commented 5 months ago

Implements my proposal from #16 :

Fixes #16

Ylannl commented 5 months ago

I did some more refactoring:

Ylannl commented 5 months ago

Should we use target_compile_definitions() (https://cmake.org/cmake/help/latest/command/target_compile_definitions.html) instead of the config.hpp in the configured folder? Or are there other reasons to have that other than just adding defines?

balazsdukai commented 5 months ago

Should we use target_compile_definitions() (https://cmake.org/cmake/help/latest/command/target_compile_definitions.html) instead of the config.hpp in the configured folder? Or are there other reasons to have that other than just adding defines?

Yes, as far as I understand, target_compile_definitions and configure_file serve different purposes. In the examples I've seen, the latter is used for the communication between cmake and the source code. By far the most common use case is to pass the version to the code. I haven't set up the version here, because I was not sure what's it gonna be. I also use it for setting flags/defines, so that we have all variable definitions that need to be passed to the source code in one place. A more complete example would be in the logger experiment config.hpp.in and the use of its variables in the main.cpp

The cmake book uses the configure files basically only for passing the version number to the code, while it uses target_compile_definitions for defines.

I guess we could do the same? I've been looking for different recommendations, but I haven't found much.

balazsdukai commented 5 months ago

With 0761c0b the github action was set up for building all targets with vcpkg on all platforms that we support. These are ubuntu 22.04, 24.04, macos 13, 14, windows server 2022.

For future reference, our aim is to be able to build roofer with the default compiler on each platform. Although, this is a not a hard rule, and we might eventually require a newer compiler if a feature justifies it.

balazsdukai commented 5 months ago

I've unified the various test directories and set up two integration test, one for crop and one for the reconstruct app. The tests use the main executables, there is no separate exe just for the test. Now the build action also includes the running of the tests. I removed the Catch2 dependency, since we don't have unit tests atm, and CTest is sufficient for what is currently set up.

The test data is managed with FetchContent and the data is stored on the 3DGI server at https://data.3dgi.xyz/roofer-test-data. FetchContent downloads and extracts the data during the configuration. If the files already exist on disk, the download is skipped.

The toml config files for running crop and reconstruct are checked into git, because I consider them part of the test definition.

The tests fail, but it seems that the errors are not related to the CI setup.

balazsdukai commented 5 months ago

I added a pre-commit hook to enforce clang-fomat on the files. It checks if the files change after running clang-format on them, and it fails if there are formatting changes.

In addition to clang-format on the header and source files, it has additional checks for all files:

It uses the pre-commit tool which has its official github action. It can be run locally too, which will automatically fix the files, e.g. 8d1eaf9 is the result of running pre-commit run --all-files.

Ylannl commented 5 months ago

I added a pre-commit hook to enforce clang-fomat on the files. It checks if the files change after running clang-format on them, and it fails if there are formatting changes.

In addition to clang-format on the header and source files, it has additional checks for all files:

  • Makes sure files end in a newline and only a newline.
  • Trims trailing whitespace.

It uses the pre-commit tool which has its official github action. It can be run locally too, which will automatically fix the files, e.g. 8d1eaf9 is the result of running pre-commit run --all-files.

I suggest holding off this until we have merged with the API branch. I applied this formatting before, but than had to undo it because it made that merge very difficult.

In addition, we should probably exclude the thirdparty sources like toml.hpp and argh.h (in apps/external) from the formatting.

balazsdukai commented 4 months ago

I saw 5541a0a, but the problem with it is that the test input depends on the output of the "crop" test. Tests should be independent, because now if crop fails for some reason, "reconstruct" will fail too, even if "reconstruct" would succeed on it's own.

Thus the correct config for reconstruct needs to be added to the repo and the input data added to the wippolder test set.