diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..fe5ea28 --- /dev/null +++ b/.clang-format @@ -0,0 +1,300 @@ +# ***************************************************************************** +# Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +#http://clang.llvm.org/docs/ClangFormatStyleOptions.html + +# The style used for all options not specifically set in the configuration. +# This option is supported only in the clang-format configuration (both within +# -style='{...}' and the .clang-format file). +# LLVM A style complying with the LLVM coding standards +# Google A style complying with Google’s C++ style guide +# Chromium A style complying with Chromium’s style guide +# Mozilla A style complying with Mozilla’s style guide +# WebKit A style complying with WebKit’s style guide +BasedOnStyle: Webkit + +# The extra indent or outdent of access modifiers, e.g. public:. +AccessModifierOffset: -4 + +# If true, horizontally aligns arguments after an open bracket. +# This applies to round brackets (parentheses), angle brackets and square +# brackets. This will result in formattings like code +# someLongFunction(argument1, argument2); endcode +AlignAfterOpenBracket: AlwaysBreak + +# If true, aligns escaped newlines as far left as possible. Otherwise puts them +# into the right-most column. +#AlignEscapedNewlinesLeft + +# If true, horizontally align operands of binary and ternary expressions. +AlignOperands: true + +# If true, aligns trailing comments. +AlignTrailingComments: true + +# Allow putting all parameters of a function declaration onto the next line even +# if BinPackParameters is false. +AllowAllParametersOfDeclarationOnNextLine: true + +# Allows contracting simple braced statements to a single line. +# E.g., this allows if (a) { return; } to be put on a single line. +AllowShortBlocksOnASingleLine: false + +# If true, short case labels will be contracted to a single line. +AllowShortCaseLabelsOnASingleLine: false + +# Dependent on the value, int f() { return 0; } can be put on a single line. +# SFS_None (in configuration: None) Never merge functions into a single line. +# SFS_Inline (in configuration: Inline) Only merge functions defined inside a +# class. +# SFS_Empty (in configuration: Empty) Only merge empty functions. +# SFS_All (in configuration: All) Merge all functions fitting on a single line. +AllowShortFunctionsOnASingleLine: None + +# If true, if (a) return; can be put on a single line. +#AllowShortIfStatementsOnASingleLine: false + +# If true, while (true) continue; can be put on a single line. +AllowShortLoopsOnASingleLine: true + +# If true, always break after function definition return types. +# More truthfully called ‘break before the identifier following the type in a +# function definition’. +# PenaltyReturnTypeOnItsOwnLine becomes irrelevant. +AlwaysBreakAfterDefinitionReturnType: All + +# If true, always break before multiline string literals. +AlwaysBreakBeforeMultilineStrings: false + +# If true, always break after the template<...> of a template declaration. +AlwaysBreakTemplateDeclarations: true + +# If false, a function call’s arguments will either be all on the same line or +# will have one line each. +BinPackArguments: false + +# If false, a function call’s arguments will either be all +# on the same line or will have one line each. +BinPackParameters: false + +# The way to wrap binary operators. +# BOS_None (in configuration: None) Break after operators. +# BOS_NonAssignment (in configuration: NonAssignment) Break before operators +# that aren’t assignments. +# BOS_All (in configuration: All) Break before operators. +#BreakBeforeBinaryOperators: None + +# The brace breaking style to use. +# BS_Attach (in configuration: Attach) Always attach braces to surrounding +# context. +# BS_Linux (in configuration: Linux) Like Attach, but break before braces on +# function, namespace and class definitions. +# BS_Stroustrup (in configuration: Stroustrup) Like Attach, but break before +# function definitions, and ‘else’. +# BS_Allman (in configuration: Allman) Always break before braces. +# BS_GNU (in configuration: GNU) Always break before braces and add an extra +# level of indentation to braces of control statements, not to those of class, +# function or other definitions. +BreakBeforeBraces: Attach + +# If true, ternary operators will be placed after line breaks. +BreakBeforeTernaryOperators: true + +# Always break constructor initializers before commas and align the commas with +# the colon. +BreakConstructorInitializersBeforeComma: true + +# The column limit. +# A column limit of 0 means that there is no column limit. In this case, +# clang-format will respect the input’s line breaking decisions within +# statements unless they contradict other rules. +ColumnLimit: 80 + +# A regular expression that describes comments with special meaning, which +# should not be split into lines or otherwise changed. +CommentPragmas: "\/*(.*)*\/" + +# If the constructor initializers don’t fit on a line, put each initializer on +# its own line. +#ConstructorInitializerAllOnOneLineOrOnePerLine: false + +# The number of characters to use for indentation of constructor initializer +# lists. +ConstructorInitializerIndentWidth: 0 + +# Indent width for line continuations. +#ContinuationIndentWidth: 4 + +# If true, format braced lists as best suited for C++11 braced lists. +# Important differences: - No spaces inside the braced list. - No line break +# before the closing brace. - Indentation with the continuation indent, not with +# the block indent. +# Fundamentally, C++11 braced lists are formatted exactly like function calls +# would be formatted in their place. If the braced list follows a name (e.g. a +# type or variable name), clang-format formats as if the {} were the parentheses +# of a function call with that name. If there is no name, a zero-length name is +# assumed. +Cpp11BracedListStyle: true + +# If true, analyze the formatted file for the most common alignment of & and *. +# Point +#DerivePointerAlignment: false + +# Disables formatting at all. +#DisableFormat: false + +# If true, clang-format detects whether function calls and definitions are +# formatted with one parameter per line. +# Each call can be bin-packed, one-per-line or inconclusive. If it is +# inconclusive, e.g. completely on one line, but a decision needs to be made, +# clang-format analyzes whether there are other bin-packed cases in the input +# file and act accordingly. +# NOTE: This is an experimental flag, that might go away or be renamed. Do not +# use this in config files, etc. Use at your own risk. +ExperimentalAutoDetectBinPacking: false + +# A vector of macros that should be interpreted as foreach loops instead of as +# function calls. +# These are expected to be macros of the form: code +# FOREACH(, ...) endcode +# For example: BOOST_FOREACH. +#ForEachMacros (std::vector) + +# Indent case labels one level from the switch statement. +# When false, use the same indentation level as for the switch statement. Switch +# statement body is always indented one level more than case labels. +IndentCaseLabels: false + +# The number of columns to use for indentation. +IndentWidth: 4 + +# Indent if a function definition or declaration is wrapped after the type. +#IndentWrappedFunctionNames: false + +# If true, empty lines at the start of blocks are kept. +KeepEmptyLinesAtTheStartOfBlocks: false + +# Language, this format style is targeted at. +# LK_None (in configuration: None) Do not use. +# LK_Cpp (in configuration: Cpp) Should be used for C, C++, ObjectiveC, +# ObjectiveC++. +# LK_Java (in configuration: Java) Should be used for Java. +# LK_JavaScript (in configuration: JavaScript) Should be used for JavaScript. +# LK_Proto (in configuration: Proto) Should be used for Protocol Buffers +# (https://developers.google.com/protocol-buffers/). +Language: Cpp + +# The maximum number of consecutive empty lines to keep. +#MaxEmptyLinesToKeep: 0 + +# The indentation used for namespaces. +# NI_None (in configuration: None) Don’t indent in namespaces. +# NI_Inner (in configuration: Inner) Indent only in inner namespaces (nested in +# other namespaces). +# NI_All (in configuration: All) Indent in all namespaces. +NamespaceIndentation: None + +# The number of characters to use for indentation of ObjC blocks. +#ObjCBlockIndentWidth: 4 + +# Add a space after @property in Objective-C, i.e. use \@property (readonly) +# instead of \@property(readonly). +#ObjCSpaceAfterProperty: false + +# Add a space in front of an Objective-C protocol list, i.e. use Foo +# instead of Foo. +#ObjCSpaceBeforeProtocolList: false + +# The penalty for breaking a function call after “call(”. +#PenaltyBreakBeforeFirstCallParameter (unsigned) + +# The penalty for each line break introduced inside a comment. +#PenaltyBreakComment (unsigned) + +# The penalty for breaking before the first <<. +#PenaltyBreakFirstLessLess (unsigned) + +# The penalty for each line break introduced inside a string literal. +#PenaltyBreakString (unsigned) + +# The penalty for each character outside of the column limit. +#PenaltyExcessCharacter (unsigned) + +# Penalty for putting the return type of a function onto its own line. +#PenaltyReturnTypeOnItsOwnLine (unsigned) + +# If true, analyze the formatted file for the most common alignment of & and *. +# PointerAlignment is then used only as fallback. +PointerAlignment: Left + +# If true, a space may be inserted after C style casts. +SpaceAfterCStyleCast: false + +# If false, spaces will be removed before assignment operators. +SpaceBeforeAssignmentOperators: true + +# Defines in which cases to put a space before opening parentheses. +# SBPO_Never (in configuration: Never) Never put a space before opening +# parentheses. +# SBPO_ControlStatements (in configuration: ControlStatements) Put a space +# before opening parentheses only after control statement keywords +# (for/if/while...). +# SBPO_Always (in configuration: Always) Always put a space before opening +# parentheses, except when it’s prohibited by the syntax rules (in function-like +# macro definitions) or when determined by other style rules (after unary +# operators, opening parentheses, etc.) +SpaceBeforeParens: ControlStatements + +# If true, spaces may be inserted into ‘()’. +SpaceInEmptyParentheses: false + +# The number of spaces before trailing line comments (// - comments). +# This does not affect trailing block comments (/**/ - comments) as those +# commonly have different usage patterns and a number of special cases. +SpacesBeforeTrailingComments: 2 + +# If true, spaces will be inserted after ‘<’ and before ‘>’ in template argument +# lists +SpacesInAngles: false + +# If true, spaces may be inserted into C style casts. +SpacesInCStyleCastParentheses: false + +# If true, spaces are inserted inside container literals (e.g. ObjC and +# Javascript array and dict literals). +SpacesInContainerLiterals: false + +# If true, spaces will be inserted after ‘(‘ and before ‘)’. +SpacesInParentheses: false + +# If true, spaces will be inserted after ‘[‘ and before ‘]’. +SpacesInSquareBrackets: false + +# Format compatible with this standard, e.g. use A > instead of A> +# for LS_Cpp03. +# LS_Cpp03 (in configuration: Cpp03) Use C++03-compatible syntax. +# LS_Cpp11 (in configuration: Cpp11) Use features of C++11 (e.g. A> +# instead of A >). +# LS_Auto (in configuration: Auto) Automatic detection based on the input. +Standard: Cpp11 + +# The number of columns used for tab stops. +TabWidth: 4 + +# The way to use tab characters in the resulting file. +# UT_Never (in configuration: Never) Never use tab. +# UT_ForIndentation (in configuration: ForIndentation) Use tabs only for +# indentation. +# UT_Always (in configuration: Always) Use tabs whenever we need to fill +# whitespace that spans at least from one tab stop to the next one. +UseTab: Never + +# Indent code enclosed in an extern block +IndentExternBlock: NoIndent diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..ca0e8f1 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,14 @@ +# ***************************************************************************** +# Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +Checks: '-checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*' +WarningsAsErrors: true +HeaderFilterRegex: '.*' +FormatStyle: webkit diff --git a/.cppcheck.suppress b/.cppcheck.suppress new file mode 100644 index 0000000..b2fe9e2 --- /dev/null +++ b/.cppcheck.suppress @@ -0,0 +1,3 @@ +cstyleCast +missingIncludeSystem +missingInclude diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..8522011 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,14 @@ +name: Build and Test code + +on: + push: + branches: + - main + pull_request: + + +jobs: + call-reusable-workflow: + uses: eclipse-keyple/keyple-actions/.github/workflows/reusable-cpp-build-and-test.yml@main # NOSONAR - trusted public reusable workflow + with: + test_executable_name: 'build/bin/keypluginstoragecardcppapi_ut' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8292a8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Build directories +build +out + +# IDE files +CMakeSettings.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..91c5b58 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,47 @@ +#************************************************************************************************** +#* Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * +#* * +#* This program and the accompanying materials are made available under the * +#* terms of the MIT License which is available at https://opensource.org/licenses/MIT. * +#* * +#* SPDX-License-Identifier: MIT * +#**************************************************************************************************/ + +fail_fast: false + +repos: + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + + - repo: https://github.com/pocc/pre-commit-hooks + rev: master + hooks: + - id: clang-tidy + name: clang-tidy + entry: clang-tidy -p=build + --system-headers + --fix-errors + + # Code formatting (see .clang-format for config used). + - id: clang-format + name: clang-format + args: [-i] + + # Static code analysis (for C++ files). + - id: cppcheck + name: cppcheck + args: [--enable=all, + --error-exitcode=1, + --language=c++, + --suppressions-list=./.cppcheck.suppress] + files: \.(cpp|hpp)$ + + # Coding style analysis. Based on Google C++ code style. + # cpplint configuration can be found in CPPLINT.cfg. + - id: cpplint diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..acc787f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,27 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.1.0] - 2026-02-06 +### Added +- Documentation of recommended status words for `ApduInterpreterSpi` implementations +- Exception handling guidelines for `CommandProcessorApi` implementations +- Added `KeyStorageType` enum to specify memory type (`VOLATILE` or `NON_VOLATILE`). +- Added `loadKey` method to `CommandProcessorApi` interface using `KeyStorageType` for loading card-specific + authentication keys into reader memory. +- Added `generalAuthenticate` method to `CommandProcessorApi` interface for performing authentication to contactless + cards using previously loaded keys. +### Changed +- Enhanced documentation with comprehensive error handling information +- Added status word reference table following ISO 7816-4 and PC/SC standards + +## [1.0.0] - 2025-07-08 +This is the initial release. + +[unreleased]: https://github.com/eclipse-keyple/keyple-plugin-storagecard-cpp-api/compare/1.1.0...HEAD +[1.1.0]: https://github.com/eclipse-keyple/keyple-plugin-storagecard-cpp-api/compare/1.0.0...1.1.0 +[1.0.0]: https://github.com/eclipse-keyple/keyple-plugin-storagecard-cpp-api/releases/tag/1.0.0 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ea364ab --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,44 @@ +# ***************************************************************************** +# Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) + +PROJECT(KeyplePluginStorageCardCppApi C CXX) + +SET(CMAKE_PROJECT_VERSION_MAJOR "1") +SET(CMAKE_PROJECT_VERSION_MINOR "1") +SET(CMAKE_PROJECT_VERSION_PATCH "0") + +SET(CMAKE_PROJECT_VERSION "${CMAKE_PROJECT_VERSION_MAJOR}. + ${CMAKE_PROJECT_VERSION_MINOR}. + ${CMAKE_PROJECT_VERSION_PATCH}") + +SET(PACKAGE_NAME "keyple-plugin-storagecard-cpp-api") +SET(PACKAGE_VERSION ${CMAKE_PROJECT_VERSION}) +SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") + +SET(CMAKE_MACOSX_RPATH 1) +SET(CMAKE_CXX_STANDARD 11) + +# Compilers +SET(CMAKE_C_COMPILER_WORKS 1) +SET(CMAKE_CXX_COMPILER_WORKS 1) + +IF(NOT TOOLCHAIN_FILE) + MESSAGE(FATAL_ERROR "Toolchain file not specified") +ENDIF() + +# Set common output directory +SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +# Add projects +ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/include) +ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..33bd8b6 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,93 @@ +# Community Code of Conduct + +**Version 2.0 +January 1, 2023** + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as community members, contributors, Committers[^1], and Project Leads (collectively "Contributors") pledge to make participation in our projects and our community a harassment-free and inclusive experience for everyone. + +This Community Code of Conduct ("Code") outlines our behavior expectations as members of our community in all Eclipse Foundation activities, both offline and online. It is not intended to govern scenarios or behaviors outside of the scope of Eclipse Foundation activities. Nor is it intended to replace or supersede the protections offered to all our community members under the law. Please follow both the spirit and letter of this Code and encourage other Contributors to follow these principles into our work. Failure to read or acknowledge this Code does not excuse a Contributor from compliance with the Code. + +## Our Standards + +Examples of behavior that contribute to creating a positive and professional environment include: + +- Using welcoming and inclusive language; +- Actively encouraging all voices; +- Helping others bring their perspectives and listening actively. If you find yourself dominating a discussion, it is especially important to encourage other voices to join in; +- Being respectful of differing viewpoints and experiences; +- Gracefully accepting constructive criticism; +- Focusing on what is best for the community; +- Showing empathy towards other community members; +- Being direct but professional; and +- Leading by example by holding yourself and others accountable + +Examples of unacceptable behavior by Contributors include: + +- The use of sexualized language or imagery; +- Unwelcome sexual attention or advances; +- Trolling, insulting/derogatory comments, and personal or political attacks; +- Public or private harassment, repeated harassment; +- Publishing others' private information, such as a physical or electronic address, without explicit permission; +- Violent threats or language directed against another person; +- Sexist, racist, or otherwise discriminatory jokes and language; +- Posting sexually explicit or violent material; +- Sharing private content, such as emails sent privately or non-publicly, or unlogged forums such as IRC channel history; +- Personal insults, especially those using racist or sexist terms; +- Excessive or unnecessary profanity; +- Advocating for, or encouraging, any of the above behavior; and +- Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +With the support of the Eclipse Foundation employees, consultants, officers, and directors (collectively, the "Staff"), Committers, and Project Leads, the Eclipse Foundation Conduct Committee (the "Conduct Committee") is responsible for clarifying the standards of acceptable behavior. The Conduct Committee takes appropriate and fair corrective action in response to any instances of unacceptable behavior. + +## Scope + +This Code applies within all Project, Working Group, and Interest Group spaces and communication channels of the Eclipse Foundation (collectively, "Eclipse spaces"), within any Eclipse-organized event or meeting, and in public spaces when an individual is representing an Eclipse Foundation Project, Working Group, Interest Group, or their communities. Examples of representing a Project or community include posting via an official social media account, personal accounts, or acting as an appointed representative at an online or offline event. Representation of Projects, Working Groups, and Interest Groups may be further defined and clarified by Committers, Project Leads, or the Staff. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the Conduct Committee via conduct@eclipse-foundation.org. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Without the explicit consent of the reporter, the Conduct Committee is obligated to maintain confidentiality with regard to the reporter of an incident. The Conduct Committee is further obligated to ensure that the respondent is provided with sufficient information about the complaint to reply. If such details cannot be provided while maintaining confidentiality, the Conduct Committee will take the respondent‘s inability to provide a defense into account in its deliberations and decisions. Further details of enforcement guidelines may be posted separately. + +Staff, Committers and Project Leads have the right to report, remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code, or to block temporarily or permanently any Contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. Any such actions will be reported to the Conduct Committee for transparency and record keeping. + +Any Staff (including officers and directors of the Eclipse Foundation), Committers, Project Leads, or Conduct Committee members who are the subject of a complaint to the Conduct Committee will be recused from the process of resolving any such complaint. + +## Responsibility + +The responsibility for administering this Code rests with the Conduct Committee, with oversight by the Executive Director and the Board of Directors. For additional information on the Conduct Committee and its process, please write to . + +## Investigation of Potential Code Violations + +All conflict is not bad as a healthy debate may sometimes be necessary to push us to do our best. It is, however, unacceptable to be disrespectful or offensive, or violate this Code. If you see someone engaging in objectionable behavior violating this Code, we encourage you to address the behavior directly with those involved. If for some reason, you are unable to resolve the matter or feel uncomfortable doing so, or if the behavior is threatening or harassing, please report it following the procedure laid out below. + +Reports should be directed to . It is the Conduct Committee’s role to receive and address reported violations of this Code and to ensure a fair and speedy resolution. + +The Eclipse Foundation takes all reports of potential Code violations seriously and is committed to confidentiality and a full investigation of all allegations. The identity of the reporter will be omitted from the details of the report supplied to the accused. Contributors who are being investigated for a potential Code violation will have an opportunity to be heard prior to any final determination. Those found to have violated the Code can seek reconsideration of the violation and disciplinary action decisions. Every effort will be made to have all matters disposed of within 60 days of the receipt of the complaint. + +## Actions +Contributors who do not follow this Code in good faith may face temporary or permanent repercussions as determined by the Conduct Committee. + +This Code does not address all conduct. It works in conjunction with our [Communication Channel Guidelines](https://www.eclipse.org/org/documents/communication-channel-guidelines/), [Social Media Guidelines](https://www.eclipse.org/org/documents/social_media_guidelines.php), [Bylaws](https://www.eclipse.org/org/documents/eclipse-foundation-be-bylaws-en.pdf), and [Internal Rules](https://www.eclipse.org/org/documents/ef-be-internal-rules.pdf) which set out additional protections for, and obligations of, all contributors. The Foundation has additional policies that provide further guidance on other matters. + +It’s impossible to spell out every possible scenario that might be deemed a violation of this Code. Instead, we rely on one another’s good judgment to uphold a high standard of integrity within all Eclipse Spaces. Sometimes, identifying the right thing to do isn’t an easy call. In such a scenario, raise the issue as early as possible. + +## No Retaliation + +The Eclipse community relies upon and values the help of Contributors who identify potential problems that may need to be addressed within an Eclipse Space. Any retaliation against a Contributor who raises an issue honestly is a violation of this Code. That a Contributor has raised a concern honestly or participated in an investigation, cannot be the basis for any adverse action, including threats, harassment, or discrimination. If you work with someone who has raised a concern or provided information in an investigation, you should continue to treat the person with courtesy and respect. If you believe someone has retaliated against you, report the matter as described by this Code. Honest reporting does not mean that you have to be right when you raise a concern; you just have to believe that the information you are providing is accurate. + +False reporting, especially when intended to retaliate or exclude, is itself a violation of this Code and will not be accepted or tolerated. + +Everyone is encouraged to ask questions about this Code. Your feedback is welcome, and you will get a response within three business days. Write to . + +## Amendments + +The Eclipse Foundation Board of Directors may amend this Code from time to time and may vary the procedures it sets out where appropriate in a particular case. + +### Attribution + +This Code was inspired by the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4, available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct/). + +[^1]: Capitalized terms used herein without definition shall have the meanings assigned to them in the Bylaws. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..76a4db5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,43 @@ +# Contributing to 'Eclipse Keyple' + +**Welcome to the Eclipse Keyple Community!** + +We are thrilled to have you onboard and look forward to your contributions. Whether you're a coder, designer, +documenter, or enthusiast, your involvement is invaluable to us. Here's how you can start contributing to Eclipse +Keyple: + +## Quick Start + +1. **Read the Contribution Guidelines**: Before starting, please visit our detailed contributing guide at the +[Eclipse Keyple Contribution Guide](https://keyple.org/community/contributing/). +This guide covers all the necessary information about contributing to the project. + +2. **Join the mailing list**: Connect with other contributors on our +[mailing list](https://accounts.eclipse.org/mailing-list/keyple-dev/). +It's a great place to ask questions, share ideas, and collaborate. + +3. **Explore Open Issues**: Check out the issues tab in our GitHub repository. + +## How to Contribute + +- **Code**: Submit pull requests with bug fixes, new features, and improvements. Make sure to follow the code style and +testing guidelines. + +- **Documentation**: Help us improve our documentation by fixing errors, adding examples, or writing tutorials. + +- **Feedback**: Share your experience using Eclipse Keyple. Feedback on usability, features, and your overall experience +is incredibly valuable. + +- **Community Support**: Answer questions on the community forums, help with user support, and participate in +discussions. + +## Need Help? + +If you have any questions or need assistance, please reach out on the +[mailing list](https://accounts.eclipse.org/mailing-list/keyple-dev/). + +--- + +_Your contribution is the key to the success of Eclipse Keyple. Let's build something amazing together!_ + +--- diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 0000000..35a93d5 --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,3 @@ +set noparent +filter=-whitespace/indent,-build/c++11,-runtime/references +linelength=80 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e48e096 --- /dev/null +++ b/LICENSE @@ -0,0 +1,277 @@ +Eclipse Public License - v 2.0 + + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE + PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION + OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + + a) in the case of the initial Contributor, the initial content + Distributed under this Agreement, and + + b) in the case of each subsequent Contributor: + i) changes to the Program, and + ii) additions to the Program; + where such changes and/or additions to the Program originate from + and are Distributed by that particular Contributor. A Contribution + "originates" from a Contributor if it was added to the Program by + such Contributor itself or anyone acting on such Contributor's behalf. + Contributions do not include changes or additions to the Program that + are not Modified Works. + +"Contributor" means any person or entity that Distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which +are necessarily infringed by the use or sale of its Contribution alone +or when combined with the Program. + +"Program" means the Contributions Distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this Agreement +or any Secondary License (as applicable), including Contributors. + +"Derivative Works" shall mean any work, whether in Source Code or other +form, that is based on (or derived from) the Program and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. + +"Modified Works" shall mean any work in Source Code or other form that +results from an addition to, deletion from, or modification of the +contents of the Program, including, for purposes of clarity any new file +in Source Code form that contains any contents of the Program. Modified +Works shall not include works that contain only declarations, +interfaces, types, classes, structures, or files of the Program solely +in each case in order to link to, bind by name, or subclass the Program +or Modified Works thereof. + +"Distribute" means the acts of a) distributing or b) making available +in any manner that enables the transfer of a copy. + +"Source Code" means the form of a Program preferred for making +modifications, including but not limited to software source code, +documentation source, and configuration files. + +"Secondary License" means either the GNU General Public License, +Version 2.0, or any later versions of that license, including any +exceptions or additional permissions as identified by the initial +Contributor. + +2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free copyright + license to reproduce, prepare Derivative Works of, publicly display, + publicly perform, Distribute and sublicense the Contribution of such + Contributor, if any, and such Derivative Works. + + b) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free patent + license under Licensed Patents to make, use, sell, offer to sell, + import and otherwise transfer the Contribution of such Contributor, + if any, in Source Code or other form. This patent license shall + apply to the combination of the Contribution and the Program if, at + the time the Contribution is added by the Contributor, such addition + of the Contribution causes such combination to be covered by the + Licensed Patents. The patent license shall not apply to any other + combinations which include the Contribution. No hardware per se is + licensed hereunder. + + c) Recipient understands that although each Contributor grants the + licenses to its Contributions set forth herein, no assurances are + provided by any Contributor that the Program does not infringe the + patent or other intellectual property rights of any other entity. + Each Contributor disclaims any liability to Recipient for claims + brought by any other entity based on infringement of intellectual + property rights or otherwise. As a condition to exercising the + rights and licenses granted hereunder, each Recipient hereby + assumes sole responsibility to secure any other intellectual + property rights needed, if any. For example, if a third party + patent license is required to allow Recipient to Distribute the + Program, it is Recipient's responsibility to acquire that license + before distributing the Program. + + d) Each Contributor represents that to its knowledge it has + sufficient copyright rights in its Contribution, if any, to grant + the copyright license set forth in this Agreement. + + e) Notwithstanding the terms of any Secondary License, no + Contributor makes additional grants to any Recipient (other than + those set forth in this Agreement) as a result of such Recipient's + receipt of the Program under the terms of a Secondary License + (if permitted under the terms of Section 3). + +3. REQUIREMENTS + +3.1 If a Contributor Distributes the Program in any form, then: + + a) the Program must also be made available as Source Code, in + accordance with section 3.2, and the Contributor must accompany + the Program with a statement that the Source Code for the Program + is available under this Agreement, and informs Recipients how to + obtain it in a reasonable manner on or through a medium customarily + used for software exchange; and + + b) the Contributor may Distribute the Program under a license + different than this Agreement, provided that such license: + i) effectively disclaims on behalf of all other Contributors all + warranties and conditions, express and implied, including + warranties or conditions of title and non-infringement, and + implied warranties or conditions of merchantability and fitness + for a particular purpose; + + ii) effectively excludes on behalf of all other Contributors all + liability for damages, including direct, indirect, special, + incidental and consequential damages, such as lost profits; + + iii) does not attempt to limit or alter the recipients' rights + in the Source Code under section 3.2; and + + iv) requires any subsequent distribution of the Program by any + party to be under a license that satisfies the requirements + of this section 3. + +3.2 When the Program is Distributed as Source Code: + + a) it must be made available under this Agreement, or if the + Program (i) is combined with other material in a separate file or + files made available under a Secondary License, and (ii) the initial + Contributor attached to the Source Code the notice described in + Exhibit A of this Agreement, then the Program may be made available + under the terms of such Secondary Licenses, and + + b) a copy of this Agreement must be included with each copy of + the Program. + +3.3 Contributors may not remove or alter any copyright, patent, +trademark, attribution notices, disclaimers of warranty, or limitations +of liability ("notices") contained within the Program from any copy of +the Program which they Distribute, provided that Contributors may add +their own appropriate notices. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities +with respect to end users, business partners and the like. While this +license is intended to facilitate the commercial use of the Program, +the Contributor who includes the Program in a commercial product +offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes +the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and indemnify every +other Contributor ("Indemnified Contributor") against any losses, +damages and costs (collectively "Losses") arising from claims, lawsuits +and other legal actions brought by a third party against the Indemnified +Contributor to the extent caused by the acts or omissions of such +Commercial Contributor in connection with its distribution of the Program +in a commercial product offering. The obligations in this section do not +apply to any claims or Losses relating to any actual or alleged +intellectual property infringement. In order to qualify, an Indemnified +Contributor must: a) promptly notify the Commercial Contributor in +writing of such claim, and b) allow the Commercial Contributor to control, +and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may +participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those performance +claims and warranties, and if a court requires any other Contributor to +pay any damages as a result, the Commercial Contributor must pay +those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF +TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR +PURPOSE. Each Recipient is solely responsible for determining the +appropriateness of using and distributing the Program and assumes all +risks associated with its exercise of rights under this Agreement, +including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs +or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS +SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE +EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other software +or hardware) infringes such Recipient's patent(s), then such Recipient's +rights granted under Section 2(b) shall terminate as of the date such +litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign the +responsibility to serve as the Agreement Steward to a suitable separate +entity. Each new version of the Agreement will be given a distinguishing +version number. The Program (including Contributions) may always be +Distributed subject to the version of the Agreement under which it was +received. In addition, after a new version of the Agreement is published, +Contributor may elect to Distribute the Program (including its +Contributions) under the new version. + +Except as expressly stated in Sections 2(a) and 2(b) above, Recipient +receives no rights or licenses to the intellectual property of any +Contributor under this Agreement, whether expressly, by implication, +estoppel or otherwise. All rights in the Program not expressly granted +under this Agreement are reserved. Nothing in this Agreement is intended +to be enforceable by any entity that is not a Contributor or Recipient. +No third-party beneficiary rights are created under this Agreement. + +Exhibit A - Form of Secondary Licenses Notice + +"This Source Code may also be made available under the following +Secondary Licenses when the conditions for such availability set forth +in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), +version(s), and exceptions or additional permissions here}." + + Simply including a copy of this Agreement, including this Exhibit A + is not sufficient to license the Source Code under Secondary Licenses. + + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to + look for such a notice. + + You may add additional accurate notices of copyright ownership. diff --git a/NOTICE.md b/NOTICE.md new file mode 100644 index 0000000..350c5d7 --- /dev/null +++ b/NOTICE.md @@ -0,0 +1,29 @@ +# Notices for 'Eclipse Keyple' C++ implementation + +This content is produced and maintained by the Eclipse Keyple project. + +* Project home: https://projects.eclipse.org/projects/iot.keyple + +## Trademarks + +* Eclipse Keyple and the Eclipse Keyple project are Trademarks of the Eclipse Foundation, Inc. +* Eclipse® is a Trademark of the Eclipse Foundation, Inc. +* Eclipse Foundation is a Trademark of the Eclipse Foundation, Inc. + +## Copyright + +All content is the property of the respective authors or their employers. +For more information regarding authorship of content, please consult the +listed source code repository logs. + +## Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License v. 2.0 which is available at +http://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html + +SPDX-License-Identifier: EPL-2.0 + +## Third-party Content + +No third-party content. diff --git a/PUBLISHERS.yml b/PUBLISHERS.yml new file mode 100644 index 0000000..e56d6c7 --- /dev/null +++ b/PUBLISHERS.yml @@ -0,0 +1,18 @@ +url: https://github.com/eclipse/keyple-plugin-storagecard-cpp-api +organization: + name: Eclipse Keyple + url: https://keyple.org/ +licenses: + - name: Eclipse Public License - v 2.0 + url: https://www.eclipse.org/legal/epl-2.0/ + distribution: repo +developers: + - name: Keyple Contributors + email: keyple-dev@eclipse.org +scm: + connection: scm:git:git://github.com/eclipse/keyple-plugin-storagecard-cpp-api.git + developerConnection: scm:git:https://github.com/eclipse/keyple-plugin-storagecard-cpp-api.git + url: https://github.com/eclipse/keyple-plugin-storagecard-cpp-api +ciManagement: + system: GitHub Actions + url: https://github.com/eclipse/keyple-plugin-storagecard-cpp-api/actions diff --git a/README.md b/README.md index 85b38e3..bf7972c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ # keyple-plugin-storagecard-cpp-api -Eclipse Keyple™ Project - Storage Card Plugin API + +## Overview + +The **Keyple Plugin Storage Card** C++ API is dedicated to the development of Keyple plugins supporting +contactless storage cards (e.g. NXP Mifare Ultralight, NXP Mifare Classic, STMicroelectronics ST25/SRT512). + +This library **should not be imported explicitly** by the main application. + +## User Guide & Download Information + +The full documentation, including download information is available in the **Documentation** section of the +official Keyple website [keyple.org](https://keyple.org) + +## Build the Code + +The code is built with CMake and dependencies (GoogleTest) are resolved via CMake's `FetchContent`, downloaded at +configure time. A toolchain file is required for every build; see `toolchain/` for the profiles used in CI +(`gcc-linux`, `clang-macos`, `clang-windows`, etc.), for example: + +```bash +mkdir build && cd build +cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain/clang-macos.cmake +cmake --build . +./bin/keypluginstoragecardcppapi_ut +``` + +## Code Contributions + +We welcome code contributions through merge requests. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..58a4e95 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,9 @@ +# Security Policy + +This project implements the Eclipse Foundation Security Policy + +* https://www.eclipse.org/security + +## Reporting a Vulnerability + +Please report vulnerabilities to the Eclipse Foundation Security Team at security@eclipse.org diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..7c4c6fb --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,37 @@ +# ***************************************************************************** +# Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +SET(LIBRARY_NAME keypluginstoragecardcppapi) + +ADD_LIBRARY( + + ${LIBRARY_NAME} + + INTERFACE +) + +ADD_LIBRARY( + + Keyple::Plugin::StorageCard + + ALIAS + + ${LIBRARY_NAME} +) + +TARGET_INCLUDE_DIRECTORIES( + + ${LIBRARY_NAME} + + INTERFACE + + $ + $ +) diff --git a/include/keyple/core/plugin/storagecard/ApduInterpreterFactory.hpp b/include/keyple/core/plugin/storagecard/ApduInterpreterFactory.hpp new file mode 100644 index 0000000..afe307d --- /dev/null +++ b/include/keyple/core/plugin/storagecard/ApduInterpreterFactory.hpp @@ -0,0 +1,46 @@ +/****************************************************************************** + * Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +namespace keyple { +namespace core { +namespace plugin { +namespace storagecard { + +/** + * Factory interface for creating instances of APDU interpreters. + * + *

