OpenMLDB icon indicating copy to clipboard operation
OpenMLDB copied to clipboard

build(clean): allow delete proto/swig generated files in project

Open zhanghaohit opened this issue 4 years ago • 8 comments

two minor bugs in Makefile:

  • make clean doesn't clean the swig genereated files
  • HYBRIDSE_CMAKE_DEPS_FLAGS := -DHYBRIDSE_TESTING_ENABLE=OFF -DEXAMPLES_ENABLE=OFF -DPYSDK_ENABLE=OFF -DJAVASDK_ENABLE=OFF these options are cached, simply overriding cannot change these values.

Expected Behavior

  • make clean at least provide an option to clean the generated files, including swig, proto and so on.
  • By simply make JAVASDK_ENABLE=ON, we can make the hybridse javasdk

Current Behavior

  • make clean only delete the build and hybridse/build
  • make JAVASDK_ENABLE=ON does not work as expected

zhanghaohit avatar Dec 13 '21 10:12 zhanghaohit

  1. Problem 1 Does it affected to proto generated files?
  2. Problem 2, a solution might rm HYBRIDSE_ CMAKE_DEPS_FLAGS, but increase compile time.

What about the convention: not compile tests when hitting make, while keep test targets still available in build directory?

aceforeverd avatar Dec 13 '21 12:12 aceforeverd

  1. Problem 1 Does it affected to proto generated files?
  2. Problem 2, a solution might rm HYBRIDSE_ CMAKE_DEPS_FLAGS, but increase compile time.

What about the convention: not compile tests when hitting make, while keep test targets still available in build directory?

  1. Problem 1. If the .proto file or swig definition changes, does it re-compile atomically by executing make again? If not, we have to delete all the generated files by make clean. Otherwise, users have to manually find and delete if they change proto or swig.
  2. Problem 2. Maybe we can change the default value in the hybridse/CMakeLists.txt?

I think not compiling test by default is better? we can just keep the test target as what we currently do.

zhanghaohit avatar Dec 13 '21 16:12 zhanghaohit

  1. Problem 1 Does it affected to proto generated files?
  2. Problem 2, a solution might rm HYBRIDSE_ CMAKE_DEPS_FLAGS, but increase compile time.

What about the convention: not compile tests when hitting make, while keep test targets still available in build directory?

  1. Problem 1. If the .proto file or swig definition changes, does it re-compile atomically by executing make again? If not, we have to delete all the generated files by make clean. Otherwise, users have to manually find and delete if they change proto or swig.
  2. Problem 2. Maybe we can change the default value in the hybridse/CMakeLists.txt?

I think not compiling test by default is better? we can just keep the test target as what we currently do.

Yes, should not compile tests but just openmldb binary and a few libraries used by java & python module. We need filter a little about test targets, some unittest, some integration test.

For problem 1, I made some work in #884, which will replace some of add_custom_command with add_custom_target, it will always re-run even the target file already exists.

aceforeverd avatar Dec 16 '21 07:12 aceforeverd

there is two clean task:

  1. in build directory
  2. make clean in project root

each won't clean parent directories, only sub directories.

so for build's clean, it will only clean generated files inside build, which is *.pb.h. Other files inside source, e.g *_proto.java | *_swig.java, only cleaned in top project root

TODO

  • [x] allow clean proto generated files
  • [ ] allow clean swig generate files and libraries

In detail:

file type location clean strategy
proto gen c headers ${build_dir}/**/*.pb.h requires #1091 make -C ${build_dir} clean / make clean
proto gen java classes openmldb-(import/native/taskmanager/common)
requires #1090
make clean
swig gen java classes hybridse-native/openmldb-native make clean
swig gen native libraries (after copy) hybridse-native / openmldb-native make clean
swig gen python files TBD TBD
swig gen python libraries TBD TBD

@zhanghaohit any idea ?

aceforeverd avatar Jan 13 '22 07:01 aceforeverd

two minor bugs in Makefile:

  • make clean doesn't clean the swig genereated files
  • HYBRIDSE_CMAKE_DEPS_FLAGS := -DHYBRIDSE_TESTING_ENABLE=OFF -DEXAMPLES_ENABLE=OFF -DPYSDK_ENABLE=OFF -DJAVASDK_ENABLE=OFF these options are cached, simply overriding cannot change these values.

Expected Behavior

  • make clean at least provide an option to clean the generated files, including swig, proto and so on.
  • By simply make JAVASDK_ENABLE=ON, we can make the hybridse javasdk

Current Behavior

  • make clean only delete the build and hybridse/build
  • make JAVASDK_ENABLE=ON does not work as expected

problem 2 solved, now left 1, I'll change the title

aceforeverd avatar Jan 13 '22 09:01 aceforeverd

bugfix-P1

lumianph avatar Feb 17 '22 01:02 lumianph

another inconsistent behavior: the compile_proto function in src/cmakelists.txt specify output to *.pb.cc only but the command actually produce multiple files e.g the java proto files.

custom command will skip next if *.pb.cc exists while java file not .

aceforeverd avatar Jul 05 '22 01:07 aceforeverd