-
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.
Signed-off-by: Yauheni Khnykin <[email protected]>
- Loading branch information
Showing
47 changed files
with
1,979 additions
and
55 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## Overview | ||
|
||
[README.md](../README.md) in the root provides basic information about Gluecodium. | ||
It's simplier to keep C++ code in shared library when binding is necessary for Java and for Swift. | ||
In examples simpliest configuration is used. For more advanced check `cmake/tests/unit` tests. | ||
|
||
## CMake Gluecodium wraper. | ||
|
||
This is set of cmake functions which provide the following functionality: | ||
- Download Gluecodium from artifactory. | ||
- Add step to generate code. | ||
- Set options to configure generated code. | ||
- Help to configure a target to include generated C++/Swift/Java/Flutter sources, add include directories, etc. | ||
|
||
While examples work with shipped CMake Gluecodium wraper in real application it's handy to clone only subtree `cmake/modules`. | ||
|
||
## Example `calculator`. | ||
|
||
What this example demonstrates: | ||
- How to configure the project to generate C++, Java and Swift source code. | ||
- How to use the generated code in Android and iOS applications. | ||
- How to describe basic primitives like `class`, `interface`, `struct` and how to interact with them | ||
- How to make platform-only comment and links. | ||
|
||
What this example DOESN'T demonstrate: | ||
- How to make complex build setup with several modules. | ||
- How to describe custom types. | ||
- How to make Flutter plugin. | ||
- How to use advanced Gluecodium features: tags, advanced manupulations with comments, properties, etc. | ||
|
||
For detailed desription check [calculator/README.md](calculator/README.md) |
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,77 @@ | ||
# Copyright (C) 2016-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 | ||
|
||
cmake_minimum_required(VERSION 3.12) | ||
|
||
project(gluecodium.calculator) | ||
|
||
option(ENABLE_APP "Enables iOS app which demostrates how to use the generated code" ON) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
if(CMAKE_GENERATOR STREQUAL "Xcode") | ||
enable_language(Swift) | ||
endif() | ||
|
||
# Path to Gluecodium CMake wrapper | ||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../cmake/modules") | ||
|
||
include(gluecodium/Gluecodium) | ||
|
||
# Android requires C++ code to be built as shared library. | ||
# For iOS it's recommended (but not required) to do Framework because it's consistent | ||
# to Android setup and simplifies CMake scripts and it allows to use framework with | ||
# Xcode projects which are not originated from CMake (for example cocoapods or | ||
# generated by Xcode itself). | ||
add_library(mylibrary SHARED "${CMAKE_CURRENT_LIST_DIR}/cpp/CalculatorImpl.cpp") | ||
|
||
# C++ (cpp) generator usually always necessary, android and swift depend on current platform. | ||
set (_generators cpp) | ||
if (ANDROID) | ||
list (APPEND _generators android) | ||
elseif (CMAKE_GENERATOR STREQUAL "Xcode") | ||
list (APPEND _generators swift) | ||
endif() | ||
|
||
# Add step to generate sources. Lime files are specified below. | ||
gluecodium_generate(mylibrary GENERATORS ${_generators}) | ||
|
||
# Gluecodium has plenty options which can be configured with target properties | ||
# prfixed with `GLUECODIUM_`. To learn all the properties configure the project | ||
# with `-DGLUECODIUM_PRINT_KNOWN_PROPERTIES=ON` parameter. | ||
set_target_properties(mylibrary PROPERTIES | ||
# Not required, but highly desired Java annotations. | ||
GLUECODIUM_JAVA_NONNULL_ANNOTATION "androidx.annotation.NonNull" | ||
GLUECODIUM_JAVA_NULLABLE_ANNOTATION "androidx.annotation.Nullable" | ||
|
||
# Set prefix for java package. | ||
GLUECODIUM_JAVA_PACKAGE "com") | ||
|
||
# This is the most convenient way to add lime files from which Gluecodium generates code. | ||
set_property(TARGET mylibrary APPEND PROPERTY GLUECODIUM_LIME_SOURCES | ||
"${CMAKE_CURRENT_LIST_DIR}/lime/Calculator.lime") | ||
|
||
if (CMAKE_GENERATOR STREQUAL "Xcode") | ||
# Make CMake to build framework. | ||
set_target_properties(mylibrary PROPERTIES | ||
FRAMEWORK TRUE | ||
XCODE_ATTRIBUTE_DEFINES_MODULE YES) | ||
|
||
if(ENABLE_APP AND IOS) | ||
add_subdirectory("ios") | ||
endif() | ||
endif() |
Oops, something went wrong.