Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: c-protected-header-files decision #216

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions decisions/2024-01-c-protected-header-files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# C protected header files

<!-- This template is inspired by
https://github.com/GoogleCloudPlatform/emblem/tree/main/docs/decisions -->

* **Status:** Draft <!-- / Approved / Rejected / Superseded -->
* **Last Updated:** 2024-01-03
* **Objective:** Add a formal specification for supporting protected
(i.e. visible for testing in Dart) header files

## Context & Problem Statement

Right now we support entirely public, or entirely private (to the single C file)
symbols. What's missing is a way to add header files that are shared between
multiple C files and the tests, but not exposed in the public API of the C SDK.
This document's goal is to come to a decision on how best to solve this problem.

## Goals

* Expose symbols to tests and multiple C files without exposing to the public API

### Non-goals

* Change the existing project layout in any way, this should be an entirely
additive approach. Symbols may be moved to the new semantic, but entirely
public/private symbols should remain where they are.

## Other considerations <!-- optional -->

* We should take into account how this might affect packaging in the future.

## Considered Options <!-- optional -->

* ### Option 1 - `.h` files in `src/`

A simple approach which avoids adding new directories to the project. The protected
files go into .h files which are stored with the `.c` files in `src/`. Then the
`src/` folder can be included for internal linking, but the symbols remain excluded
from the include directories exported from our package.

* ### Option 2 - New internal include directory

Add a new directory to store these protected include files. Then they can be
included for testing and internal linking, but not exposed to end consumers of
the SDK.

## Proposal Summary

There are two main options, add these symbols to the existing `src/` directory,
or create a new directory for them.

## Proposal in Detail

### Expected Consequences <!-- optional -->

* We will be able to make breaking changes in the internal API without affecting
end consumers of the SDK.
* We don't have to worry about polluting the included symbols in order to break
functions up for unit testing.
Loading