Skip to content

Commit

Permalink
Cross-parsing (#77)
Browse files Browse the repository at this point in the history
* Multi-pass wip

* Wip

* Start adding tests

* Beginning of integration tests

* Create features folder

* Fix `.csproj`

* Cleanup tests

* Add platform check for integration tests

* Improve exception output for Clang errors + move around some files

* Fix linux C header helper

* Update error message

* Re-structure for integration tests

* Restructure for logging

* Restructure more for logging and DI

* Start logging clang explorer

* Update logs + libclang generated code

* Seal classes

* Finish logging for extract

* Finish first round of integration tests

* Use main handler for backwards compatibility

* Fix config file path option

* Change `config.json` schema

* Restructure + add schema

* Fix build errors

* Finish schema attributes

* Rollback to uppercase `C2CS` for C# project name

* Add Linux system include path

* Update GitHub action

* Update GitHub action

* Update main.yml

* Log when system directory does not exist

* Short circuit when a use case step fails

* Refactor integration test fixture data

* Assert ast is not empty in fixture

* Add log for failing Clang parse diagnostics

* Change log to error

* Change failure log to use error log level

* Update GitHub actions

* Restructure

* Update GitHub actions

* Update GitHub actions

* Fix mistake

* Fix clang arguments builder

* Improve logging for failed use case step

* Restructure

* Don't throw

* Add linux system include directory

* Update GitHub actions

* Update `c2cs_helper.h`

* Write code to console

* Upload test bin files

* Update GitHub actions

* Upload test data files for debugging

* Upload test data for debugging with platform name

* Upload test data only on failure

* Use `gnu` for Windows when parsing C code for Windows target

* Update `c2cs_helper.h`

* Restructure + use target platform arch + os when checking plat mismatch

* Update `c2cs_helper.h` for windows-gnu

* Update libclang`Index.h`

* Fix enums and some small things

* Use official Clang on Linux

* Fix failing integration test

* Use hard coded check for libclang on Linux as find is taking too long

* Install and use Clang from direct LLVM downloads in GitHub actions

* Try to fix GitHub actions

* Fix GitHub action workflow

* Fix GitHub action workflow

* Move scripts out of `/.github/ folder

* Try to debug GitHub action workflow

* Try to debug GitHub action workflow more

* Try to debug GitHub action workflow again

* Update main.yml

* Clone repository before executing scripts

* install gcc-multilib to fix C compilation/parsing errors


x

* Use specific configuration files per platform to avoid Clang bug

* Don't pack clang dynamic link libraries

* Use PowerShell for shell on Windows

* Try to fix Windows GitHub action workflow

* Try to fix Windows GitHub action workflow

* Try to fix Windows GitHub action workflow

* Try to fix

* Try to fix

* Try to fix

* Fix system header includes

* Don't include native libraries during pack

* Log clang installed path

* Update main.yml

* Upload main.yml

* Update main.yml

* Use dynamic link libraries for integration tests

* Download libclang faster using NuGet

* Use `unzip`

* Escape when running scripts

* Fix integration tests for Windows

* Try to fix Windows installation of Clang mingw64

* Try to fix Windows installation of Clang mingw64

* Rename request to configuration

* Update main.yml

* Update main.yml

* Update main.yml

* Update docs

* Update schema

* Update hello world example config

* Update docs

* Update docs
  • Loading branch information
lithiumtoast authored Apr 14, 2022
1 parent 2a0edd8 commit 979480b
Show file tree
Hide file tree
Showing 223 changed files with 8,136 additions and 3,722 deletions.
76 changes: 66 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,71 @@ on:
jobs:
dotnet-job:
name: ".NET"
runs-on: ubuntu-latest
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- { name: Windows x64 (mingw64), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64 }
- { name: Windows x64, os: windows-latest, shell: bash }
# Using Ubuntu 18.04 because of GitHub Actions Runner bug: https://github.com/actions/runner/issues/1819#issuecomment-1098641309
- { name: Linux x64, os: ubuntu-18.04, shell: bash }
- { name: macOS x64, os: macos-latest, shell: bash }
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- uses: bottlenoselabs/github-actions-dotnet@v2
with:
repository: '${{ github.repository }}'
dotnet-sdk-version: '6.0.x'
is-enabled-pack: 'true'
upload-myget-org: "${{ github.event_name == 'push' || startsWith(github.ref, 'refs/tags/v') }}"
upload-nuget-org: "${{ startsWith(github.ref, 'refs/tags/v') }}"
myget-access-token: '${{ secrets.MYGET_ACCESS_TOKEN }}'
nuget-access-token: '${{ secrets.NUGET_ACCESS_TOKEN }}'

- name: "Set up MSYS2"
if: matrix.platform.shell == 'msys2 {0}'
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.platform.msystem }}
install: >-
${{ matrix.platform.msys-env }}-gcc
${{ matrix.platform.msys-env }}-cmake
${{ matrix.platform.msys-env }}-ninja
${{ matrix.platform.msys-env }}-pkg-config
unzip
- name: "Clone Git repository"
uses: actions/checkout@v1
with:
fetch-depth: 0
submodules: 'recursive'

- name: "Install Clang: Windows"
if: matrix.platform.os == 'windows-latest'
run: |
source "${{ github.workspace }}\scripts\install-clang-x64-windows.sh"
- name: "Install Clang: Linux"
if: matrix.platform.os == 'ubuntu-18.04'
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
source "${{ github.workspace }}/scripts/install-clang-x64-ubuntu_18_04.sh"
- name: "Install Clang: macOS"
if: matrix.platform.os == 'macos-latest'
run: |
source "${{ github.workspace }}/scripts/install-clang-macos.sh"
- name: ".NET"
uses: bottlenoselabs/github-actions-dotnet@v3
with:
dotnet-sdk-version: "6.0.x"
solution-or-project: "${{ github.workspace }}/C2CS.sln"
is-enabled-upload-myget: "${{ matrix.platform.os == 'ubuntu-18.04' && ( github.event_name == 'push' || startsWith(github.ref, 'refs/tags/v') ) }}"
is-enabled-upload-nuget: "${{ matrix.platform.os == 'ubuntu-18.04' && startsWith(github.ref, 'refs/tags/v') }}"
myget-access-token: "${{ secrets.MYGET_ACCESS_TOKEN }}"
nuget-access-token: "${{ secrets.NUGET_ACCESS_TOKEN }}"

- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: "Failing Test Data ${{ matrix.platform.name }}"
path: |
${{ github.workspace }}/bin/*Tests*/**/*.cs
${{ github.workspace }}/bin/*Tests*/**/ast/*.json
101 changes: 58 additions & 43 deletions C2CS.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,29 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "helloworld-c", "src\cs\exam
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "helloworld-cs", "src\cs\examples\helloworld\helloworld-cs\helloworld-cs.csproj", "{3549CD6F-971A-4456-8F80-EFC826AECC04}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "clang-cs", "src\cs\production\clang-cs\clang-cs.csproj", "{D22C766F-7E8B-4E81-899E-6CA1E624779B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS", "src\cs\production\C2CS\C2CS.csproj", "{2E53A130-519C-4C5F-8D76-86CEA17A160F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "clang-c", "src\cs\production\clang-c\clang-c.csproj", "{2CF10B9A-7845-4DB7-9B02-75D62A4DABA4}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{995D2D9A-AAF6-4034-8625-5BB812C2870F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS", "src\cs\production\C2CS\C2CS.csproj", "{2E53A130-519C-4C5F-8D76-86CEA17A160F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Tests.Integration", "src\cs\tests\C2CS.Tests.Integration\C2CS.Tests.Integration.csproj", "{3C179AE6-E9B5-4B89-B441-863FF393CC85}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "features", "features", "{FF3312B1-10D2-4B8A-AD43-3F6D9CE5E61F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Feature.ReadCodeC", "src\cs\production\features\C2CS.Feature.ReadCodeC\C2CS.Feature.ReadCodeC.csproj", "{EB040AE8-5CF1-4A79-9881-2B5CAED4D224}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Feature.BuildLibraryC", "src\cs\production\features\C2CS.Feature.BuildLibraryC\C2CS.Feature.BuildLibraryC.csproj", "{00E6F00B-FF25-40AA-BE41-5A736FA1541C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Feature.WriteCodeCSharp", "src\cs\production\features\C2CS.Feature.WriteCodeCSharp\C2CS.Feature.WriteCodeCSharp.csproj", "{56251683-F977-4AFC-A51D-733F9D022A61}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Runtime", "src\cs\production\C2CS.Runtime\C2CS.Runtime.csproj", "{16C004F6-755D-4976-9EEB-A61BE1223AF2}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "infrastructure", "infrastructure", "{3F11D389-67E8-40D9-B235-224F27F7BFC8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Common", "src\cs\production\C2CS.Common\C2CS.Common.csproj", "{2B7BFB9A-E304-4855-ABEF-A4F426BC78F3}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "clang-cs", "src\cs\production\infrastructure\clang-cs\clang-cs.csproj", "{BEE5DEBA-4A80-47FC-9C0C-80F136EBBA71}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Feature.BuildLibraryC", "src\cs\production\C2CS.Feature.BuildLibraryC\C2CS.Feature.BuildLibraryC.csproj", "{9BA29F5A-ECF9-41E3-944C-28B7D837D50B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "clang-c", "src\cs\production\infrastructure\clang-c\clang-c.csproj", "{E206B026-28AB-41D9-8B44-A3EC8A216FA3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Feature.ExtractAbstractSyntaxTreeC", "src\cs\production\C2CS.Feature.ExtractAbstractSyntaxTreeC\C2CS.Feature.ExtractAbstractSyntaxTreeC.csproj", "{1D574489-0CE2-4BAC-AA53-92AA69FB69FD}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Runtime", "src\cs\production\infrastructure\C2CS.Runtime\C2CS.Runtime.csproj", "{C3ACC4B9-2573-4171-BA52-959725A74D25}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Feature.BindgenCSharp", "src\cs\production\C2CS.Feature.BindgenCSharp\C2CS.Feature.BindgenCSharp.csproj", "{A126534B-01B0-477B-9DDB-43BA54D09CA1}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C2CS.Common", "src\cs\production\infrastructure\C2CS.Common\C2CS.Common.csproj", "{9500EF1F-4F03-4D02-99E6-5140C806EB0C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -40,50 +48,57 @@ Global
{3549CD6F-971A-4456-8F80-EFC826AECC04}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3549CD6F-971A-4456-8F80-EFC826AECC04}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3549CD6F-971A-4456-8F80-EFC826AECC04}.Release|Any CPU.Build.0 = Release|Any CPU
{D22C766F-7E8B-4E81-899E-6CA1E624779B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D22C766F-7E8B-4E81-899E-6CA1E624779B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D22C766F-7E8B-4E81-899E-6CA1E624779B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D22C766F-7E8B-4E81-899E-6CA1E624779B}.Release|Any CPU.Build.0 = Release|Any CPU
{2CF10B9A-7845-4DB7-9B02-75D62A4DABA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CF10B9A-7845-4DB7-9B02-75D62A4DABA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CF10B9A-7845-4DB7-9B02-75D62A4DABA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CF10B9A-7845-4DB7-9B02-75D62A4DABA4}.Release|Any CPU.Build.0 = Release|Any CPU
{2E53A130-519C-4C5F-8D76-86CEA17A160F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E53A130-519C-4C5F-8D76-86CEA17A160F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E53A130-519C-4C5F-8D76-86CEA17A160F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E53A130-519C-4C5F-8D76-86CEA17A160F}.Release|Any CPU.Build.0 = Release|Any CPU
{16C004F6-755D-4976-9EEB-A61BE1223AF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16C004F6-755D-4976-9EEB-A61BE1223AF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16C004F6-755D-4976-9EEB-A61BE1223AF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16C004F6-755D-4976-9EEB-A61BE1223AF2}.Release|Any CPU.Build.0 = Release|Any CPU
{2B7BFB9A-E304-4855-ABEF-A4F426BC78F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B7BFB9A-E304-4855-ABEF-A4F426BC78F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B7BFB9A-E304-4855-ABEF-A4F426BC78F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B7BFB9A-E304-4855-ABEF-A4F426BC78F3}.Release|Any CPU.Build.0 = Release|Any CPU
{9BA29F5A-ECF9-41E3-944C-28B7D837D50B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BA29F5A-ECF9-41E3-944C-28B7D837D50B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BA29F5A-ECF9-41E3-944C-28B7D837D50B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BA29F5A-ECF9-41E3-944C-28B7D837D50B}.Release|Any CPU.Build.0 = Release|Any CPU
{1D574489-0CE2-4BAC-AA53-92AA69FB69FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D574489-0CE2-4BAC-AA53-92AA69FB69FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D574489-0CE2-4BAC-AA53-92AA69FB69FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D574489-0CE2-4BAC-AA53-92AA69FB69FD}.Release|Any CPU.Build.0 = Release|Any CPU
{A126534B-01B0-477B-9DDB-43BA54D09CA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A126534B-01B0-477B-9DDB-43BA54D09CA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A126534B-01B0-477B-9DDB-43BA54D09CA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A126534B-01B0-477B-9DDB-43BA54D09CA1}.Release|Any CPU.Build.0 = Release|Any CPU
{3C179AE6-E9B5-4B89-B441-863FF393CC85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C179AE6-E9B5-4B89-B441-863FF393CC85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C179AE6-E9B5-4B89-B441-863FF393CC85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C179AE6-E9B5-4B89-B441-863FF393CC85}.Release|Any CPU.Build.0 = Release|Any CPU
{EB040AE8-5CF1-4A79-9881-2B5CAED4D224}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB040AE8-5CF1-4A79-9881-2B5CAED4D224}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB040AE8-5CF1-4A79-9881-2B5CAED4D224}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB040AE8-5CF1-4A79-9881-2B5CAED4D224}.Release|Any CPU.Build.0 = Release|Any CPU
{00E6F00B-FF25-40AA-BE41-5A736FA1541C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00E6F00B-FF25-40AA-BE41-5A736FA1541C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E6F00B-FF25-40AA-BE41-5A736FA1541C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00E6F00B-FF25-40AA-BE41-5A736FA1541C}.Release|Any CPU.Build.0 = Release|Any CPU
{56251683-F977-4AFC-A51D-733F9D022A61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56251683-F977-4AFC-A51D-733F9D022A61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56251683-F977-4AFC-A51D-733F9D022A61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56251683-F977-4AFC-A51D-733F9D022A61}.Release|Any CPU.Build.0 = Release|Any CPU
{BEE5DEBA-4A80-47FC-9C0C-80F136EBBA71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BEE5DEBA-4A80-47FC-9C0C-80F136EBBA71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEE5DEBA-4A80-47FC-9C0C-80F136EBBA71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEE5DEBA-4A80-47FC-9C0C-80F136EBBA71}.Release|Any CPU.Build.0 = Release|Any CPU
{E206B026-28AB-41D9-8B44-A3EC8A216FA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E206B026-28AB-41D9-8B44-A3EC8A216FA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E206B026-28AB-41D9-8B44-A3EC8A216FA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E206B026-28AB-41D9-8B44-A3EC8A216FA3}.Release|Any CPU.Build.0 = Release|Any CPU
{C3ACC4B9-2573-4171-BA52-959725A74D25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3ACC4B9-2573-4171-BA52-959725A74D25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3ACC4B9-2573-4171-BA52-959725A74D25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3ACC4B9-2573-4171-BA52-959725A74D25}.Release|Any CPU.Build.0 = Release|Any CPU
{9500EF1F-4F03-4D02-99E6-5140C806EB0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9500EF1F-4F03-4D02-99E6-5140C806EB0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9500EF1F-4F03-4D02-99E6-5140C806EB0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9500EF1F-4F03-4D02-99E6-5140C806EB0C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{69316361-0268-46E8-ADE6-89102DEB3166} = {E5C474A9-491B-4719-B253-09F93D5CEA5B}
{1DD50076-2E66-4EC4-99AA-D8F2539EF48D} = {69316361-0268-46E8-ADE6-89102DEB3166}
{3549CD6F-971A-4456-8F80-EFC826AECC04} = {69316361-0268-46E8-ADE6-89102DEB3166}
{D22C766F-7E8B-4E81-899E-6CA1E624779B} = {0B6FBBF3-28F7-4374-9CDD-3C8B1DFD2AB8}
{2CF10B9A-7845-4DB7-9B02-75D62A4DABA4} = {0B6FBBF3-28F7-4374-9CDD-3C8B1DFD2AB8}
{2E53A130-519C-4C5F-8D76-86CEA17A160F} = {0B6FBBF3-28F7-4374-9CDD-3C8B1DFD2AB8}
{16C004F6-755D-4976-9EEB-A61BE1223AF2} = {0B6FBBF3-28F7-4374-9CDD-3C8B1DFD2AB8}
{2B7BFB9A-E304-4855-ABEF-A4F426BC78F3} = {0B6FBBF3-28F7-4374-9CDD-3C8B1DFD2AB8}
{9BA29F5A-ECF9-41E3-944C-28B7D837D50B} = {0B6FBBF3-28F7-4374-9CDD-3C8B1DFD2AB8}
{1D574489-0CE2-4BAC-AA53-92AA69FB69FD} = {0B6FBBF3-28F7-4374-9CDD-3C8B1DFD2AB8}
{A126534B-01B0-477B-9DDB-43BA54D09CA1} = {0B6FBBF3-28F7-4374-9CDD-3C8B1DFD2AB8}
{3C179AE6-E9B5-4B89-B441-863FF393CC85} = {995D2D9A-AAF6-4034-8625-5BB812C2870F}
{FF3312B1-10D2-4B8A-AD43-3F6D9CE5E61F} = {0B6FBBF3-28F7-4374-9CDD-3C8B1DFD2AB8}
{EB040AE8-5CF1-4A79-9881-2B5CAED4D224} = {FF3312B1-10D2-4B8A-AD43-3F6D9CE5E61F}
{00E6F00B-FF25-40AA-BE41-5A736FA1541C} = {FF3312B1-10D2-4B8A-AD43-3F6D9CE5E61F}
{56251683-F977-4AFC-A51D-733F9D022A61} = {FF3312B1-10D2-4B8A-AD43-3F6D9CE5E61F}
{3F11D389-67E8-40D9-B235-224F27F7BFC8} = {0B6FBBF3-28F7-4374-9CDD-3C8B1DFD2AB8}
{BEE5DEBA-4A80-47FC-9C0C-80F136EBBA71} = {3F11D389-67E8-40D9-B235-224F27F7BFC8}
{E206B026-28AB-41D9-8B44-A3EC8A216FA3} = {3F11D389-67E8-40D9-B235-224F27F7BFC8}
{C3ACC4B9-2573-4171-BA52-959725A74D25} = {3F11D389-67E8-40D9-B235-224F27F7BFC8}
{9500EF1F-4F03-4D02-99E6-5140C806EB0C} = {3F11D389-67E8-40D9-B235-224F27F7BFC8}
EndGlobalSection
EndGlobal
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ C to C# library bindings code generator. In go `.h` file, out come `.cs` file.

## Documentation

For documentation see the [docs/README.md](docs/README.md). This includes:

- [How to install `C2CS`](docs/README.md#install)
- [How to use `C2CS`](docs/README.md#how-to-use).
- [How to build `C2CS` and the examples from source](docs/README.md#building-from-source).
- [Examples](docs/README.md#examples).
For documentation on how to install, use, or build `C2CS` see the [docs/README.md](docs/README.md).

## Background: Why?

Expand All @@ -24,13 +19,15 @@ If you are not familiar already with interoperability of C/C++ with C#, it's ass

### Solution

Automatically generate the bindings by compiling/parsing a C `.h` file. Essentially, the C public programmer application interface (API, those functions you want to call) is tranpiled to C# for the target application binary interface (ABI, operating- system/architecture combo) for use via platform invoke (P/Invoke).
Automatically generate the bindings by compiling/parsing a C `.h` file. The C API (application programmer interface; those functions you want to call) is tranpiled to C# for the target ABI (application binary interface; a Clang target triple `arch-vendor-os-environment`, e.g. `x86_64-pc-windows-msvc`) for use via P/Invoke (platform invoke).

This includes all C extern functions which are transpiled to `static` methods respecitively in C# using `DllImport` attribute. Also includes transpiling all the C types to C# which are found through transitive property to the extern functions such as: `struct`s, `enum`s, and `const`s. C# `struct`s are generated instead of `class`es on purpose to achieve 1-1 bit-representation of C to C# types called *blittable* types. The reason for blittable types is to achieve pass-through marshalling and active avoidance of the Garbage Collector in C# for best possible runtime performance and portability when doing interoperability with C.
Includes all C extern functions which are transpiled to `static` methods respecitively in C# using `DllImport` attribute. The C types which are found through transitive property to the extern functions such as: `struct`s, `enum`s, and `const`s are also transpiled to C#. C# `struct`s are generated instead of `class`es on purpose to achieve 1-1 bit-representation of C to C# types called *blittable* types. The reason for blittable types is to achieve pass-through marshalling and active avoidance of the Garbage Collector in C# for best possible runtime performance and portability when doing interoperability with C.

This is all accomplished by using [libclang](https://clang.llvm.org/docs/Tooling.html) for parsing C and [Roslyn](https://github.com/dotnet/roslyn) for generating C#. All naming is left as found in the C header `.h` file(s).

![c2cs|width=400px](./docs/c2cs.png)
<p align="center">
<img width="460" src="./docs/c2cs.png">
</p>

### Limitations

Expand Down
Loading

0 comments on commit 979480b

Please sign in to comment.