Compare commits

...

4 commits

Author SHA1 Message Date
Roman Telezhynskyi 98b6168588 Give task more memory. Let the analyzer detect the number of threads automatically. 2024-02-08 17:44:42 +02:00
Roman Telezhynskyi 13b225d5c9 Update Qbs version. 2024-02-08 16:41:52 +02:00
Roman Telezhynskyi 87662cb70f Use size() instead of strlen. 2024-02-05 14:56:33 +02:00
Roman Telezhynskyi b9f3e7c601 Analyze code with Sonar cloud. 2024-02-05 14:46:30 +02:00
10 changed files with 112 additions and 46 deletions

View file

@ -37,10 +37,33 @@ linux_qt6_task_template: &LINUX_QT6_TASK_TEMPLATE
- qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER}
- qbs setup-qt /usr/bin/qmake6 qt6
- qbs config profiles.qt6.baseProfile ${COMPILER}
- qbs-config defaultProfile qt6
- qbs config defaultProfile qt6
- qbs build -f valentina.qbs -d build --jobs $(nproc) profile:qt6 config:release modules.buildconfig.enableCcache:${ENABLE_CCACHE} modules.cpp.linkerVariant:mold --force-probe-execution
- qbs -p autotest-runner -d build profile:qt6 config:release
- ccache -s
linux_qt6_sonar_task_template: &LINUX_QT6_TASK_SONAR_TEMPLATE
install_script:
- bash -c "$PACKAGE_MANAGER_INSTALL -y qt6-base-dev qt6-l10n-tools libqt6svg6-dev qt6-base-dev-tools qmake6 libxerces-c-dev poppler-utils libgl1-mesa-dev"
build_script:
- uname -a
- mkdir -pm 0700 $XDG_RUNTIME_DIR
- Xvfb $DISPLAY -ac -screen 0 1600x1200x24+32 -nolisten tcp -nolisten unix &
- sleep 1
- echo $PATH
- which qmake6
- which qbs
- pwd
- ls -l /usr/bin/ | grep -E "${COMPILER_REGEX}"
- ${COMPILER} --version
- qmake6 --version
- qbs --version
- qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER}
- qbs setup-qt /usr/bin/qmake6 qt6
- qbs config profiles.qt6.baseProfile ${COMPILER}
- qbs config defaultProfile qt6
- build-wrapper-linux-x86-64 --out-dir bw-output qbs build --no-install -f valentina.qbs -d build profile:qt6 config:release modules.buildconfig.enableCcache:false modules.cpp.linkerVariant:mold
- sonar-scanner -Dsonar.cfamily.threads=$(nproc) -Dsonar.scm.revision=${CIRRUS_CHANGE_IN_REPO} -Dsonar.links.ci=https://cirrus-ci.com/task/${CIRRUS_TASK_ID} -Dsonar.branch.name=${CIRRUS_BRANCH}
linux_qt5_qmake_task_template: &LINUX_QT5_QMAKE_TASK_TEMPLATE
install_script:
@ -82,7 +105,7 @@ linux_qt5_qbs_task_template: &LINUX_QT5_QBS_TASK_TEMPLATE
- qbs --version
- qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER}
- qbs setup-qt /usr/bin/qmake qt5
- qbs-config defaultProfile qt5
- qbs config defaultProfile qt5
- qbs config profiles.qt5.baseProfile ${COMPILER}
- qbs build -f valentina.qbs -d build --jobs $(nproc) profile:qt5 config:release modules.buildconfig.enableCcache:${ENABLE_CCACHE} modules.cpp.linkerVariant:mold --force-probe-execution
- qbs -p autotest-runner -d build profile:qt5 config:release
@ -126,6 +149,16 @@ linux_task:
container:
cpu: 8
memory: 8G # Set to 8GB to avoid OOM. https://cirrus-ci.org/guide/linux/#linux-container
- name: 'Sonar, latest Clang [Qt6]'
<< : *LINUX_QT6_TASK_SONAR_TEMPLATE
env:
QT_SELECT: "qt6"
SONAR_TOKEN: ENCRYPTED[!715ab983713a5035d505d2c601c9bb78a9475b9a04db62cdda9c674affd58ac956e563ce6d38228b48e05c4dbea2f52d!]
container:
cpu: 8
memory: 10G # Set to 10GB to avoid OOM. https://cirrus-ci.org/guide/linux/#linux-container
sonar_cache:
folder: "${HOME}/.sonar/cache"
- container:
image: dismine/gcc-ubuntu:13
env:
@ -276,7 +309,7 @@ macos_task_template: &MACOS_TASK_TEMPLATE
- qbs setup-toolchains --detect
- qbs config --list profiles
- qbs setup-qt /opt/homebrew/opt/qt6/bin/qmake qt6
- qbs-config defaultProfile qt6
- qbs config defaultProfile qt6
- qbs config profiles.qt6.baseProfile clang
- qbs build -f valentina.qbs -d $CIRRUS_WORKING_DIR/build --jobs $(nproc) config:release modules.buildconfig.enableUnitTests:false modules.buildconfig.enableMultiBundle:${MULTI_BUNDLE} qbs.installRoot:$CIRRUS_WORKING_DIR/build/install-root profile:qt6 project.minimumMacosVersion:${MACOS_DEPLOYMENT_TARGET} modules.buildconfig.enableCcache:${ENABLE_CCACHE} moduleProviders.qbspkgconfig.extraPaths:$(brew --prefix xerces-c)/lib/pkgconfig,$(brew --prefix qt6)/lib/pkgconfig,$(brew --prefix openssl@1.1)/lib/pkgconfig "modules.buildconfig.signingIdentity:$MACOS_CERTIFICATE_NAME" modules.macdeployqt.libpath:$(brew --prefix qt6)/lib,$(brew --prefix poppler)/lib modules.macdeployqt.macdeployqtProgramBinPath:${HOME}/macdeployqt-install-dir
- qbs build -f valentina.qbs -d $CIRRUS_WORKING_DIR/build -p 'Valentina DMG' --force-probe-execution --jobs $(nproc) config:release modules.buildconfig.enableUnitTests:false modules.buildconfig.enableMultiBundle:${MULTI_BUNDLE} qbs.installRoot:$CIRRUS_WORKING_DIR/build/install-root profile:qt6 project.minimumMacosVersion:${MACOS_DEPLOYMENT_TARGET} modules.buildconfig.enableCcache:${ENABLE_CCACHE} moduleProviders.qbspkgconfig.extraPaths:$(brew --prefix xerces-c)/lib/pkgconfig,$(brew --prefix qt6)/lib/pkgconfig,$(brew --prefix openssl@1.1)/lib/pkgconfig "modules.buildconfig.signingIdentity:$MACOS_CERTIFICATE_NAME" modules.macdeployqt.libpath:$(brew --prefix qt6)/lib,$(brew --prefix poppler)/lib modules.macdeployqt.macdeployqtProgramBinPath:${HOME}/macdeployqt-install-dir

