qt/cbor: split cbor into separate package

This commit is contained in:
mappu 2024-11-04 22:16:01 +13:00
parent b4b6204832
commit 9e33eb65b6
3 changed files with 70 additions and 5 deletions

View File

@ -58,7 +58,7 @@ func InsertTypedefs(qt6 bool) {
} }
func AllowHeader(fullpath string) bool { func Widgets_AllowHeader(fullpath string) bool {
fname := filepath.Base(fullpath) fname := filepath.Base(fullpath)
if strings.HasSuffix(fname, `_impl.h`) { if strings.HasSuffix(fname, `_impl.h`) {

View File

@ -2,10 +2,13 @@ package main
import ( import (
"path/filepath" "path/filepath"
"strings"
) )
func ProcessLibraries(clangBin, outDir, extraLibsDir string) { func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
AllowAllHeaders := func(string) bool { return true }
flushKnownTypes() flushKnownTypes()
InsertTypedefs(false) InsertTypedefs(false)
@ -16,17 +19,47 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
"/usr/include/x86_64-linux-gnu/qt5/QtGui", "/usr/include/x86_64-linux-gnu/qt5/QtGui",
"/usr/include/x86_64-linux-gnu/qt5/QtWidgets", "/usr/include/x86_64-linux-gnu/qt5/QtWidgets",
}, },
func(fullpath string) bool {
// Block cbor and generate it separately
fname := filepath.Base(fullpath)
if strings.HasPrefix(fname, "qcbor") {
return false
}
return Widgets_AllowHeader(fullpath)
},
clangBin, clangBin,
pkgConfigCflags("Qt5Widgets"), pkgConfigCflags("Qt5Widgets"),
outDir, outDir,
ClangMatchSameHeaderDefinitionOnly, ClangMatchSameHeaderDefinitionOnly,
) )
generate(
"qt/cbor",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtCore",
},
func(fullpath string) bool {
// Only include the same json, xml, cbor files excluded above
fname := filepath.Base(fullpath)
if strings.HasPrefix(fname, "qcbor") {
return true
}
return false
},
clangBin,
pkgConfigCflags("Qt5Core"),
outDir,
ClangMatchSameHeaderDefinitionOnly,
)
generate( generate(
"qt/printsupport", "qt/printsupport",
[]string{ []string{
"/usr/include/x86_64-linux-gnu/qt5/QtPrintSupport", "/usr/include/x86_64-linux-gnu/qt5/QtPrintSupport",
}, },
AllowAllHeaders,
clangBin, clangBin,
pkgConfigCflags("Qt5PrintSupport"), pkgConfigCflags("Qt5PrintSupport"),
outDir, outDir,
@ -39,6 +72,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
[]string{ []string{
"/usr/include/x86_64-linux-gnu/qt5/Qsci", "/usr/include/x86_64-linux-gnu/qt5/Qsci",
}, },
AllowAllHeaders,
clangBin, clangBin,
pkgConfigCflags("Qt5PrintSupport"), pkgConfigCflags("Qt5PrintSupport"),
outDir, outDir,
@ -51,6 +85,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
[]string{ []string{
filepath.Join(extraLibsDir, "scintilla/qt/ScintillaEdit/ScintillaEdit.h"), filepath.Join(extraLibsDir, "scintilla/qt/ScintillaEdit/ScintillaEdit.h"),
}, },
AllowAllHeaders,
clangBin, clangBin,
"--std=c++1z "+pkgConfigCflags("ScintillaEdit"), "--std=c++1z "+pkgConfigCflags("ScintillaEdit"),
outDir, outDir,
@ -70,18 +105,48 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
"/usr/include/x86_64-linux-gnu/qt6/QtGui", "/usr/include/x86_64-linux-gnu/qt6/QtGui",
"/usr/include/x86_64-linux-gnu/qt6/QtWidgets", "/usr/include/x86_64-linux-gnu/qt6/QtWidgets",
}, },
func(fullpath string) bool {
// Block cbor and generate it separately
fname := filepath.Base(fullpath)
if strings.HasPrefix(fname, "qcbor") {
return false
}
return Widgets_AllowHeader(fullpath)
},
clangBin, clangBin,
"--std=c++17 "+pkgConfigCflags("Qt6Widgets"), "--std=c++17 "+pkgConfigCflags("Qt6Widgets"),
outDir, outDir,
ClangMatchSameHeaderDefinitionOnly, ClangMatchSameHeaderDefinitionOnly,
) )
generate(
"qt6/cbor",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtCore",
},
func(fullpath string) bool {
// Only include the same json, xml, cbor files excluded above
fname := filepath.Base(fullpath)
if strings.HasPrefix(fname, "qcbor") {
return true
}
return false
},
clangBin,
pkgConfigCflags("Qt6Core"),
outDir,
ClangMatchSameHeaderDefinitionOnly,
)
// Qt 6 QtPrintSupport // Qt 6 QtPrintSupport
generate( generate(
"qt6/printsupport", "qt6/printsupport",
[]string{ []string{
"/usr/include/x86_64-linux-gnu/qt6/QtPrintSupport", "/usr/include/x86_64-linux-gnu/qt6/QtPrintSupport",
}, },
AllowAllHeaders,
clangBin, clangBin,
"--std=c++17 "+pkgConfigCflags("Qt6PrintSupport"), "--std=c++17 "+pkgConfigCflags("Qt6PrintSupport"),
outDir, outDir,

View File

@ -28,7 +28,7 @@ func importPathForQtPackage(packageName string) string {
return BaseModule + "/" + packageName return BaseModule + "/" + packageName
} }
func findHeadersInDir(srcDir string) []string { func findHeadersInDir(srcDir string, allowHeader func(string) bool) []string {
content, err := os.ReadDir(srcDir) content, err := os.ReadDir(srcDir)
if err != nil { if err != nil {
panic(err) panic(err)
@ -44,7 +44,7 @@ func findHeadersInDir(srcDir string) []string {
continue continue
} }
fullPath := filepath.Join(srcDir, includeFile.Name()) fullPath := filepath.Join(srcDir, includeFile.Name())
if !AllowHeader(fullPath) { if !allowHeader(fullPath) {
continue continue
} }
ret = append(ret, fullPath) ret = append(ret, fullPath)
@ -93,14 +93,14 @@ func pkgConfigCflags(packageName string) string {
return string(stdout) return string(stdout)
} }
func generate(packageName string, srcDirs []string, clangBin, cflagsCombined, outDir string, matcher ClangMatcher) { func generate(packageName string, srcDirs []string, allowHeaderFn func(string) bool, clangBin, cflagsCombined, outDir string, matcher ClangMatcher) {
var includeFiles []string var includeFiles []string
for _, srcDir := range srcDirs { for _, srcDir := range srcDirs {
if strings.HasSuffix(srcDir, `.h`) { if strings.HasSuffix(srcDir, `.h`) {
includeFiles = append(includeFiles, srcDir) // single .h includeFiles = append(includeFiles, srcDir) // single .h
} else { } else {
includeFiles = append(includeFiles, findHeadersInDir(srcDir)...) includeFiles = append(includeFiles, findHeadersInDir(srcDir, allowHeaderFn)...)
} }
} }