From 7c61f30c4df2a5e772f4f4495377f689c469ee0c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Fri, 27 Sep 2013 10:28:03 +0200 Subject: [PATCH] - initial; from fc --- 0001-new-ParameterFence-flag.patch | 62 ++++++++++++++ ...flag-to-allow-options-with-no-short-.patch | 81 +++++++++++++++++++ 0003-new-SuppressHelp-flag.patch | 51 ++++++++++++ qcommandline-fix-pkg-config-paths.patch | 32 ++++++++ qcommandline.spec | 70 ++++++++++++++++ 5 files changed, 296 insertions(+) create mode 100644 0001-new-ParameterFence-flag.patch create mode 100644 0002-new-NoShortName-flag-to-allow-options-with-no-short-.patch create mode 100644 0003-new-SuppressHelp-flag.patch create mode 100644 qcommandline-fix-pkg-config-paths.patch create mode 100644 qcommandline.spec diff --git a/0001-new-ParameterFence-flag.patch b/0001-new-ParameterFence-flag.patch new file mode 100644 index 0000000..1b9db7b --- /dev/null +++ b/0001-new-ParameterFence-flag.patch @@ -0,0 +1,62 @@ +From 5a3e26fb4d2d3e90778d38e61854e193c9b26124 Mon Sep 17 00:00:00 2001 +From: Dan Callaghan +Date: Wed, 9 Jan 2013 19:40:22 +1000 +Subject: [PATCH 1/4] new ParameterFence flag + +This allows callers to define a parameter or option that causes every +subsequent argument to be parsed as a parameter, even if it looks like +an option. + +This patch is based on the following phantomjs commit: + +commit 23fe144a398239d25bf2a6624003274c3c3d6a50 +Author: Ryan Cumming +Date: Fri Sep 14 08:04:06 2012 -0700 + + Treat all args after the script name as script args + + This fixes CapserJS which builds a command line like this: + phantomjs bin/bootstrap.js --casper-path=~/capserjs --cli + + That works on Phantom 1.6 but not on master due to the qcommandline + port. + + Fix by extending qcommandlne to take a ParameterFence flag which causes + it to treat any options after a parameter as arguments. Switch + "scriptname" to use that so the 1.6 behaviour is restored. + + http://code.google.com/p/phantomjs/issues/detail?id=55 +--- + src/qcommandline.cpp | 3 +++ + src/qcommandline.h | 1 + + 2 files changed, 4 insertions(+) + +diff --git a/src/qcommandline.cpp b/src/qcommandline.cpp +index bc28eff..c92a807 100644 +--- a/src/qcommandline.cpp ++++ b/src/qcommandline.cpp +@@ -222,6 +222,9 @@ QCommandLine::parse() + entry.flags = (QCommandLine::Flags) (entry.flags | QCommandLine::Optional); + } + ++ if (entry.flags & QCommandLine::ParameterFence) ++ allparam = true; ++ + emit paramFound(entry.longName, arg); + + if (!(entry.flags & QCommandLine::Multiple)) +diff --git a/src/qcommandline.h b/src/qcommandline.h +index 6632d3c..2511127 100644 +--- a/src/qcommandline.h ++++ b/src/qcommandline.h +@@ -85,6 +85,7 @@ public: + Multiple = 0x04, /**< argument can be used multiple time and will produce multiple signals. */ + MandatoryMultiple = Mandatory|Multiple, + OptionalMultiple = Optional|Multiple, ++ ParameterFence = 0x08, /**< all arguments after this point are considered parameters, not options. */ + } Flags; + + /** +-- +1.7.11.7 + diff --git a/0002-new-NoShortName-flag-to-allow-options-with-no-short-.patch b/0002-new-NoShortName-flag-to-allow-options-with-no-short-.patch new file mode 100644 index 0000000..56aaec2 --- /dev/null +++ b/0002-new-NoShortName-flag-to-allow-options-with-no-short-.patch @@ -0,0 +1,81 @@ +From 8b825f662058c0e32d08f37f7bbb2243dcded8b0 Mon Sep 17 00:00:00 2001 +From: Dan Callaghan +Date: Thu, 10 Jan 2013 10:17:19 +1000 +Subject: [PATCH 2/4] new NoShortName flag, to allow options with no short + name + +This patch is based on the following phantomjs commit: + +commit a5eb729c9d187a90f7be97f29f5bc5f9bcac39c7 +Author: Ariya Hidayat +Date: Sun Sep 2 00:22:34 2012 -0700 + + Modify QCommandLine to suit our needs better. + + Allow null shortname for options. + Do not include params in the help text. + + http://code.google.com/p/phantomjs/issues/detail?id=55 +--- + src/qcommandline.cpp | 23 +++++++++++++++-------- + src/qcommandline.h | 1 + + 2 files changed, 16 insertions(+), 8 deletions(-) + +diff --git a/src/qcommandline.cpp b/src/qcommandline.cpp +index c92a807..cb6e2ff 100644 +--- a/src/qcommandline.cpp ++++ b/src/qcommandline.cpp +@@ -156,11 +156,13 @@ QCommandLine::parse() + bool allparam = false; + + foreach (QCommandLineConfigEntry entry, d->config) { +- if (entry.type != QCommandLine::Param && entry.shortName == QLatin1Char('\0')) ++ if (entry.type != QCommandLine::Param && !(entry.flags & QCommandLine::NoShortName) ++ && entry.shortName == QLatin1Char('\0')) + qWarning() << QLatin1String("QCommandLine: Empty shortname detected"); + if (entry.longName.isEmpty()) +- qWarning() << QLatin1String("QCommandLine: Empty shortname detected"); +- if (entry.type != QCommandLine::Param && conf.find(entry.shortName) != conf.end()) ++ qWarning() << QLatin1String("QCommandLine: Empty longname detected"); ++ if (entry.type != QCommandLine::Param && !(entry.flags & QCommandLine::NoShortName) ++ && conf.find(entry.shortName) != conf.end()) + qWarning() << QLatin1String("QCommandLine: Duplicated shortname detected ") << entry.shortName; + if (conf.find(entry.longName) != conf.end()) + qWarning() << QLatin1String("QCommandLine: Duplicated longname detected ") << entry.shortName; +@@ -463,11 +465,16 @@ QCommandLine::help(bool logo) + foreach (QCommandLineConfigEntry entry, d->config) { + QString val; + +- if (entry.type == QCommandLine::Option) +- val = QLatin1String("-") + QString(entry.shortName) + +- QLatin1String(",--") + entry.longName + QLatin1String("="); +- if (entry.type == QCommandLine::Switch) +- val = QLatin1String("-") + QString(entry.shortName) + QLatin1String(",--") + entry.longName; ++ if (entry.type == QCommandLine::Option) { ++ if (entry.shortName != QLatin1Char('\0')) ++ val = QLatin1String("-") + QString(entry.shortName) + QLatin1Char(','); ++ val += QLatin1String("--") + entry.longName + QLatin1String("="); ++ } ++ if (entry.type == QCommandLine::Switch) { ++ if (entry.shortName != QLatin1Char('\0')) ++ val = QLatin1String("-") + QString(entry.shortName) + QLatin1Char(','); ++ val += QLatin1String("--") + entry.longName; ++ } + if (entry.type == QCommandLine::Param) + val = entry.longName; + +diff --git a/src/qcommandline.h b/src/qcommandline.h +index 2511127..4263f43 100644 +--- a/src/qcommandline.h ++++ b/src/qcommandline.h +@@ -86,6 +86,7 @@ public: + MandatoryMultiple = Mandatory|Multiple, + OptionalMultiple = Optional|Multiple, + ParameterFence = 0x08, /**< all arguments after this point are considered parameters, not options. */ ++ NoShortName = 0x10, /**< switch or option having only a long name, no short name */ + } Flags; + + /** +-- +1.7.11.7 + diff --git a/0003-new-SuppressHelp-flag.patch b/0003-new-SuppressHelp-flag.patch new file mode 100644 index 0000000..01e5023 --- /dev/null +++ b/0003-new-SuppressHelp-flag.patch @@ -0,0 +1,51 @@ +From 014e03a28b400d383a95bd84ad59800f3edc44ae Mon Sep 17 00:00:00 2001 +From: Dan Callaghan +Date: Thu, 10 Jan 2013 10:20:06 +1000 +Subject: [PATCH 3/4] new SuppressHelp flag + +This patch is based on the following phantomjs commit: + +commit a5eb729c9d187a90f7be97f29f5bc5f9bcac39c7 +Author: Ariya Hidayat +Date: Sun Sep 2 00:22:34 2012 -0700 + + Modify QCommandLine to suit our needs better. + + Allow null shortname for options. + Do not include params in the help text. + + http://code.google.com/p/phantomjs/issues/detail?id=55 +--- + src/qcommandline.cpp | 3 +++ + src/qcommandline.h | 1 + + 2 files changed, 4 insertions(+) + +diff --git a/src/qcommandline.cpp b/src/qcommandline.cpp +index cb6e2ff..0e28bc8 100644 +--- a/src/qcommandline.cpp ++++ b/src/qcommandline.cpp +@@ -463,6 +463,9 @@ QCommandLine::help(bool logo) + int max = 0; + + foreach (QCommandLineConfigEntry entry, d->config) { ++ if (entry.flags & QCommandLine::SuppressHelp) ++ continue; ++ + QString val; + + if (entry.type == QCommandLine::Option) { +diff --git a/src/qcommandline.h b/src/qcommandline.h +index 4263f43..017314c 100644 +--- a/src/qcommandline.h ++++ b/src/qcommandline.h +@@ -87,6 +87,7 @@ public: + OptionalMultiple = Optional|Multiple, + ParameterFence = 0x08, /**< all arguments after this point are considered parameters, not options. */ + NoShortName = 0x10, /**< switch or option having only a long name, no short name */ ++ SuppressHelp = 0x20, /**< argument will be omitted from help message */ + } Flags; + + /** +-- +1.7.11.7 + diff --git a/qcommandline-fix-pkg-config-paths.patch b/qcommandline-fix-pkg-config-paths.patch new file mode 100644 index 0000000..c374d8f --- /dev/null +++ b/qcommandline-fix-pkg-config-paths.patch @@ -0,0 +1,32 @@ +From 8ea45650e589ad3db45e56d130841027542956df Mon Sep 17 00:00:00 2001 +From: Dan Callaghan +Date: Thu, 10 Jan 2013 10:45:27 +1000 +Subject: [PATCH 4/4] fix pkg-config paths + +--- + QCommandLine.pc.in | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/QCommandLine.pc.in b/QCommandLine.pc.in +index 56f7caa..c36bf55 100644 +--- a/QCommandLine.pc.in ++++ b/QCommandLine.pc.in +@@ -1,11 +1,11 @@ + prefix=@CMAKE_INSTALL_PREFIX@ + exec_prefix=${prefix} +-libdir=${prefix}/@LIB_INSTALL_DIR@ +-includedir=${prefix}/@INCLUDE_INSTALL_DIR@ ++libdir=@LIB_INSTALL_DIR@ ++includedir=@INCLUDE_INSTALL_DIR@ + + Name: QCommandLine + Description: QCommandLine is a qt-based library to parse command options + Version: @QCOMMANDLINE_LIB_MAJOR_VERSION@.@QCOMMANDLINE_LIB_MINOR_VERSION@.@QCOMMANDLINE_LIB_PATCH_VERSION@ + Requires: QtCore + Libs: -L${libdir} -lqcommandline +-Cflags: -I${includedir} +\ No newline at end of file ++Cflags: -I${includedir} +-- +1.7.11.7 + diff --git a/qcommandline.spec b/qcommandline.spec new file mode 100644 index 0000000..e5ff877 --- /dev/null +++ b/qcommandline.spec @@ -0,0 +1,70 @@ +Summary: Command line parser for Qt programs +Name: qcommandline +Version: 0.3.0 +Release: 1 +License: LGPL v2+ +Group: X11/Libraries +URL: http://xf.iksaif.net/dev/qcommandline.html +Source0: http://xf.iksaif.net/dev/qcommandline/%{name}-%{version}.tar.bz2 +# Source0-md5: 89cb472a54306c7399c55285e142a84c +# http://dev.iksaif.net/issues/253 +Patch0: %{name}-fix-pkg-config-paths.patch +# http://dev.iksaif.net/issues/252 -- enhancements for PhantomJS +Patch101: 0001-new-ParameterFence-flag.patch +Patch102: 0002-new-NoShortName-flag-to-allow-options-with-no-short-.patch +Patch103: 0003-new-SuppressHelp-flag.patch +BuildRequires: cmake +BuildRequires: qt-devel + +%description +QCommandLine is a command line parser for Qt programs (like getopt). +Features include options, switches, parameters and automatic +- --version/--help generation. + +%package devel +Summary: Development files for %{name} +Requires: %{name} = %{version}-%{release} +Requires: cmake +Requires: pkgconfig + +%description devel +Development files for building against %{name}. + +%prep +%setup -q +%patch0 -p1 +%patch101 -p1 +%patch102 -p1 +%patch103 -p1 + +%build +mkdir build +cd build +%cmake .. \ + -DCMAKE_MODULES_INSTALL_DIR=%{_datadir}/cmake/Modules +%{__make} + +%install +rm -rf $RPM_BUILD_ROOT + +%{__make} -C build install \ + DESTDIR=$RPM_BUILD_ROOT + +%files +%defattr(644,root,root,755) +%attr(755,root,root) %{_libdir}/lib%{name}.so.*.* +%attr(755,root,root) %ghost %{_libdir}/lib%{name}.so.0 + +%files devel +%defattr(644,root,root,755) +%doc examples/ +%attr(755,root,root) %{_libdir}/lib%{name}.so +%{_includedir}/%{name} +%{_pkgconfigdir}/QCommandLine.pc +%{_datadir}/cmake/Modules/FindQCommandLine.cmake + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%clean +rm -rf $RPM_BUILD_ROOT -- 2.44.0