Skip to content

Commit

Permalink
[CAPI] Add circt-capi target and build it in CI (#7017)
Browse files Browse the repository at this point in the history
Add a `circt-capi` target that depends on all C API libraries. Introduce
a new `add_circt_public_c_api_library` CMake function that wraps around
the MLIR equivalent, but also adds a dependency from `circt-capi`. Make
at least the short integration tests CI job build the `circt-capi`
target to ensure it has a bit of CI coverage.
  • Loading branch information
fabianschuiki authored May 9, 2024
1 parent 1a311bb commit 719bbfd
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/shortIntegrationTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
-DCIRCT_SLANG_FRONTEND_ENABLED=ON
- name: Test CIRCT
run: |
ninja -C build check-circt -j$(nproc)
ninja -C build check-circt circt-capi -j$(nproc)
- name: Unit Test CIRCT
run: |
ninja -C build check-circt-unit -j$(nproc)
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ add_custom_target(circt-headers)
set_target_properties(circt-headers PROPERTIES FOLDER "Misc")
add_custom_target(circt-doc)

# Umbrella target that builds all C API bindings.
add_custom_target(circt-capi)

# Add MLIR and LLVM headers to the include path
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})
Expand Down
5 changes: 5 additions & 0 deletions cmake/modules/AddCIRCT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ function(add_circt_interface interface)
add_dependencies(circt-headers MLIR${interface}IncGen)
endfunction()

function(add_circt_public_c_api_library name)
add_mlir_public_c_api_library(${ARGV})
add_dependencies(circt-capi ${name})
endfunction()

