-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes various issues related framework imports in Swift
- Fixes self import in final framework. - Adds preprocessor conditionds to disable an import. Signed-off-by: Yauheni Khnykin <[email protected]>
- Loading branch information
Showing
9 changed files
with
233 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...meworks/dependent-frameworks-and-dependent-object-libs-in-single-framework/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
|
||
project(gluecodium.test) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
|
||
# Following hierarchy ended up in Swift code which mistakenly. | ||
# - imported framework1 in OBJECT BASE. | ||
# - unconditionally imported framework1 and framework2 in OBJECT DEPENDANT1. | ||
# | ||
# OBJECT BASE | ||
# / \ \ | ||
# FRAMEWORK BASE1 \ FRAMEWORK BASE2 | ||
# | \ | | ||
# OBJECT DEPENDANT1 OBJECT DEPENDANT2 | ||
# | \ | | ||
# | \ | | ||
# | \ | | ||
# FRAMEWORK DEPENDANT1 FRAMEWORK DEPENDANT2 | ||
|
||
if(NOT APPLE OR NOT CMAKE_GENERATOR STREQUAL "Xcode") | ||
return() | ||
endif() | ||
|
||
enable_language(Swift) | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${GLUECODIUM_CMAKE_DIR}/modules") | ||
|
||
include(${GLUECODIUM_CMAKE_TESTS_DIR}/utils/assert.cmake) | ||
include(gluecodium/Gluecodium) | ||
include(gluecodium/Swift) | ||
|
||
# OBJECT BASE | ||
add_library(ObjectBase OBJECT) | ||
gluecodium_generate(ObjectBase GENERATORS cpp swift) | ||
gluecodium_target_lime_sources(ObjectBase | ||
PUBLIC "${CMAKE_CURRENT_LIST_DIR}/lime/common_main_foo.lime") | ||
set_target_properties(ObjectBase PROPERTIES GLUECODIUM_SWIFT_EXPOSE_INTERNALS ON) | ||
|
||
# Framework base 1 | ||
add_library(FrameworkBase1 SHARED "${CMAKE_CURRENT_LIST_DIR}/cpp/CommonMainFooImpl.cpp") | ||
target_link_libraries(FrameworkBase1 PUBLIC ObjectBase) | ||
set(MACOSX_FRAMEWORK_NAME FrameworkBase1) | ||
set_target_properties( | ||
FrameworkBase1 | ||
PROPERTIES FRAMEWORK TRUE | ||
MACOSX_FRAMEWORK_IDENTIFIER gluecodium.common.main.test | ||
XCODE_ATTRIBUTE_DEFINES_MODULE YES) | ||
gluecodium_target_swift_sources(FrameworkBase1 COLLECT_FROM_DEPENDENCIES | ||
ADD_MODULE_MODULEMAP) | ||
|
||
# Framework base 2 | ||
add_library(FrameworkBase2 SHARED EXCLUDE_FROM_ALL "${CMAKE_CURRENT_LIST_DIR}/cpp/CommonMainFooImpl.cpp") | ||
target_link_libraries(FrameworkBase2 PUBLIC ObjectBase) | ||
set(MACOSX_FRAMEWORK_NAME FrameworkBase2) | ||
set_target_properties( | ||
FrameworkBase2 | ||
PROPERTIES FRAMEWORK TRUE | ||
MACOSX_FRAMEWORK_IDENTIFIER gluecodium.common.main.test | ||
XCODE_ATTRIBUTE_DEFINES_MODULE YES) | ||
gluecodium_target_swift_sources(FrameworkBase2 COLLECT_FROM_DEPENDENCIES | ||
ADD_MODULE_MODULEMAP) | ||
|
||
# MAIN | ||
add_library(ObjectDependant1 OBJECT) | ||
gluecodium_generate(ObjectDependant1 GENERATORS cpp swift MAIN_ONLY) | ||
gluecodium_target_lime_sources(ObjectDependant1 | ||
PRIVATE "${CMAKE_CURRENT_LIST_DIR}/lime/main_bar.lime") | ||
target_link_libraries(ObjectDependant1 PUBLIC FrameworkBase1) | ||
|
||
add_library(ObjectDependant2 OBJECT EXCLUDE_FROM_ALL) | ||
gluecodium_generate(ObjectDependant2 GENERATORS cpp swift MAIN_ONLY) | ||
gluecodium_target_lime_sources(ObjectDependant2 | ||
PRIVATE "${CMAKE_CURRENT_LIST_DIR}/lime/main_bar.lime") | ||
target_link_libraries(ObjectDependant2 PUBLIC ObjectBase FrameworkBase2) | ||
|
||
add_library(FrameworkDependant1 SHARED "${CMAKE_CURRENT_LIST_DIR}/cpp/MainBarImpl.cpp" "${CMAKE_CURRENT_LIST_DIR}/cpp/MainBarImpl.cpp") | ||
target_link_libraries(FrameworkDependant1 PRIVATE ObjectDependant1) | ||
set(MACOSX_FRAMEWORK_NAME FrameworkDependant1) | ||
set_target_properties( | ||
FrameworkDependant1 | ||
PROPERTIES FRAMEWORK TRUE | ||
MACOSX_FRAMEWORK_IDENTIFIER gluecodium.main.test | ||
XCODE_ATTRIBUTE_DEFINES_MODULE YES | ||
XCODE_ATTRIBUTE_SWIFT_ACTIVE_COMPILATION_CONDITIONS "DONT_IMPORT_FRAMEWORKBASE2") | ||
gluecodium_target_swift_sources(FrameworkDependant1 COLLECT_FROM_DEPENDENCIES ADD_MODULE_MODULEMAP) | ||
gluecodium_target_link_frameworks( | ||
FrameworkDependant1 FRAMEWORKS FrameworkBase1 | ||
COMMON_FRAMEWORK FrameworkBase1) | ||
|
||
|
||
add_library(FrameworkDependant2 SHARED EXCLUDE_FROM_ALL "${CMAKE_CURRENT_LIST_DIR}/cpp/MainBarImpl.cpp" "${CMAKE_CURRENT_LIST_DIR}/cpp/MainBarImpl.cpp") | ||
target_link_libraries(FrameworkDependant2 PRIVATE ObjectDependant1 ObjectDependant2) | ||
set(MACOSX_FRAMEWORK_NAME FrameworkDependant2) | ||
set_target_properties( | ||
FrameworkDependant2 | ||
PROPERTIES FRAMEWORK TRUE | ||
MACOSX_FRAMEWORK_IDENTIFIER gluecodium.main.test | ||
XCODE_ATTRIBUTE_DEFINES_MODULE YES) | ||
gluecodium_target_swift_sources(FrameworkDependant2 COLLECT_FROM_DEPENDENCIES ADD_MODULE_MODULEMAP) | ||
gluecodium_target_link_frameworks( | ||
FrameworkDependant2 FRAMEWORKS FrameworkBase2 | ||
COMMON_FRAMEWORK FrameworkBase2) |
29 changes: 29 additions & 0 deletions
29
...endent-frameworks-and-dependent-object-libs-in-single-framework/cpp/CommonMainFooImpl.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (C) 2020 HERE Europe B.V. | ||
// | ||
// 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. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// License-Filename: LICENSE | ||
// | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
#include "unit/test/CommonMainFoo.h" | ||
|
||
namespace unit::test { | ||
std::shared_ptr<CommonMainFoo> | ||
CommonMainFoo::make() | ||
{ | ||
return nullptr; | ||
} | ||
} // namespace unit::test |
29 changes: 29 additions & 0 deletions
29
...ks/dependent-frameworks-and-dependent-object-libs-in-single-framework/cpp/MainBarImpl.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (C) 2023 HERE Europe B.V. | ||
// | ||
// 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. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// License-Filename: LICENSE | ||
// | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
#include "unit/test/MainBar.h" | ||
|
||
namespace unit::test { | ||
std::shared_ptr<MainBar> | ||
MainBar::make() | ||
{ | ||
return nullptr; | ||
} | ||
} // namespace unit::test |
22 changes: 22 additions & 0 deletions
22
...endent-frameworks-and-dependent-object-libs-in-single-framework/lime/common_main_foo.lime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (C) 2023 HERE Europe B.V. | ||
# | ||
# 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. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# License-Filename: LICENSE | ||
|
||
package unit.test | ||
|
||
class CommonMainFoo { | ||
constructor make() | ||
} |
22 changes: 22 additions & 0 deletions
22
...rks/dependent-frameworks-and-dependent-object-libs-in-single-framework/lime/main_bar.lime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (C) 2023 HERE Europe B.V. | ||
# | ||
# 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. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# License-Filename: LICENSE | ||
|
||
package unit.test | ||
|
||
class MainBar { | ||
constructor make() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters