From e060208417c9c60cc5259be61b4062284fdecee8 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Tue, 23 Jul 2024 09:41:03 +0800 Subject: [PATCH] llcppg design --- chore/llcppg/README.md | 26 +++++++++ .../llcppg/design.md | 53 ++++++++++++++++--- 2 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 chore/llcppg/README.md rename doc/cpp-auto-tool-architecture-documentation.md => chore/llcppg/design.md (86%) diff --git a/chore/llcppg/README.md b/chore/llcppg/README.md new file mode 100644 index 00000000..43a3c237 --- /dev/null +++ b/chore/llcppg/README.md @@ -0,0 +1,26 @@ +llcppg - Autogen tool for C/C++ libraries +==== + +## Usage + +```sh +llcppg [config-file] +``` + +If `config-file` is not specified, a `llcppg.cfg` file is used in current directory. The configuration file format is as follows: + +```json +{ + "name": "inireader", + "cflags": "$(pkg-config --cflags inireader)", + "include": [ + "INIReader.h", + "AnotherHeaderFile.h" + ], + "libs": "$(pkg-config --libs inireader)" +} +``` + +## Design + +See [Design of llcppg](design.md). diff --git a/doc/cpp-auto-tool-architecture-documentation.md b/chore/llcppg/design.md similarity index 86% rename from doc/cpp-auto-tool-architecture-documentation.md rename to chore/llcppg/design.md index 5b05a229..29247d50 100644 --- a/doc/cpp-auto-tool-architecture-documentation.md +++ b/chore/llcppg/design.md @@ -1,12 +1,53 @@ -# C++ Automation Tool Architecture Documentation +Design of llcppg +===== -## Overall Approach +## Usage -### Modules +```sh +llcppg [config-file] +``` -1. Parsing Module -2. Function Declaration Generation Module -3. Code Generation Module +If `config-file` is not specified, a `llcppg.cfg` file is used in current directory. The configuration file format is as follows: + +```json +{ + "name": "inireader", + "cflags": "$(pkg-config --cflags inireader)", + "include": [ + "INIReader.h", + "AnotherHeaderFile.h" + ], + "libs": "$(pkg-config --libs inireader)" +} +``` + +## Steps + +1. llcppsymg: Generate symbol table for a C/C++ library +2. Manually modify the desired Go symbols in symbol table +3. llcppsigfetch: Fetch information of C/C++ symbols +4. gogensig: Generate a go package by information of symbols + + +### llcppsymg + +```sh +llcppsymg config-file +``` + +It generates symbol tables. Its file format is as follows: + +```json +[ + { + "mangle": "_ZN9INIReaderC1EPKcm", + "c++": "INIReader::INIReader(char const*, unsigned long)", + "go": "(*Reader).Init__0" + }, +] +``` + +## Overall ### Process