Build process improvements#2
Conversation
The build type is left empty if CMakeLists.txt doesn't set it before first project call. Signed-off-by: Pauli <suokkos@gmail.com>
Signed-off-by: Pauli <suokkos@gmail.com>
CMake offers standardized way to select C++ version. This method checks if requested version is supported and sets correct compiler flags. Thread support should use find_package to get system specific compiler and linker flags. Signed-off-by: Pauli <suokkos@gmail.com>
Preferred method to change any compiler settings is to set them for a specific target with visibility flags. PRIVATE means include directories are used only compiling the target. Any depending target won't inherit directories listed for the target. Signed-off-by: Pauli <suokkos@gmail.com>
External projects should be build with same build type and prefix. This allows better control over build process. I also added RPATH configuration to make sure installed binary can find libpistache.so. Signed-off-by: Pauli <suokkos@gmail.com>
6b2295b to
601612b
Compare
My target was to reduce build times for local testing and images. There is many interlinked changes to image building which should make caching better. The biggest changes is external projects using submodules for sources. This allows build process to reduce numbers of times sources are downloaded. Image building still uses remote source. Changes allow better caching for sources. Submodules use relative paths to make sure submodule update uses same protocol as clone. Image build is split two variants. The developer build uses local/* tag to allow quick testing using sources from the working tree. On other hand release builds use git repository with a tag. This makes sure release build will use correct sources without any local changes. Base image and build dependencies install was changed. Base image was upgraded to the latest Debian stable release. Package install command specifies all build dependencies explicitly and avoids install recommendations. The last bit of changes makes sure deployed image includes only runtime dependencies. It adds an empty image where binaries are copied from the build image. Signed-off-by: Pauli <suokkos@gmail.com>
It appears that .dockerignore use different syntax compared to .gitignore. This requires a bit processing to reuse .gitignore for Docker build.
601612b to
37aeebb
Compare
|
Most of the proposed changes are made to files that are generated using openapi generator. I agree that modern cmake and git submodules practices are preferred, but I'm not keen to have these files changed unnecessarily as the changes will only be overwritten if the generator is rerun. |
In that case I propose we generate openapi changes to openapi. When a new generated server has been committed to the branch then simple merge will update only changed code in the master. Conflicts will be easy to resolve. I'm assuming the generator generates same code for unchanged parts of api. |
kiat-huang
left a comment
There was a problem hiding this comment.
Any blockers to merging this?
In theory, the proposal to generate openapi changes into a separate branch to be merged into the main branch should work. I'm not sure about the east of resolving the conflicts until this has been tested. Perhaps we can put this in a different branch until we have a chance to test it when an api change comes in |
These changes require repository to have a tag named exactly same as ${VERSION} in Makefile.
.dockerignore is a symbolic link to .gitignore.
Set default build type to Release
The build type is left empty if CMakeLists.txt doesn't set it before
first project call.
Add install target for api-server
Use standard way to set C++ version and link to threads
CMake offers standardized way to select C++ version. This method checks
if requested version is supported and sets correct compiler flags.
Thread support should use find_package to get system specific compiler
and linker flags.
Use target include directories
Preferred method to change any compiler settings is to set them for a
specific target with visibility flags. PRIVATE means include directories
are used only compiling the target. Any depending target won't inherit
directories listed for the target.
Forward prefix and build type to external projects
External projects should be build with same build type and prefix. This
allows better control over build process. I also added RPATH
configuration to make sure installed binary can find libpistache.so.
Use submodules for external projects and optimize image build
My target was to reduce build times for local testing and images. There
is many interlinked changes to image building which should make caching
better.
The biggest changes is external projects using submodules for sources.
This allows build process to reduce numbers of times sources are
downloaded. Image building still uses remote source. Changes allow
better caching for sources. Submodules use relative paths to make sure
submodule update uses same protocol as clone.
Image build is split two variants. The developer build uses local/* tag
to allow quick testing using sources from the working tree. On other
hand release builds use git repository with a tag. This makes sure
release build will use correct sources without any local changes.
Base image and build dependencies install was changed. Base image was
upgraded to the latest Debian stable release. Package install command
specifies all build dependencies explicitly and avoids install
recommendations.
The last bit of changes makes sure deployed image includes only runtime
dependencies. It adds an empty image where binaries are copied from the
build image.