# Additional parameters are forwarded to tablegen.
function(add_circt_doc tablegen_file output_path command)
set(LLVM_TARGET_DEFINITIONS ${tablegen_file}.td)
Expand Down
2 changes: 1 addition & 1 deletion lib/CAPI/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_public_c_api_library(CIRCTCAPIConversion
add_circt_public_c_api_library(CIRCTCAPIConversion
Passes.cpp

LINK_LIBS PUBLIC
Expand Down
36 changes: 18 additions & 18 deletions lib/CAPI/Dialect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(LLVM_OPTIONAL_SOURCES
Verif.cpp
)

add_mlir_public_c_api_library(CIRCTCAPIComb
add_circt_public_c_api_library(CIRCTCAPIComb
Comb.cpp

LINK_LIBS PUBLIC
Expand All @@ -29,23 +29,23 @@ add_mlir_public_c_api_library(CIRCTCAPIComb
CIRCTCombTransforms
)

add_mlir_public_c_api_library(CIRCTCAPIDebug
add_circt_public_c_api_library(CIRCTCAPIDebug
Debug.cpp

LINK_LIBS PUBLIC
MLIRCAPIIR
CIRCTDebug
)

add_mlir_public_c_api_library(CIRCTCAPIESI
add_circt_public_c_api_library(CIRCTCAPIESI
ESI.cpp

LINK_LIBS PUBLIC
MLIRCAPIIR
CIRCTESI
)

add_mlir_public_c_api_library(CIRCTCAPIFIRRTL
add_circt_public_c_api_library(CIRCTCAPIFIRRTL
FIRRTL.cpp

LINK_LIBS PUBLIC
Expand All @@ -54,15 +54,15 @@ add_mlir_public_c_api_library(CIRCTCAPIFIRRTL
CIRCTImportFIRFile
)

add_mlir_public_c_api_library(CIRCTCAPICHIRRTL
add_circt_public_c_api_library(CIRCTCAPICHIRRTL
CHIRRTL.cpp

LINK_LIBS PUBLIC
MLIRCAPIIR
CIRCTFIRRTL
)

add_mlir_public_c_api_library(CIRCTCAPIMSFT
add_circt_public_c_api_library(CIRCTCAPIMSFT
MSFT.cpp

DEPENDS
Expand All @@ -75,31 +75,31 @@ add_mlir_public_c_api_library(CIRCTCAPIMSFT
CIRCTMSFTTransforms
)

add_mlir_public_c_api_library(CIRCTCAPIHW
add_circt_public_c_api_library(CIRCTCAPIHW
HW.cpp

LINK_LIBS PUBLIC
MLIRCAPIIR
CIRCTHW
)

add_mlir_public_c_api_library(CIRCTCAPILLHD
add_circt_public_c_api_library(CIRCTCAPILLHD
LLHD.cpp

LINK_LIBS PUBLIC
MLIRCAPIIR
CIRCTLLHD
)

add_mlir_public_c_api_library(CIRCTCAPIMoore
add_circt_public_c_api_library(CIRCTCAPIMoore
Moore.cpp

LINK_LIBS PUBLIC
MLIRCAPIIR
CIRCTMoore
)

add_mlir_public_c_api_library(CIRCTCAPIOM
add_circt_public_c_api_library(CIRCTCAPIOM
OM.cpp

LINK_LIBS PUBLIC
Expand All @@ -108,7 +108,7 @@ add_mlir_public_c_api_library(CIRCTCAPIOM
CIRCTOMEvaluator
)

add_mlir_public_c_api_library(CIRCTCAPISeq
add_circt_public_c_api_library(CIRCTCAPISeq
Seq.cpp

LINK_LIBS PUBLIC
Expand All @@ -117,7 +117,7 @@ add_mlir_public_c_api_library(CIRCTCAPISeq
CIRCTSeqTransforms
)

add_mlir_public_c_api_library(CIRCTCAPISV
add_circt_public_c_api_library(CIRCTCAPISV
SV.cpp

LINK_LIBS PUBLIC
Expand All @@ -126,7 +126,7 @@ add_mlir_public_c_api_library(CIRCTCAPISV
CIRCTSVTransforms
)

add_mlir_public_c_api_library(CIRCTCAPIFSM
add_circt_public_c_api_library(CIRCTCAPIFSM
FSM.cpp

DEPENDS
Expand All @@ -139,7 +139,7 @@ add_mlir_public_c_api_library(CIRCTCAPIFSM
CIRCTFSMToSV
)

add_mlir_public_c_api_library(CIRCTCAPIHandshake
add_circt_public_c_api_library(CIRCTCAPIHandshake
Handshake.cpp

LINK_LIBS PUBLIC
Expand All @@ -150,7 +150,7 @@ add_mlir_public_c_api_library(CIRCTCAPIHandshake
CIRCTCFToHandshake
)

add_mlir_public_c_api_library(CIRCTCAPIHWArith
add_circt_public_c_api_library(CIRCTCAPIHWArith
HWArith.cpp

LINK_LIBS PUBLIC
Expand All @@ -159,7 +159,7 @@ add_mlir_public_c_api_library(CIRCTCAPIHWArith
CIRCTHWArithToHW
)

add_mlir_public_c_api_library(CIRCTCAPIVerif
add_circt_public_c_api_library(CIRCTCAPIVerif
Verif.cpp

LINK_LIBS PUBLIC
Expand All @@ -168,15 +168,15 @@ add_mlir_public_c_api_library(CIRCTCAPIVerif
CIRCTVerifToSV
)

add_mlir_public_c_api_library(CIRCTCAPILTL
add_circt_public_c_api_library(CIRCTCAPILTL
LTL.cpp

LINK_LIBS PUBLIC
MLIRCAPIIR
CIRCTLTL
)

add_mlir_public_c_api_library(CIRCTCAPIEmit
add_circt_public_c_api_library(CIRCTCAPIEmit
Emit.cpp

LINK_LIBS PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion lib/CAPI/ExportFIRRTL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_public_c_api_library(CIRCTCAPIExportFIRRTL
add_circt_public_c_api_library(CIRCTCAPIExportFIRRTL
ExportFIRRTL.cpp

LINK_LIBS PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion lib/CAPI/ExportVerilog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_public_c_api_library(CIRCTCAPIExportVerilog
add_circt_public_c_api_library(CIRCTCAPIExportVerilog
ExportVerilog.cpp

LINK_LIBS PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion lib/CAPI/Firtool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_mlir_public_c_api_library(CIRCTCAPIFirtool
add_circt_public_c_api_library(CIRCTCAPIFirtool
Firtool.cpp

LINK_LIBS PUBLIC
Expand Down

0 comments on commit 719bbfd

Please sign in to comment.