Skip to content

Commit

Permalink
build: add option EMIL_FETCH_ECHO_COMPILERS to avoid building the com…
Browse files Browse the repository at this point in the history
…pilers even on host (#718)

* build: add option EMIL_FETCH_ECHO_COMPILERS to avoid building the compilers even on host

* Fetch echo compilers by default
  • Loading branch information
richardapeters authored Oct 24, 2024
1 parent 61e09d7 commit e53ecba
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ endif()
# options.
if (EMIL_STANDALONE AND EMIL_HOST_BUILD)
set(EMIL_DEFAULTOPT On)
set(EMIL_DEFAULTOPT_INVERTED Off)
else()
set(EMIL_DEFAULTOPT Off)
set(EMIL_DEFAULTOPT_INVERTED On)
endif()

# When building EmIL by itself do not exclude any targets from all
Expand All @@ -90,7 +92,13 @@ option(EMIL_ENABLE_FUZZING "Enable building the fuzzing targets" Off)
option(EMIL_ENABLE_DOCKER_TOOLS "Enable shift-left tools (e.g. linters, formatters) that are run using Docker" On)
option(EMIL_GENERATE_PACKAGE_CONFIG "Enable generation of package configuration and install files" ${EMIL_HOST_BUILD})
option(EMIL_ENABLE_TRACING "Enable Tracing" On)
option(EMIL_BUILD_ECHO_COMPILERS "Build and install the Protobuf ECHO compilers" ${EMIL_DEFAULTOPT})
option(EMIL_FETCH_ECHO_COMPILERS "Fetch the Protobuf ECHO compilers from GitHub" ${EMIL_DEFAULTOPT_INVERTED})
if (NOT EMIL_FETCH_ECHO_COMPILERS)
set(EMIL_DEFAULTOPT_BUILD_ECHO_COMPILERS ${EMIL_DEFAULTOPT})
else()
set(EMIL_DEFAULTOPT_BUILD_ECHO_COMPILERS Off)
endif()
option(EMIL_BUILD_ECHO_COMPILERS "Build and install the Protobuf ECHO compilers" ${EMIL_DEFAULTOPT_BUILD_ECHO_COMPILERS})

# Enable or disable optional features.
option(EMIL_INCLUDE_MBEDTLS "Include MbedTLS as part of EmIL" On)
Expand Down
2 changes: 1 addition & 1 deletion protobuf/echo/protocol_buffer_echo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function(emil_fetch_echo_plugins)
#
# (See: https://cmake.org/cmake/help/latest/module/FetchContent.html#commands)

if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING)
if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT EMIL_FETCH_ECHO_COMPILERS)
# In a host build where we are not cross-compiling we use the built echo plug-ins
return()
endif()
Expand Down
2 changes: 1 addition & 1 deletion protobuf/protoc_echo_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (EMIL_HOST_BUILD)
if (EMIL_HOST_BUILD AND NOT EMIL_FETCH_ECHO_COMPILERS)
add_library(protobuf.protoc_echo_plugin_lib ${EMIL_EXCLUDE_FROM_ALL} STATIC)

target_compile_definitions(protobuf.protoc_echo_plugin_lib PRIVATE
Expand Down
8 changes: 7 additions & 1 deletion protobuf/protoc_echo_plugin/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
if (EMIL_FETCH_ECHO_COMPILERS)
set(NOT_EMIL_FETCH_ECHO_COMPILERS false)
else()
set(NOT_EMIL_FETCH_ECHO_COMPILERS true)
endif()

add_executable(protobuf.protoc_echo_plugin_test)
emil_build_for(protobuf.protoc_echo_plugin_test BOOL EMIL_BUILD_TESTS)
emil_build_for(protobuf.protoc_echo_plugin_test BOOL EMIL_BUILD_TESTS PREREQUISITE_BOOL NOT_EMIL_FETCH_ECHO_COMPILERS)
emil_add_test(protobuf.protoc_echo_plugin_test)

protocol_buffer_echo_cpp(protobuf.protoc_echo_plugin_test ../../echo/test/TestMessages.proto)
Expand Down
2 changes: 1 addition & 1 deletion protobuf/protoc_echo_plugin_csharp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING)
if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT EMIL_FETCH_ECHO_COMPILERS)
add_executable(protobuf.protoc_echo_plugin_csharp)
emil_build_for(protobuf.protoc_echo_plugin_csharp BOOL EMIL_BUILD_ECHO_COMPILERS)
emil_install(protobuf.protoc_echo_plugin_csharp EXPORT emilProtobufTargets DESTINATION bin)
Expand Down
2 changes: 1 addition & 1 deletion protobuf/protoc_echo_plugin_java/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING)
if (EMIL_HOST_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT EMIL_FETCH_ECHO_COMPILERS)
add_executable(protobuf.protoc_echo_plugin_java)
emil_build_for(protobuf.protoc_echo_plugin_java BOOL EMIL_BUILD_ECHO_COMPILERS)
emil_install(protobuf.protoc_echo_plugin_java EXPORT emilProtobufTargets DESTINATION bin)
Expand Down

0 comments on commit e53ecba

Please sign in to comment.