4
.gitignore vendored
View file

@ -169,3 +169,7 @@ __pycache__
# Temporary svg cursor files
/src/app/valentina/share/resources/cursor/svg/light/
/src/app/valentina/share/resources/cursor/svg/dark/
# Sonar Cloud
.scannerwork
bw-output

View file

@ -7,6 +7,7 @@
[![Dev version](https://img.shields.io/badge/Dev-v0.7.52-yellow)](https://smart-pattern.com.ua/valentina/version/0.7.52/)
[![Build Status](https://api.cirrus-ci.com/github/dismine/valentina.svg)](https://cirrus-ci.com/github/dismine/valentina)
[![Build status](https://ci.appveyor.com/api/projects/status/m505f1pfs19j81nt/branch/develop?svg=true)](https://ci.appveyor.com/project/dismi_/valentina)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=dismine_valentina&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=dismine_valentina)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
Welcome to [Valentina](https://smart-pattern.com.ua/), a versatile cross-platform patternmaking program designed for creating and modeling clothing patterns. Whether you prefer using standard sizing tables or individual measurements, this software provides a flexible environment for pattern creation. Valentina seamlessly integrates modern technologies with traditional methods to offer a comprehensive patternmaking tool.

View file

@ -310,7 +310,7 @@ for:
- set PATH=%QTDIR%\bin;%QTDIR%\include;C:\ProgramData\chocolatey\bin;C:\Qt\Tools\QtCreator\bin;C:\Tools\PsTools;C:\Program Files\Git\cmd;C:\Program Files\Git\usr\bin;C:\Program Files\Git LFS;C:\Tools\GitVersion;C:\Windows\system32;C:\Windows;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\CMake\bin;%PYTHON%;%PYTHON%\Scripts;C:\Program Files (x86)\Inno Setup 6
# Set VC variables for the platform
- ps: |
& choco install qbs -y
& choco install qbs -y --version=2.2.2
if ($env:COMPILER -eq "msvc") {
if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2022") {
if ($env:ARCH -eq "x64") {
@ -357,13 +357,6 @@ for:
- dir %QTDIR%
- dir "%QTDIR%\bin"
- qbs --version
# Patch Qbs. Remove after Qbs 2.2.1+.
- ps: |
Invoke-WebRequest -Uri "https://gist.githubusercontent.com/dismine/43f3c51e05f3317c5d4fe16cd3c4b6d8/raw/2d297bcb53c2c022f740509923adf1eb1796afe2/qbs-pkg-config-probe.patch" -OutFile "$env:USERPROFILE\qbs-pkg-config-probe.patch"
$qbsInstallationDir = "C:\ProgramData\chocolatey\lib\qbs\tools"
cmd.exe /c "patch -p1 -N -d $qbsInstallationDir -i $env:USERPROFILE\qbs-pkg-config-probe.patch"
Remove-Item -Path "$qbsInstallationDir\share\qbs\imports\qbs\Probes\qbs-pkg-config-probe.js.rej" -ErrorAction SilentlyContinue
Remove-Item -Path "$env:USERPROFILE\qbs-pkg-config-probe.patch" -ErrorAction SilentlyContinue
before_build:
- cd %APPVEYOR_BUILD_FOLDER%

View file

@ -22,7 +22,7 @@ rm -r ./share
# Resolve any changes to config
qbs resolve -d ../../build_translations modules.i18n.update:true moduleProviders.Qt.qmakeFilePaths:$HOME/Qt6.5/6.5.0/gcc_64/bin/qmake
# Update local strings
qbs -d ../../build_translations -f ../valentina.qbs -p 'Translations' modules.i18n.update:true moduleProviders.Qt.qmakeFilePaths:$HOME/Qt6.5/6.5.0/gcc_64/bin/qmake
qbs -d ../../build_translations -f ../valentina.qbs -p 'Translations' modules.i18n.update:true moduleProviders.Qt.qmakeFilePaths:$HOME/Qt6.6/6.6.0/gcc_64/bin/qmake
end=$(date +%s)
runtime=$(python3 -c "print('Time passed %u:%02u seconds' % ((${end} - ${start})/60, (${end} - ${start})%60))")

View file

@ -1,9 +0,0 @@
#!/bin/sh
# Helps to run Clang Static Analyzer.
# Please, run this script from folder <root_folder>/scripts.
cd ..
rm -rfv build
mkdir build
cd build
qmake ../Valentina.pro -r -spec linux-clang CONFIG+=debug
scan-build --use-cc clang --use-c++ clang++ make -j$(nproc)

42
scripts/sonar-scanner.sh Executable file
View file

@ -0,0 +1,42 @@
#!/bin/sh
# Analyze project with Sonar cloud on Linux.
# Please, run this script from folder <root_folder>/scripts.
set -x
BUILD_FOLDER=build_sonar
cd ..
rm -rf ../${BUILD_FOLDER}
mkdir ../${BUILD_FOLDER}
QMAKE_PATH=${HOME}/Qt6.6/6.6.0/gcc_64/bin/qmake
PROFILE=qt6Sonar
COMPILER=clang
qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER}
qbs setup-qt ${QMAKE_PATH} ${PROFILE}
qbs config profiles.${PROFILE}.baseProfile ${COMPILER}
qbs config defaultProfile ${PROFILE}
qbs config --list profiles
build-wrapper-linux-x86-64 \
--out-dir bw-output \
qbs build \
--no-install \
-d ../${BUILD_FOLDER} \
-f valentina.qbs \
--jobs $(nproc) \
profile:${PROFILE} \
config:release \
modules.buildconfig.enableCcache:false
# modules.cpp.linkerVariant:mold
current_branch=$(git rev-parse --abbrev-ref HEAD)
current_revision=$(git rev-parse HEAD)
sonar-scanner \
-Dsonar.cfamily.threads=$(nproc) \
-Dsonar.branch.name=$current_branch \
-Dsonar.scm.revision=$current_revision

View file

@ -1,15 +1,15 @@
sonar.organization=dismine
# must be unique in a given SonarQube instance
sonar.projectKey=dismine_valentina
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=Valentina
sonar.projectVersion=0.7a
sonar.projectVersion=0.7.52
sonar.projectDescription=
Valentina is a cross-platform patternmaking program which allows designers
to create and model patterns of clothing. This software allows pattern
creation, using either standard sizing tables or an individuals set of
measurements. It blends new technologies with traditional methods to create
a unique pattern making tool.
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
@ -19,10 +19,11 @@ sonar.exclusions=**/ui_*.h, **/qrc_*.cpp, **/moc_*.cpp
sonar.test.exclusions=src/test/**/*
# The build-wrapper output dir
sonar.cfamily.build-wrapper-output=bw-outputs
sonar.cfamily.build-wrapper-output=bw-output
sonar.sources=src
sonar.cfamily.threads=2
sonar.organization=dismine
sonar.host.url=https://sonarcloud.io
sonar.links.homepage=https://smart-pattern.com.ua/
sonar.links.scm=https://gitlab.com/smart-pattern/valentina
sonar.links.issue=https://gitlab.com/smart-pattern/valentina/-/issues

View file

@ -190,11 +190,12 @@ void VAbstractConverter::ValidateXML(const QString &schema) const
XERCES_CPP_NAMESPACE::XercesDOMParser domParser;
domParser.setErrorHandler(&parserErrorHandler);
QByteArray data = fileSchema.readAll();
QByteArray const data = fileSchema.readAll();
const char *schemaData = data.constData();
const auto schemaSize = static_cast<size_t>(data.size());
QScopedPointer<XERCES_CPP_NAMESPACE::InputSource> grammarSource(new XERCES_CPP_NAMESPACE::MemBufInputSource(
reinterpret_cast<const XMLByte *>(schemaData), strlen(schemaData), "schema"));
reinterpret_cast<const XMLByte *>(schemaData), schemaSize, "schema"));
if (domParser.loadGrammar(*grammarSource, XERCES_CPP_NAMESPACE::Grammar::SchemaGrammarType, true) == nullptr)
{
@ -229,11 +230,12 @@ void VAbstractConverter::ValidateXML(const QString &schema) const
throw VException(errorMsg);
}
QByteArray patternFileData = pattern.readAll();
QByteArray const patternFileData = pattern.readAll();
const char *patternData = patternFileData.constData();
const auto patternSize = static_cast<size_t>(patternFileData.size());
QScopedPointer<XERCES_CPP_NAMESPACE::InputSource> patternSource(new XERCES_CPP_NAMESPACE::MemBufInputSource(
reinterpret_cast<const XMLByte *>(patternData), strlen(patternData), "pattern"));
reinterpret_cast<const XMLByte *>(patternData), patternSize, "pattern"));
domParser.parse(*patternSource);

View file

@ -27,19 +27,19 @@
*************************************************************************/
#include "tst_xsdschema.h"
#include "../ifc/xml/vpatternconverter.h"
#include "../ifc/xml/vlabeltemplateconverter.h"
#include "../ifc/xml/vlayoutconverter.h"
#include "../ifc/xml/vparsererrorhandler.h"
#include "../ifc/xml/vpatternconverter.h"
#include "../ifc/xml/vvitconverter.h"
#include "../ifc/xml/vvstconverter.h"
#include "../ifc/xml/vwatermarkconverter.h"
#include "../ifc/xml/vparsererrorhandler.h"
#include <QTest>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <QMap>
#else
@ -65,16 +65,14 @@ void ValidateSchema(const QString &schema)
XERCES_CPP_NAMESPACE::XercesDOMParser domParser;
domParser.setErrorHandler(&parserErrorHandler);
QByteArray data = fileSchema.readAll();
const char* schemaData = data.constData();
QByteArray const data = fileSchema.readAll();
const char *schemaData = data.constData();
const auto schemaSize = static_cast<size_t>(data.size());
QScopedPointer<XERCES_CPP_NAMESPACE::InputSource> grammarSource(
new XERCES_CPP_NAMESPACE::MemBufInputSource(reinterpret_cast<const XMLByte*>(schemaData),
strlen(schemaData), "schema"));
QScopedPointer<XERCES_CPP_NAMESPACE::InputSource> grammarSource(new XERCES_CPP_NAMESPACE::MemBufInputSource(
reinterpret_cast<const XMLByte *>(schemaData), schemaSize, "schema"));
if (domParser.loadGrammar(
*grammarSource,
XERCES_CPP_NAMESPACE::Grammar::SchemaGrammarType, true) == nullptr)
if (domParser.loadGrammar(*grammarSource, XERCES_CPP_NAMESPACE::Grammar::SchemaGrammarType, true) == nullptr)
{
QFAIL(qUtf8Printable(QStringLiteral("%1 Could not load schema file '%2'.")
.arg(parserErrorHandler.StatusMessage(), fileSchema.fileName())));
@ -115,12 +113,13 @@ auto HashToMap(const QHash<unsigned int, QString> &hash) -> QMap<unsigned int, Q
return map;
}
} // namespace
} // namespace
//---------------------------------------------------------------------------------------------------------------------
TST_XSDShema::TST_XSDShema(QObject *parent)
:QObject(parent)
{}
: QObject(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void TST_XSDShema::TestPatternSchema_data()