The purpose of this interface is to provide an APDU interpreter factory + * designed to be supplied to plugins capable of handling storage-type smart + * card processing functionalities. + * + *

This interface is designed to be implemented by card APDU interpreter + * libraries, enabling the creation of specific APDU interpreter instances + * tailored to handle APDU commands and their processing requirements. + * + *

Implementations must be instances of + * keyple::core::plugin::storagecard::internal::spi::ApduInterpreterFactorySpi + * providing the logic for a concrete APDU interpreter. + * + * @since 1.0.0 + */ +class ApduInterpreterFactory { +public: + /** + * Virtual destructor. + */ + virtual ~ApduInterpreterFactory() = default; +}; + +} /* namespace storagecard */ +} /* namespace plugin */ +} /* namespace core */ +} /* namespace keyple */ diff --git a/include/keyple/core/plugin/storagecard/PluginStorageCardApiProperties.hpp b/include/keyple/core/plugin/storagecard/PluginStorageCardApiProperties.hpp new file mode 100644 index 0000000..1451304 --- /dev/null +++ b/include/keyple/core/plugin/storagecard/PluginStorageCardApiProperties.hpp @@ -0,0 +1,30 @@ +/****************************************************************************** + * Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +#include + +namespace keyple { +namespace core { +namespace plugin { +namespace storagecard { + +/** + * API properties. + * + * @since 1.0.0 + */ +static const std::string& PluginStorageCardApiProperties_VERSION = "1.1"; + +} /* namespace storagecard */ +} /* namespace plugin */ +} /* namespace core */ +} /* namespace keyple */ diff --git a/include/keyple/core/plugin/storagecard/internal/CommandProcessorApi.hpp b/include/keyple/core/plugin/storagecard/internal/CommandProcessorApi.hpp new file mode 100644 index 0000000..08b5867 --- /dev/null +++ b/include/keyple/core/plugin/storagecard/internal/CommandProcessorApi.hpp @@ -0,0 +1,244 @@ +/****************************************************************************** + * Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +#include +#include + +#include "keyple/core/plugin/storagecard/internal/KeyStorageType.hpp" + +namespace keyple { +namespace core { +namespace plugin { +namespace storagecard { +namespace internal { + +/** + * Interface defining a command processor for interacting with a storage + * card. + * + *

To be implemented by the plugin. + * + *

Exception Handling

+ * + *

All methods may throw exceptions to indicate error conditions. + * Implementations should distinguish between: + * + *

    + *
  • std::invalid_argument - For invalid parameters that can be + * validated before hardware access + *
  • std::exception - For technical errors during hardware operations + * (communication failures, authentication failures, etc.) + *
+ * + *

The exception message should provide clear diagnostic information + * about the failure cause. + * + * @since 1.0.0 + */ +class CommandProcessorApi { +public: + /** + * Virtual destructor. + */ + virtual ~CommandProcessorApi() = default; + + /** + * Transmits a standard APDU command to the card. + * + * @param apdu The APDU ISO 7816-4 command. + * @return The response from the card including both data and status + * words. + * @throw std::invalid_argument if apdu is empty or invalid. + * @throw std::exception if transmission fails or communication error + * occurs. + * @since 1.0.0 + */ + virtual std::vector + transmitIsoApdu(const std::vector& apdu) = 0; + + /** + * Retrieves the Unique Identifier (UID) of the card. + * + *

This method obtains the UID which uniquely identifies the card. + * The UID length varies depending on the card type. + * + *

If the UID is not available for the current card type, an empty + * byte array will be returned. + * + * @return A byte array containing the card's UID, or an empty array if + * the UID is not available. + * @throw std::exception if the retrieval operation fails or + * communication error occurs. + * @since 1.0.0 + */ + virtual std::vector getUID() = 0; + + /** + * Reads data starting from a specified block address. + * + *

This method handles reading memory blocks according to the card's + * memory page structure. The requested length should be a multiple of + * the card's page size and must not exceed the maximum readable size in + * a single exchange with the specific card type. + * + *

For example, Mifare Ultralight cards have 4-byte pages, but each + * read command returns 4 pages (16 bytes) at once. ST25/SRT512 cards + * read one page at a time. + * + *

If the requested length is shorter than the actual exchange size + * with the card, the response will be truncated accordingly. + * + * @param blockAddress The address of the first block to be read. + * @param length The number of bytes to read, should be a multiple of + * the card's page size and must not exceed the maximum readable size + * for the specific card type. + * @return A byte array containing the block data. + * @throw std::invalid_argument if blockAddress is out of range or + * length is negative, not compatible with the card's page structure, or + * exceeds the maximum readable size. + * @throw std::exception if the read operation fails or communication + * error occurs. + * @since 1.0.0 + */ + virtual std::vector + readBlock(int blockAddress, int length) = 0; + + /** + * Writes data to a specified memory block on the card. + * + *

This method handles writing memory blocks according to the card's + * memory page structure. The data length must exactly match the + * exchange size for the specific card type. + * + * @param blockAddress The address of the first block to be written. + * @param data The byte array containing the data to write. The length + * must match exactly the card's page size or exchange size. + * @throw std::invalid_argument if blockAddress is out of range or if + * data length does not match the required exchange size for the card + * type. + * @throw std::exception if the write operation fails or communication + * error occurs. + * @since 1.0.0 + */ + virtual void + writeBlock(int blockAddress, const std::vector& data) = 0; + + /** + * Loads a card-specific authentication key into the reader's memory. + * + *

This method stores a card key in either volatile (RAM) or + * non-volatile (EEPROM) memory of the card reader. The key can be + * subsequently used by the generalAuthenticate(int, int, int) method to + * authenticate to the card. This command can be used for all kinds of + * contactless cards. + * + *

Volatile memory provides temporary storage that is cleared when + * the reader loses power, while non-volatile memory persists across + * power cycles. The availability of non-volatile memory depends on the + * specific reader hardware. + * + *

The key structure and length depend on the card type. For + * example: + * + *

    + *
  • Mifare cards: 6-byte keys (Type A or Type B) + *
  • Other contactless cards: card-specific key formats + *
+ * + *

The key number parameter identifies the storage location in the + * reader's memory. The valid range and meaning of key numbers depend on + * the reader implementation and whether volatile or non-volatile memory + * is used. Consult the reader documentation for specific key number + * assignments. + * + *

Note that keys stored in memory cannot be read back for security + * reasons. Once loaded, they can only be used for authentication + * operations. + * + * @param keyStorageType The type of memory to store the key in + * (VOLATILE or NON_VOLATILE). + * @param keyNumber The key index identifying the storage location. + * Valid ranges depend on the reader implementation and memory type. + * @param key A byte array containing the card-specific key value. Must + * not be empty. The required length depends on the card type and + * authentication algorithm. + * @throw std::invalid_argument if key is empty, if the key length is + * not valid for the card type, or if keyNumber is not in the valid + * range for the reader and memory type. + * @throw std::exception if the load operation fails, if the specified + * memory type is not available on the reader hardware, or if a + * communication error occurs. + * @see generalAuthenticate(int, int, int) + * @since 1.1.0 + */ + virtual void loadKey( + KeyStorageType keyStorageType, + int keyNumber, + const std::vector& key) + = 0; + + /** + * Performs authentication to a contactless card using a previously + * loaded key. + * + *

This method authenticates to a specific memory location on the + * card using a key that was previously loaded into the reader's memory + * via the loadKey(KeyStorageType, int, const std::vector&) + * method. Successful authentication is typically required before + * performing read or write operations on protected memory areas. + * + *

The authentication process establishes a secure session between + * the reader and the card. The block address represents the block + * number or starting byte number of the card to be authenticated, + * depending on the card type. + * + *

The key type parameter is card-specific and indicates which type + * of key to use for authentication. Examples: + * + *

    + *
  • Mifare cards: 0x60 (KEY_A) or 0x61 (KEY_B) + *
  • Other contactless cards: card-specific key type values + *
+ * + *

The key number parameter references a key previously loaded via + * loadKey(KeyStorageType, int, const std::vector&) and + * identifies which stored key to use for this authentication + * operation. + * + * @param blockAddress The block number or starting byte number on the + * card where authentication is to be performed. Valid range depends on + * the card type and memory structure. + * @param keyType The type of key to use for authentication. The valid + * values are card-specific (e.g., 0x60 or 0x61 for Mifare cards). + * @param keyNumber The index of the previously loaded key to use for + * authentication. Must reference a key that was loaded via + * loadKey(KeyStorageType, int, const std::vector&). + * @return true if authentication succeeded, false if authentication + * failed (e.g., incorrect key). + * @throw std::invalid_argument if blockAddress is out of valid range + * for the card type, if keyType is not supported by the card, or if + * keyNumber does not reference a valid loaded key. + * @throw std::exception if the referenced key was not previously + * loaded, if the card does not support authentication, or if a + * communication error occurs. + * @see loadKey(KeyStorageType, int, const std::vector&) + * @since 1.1.0 + */ + virtual bool + generalAuthenticate(int blockAddress, int keyType, int keyNumber) = 0; +}; + +} /* namespace internal */ +} /* namespace storagecard */ +} /* namespace plugin */ +} /* namespace core */ +} /* namespace keyple */ diff --git a/include/keyple/core/plugin/storagecard/internal/KeyStorageType.hpp b/include/keyple/core/plugin/storagecard/internal/KeyStorageType.hpp new file mode 100644 index 0000000..14c5d88 --- /dev/null +++ b/include/keyple/core/plugin/storagecard/internal/KeyStorageType.hpp @@ -0,0 +1,51 @@ +/****************************************************************************** + * Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +namespace keyple { +namespace core { +namespace plugin { +namespace storagecard { +namespace internal { + +/** + * Enumeration defining the memory types available for key storage in the + * reader. + * + * @since 1.1.0 + */ +enum class KeyStorageType { + /** + * Volatile memory (RAM). + * + *

Keys stored here are lost when the reader is powered off or reset. + * This is generally faster and supports unlimited write cycles. + * + * @since 1.1.0 + */ + VOLATILE, + + /** + * Non-volatile memory (EEPROM/Flash). + * + *

Keys stored here persist across power cycles. Note that + * non-volatile memory typically has a limited number of write cycles. + * + * @since 1.1.0 + */ + NON_VOLATILE +}; + +} /* namespace internal */ +} /* namespace storagecard */ +} /* namespace plugin */ +} /* namespace core */ +} /* namespace keyple */ diff --git a/include/keyple/core/plugin/storagecard/internal/spi/ApduInterpreterFactorySpi.hpp b/include/keyple/core/plugin/storagecard/internal/spi/ApduInterpreterFactorySpi.hpp new file mode 100644 index 0000000..39aa46c --- /dev/null +++ b/include/keyple/core/plugin/storagecard/internal/spi/ApduInterpreterFactorySpi.hpp @@ -0,0 +1,50 @@ +/****************************************************************************** + * Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +#include + +#include "keyple/core/plugin/storagecard/ApduInterpreterFactory.hpp" +#include "keyple/core/plugin/storagecard/internal/spi/ApduInterpreterSpi.hpp" + +namespace keyple { +namespace core { +namespace plugin { +namespace storagecard { +namespace internal { +namespace spi { + +using keyple::core::plugin::storagecard::ApduInterpreterFactory; + +/** + * Factory interface for creating instances of ApduInterpreterSpi. + * + *

To be implemented by the storage card APDU interpreter. + * + * @since 1.0.0 + */ +class ApduInterpreterFactorySpi : public ApduInterpreterFactory { +public: + /** + * Creates a new instance of an APDU interpreter. + * + * @return A new instance of ApduInterpreterSpi. + * @since 1.0.0 + */ + virtual std::unique_ptr createApduInterpreter() = 0; +}; + +} /* namespace spi */ +} /* namespace internal */ +} /* namespace storagecard */ +} /* namespace plugin */ +} /* namespace core */ +} /* namespace keyple */ diff --git a/include/keyple/core/plugin/storagecard/internal/spi/ApduInterpreterSpi.hpp b/include/keyple/core/plugin/storagecard/internal/spi/ApduInterpreterSpi.hpp new file mode 100644 index 0000000..1ee2e91 --- /dev/null +++ b/include/keyple/core/plugin/storagecard/internal/spi/ApduInterpreterSpi.hpp @@ -0,0 +1,172 @@ +/****************************************************************************** + * Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#pragma once + +#include +#include +#include + +#include "keyple/core/plugin/storagecard/internal/CommandProcessorApi.hpp" + +namespace keyple { +namespace core { +namespace plugin { +namespace storagecard { +namespace internal { +namespace spi { + +using keyple::core::plugin::storagecard::internal::CommandProcessorApi; + +/** + * Interface defining an APDU interpreter for processing commands sent to + * storage cards. + * + *

Its implementation is provided by ApduInterpreterFactorySpi. + * + *

Upon calling processApdu, implementations determine how to invoke the + * appropriate methods of CommandProcessorApi based on the APDU class byte + * (CLA) and instruction (INS). + * + *

APDU Processing Strategy

+ * + *

The interpreter follows a two-pathway processing model: + * + *

    + *
  • Standard ISO 7816-4 APDUs (CLA != 0xFF): Directly + * transmitted via CommandProcessorApi::transmitIsoApdu(const + * std::vector&) without interpretation. + *
  • Storage Card APDUs (CLA = 0xFF): Interpreted and + * translated into CommandProcessorApi method calls based on the + * instruction byte: + *
      + *
    • INS 0xCA → CommandProcessorApi::getUID() - Get card UID + *
    • INS 0xB0 → CommandProcessorApi::readBlock(int, int) - + * Read binary data + *
    • INS 0xD6 → CommandProcessorApi::writeBlock(int, const + * std::vector&) - Write binary data + *
    • INS 0x82 → CommandProcessorApi::loadKey(KeyStorageType, + * int, const std::vector&) - Load authentication key + *
    • INS 0x86 → CommandProcessorApi::generalAuthenticate(int, + * int, int) - Authenticate with key + *
    + *
+ * + *

Error Handling Strategy

+ * + *

This interface follows a trust-based validation + * approach: + * + *

    + *
  • Validation is performed upstream by the card + * extension that generates the APDUs. Since this extension is part + * of the same ecosystem, its output is trusted. + *
  • CommandProcessorApi does not perform parameter + * validation and trusts the incoming data to be correct. + *
  • Exceptions propagate to the caller unless they + * represent normal protocol conditions (e.g., authentication + * failure, unsupported instruction). + *
  • Status words are returned only for + * protocol-level conditions, not validation errors. + *
+ * + *

Status Words Usage

+ * + *

Implementations return ISO 7816-4 / PC/SC compliant status words for + * the following conditions: + * + * + * + * + * + * + * + *
Status Words returned by implementations
Status WordCodeUsage
Success0x9000Successful execution
Security status not satisfied0x6982 + * Authentication failed (PC/SC compliant)
INS not supported0x6D00Unknown instruction + * code
+ * + *

Exception Propagation

+ * + *

The following error conditions may result in exceptions: + * + *

    + *
  • Hardware/communication errors (card not + * responding, transmission failure) - thrown by CommandProcessorApi + *
  • Protocol-level errors that cannot be represented + * by status words - may be thrown by implementations + *
+ * + *

Note: Parameter validation (P1/P2 values, data + * lengths, key numbers, etc.) is the responsibility of the card extension + * generating the APDUs, not this interface or its implementations. + * + *

PC/SC Compliance

+ * + *

Storage card commands (CLA=0xFF) follow the PC/SC v2.01.09 + * specification: + * + *

    + *
  • LOAD KEY: FF 82 [P1] [P2] 06 [6-byte key] + *
  • GENERAL AUTHENTICATE: FF 86 00 00 05 + * [version][addr-MSB][addr-LSB][key-type][key-num] + *
  • GET DATA (UID): FF CA 00 00 [Le] + *
  • READ BINARY: FF B0 [P1] [P2] [Le] + *
  • UPDATE BINARY: FF D6 [P1] [P2] [Lc] [data] + *
+ * + * @see CommandProcessorApi + * @see ApduInterpreterFactorySpi + * @since 1.0.0 + */ +class ApduInterpreterSpi { +public: + /** + * Virtual destructor. + */ + virtual ~ApduInterpreterSpi() = default; + + /** + * Sets the command processor responsible for handling APDU execution. + * + * @param commandProcessor The CommandProcessorApi instance used for + * APDU communication. + * @since 1.0.0 + */ + virtual void setCommandProcessor( + const std::shared_ptr& commandProcessor) + = 0; + + /** + * Processes an APDU command by invoking the corresponding methods of + * CommandProcessorApi based on the card type. + * + *

If the card supports standard ISO 7816-4 APDUs, this method calls + * CommandProcessorApi::transmitIsoApdu(const std::vector&). + * Otherwise, it interprets the APDU and executes the required read or + * write operations through CommandProcessorApi::readBlock(int, int) or + * CommandProcessorApi::writeBlock(int, const std::vector&). + * + * @param apdu The APDU command as a byte array. + * @return The response as a byte array. + * @throw std::invalid_argument if the APDU is empty or invalid. + * @throw std::exception if the transmission fails or a communication + * error occurs. + * @since 1.0.0 + */ + virtual std::vector processApdu( + const std::vector& apdu) = 0; +}; + +} /* namespace spi */ +} /* namespace internal */ +} /* namespace storagecard */ +} /* namespace plugin */ +} /* namespace core */ +} /* namespace keyple */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..48ad53b --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,12 @@ +# ***************************************************************************** +# Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +# Add projects +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt new file mode 100644 index 0000000..dc68856 --- /dev/null +++ b/src/test/CMakeLists.txt @@ -0,0 +1,38 @@ +# ***************************************************************************** +# Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +SET(EXECTUABLE_NAME keypluginstoragecardcppapi_ut) + +INCLUDE_DIRECTORIES( + + ${CMAKE_CURRENT_SOURCE_DIR} +) + +ADD_EXECUTABLE( + + ${EXECTUABLE_NAME} + + ${CMAKE_CURRENT_SOURCE_DIR}/MainTest.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/PluginStorageCardApiPropertiesTest.cpp +) + +# Add necessary deps +INCLUDE(CMakeLists.txt.googletest) + +TARGET_LINK_LIBRARIES( + + ${EXECTUABLE_NAME} + + PRIVATE + + gtest + gmock + Keyple::Plugin::StorageCard +) diff --git a/src/test/CMakeLists.txt.googletest b/src/test/CMakeLists.txt.googletest new file mode 100644 index 0000000..6f604f4 --- /dev/null +++ b/src/test/CMakeLists.txt.googletest @@ -0,0 +1,41 @@ +# ***************************************************************************** +# Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * +# * +# This program and the accompanying materials are made available under the * +# terms of the MIT License which is available at * +# https://opensource.org/licenses/MIT. * +# * +# SPDX-License-Identifier: MIT * +# *****************************************************************************/ + +# FetchContent added in CMake 3.11, downloads during the configure step +# FetchContent_MakeAvailable was added in CMake 3.14; simpler usage +INCLUDE(FetchContent) + +IF(NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/googletest-src") + + MESSAGE("-- > Fetching GTest from keyple-plugin-storagecard-cpp-api") + + FetchContent_Declare( + + googletest + + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG v1.14.0 + ) + +ELSE() + + FetchContent_Declare( + + googletest + + SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/googletest-src + ) + +ENDIF() + +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +FetchContent_MakeAvailable(googletest) diff --git a/src/test/MainTest.cpp b/src/test/MainTest.cpp new file mode 100644 index 0000000..02ef35e --- /dev/null +++ b/src/test/MainTest.cpp @@ -0,0 +1,21 @@ +/****************************************************************************** + * Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include "gtest/gtest.h" + +int +main(int argc, char** argv) +{ + /* Initialize GTest */ + ::testing::InitGoogleTest(&argc, argv); + + /* Run */ + return RUN_ALL_TESTS(); +} diff --git a/src/test/PluginStorageCardApiPropertiesTest.cpp b/src/test/PluginStorageCardApiPropertiesTest.cpp new file mode 100644 index 0000000..0c23c66 --- /dev/null +++ b/src/test/PluginStorageCardApiPropertiesTest.cpp @@ -0,0 +1,26 @@ +/****************************************************************************** + * Copyright (c) 2026 Calypso Networks Association https://calypsonet.org/ * + * * + * This program and the accompanying materials are made available under the * + * terms of the MIT License which is available at * + * https://opensource.org/licenses/MIT. * + * * + * SPDX-License-Identifier: MIT * + ******************************************************************************/ + +#include +#include + +#include "gtest/gtest.h" + +#include "keyple/core/plugin/storagecard/PluginStorageCardApiProperties.hpp" + +using keyple::core::plugin::storagecard::PluginStorageCardApiProperties_VERSION; + +TEST(PluginStorageCardApiPropertiesTest, versionIsCorrectlyWritten) +{ + const std::string& apiVersion = PluginStorageCardApiProperties_VERSION; + const std::regex r("\\d+\\.\\d+"); + + ASSERT_TRUE(std::regex_match(apiVersion, r)); +} diff --git a/toolchain/arm-unknown-gnueabi-linux.cmake b/toolchain/arm-unknown-gnueabi-linux.cmake new file mode 100644 index 0000000..3683870 --- /dev/null +++ b/toolchain/arm-unknown-gnueabi-linux.cmake @@ -0,0 +1,26 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) +SET(TOOLCHAIN_FILE "arm-unknown-gnueabi-linux.cmake") + +# Path +SET(ARM_TOOLCHAIN_DIR /home/amunsch/toolchain/yt/imx) +SET(ARM_COMPILER_DIR ${ARM_TOOLCHAIN_DIR}/bin) +SET(ARM_SYSROOT_DIR ${ARM_TOOLCHAIN_DIR}/arm-unknown-linux-gnueabi/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER ${ARM_COMPILER_DIR}/arm-unknown-linux-gnueabi-gcc) +SET(CMAKE_CXX_COMPILER ${ARM_COMPILER_DIR}/arm-unknown-linux-gnueabi-g++) + +# Here is the target environment located +SET(CMAKE_FIND_ROOT_PATH ${ARM_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Linker +SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${ARM_SYSROOT_DIR}") +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${ARM_SYSROOT_DIR} -L${ARM_SYSROOT_DIR}") diff --git a/toolchain/clang-8-linux.cmake b/toolchain/clang-8-linux.cmake new file mode 100644 index 0000000..93222ef --- /dev/null +++ b/toolchain/clang-8-linux.cmake @@ -0,0 +1,44 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) +SET(TOOLCHAIN_FILE "clang-8-linux.cmake") + +# Path +SET(CLANG_TOOLCHAIN_DIR /usr) +SET(CLANG_COMPILER_DIR ${CLANG_TOOLCHAIN_DIR}/bin) +#SET(CLANG_SYSROOT_DIR ${CLANG_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER ${CLANG_COMPILER_DIR}/clang-8) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER ${CLANG_COMPILER_DIR}/clang++-8) +#SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +#SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +# Here is the target environment located +#SET(CMAKE_FIND_ROOT_PATH ${CLANG_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Compiler flags +SET(CMAKE_CXX_FLAGS "") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR} -L${CLANG_SYSROOT_DIR}") + +# Libraries type +SET(LIBRARY_TYPE SHARED) diff --git a/toolchain/clang-9-linux.cmake b/toolchain/clang-9-linux.cmake new file mode 100644 index 0000000..4c13b7f --- /dev/null +++ b/toolchain/clang-9-linux.cmake @@ -0,0 +1,44 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) +SET(TOOLCHAIN_FILE "clang-9-linux.cmake") + +# Path +SET(CLANG_TOOLCHAIN_DIR /usr) +SET(CLANG_COMPILER_DIR ${CLANG_TOOLCHAIN_DIR}/bin) +#SET(CLANG_SYSROOT_DIR ${CLANG_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER ${CLANG_COMPILER_DIR}/clang-9) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER ${CLANG_COMPILER_DIR}/clang++-9) +#SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +#SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +# Here is the target environment located +#SET(CMAKE_FIND_ROOT_PATH ${CLANG_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Compiler flags +SET(CMAKE_CXX_FLAGS "") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR} -L${CLANG_SYSROOT_DIR}") + +# Libraries type +SET(LIBRARY_TYPE SHARED) diff --git a/toolchain/clang-linux.cmake b/toolchain/clang-linux.cmake new file mode 100644 index 0000000..6282777 --- /dev/null +++ b/toolchain/clang-linux.cmake @@ -0,0 +1,44 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) +SET(TOOLCHAIN_FILE "clang-linux.cmake") + +# Path +#SET(CLANG_TOOLCHAIN_DIR /usr) +#SET(CLANG_COMPILER_DIR ${CLANG_TOOLCHAIN_DIR}/bin) +#SET(CLANG_SYSROOT_DIR ${CLANG_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER clang) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER clang++) +#SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +#SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +# Here is the target environment located +#SET(CMAKE_FIND_ROOT_PATH ${CLANG_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Compiler flags +SET(CMAKE_CXX_FLAGS "") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR} -L${CLANG_SYSROOT_DIR}") + +# Libraries type +SET(LIBRARY_TYPE SHARED) diff --git a/toolchain/clang-macos.cmake b/toolchain/clang-macos.cmake new file mode 100644 index 0000000..29a03d5 --- /dev/null +++ b/toolchain/clang-macos.cmake @@ -0,0 +1,44 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Darwin) +SET(TOOLCHAIN_FILE "clang-macos.cmake") + +# Path +SET(CLANG_TOOLCHAIN_DIR /usr) +SET(CLANG_COMPILER_DIR ${CLANG_TOOLCHAIN_DIR}/bin) +#SET(CLANG_SYSROOT_DIR ${CLANG_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER ${CLANG_COMPILER_DIR}/clang) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER ${CLANG_COMPILER_DIR}/clang++) +#SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +#SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +# Here is the target environment located +#SET(CMAKE_FIND_ROOT_PATH ${CLANG_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Compiler flags +SET(CMAKE_CXX_FLAGS "") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR} -L${CLANG_SYSROOT_DIR}") + +# Libraries type +SET(LIBRARY_TYPE SHARED) diff --git a/toolchain/clang-windows.cmake b/toolchain/clang-windows.cmake new file mode 100644 index 0000000..cfd971c --- /dev/null +++ b/toolchain/clang-windows.cmake @@ -0,0 +1,70 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Windows) +SET(TOOLCHAIN_FILE "clang-windows.cmake") + +# Path +#SET(CLANG_TOOLCHAIN_DIR /usr) +#SET(CLANG_COMPILER_DIR ${CLANG_TOOLCHAIN_DIR}/bin) +#SET(CLANG_SYSROOT_DIR ${CLANG_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER cl.exe) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER cl.exe) +#SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +#SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +# Here is the target environment located +#SET(CMAKE_FIND_ROOT_PATH ${CLANG_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Compiler flags +#SET(CMAKE_CXX_FLAGS "") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # multi proces +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") # warning level +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") # warning as error +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi") # debug symbols +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Od") # disables optimization +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Ob0") # controls inline expans. +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Oy-") # rem. omit frame pointer +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D WIN32") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _WINDOWS") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _WINDLL") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _MBCS") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _CRT_SECURE_NO_WARNINGS") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Gm-") # rem. minimal rebuild +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") # exception handling +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /RTC1") # runtime error check +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MDd") # debug multi thread dll +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS") # buffers security check +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise") # floating point +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t") # standard behaviour +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:forScope") # +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:inline") # +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR") # enables RTTI +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Gd") # uses __cdecl convention +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /TP") # all sources are C++ +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /analyze-") # rem. code analysis +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4275") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4290") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4309") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4834") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4373") + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR} -L${CLANG_SYSROOT_DIR}") + +# Libraries type +SET(LIBRARY_TYPE SHARED) + +# Special tricks +INCLUDE(GenerateExportHeader) diff --git a/toolchain/gcc-10-linux.cmake b/toolchain/gcc-10-linux.cmake new file mode 100644 index 0000000..3282cd6 --- /dev/null +++ b/toolchain/gcc-10-linux.cmake @@ -0,0 +1,45 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) +SET(TOOLCHAIN_FILE "gcc-10-linux.cmake") + +# Path +SET(GCC_TOOLCHAIN_DIR /usr) +SET(GCC_COMPILER_DIR ${GCC_TOOLCHAIN_DIR}/bin) +#SET(GCC_SYSROOT_DIR ${GCC_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER ${GCC_COMPILER_DIR}/gcc-9) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER ${GCC_COMPILER_DIR}/g++-9) +#SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +#SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +# Here is the target environment located +#SET(CMAKE_FIND_ROOT_PATH ${GCC_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Compiler flags +SET(CMAKE_CXX_FLAGS "") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR} -L${GCC_SYSROOT_DIR}") + +# Libraries type +SET(LIBRARY_TYPE SHARED) diff --git a/toolchain/gcc-4.8.3-linux.cmake b/toolchain/gcc-4.8.3-linux.cmake new file mode 100644 index 0000000..e6d3df0 --- /dev/null +++ b/toolchain/gcc-4.8.3-linux.cmake @@ -0,0 +1,29 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) +SET(TOOLCHAIN_FILE "gcc-4.8.3-linux.cmake") + +# Path +SET(GCC_TOOLCHAIN_DIR /home/amunsch/Downloads/gcc-4.8.3) +SET(GCC_COMPILER_DIR ${GCC_TOOLCHAIN_DIR}/bin) +#SET(GCC_SYSROOT_DIR ${GCC_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER ${GCC_COMPILER_DIR}/gcc) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER ${GCC_COMPILER_DIR}/g++) +SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +# Here is the target environment located +SET(CMAKE_FIND_ROOT_PATH ${GCC_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR} -L${GCC_SYSROOT_DIR}") diff --git a/toolchain/gcc-8-linux.cmake b/toolchain/gcc-8-linux.cmake new file mode 100644 index 0000000..db27a7b --- /dev/null +++ b/toolchain/gcc-8-linux.cmake @@ -0,0 +1,45 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) +SET(TOOLCHAIN_FILE "gcc-8-linux.cmake") + +# Path +SET(GCC_TOOLCHAIN_DIR /usr) +SET(GCC_COMPILER_DIR ${GCC_TOOLCHAIN_DIR}/bin) +#SET(GCC_SYSROOT_DIR ${GCC_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER ${GCC_COMPILER_DIR}/gcc-8) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER ${GCC_COMPILER_DIR}/g++-8) +#SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +#SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +# Here is the target environment located +#SET(CMAKE_FIND_ROOT_PATH ${GCC_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Compiler flags +SET(CMAKE_CXX_FLAGS "") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR} -L${GCC_SYSROOT_DIR}") + +# Libraries type +SET(LIBRARY_TYPE SHARED) diff --git a/toolchain/gcc-9-linux.cmake b/toolchain/gcc-9-linux.cmake new file mode 100644 index 0000000..a6e923d --- /dev/null +++ b/toolchain/gcc-9-linux.cmake @@ -0,0 +1,45 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) +SET(TOOLCHAIN_FILE "gcc-9-linux.cmake") + +# Path +SET(GCC_TOOLCHAIN_DIR /usr) +SET(GCC_COMPILER_DIR ${GCC_TOOLCHAIN_DIR}/bin) +#SET(GCC_SYSROOT_DIR ${GCC_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER ${GCC_COMPILER_DIR}/gcc-9) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER ${GCC_COMPILER_DIR}/g++-9) +#SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +#SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +# Here is the target environment located +#SET(CMAKE_FIND_ROOT_PATH ${GCC_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Compiler flags +SET(CMAKE_CXX_FLAGS "") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR} -L${GCC_SYSROOT_DIR}") + +# Libraries type +SET(LIBRARY_TYPE SHARED) diff --git a/toolchain/gcc-linux.cmake b/toolchain/gcc-linux.cmake new file mode 100644 index 0000000..ff67b6e --- /dev/null +++ b/toolchain/gcc-linux.cmake @@ -0,0 +1,45 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) +SET(TOOLCHAIN_FILE "gcc-linux.cmake") + +# Path +#SET(GCC_TOOLCHAIN_DIR /usr) +#SET(GCC_COMPILER_DIR ${GCC_TOOLCHAIN_DIR}/bin) +#SET(GCC_SYSROOT_DIR ${GCC_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER gcc) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER g++) +#SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +#SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +# Here is the target environment located +#SET(CMAKE_FIND_ROOT_PATH ${GCC_SYSROOT_DIR}) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Compiler flags +SET(CMAKE_CXX_FLAGS "") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10") + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${GCC_SYSROOT_DIR} -L${GCC_SYSROOT_DIR}") + +# Libraries type +SET(LIBRARY_TYPE SHARED) diff --git a/toolchain/ios-macos.cmake b/toolchain/ios-macos.cmake new file mode 100644 index 0000000..3407d82 --- /dev/null +++ b/toolchain/ios-macos.cmake @@ -0,0 +1,94 @@ +# The name of the target operating system +SET(CMAKE_SYSTEM_NAME Darwin) +SET(TOOLCHAIN_FILE "ios-macos.cmake") + +# Path +SET(CLANG_TOOLCHAIN_DIR "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr") +SET(CLANG_COMPILER_DIR ${CLANG_TOOLCHAIN_DIR}/bin) +#SET(CLANG_SYSROOT_DIR ${CLANG_TOOLCHAIN_DIR}/sysroot) + +# Which C and C++ compiler to use +SET(CMAKE_C_COMPILER ${CLANG_COMPILER_DIR}/clang) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_CXX_COMPILER ${CLANG_COMPILER_DIR}/clang++) +#SET(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) +#SET(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib) + +SET(XCODE_IOS_PLATFORM iphoneos) +SET(IOS_ARCH arm64) +SET(CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS") + + +# If user did not specify the SDK root to use, then query xcodebuild for it. +EXECUTE_PROCESS( + COMMAND xcodebuild -version -sdk ${XCODE_IOS_PLATFORM} Path + OUTPUT_VARIABLE CMAKE_OSX_SYSROOT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +# Find (Apple's) libtool. +EXECUTE_PROCESS( + COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool + OUTPUT_VARIABLE IOS_LIBTOOL + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +# Get the SDK version information. +EXECUTE_PROCESS( + COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion + OUTPUT_VARIABLE IOS_SDK_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + +# Configure libtool to be used instead of ar + ranlib to build static libraries. +# This is required on Xcode 7+, but should also work on previous versions of +# Xcode. +SET(CMAKE_C_CREATE_STATIC_LIBRARY "${IOS_LIBTOOL} -static -o ") +SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "${IOS_LIBTOOL} -static -o ") + +# Here is the target environment located +# Set the find root to the iOS developer roots and to user defined paths. +SET(CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_OSX_SYSROOT} + ${CMAKE_PREFIX_PATH} CACHE STRING "iOS find search path root" FORCE) +# Default to searching for frameworks first. +SET(CMAKE_FIND_FRAMEWORK FIRST) +# Set up the default search directories for frameworks. +SET(CMAKE_SYSTEM_FRAMEWORK_PATH + ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks + ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks + ${CMAKE_OSX_SYSROOT}/Developer/Library/Frameworks) + +# Adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in the host environment +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + +# Compiler flags +SET(CMAKE_CXX_FLAGS "") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mios-version-min=13.0") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden ") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-abi-version=2") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++") + +SET(CMAKE_OBJCXX_FLAGS "${CMAKE_OBJCXX_FLAGS} -fembed-bitcode") + +# Linker +#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR}") +#SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CLANG_SYSROOT_DIR} -L${CLANG_SYSROOT_DIR}") +SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -mios-version-min=13.0") +SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-search_paths_first") + +# Libraries type +SET(LIBRARY_TYPE STATIC)