genbindings/main: move library list into a config file

This commit is contained in:
mappu 2024-10-20 19:09:16 +13:00
parent 5bc79ad0bb
commit ceb58fc26e
4 changed files with 105 additions and 93 deletions

View File

@ -31,5 +31,5 @@ It's tested to work on with Debian 12 / Qt 5.15 / Clang 14 / GCC 12.
You should check the following configuration:
- `main.go`: Input directories containing Qt headers
- `exceptions.go`: Check everything
- `config-libraries.go`: Input directories containing Qt headers
- `config-allowlist.go`: Check everything

View File

@ -0,0 +1,90 @@
package main
import (
"path/filepath"
)
func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
flushKnownTypes()
InsertTypedefs(false)
generate(
"qt",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtCore",
"/usr/include/x86_64-linux-gnu/qt5/QtGui",
"/usr/include/x86_64-linux-gnu/qt5/QtWidgets",
},
clangBin,
pkgConfigCflags("Qt5Widgets"),
outDir,
ClangMatchSameHeaderDefinitionOnly,
)
generate(
"qt/qprintsupport",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtPrintSupport",
},
clangBin,
pkgConfigCflags("Qt5PrintSupport"),
outDir,
ClangMatchSameHeaderDefinitionOnly,
)
// Depends on QtCore/Gui/Widgets, QPrintSupport
generate(
"qt-restricted-extras/qscintilla",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/Qsci",
},
clangBin,
pkgConfigCflags("Qt5PrintSupport"),
outDir,
ClangMatchSameHeaderDefinitionOnly,
)
// Depends on QtCore/Gui/Widgets
generate(
"qt-extras/scintillaedit",
[]string{
filepath.Join(extraLibsDir, "scintilla/qt/ScintillaEdit/ScintillaEdit.h"),
},
clangBin,
"--std=c++1z "+pkgConfigCflags("ScintillaEdit"),
outDir,
(&clangMatchUnderPath{filepath.Join(extraLibsDir, "scintilla")}).Match,
)
// FLUSH all known typedefs / ...
flushKnownTypes()
InsertTypedefs(true)
// Qt 6
generate(
"qt6",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtCore",
"/usr/include/x86_64-linux-gnu/qt6/QtGui",
"/usr/include/x86_64-linux-gnu/qt6/QtWidgets",
},
clangBin,
"--std=c++17 "+pkgConfigCflags("Qt6Widgets"),
outDir,
ClangMatchSameHeaderDefinitionOnly,
)
// Qt 6 QtPrintSupport
generate(
"qt6/qprintsupport",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtPrintSupport",
},
clangBin,
"--std=c++17 "+pkgConfigCflags("Qt6PrintSupport"),
outDir,
ClangMatchSameHeaderDefinitionOnly,
)
}

View File

@ -92,97 +92,7 @@ func pkgConfigCflags(packageName string) string {
return string(stdout)
}
func main() {
clang := flag.String("clang", "clang", "Custom path to clang")
outDir := flag.String("outdir", "../../", "Output directory for generated gen_** files")
extraLibsDir := flag.String("extralibs", "/usr/local/src/", "Base directory to find extra library checkouts")
flag.Parse()
flushKnownTypes()
InsertTypedefs(false)
generate(
"qt",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtCore",
"/usr/include/x86_64-linux-gnu/qt5/QtGui",
"/usr/include/x86_64-linux-gnu/qt5/QtWidgets",
},
*clang,
strings.Fields(pkgConfigCflags("Qt5Widgets")),
*outDir,
ClangMatchSameHeaderDefinitionOnly,
)
generate(
"qt/qprintsupport",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtPrintSupport",
},
*clang,
strings.Fields(pkgConfigCflags("Qt5PrintSupport")),
*outDir,
ClangMatchSameHeaderDefinitionOnly,
)
// Depends on QtCore/Gui/Widgets, QPrintSupport
generate(
"qt-restricted-extras/qscintilla",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/Qsci",
},
*clang,
strings.Fields(pkgConfigCflags("Qt5PrintSupport")),
*outDir,
ClangMatchSameHeaderDefinitionOnly,
)
// Depends on QtCore/Gui/Widgets
generate(
"qt-extras/scintillaedit",
[]string{
filepath.Join(*extraLibsDir, "scintilla/qt/ScintillaEdit/ScintillaEdit.h"),
},
*clang,
strings.Fields("--std=c++1z "+pkgConfigCflags("ScintillaEdit")),
*outDir,
(&clangMatchUnderPath{filepath.Join(*extraLibsDir, "scintilla")}).Match,
)
// FLUSH all known typedefs / ...
flushKnownTypes()
InsertTypedefs(true)
// Qt 6
generate(
"qt6",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtCore",
"/usr/include/x86_64-linux-gnu/qt6/QtGui",
"/usr/include/x86_64-linux-gnu/qt6/QtWidgets",
},
*clang,
strings.Fields("--std=c++17 "+pkgConfigCflags("Qt6Widgets")),
*outDir,
ClangMatchSameHeaderDefinitionOnly,
)
// Qt 6 QtPrintSupport
generate(
"qt6/qprintsupport",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtPrintSupport",
},
*clang,
strings.Fields("--std=c++17 "+pkgConfigCflags("Qt6PrintSupport")),
*outDir,
ClangMatchSameHeaderDefinitionOnly,
)
}
func generate(packageName string, srcDirs []string, clangBin string, cflags []string, outDir string, matcher ClangMatcher) {
func generate(packageName string, srcDirs []string, clangBin, cflagsCombined, outDir string, matcher ClangMatcher) {
var includeFiles []string
for _, srcDir := range srcDirs {
@ -195,6 +105,8 @@ func generate(packageName string, srcDirs []string, clangBin string, cflags []st
log.Printf("Found %d header files to process.", len(includeFiles))
cflags := strings.Fields(cflagsCombined)
outDir = filepath.Join(outDir, packageName)
cleanGeneratedFilesInDir(outDir)
@ -396,3 +308,13 @@ func generateClangCaches(includeFiles []string, clangBin string, cflags []string
close(clangChan)
clangWg.Wait()
}
func main() {
clang := flag.String("clang", "clang", "Custom path to clang")
outDir := flag.String("outdir", "../../", "Output directory for generated gen_** files")
extraLibsDir := flag.String("extralibs", "/usr/local/src/", "Base directory to find extra library checkouts")
flag.Parse()
ProcessLibraries(*clang, *outDir, *extraLibsDir)
}