Spaces:
Running
Running
| # Copyright 2026 Google LLC. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License.# protobuf_patcher.cmake | |
| message(STATUS "[LiteRTLM] Injecting shim into Protobuf root...") | |
| set(ROOT_LIST "${PROTO_SRC_DIR}/CMakeLists.txt") | |
| if(EXISTS "${ROOT_LIST}") | |
| file(READ "${ROOT_LIST}" CONTENT) | |
| string(REPLACE "project(protobuf C CXX)" | |
| "project(protobuf C CXX)\ninclude(${LITERTLM_PROTO_SHIM_PATH})" | |
| CONTENT "${CONTENT}") | |
| file(WRITE "${ROOT_LIST}" "${INJECTION}${CONTENT}") | |
| message(STATUS "[LiteRTLM] Injection successful.") | |
| else() | |
| message(FATAL_ERROR "Could not find Protobuf root CMakeLists.txt at ${ROOT_LIST}") | |
| endif() | |
| set(_proto_cmake_files | |
| "cmake/libupb.cmake" | |
| "cmake/libprotoc.cmake" | |
| "cmake/libprotobuf.cmake" | |
| "cmake/libprotobuf-lite.cmake" | |
| ) | |
| foreach(_file IN LISTS _proto_cmake_files) | |
| set(_path "${PROTO_SRC_DIR}/${_file}") | |
| if(EXISTS "${_path}") | |
| message(STATUS "[LiteRTLM] Patching visibility in ${_file}") | |
| file(READ "${_path}" _content) | |
| string(REPLACE "CXX_VISIBILITY_PRESET hidden" | |
| "CXX_VISIBILITY_PRESET default" _content "${_content}") | |
| string(REPLACE "VISIBILITY_INLINES_HIDDEN ON" | |
| "VISIBILITY_INLINES_HIDDEN OFF" _content "${_content}") | |
| file(WRITE "${_path}" "${_content}") | |
| endif() | |
| endforeach() |