Skip to content

Commit 1fdb83e

Browse files
authored
Remove old cc_rules cruft. (#6388)
This is left-over from the migration completed in #5323 (as part of b/152883646). Briefly, we used have much more complex self-contained rules that tried to manage sources, dependencies, and everything in a single rule like firebase_ios_cc_library. The migration added functions like firebase_ios_add_library that more closely matched builtin CMake primitives. I should have sent this PR as the final one in that sequence.
1 parent 101990f commit 1fdb83e

File tree

1 file changed

+0
-275
lines changed

1 file changed

+0
-275
lines changed

cmake/cc_rules.cmake

Lines changed: 0 additions & 275 deletions
Original file line numberDiff line numberDiff line change
@@ -151,156 +151,6 @@ function(firebase_ios_add_objc_test target host)
151151
endif()
152152
endfunction()
153153

154-
155-
# firebase_ios_cc_library(
156-
# target
157-
# SOURCES sources...
158-
# DEPENDS libraries...
159-
# [EXCLUDE_FROM_ALL]
160-
# )
161-
#
162-
# Defines a new library target with the given target name, sources, and
163-
# dependencies.
164-
function(firebase_ios_cc_library name)
165-
set(flag DISABLE_STRICT_WARNINGS EXCLUDE_FROM_ALL HEADER_ONLY)
166-
set(multi DEPENDS SOURCES)
167-
cmake_parse_arguments(ccl "${flag}" "" "${multi}" ${ARGN})
168-
169-
if(ccl_HEADER_ONLY)
170-
firebase_ios_generate_dummy_source(${name} ccl_SOURCES)
171-
endif()
172-
173-
firebase_ios_maybe_remove_objc_sources(sources ${ccl_SOURCES})
174-
add_library(${name} ${sources})
175-
176-
set(warnings_flag "")
177-
if(ccl_DISABLE_STRICT_WARNINGS)
178-
set(warnings_flag DISABLE_STRICT_WARNINGS)
179-
endif()
180-
firebase_ios_add_compile_options(${name} ${warnings_flag} ${sources})
181-
182-
target_compile_options(${name} PRIVATE ${FIREBASE_IOS_CXX_FLAGS})
183-
target_link_libraries(${name} PUBLIC ${ccl_DEPENDS})
184-
185-
if(ccl_EXCLUDE_FROM_ALL)
186-
set_property(
187-
TARGET ${name}
188-
PROPERTY EXCLUDE_FROM_ALL ON
189-
)
190-
endif()
191-
endfunction()
192-
193-
# firebase_ios_cc_select(
194-
# interface_library
195-
# CONDITION1 implementation_library1
196-
# [CONDITION2 implementation_library2 ...]
197-
# [DEFAULT implementation_library_default]
198-
# )
199-
#
200-
# Creates an INTERFACE library named `interface_library`.
201-
#
202-
# For each pair of condition and implementation_library, evaluates the condition
203-
# and if true makes that library an INTERFACE link library of
204-
# `interface_library`.
205-
#
206-
# If supplied, uses the `DEFAULT` implementation if no other condition matches.
207-
#
208-
# If no condition matches, fails the configuration cycle with an error message
209-
# indicating that no suitable implementation was found.
210-
function(firebase_ios_cc_select library_name)
211-
add_library(${library_name} INTERFACE)
212-
213-
list(LENGTH ARGN length)
214-
if(length GREATER 0)
215-
math(EXPR length "${length} - 1")
216-
foreach(key RANGE 0 ${length} 2)
217-
math(EXPR value "${key} + 1")
218-
list(GET ARGN ${key} condition)
219-
list(GET ARGN ${value} impl_library)
220-
221-
if((${condition} STREQUAL "DEFAULT") OR (${${condition}}))
222-
message("Using ${library_name} = ${impl_library}")
223-
target_link_libraries(
224-
${library_name} INTERFACE ${impl_library}
225-
)
226-
return()
227-
endif()
228-
endforeach()
229-
endif()
230-
231-
message(FATAL_ERROR "Could not find implementation for ${library_name}")
232-
endfunction()
233-
234-
# firebase_ios_cc_binary(
235-
# target
236-
# SOURCES sources...
237-
# DEPENDS libraries...
238-
# [EXCLUDE_FROM_ALL]
239-
# )
240-
#
241-
# Defines a new executable target with the given target name, sources, and
242-
# dependencies.
243-
function(firebase_ios_cc_binary name)
244-
set(flag DISABLE_STRICT_WARNINGS EXCLUDE_FROM_ALL)
245-
set(multi DEPENDS SOURCES)
246-
cmake_parse_arguments(ccb "${flag}" "" "${multi}" ${ARGN})
247-
248-
firebase_ios_maybe_remove_objc_sources(sources ${ccb_SOURCES})
249-
add_executable(${name} ${sources})
250-
251-
set(warnings_flag "")
252-
if(ccb_DISABLE_STRICT_WARNINGS)
253-
set(warnings_flag DISABLE_STRICT_WARNINGS)
254-
endif()
255-
firebase_ios_add_compile_options(${name} ${warnings_flag} ${sources})
256-
257-
target_compile_options(${name} PRIVATE ${FIREBASE_CXX_FLAGS})
258-
target_include_directories(${name} PRIVATE ${FIREBASE_SOURCE_DIR})
259-
target_link_libraries(${name} PRIVATE ${ccb_DEPENDS})
260-
261-
if(ccb_EXCLUDE_FROM_ALL)
262-
set_property(
263-
TARGET ${name}
264-
PROPERTY EXCLUDE_FROM_ALL ON
265-
)
266-
endif()
267-
endfunction()
268-
269-
# firebase_ios_cc_test(
270-
# target
271-
# SOURCES sources...
272-
# DEPENDS libraries...
273-
# )
274-
#
275-
# Defines a new test executable target with the given target name, sources, and
276-
# dependencies. Implicitly adds DEPENDS on GTest::GTest and GTest::Main.
277-
function(firebase_ios_cc_test name)
278-
if(NOT FIREBASE_IOS_BUILD_TESTS)
279-
return()
280-
endif()
281-
282-
set(flag DISABLE_STRICT_WARNINGS)
283-
set(multi DEPENDS SOURCES)
284-
cmake_parse_arguments(cct "${flag}" "" "${multi}" ${ARGN})
285-
286-
list(APPEND cct_DEPENDS GTest::GTest GTest::Main)
287-
288-
firebase_ios_maybe_remove_objc_sources(sources ${cct_SOURCES})
289-
add_executable(${name} ${sources})
290-
291-
set(warnings_flag "")
292-
if(cct_DISABLE_STRICT_WARNINGS)
293-
set(warnings_flag DISABLE_STRICT_WARNINGS)
294-
endif()
295-
firebase_ios_add_compile_options(${name} ${warnings_flag} ${sources})
296-
297-
add_test(${name} ${name})
298-
299-
target_compile_options(${name} PRIVATE ${FIREBASE_CXX_FLAGS})
300-
target_include_directories(${name} PRIVATE ${FIREBASE_SOURCE_DIR})
301-
target_link_libraries(${name} PRIVATE ${cct_DEPENDS})
302-
endfunction()
303-
304154
# firebase_ios_add_fuzz_test(
305155
# target
306156
# DICTIONARY dict_file
@@ -348,77 +198,6 @@ function(firebase_ios_add_fuzz_test target)
348198
endif()
349199
endfunction()
350200

351-
# maybe_remove_objc_sources(output_var sources...)
352-
#
353-
# Removes Objective-C/C++ sources from the given sources if not on an Apple
354-
# platform. Stores the resulting list in the variable named by `output_var`.
355-
function(firebase_ios_maybe_remove_objc_sources output_var)
356-
unset(sources)
357-
foreach(source ${ARGN})
358-
get_filename_component(ext ${source} EXT)
359-
if(NOT APPLE AND ((ext STREQUAL ".m") OR (ext STREQUAL ".mm")))
360-
continue()
361-
endif()
362-
list(APPEND sources ${source})
363-
endforeach()
364-
set(${output_var} ${sources} PARENT_SCOPE)
365-
endfunction()
366-
367-
# firebase_ios_add_compile_options(target [DISABLE_STRICT_WARNINGS] sources...)
368-
#
369-
# Adds FIREBASE_IOS_CXX_FLAGS or FIREBASE_IOS_CXX_FLAGS_STRICT to the compile
370-
# options of the given target depending on whether or not
371-
# DISABLE_STRICT_WARNINGS was passed.
372-
#
373-
# If any of the sources have filenames that indicate they are Objective-C adds
374-
# Either FIREBASE_IOS_OBJC_FLAGS or FIREBASE_IOS_OBJC_FLAGS_STRICT depending on
375-
# whether or not DISABLE_STRICT_WARNINGS was passed.
376-
function(firebase_ios_add_compile_options target)
377-
set(flag DISABLE_STRICT_WARNINGS)
378-
cmake_parse_arguments(aco "${flag}" "" "" ${ARGN})
379-
380-
# Only set Objective-C flags if there's at least once source file to which
381-
# that applies.
382-
set(has_objc OFF)
383-
384-
# Default to applying the strict warnings to all targets, but targets can
385-
# opt out.
386-
set(suffix _STRICT)
387-
if(aco_DISABLE_STRICT_WARNINGS)
388-
set(suffix "")
389-
endif()
390-
391-
foreach(source ${ARGN})
392-
get_filename_component(ext ${source} EXT)
393-
if((ext STREQUAL ".m") OR (ext STREQUAL ".mm"))
394-
set(has_objc ON)
395-
endif()
396-
endforeach()
397-
398-
target_compile_options(
399-
${target}
400-
PRIVATE
401-
${FIREBASE_IOS_CXX_FLAGS${suffix}}
402-
)
403-
404-
if(has_objc)
405-
target_compile_options(
406-
${target}
407-
PRIVATE
408-
${FIREBASE_IOS_OBJC_FLAGS${suffix}}
409-
)
410-
endif()
411-
412-
target_include_directories(
413-
${target}
414-
PRIVATE
415-
# Put the binary dir first so that the generated config.h trumps any one
416-
# generated statically by a Cocoapods-based build in the same source tree.
417-
${FIREBASE_BINARY_DIR}
418-
${FIREBASE_SOURCE_DIR}
419-
)
420-
endfunction()
421-
422201
# firebase_ios_add_alias(alias_target actual_target)
423202
#
424203
# Adds a library alias target `alias_target` if it does not already exist,
@@ -431,60 +210,6 @@ function(firebase_ios_add_alias ALIAS_TARGET ACTUAL_TARGET)
431210
endif()
432211
endfunction()
433212

434-
function(firebase_ios_objc_test target)
435-
if(NOT APPLE OR NOT FIREBASE_IOS_BUILD_TESTS)
436-
return()
437-
endif()
438-
439-
set(flag DISABLE_STRICT_WARNINGS EXCLUDE_FROM_ALL)
440-
set(single HOST VERSION WORKING_DIRECTORY)
441-
set(multi DEPENDS DEFINES HEADERS INCLUDES SOURCES)
442-
cmake_parse_arguments(ot "${flag}" "${single}" "${multi}" ${ARGN})
443-
444-
xctest_add_bundle(
445-
${target}
446-
${ot_HOST}
447-
${ot_SOURCES}
448-
)
449-
450-
set(warnings_flag "")
451-
if(ot_DISABLE_STRICT_WARNINGS)
452-
set(warnings_flag DISABLE_STRICT_WARNINGS)
453-
endif()
454-
firebase_ios_add_compile_options(${target} ${warnings_flag} ${ot_SOURCES})
455-
456-
target_compile_options(${target} PRIVATE ${FIREBASE_CXX_FLAGS})
457-
target_link_libraries(${target} PRIVATE ${ot_DEPENDS})
458-
459-
xctest_add_test(
460-
${target}
461-
${target}
462-
)
463-
464-
if(ot_WORKING_DIRECTORY)
465-
set_property(
466-
TEST ${target} PROPERTY
467-
WORKING_DIRECTORY ${ot_WORKING_DIRECTORY}
468-
)
469-
endif()
470-
471-
if(WITH_ASAN)
472-
set_property(
473-
TEST ${target} APPEND PROPERTY
474-
ENVIRONMENT
475-
DYLD_INSERT_LIBRARIES=${CLANG_ASAN_DYLIB}
476-
)
477-
endif()
478-
479-
if(WITH_TSAN)
480-
set_property(
481-
TEST ${target} APPEND PROPERTY
482-
ENVIRONMENT
483-
DYLD_INSERT_LIBRARIES=${CLANG_TSAN_DYLIB}
484-
)
485-
endif()
486-
endfunction()
487-
488213
# firebase_ios_generate_dummy_source(target, sources_list)
489214
#
490215
# Generates a dummy source file containing a single symbol, suitable for use as

0 commit comments

Comments
 (0)