Add stable C module ABI and component releases
This commit is contained in:
8 files changed
+535
-70
No files matched your search
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compile the public module ABI as both C and C++."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
HEADER = ROOT / "include"
|
||||
|
||||
|
||||
class ModuleAbiCTests(unittest.TestCase):
|
||||
def compile(self, compiler: str, suffix: str, standard: str) -> None:
|
||||
with tempfile.TemporaryDirectory(
|
||||
prefix="echoion-module-abi."
|
||||
) as directory:
|
||||
source = Path(directory) / f"consumer.{suffix}"
|
||||
source.write_text(
|
||||
"""
|
||||
#include <echoion/api/module/ModuleAbi.h>
|
||||
|
||||
int main(void) {
|
||||
#ifdef __cplusplus
|
||||
echoion_module_descriptor_v1 descriptor = {};
|
||||
#else
|
||||
echoion_module_descriptor_v1 descriptor = {0};
|
||||
#endif
|
||||
descriptor.struct_size = sizeof(descriptor);
|
||||
descriptor.abi_version = ECHOION_MODULE_ABI_VERSION;
|
||||
return descriptor.api == 0 ? 0 : 1;
|
||||
}
|
||||
"""
|
||||
)
|
||||
result = subprocess.run(
|
||||
[
|
||||
compiler,
|
||||
standard,
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wpedantic",
|
||||
"-Werror",
|
||||
"-I",
|
||||
str(HEADER),
|
||||
"-fsyntax-only",
|
||||
str(source),
|
||||
],
|
||||
check=False,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
|
||||
def test_header_is_c11(self) -> None:
|
||||
self.compile("cc", "c", "-std=c11")
|
||||
|
||||
def test_header_is_cpp20(self) -> None:
|
||||
self.compile("c++", "cpp", "-std=c++20")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user