Is there QMake analogue for ".." from bash? - relative-path

I'm writing a unit test using QtTest framework. I have a .pro file representing test project where i want to specify a relative path to the source files i want to test with INCLUDEPATH keyword. The source files are in the source folder, which is 2 levels above the .pro file in folder hierarchy. So, if i were to get there with bash i would go with cd .. then cd .. then cd source. I tried INCLUDEPATH += $$PWD/../../source, but this doesn't seem to work. I also couldn't find any related info in Qt docs.
How can i achieve the behaviour i want from qmake? Any help would be great.

There is a builtin (replace) function called clean_path. Documented here.

The following code did the trick for me:
defineReplace(cleanPath) {
win32:1 ~= s|\\\\|/|g
contains(1, ^/.*):pfx = /
else:pfx =
segs = $$split(1, /)
out =
for(seg, segs) {
equals(seg, ..):out = $$member(out, 0, -2)
else:!equals(seg, .):out += $$seg
}
win32:return($$join(out, \\, $$pfx))
return($$join(out, /, $$pfx))
}
srs_path = $$_PRO_FILE_PWD_/../../source
srs_path_clean = $$cleanPath($$srs_path)
INCLUDEPATH += $$srs_path_clean

Related

use 'source_group' generate the Xcode project can't jump the right directory path

I used the CMake to build an iOS XCode project, I have multiple level source code, so I use 'source_group' to organize them, here is my CMake code
file(GLOB_RECURSE MODULE_DEMO_DIR_FILES
"${MODULE_DEMO_DIR}/*.h"
"${MODULE_DEMO_DIR}/*.m"
"${MODULE_DEMO_DIR}/*.c"
"${MODULE_DEMO_DIR}/*.cc"
"${MODULE_DEMO_DIR}/*.cpp"
"${MODULE_DEMO_DIR}/info.plist"
"${MODULE_DEMO_DIR}/LaunchScreen.storyboard"
"${MODULE_DEMO_DIR}/*.entitlements"
)
foreach(file IN LISTS MODULE_DEMO_DIR_FILES)
message(DEBUG "file:${file}")
get_filename_component(fileDirectory ${file} DIRECTORY)
include_directories(${fileDirectory})
endforeach()
set(${MODULE_DEMO_SOURCES} ${MODULE_DEMO_DIR_FILES} PARENT_SCOPE)
source_group(TREE ${MODULE_DEMO_DIR} FILES ${MODULE_DEMO_DIR_FILES})
when I select any directory and right-click and select 'show in Finder', it does not jump right directory, in the xcodeproj file, I find the directory PBXGroup is this:
8CD0C75957674E25982ACF10 /* IQTextView */ = {
isa = PBXGroup;
children = (
8D7EEDCDA3CC4AA6A444A78F /* /Users/lee/Desktop/xx1/demo/company/xx2/xx3/demo/Vendor/IQKeyboardManager/IQTextView/IQTextView.h */,
F54B85341C9A4BC7BD92320D /* /Users/lee/Desktop/xx1/demo/company/xx2/xx3/demo/Vendor/IQKeyboardManager/IQTextView/IQTextView.m */,
);
name = IQTextView;
sourceTree = "<group>";
};
when I change the "name = IQTextView;" to "path = IQTextView;",it works!
my question is:
how let the PBXGroup use 'path' instead of 'name' when using CMake, so that I can jump to the true path when clicking "show in Finder" at a directory in XCode project?

Qt6Quick in yocto

Is it possible to use QtQuick in yocto? (Or I missed something out)
I created simple coffee_6.2.0.bb recipe which uses demo from
~/Qt/Examples/Qt-6.2.0/demos/coffee/
But the error is:
Could NOT find Qt6Quick (missing: Qt6Quick_DIR
Recipe is quite simple:
.. Description and license stuff..
inherit qt6-cmake
include recipes-qt/qt6/qt6.inc
PROVIDES += "coffee"
FILES_${PN} += "${datadir}/${PN}"
do_install() {
install -d ${D}${base_bindir}
install ${B}/coffee ${D}${base_bindir}/coffee
}
SRC_URI = "file://${BP}.zip"
I am using http://code.qt.io/yocto/meta-qt6.git layer.

Using #BASENAME# with install_dir of custom_target() in Meson

#BASENAME# does not appear to work in the install_dir: parameter of the Meson custom_target() function.
protoc = find_program('protoc')
protobuf_sources= [
'apples.proto',
'oranges.proto',
'pears.proto'
]
protobuf_generated_go = []
foreach protobuf_definition : protobuf_sources
protobuf_generated_go += custom_target('go_' + protobuf_definition,
command: [protoc, '--proto_path=#CURRENT_SOURCE_DIR#', '--go_out=paths=source_relative:#OUTDIR#', '#INPUT#'],
input: protobuf_definition,
output: '#BASENAME#.pb.go',
install: true,
install_dir: 'share/gocode/src/github.com/foo/bar/protobuf/go/#BASENAME#/'
)
endforeach
I need the generated files to end up in at directory based on the basename of the input file:
share/gocode/src/github.com/foo/bar/protobuf/go/apples/apples.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/oranges/oranges.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/pears/pears.pb.go
If I use #BASENAME# in install_dir: to try and create the directory needed, it does not expand, and instead just creates a literal '#BASENAME#' directory.
share/gocode/src/github.com/foo/bar/protobuf/go/#BASENAME#/apples.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/#BASENAME#/oranges.pb.go
share/gocode/src/github.com/foo/bar/protobuf/go/#BASENAME#/pears.pb.go
How can the required installed directory location based on the basename be achieved?
(just 3 files in the above example, I actually have 30+ files)
Yes, it looks as there is no support for placeholders like BASENAME for install_dir parameter since this feature aims at file names not directories. But you can process iterator that is string in a loop:
foreach protobuf_definition : protobuf_sources
...
install_dir: '.../go/#0#'.format(protobuf_definition.split('.')[0])
endforeach

How to create each page as PDF from existing PDF using mPDF in Laravel

use ZanySoft\LaravelPDF\PDF;
$mpdf = new PDF();
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile(storage_path() . '/app/public/applications/test.pdf');
// test.pdf have 2 pages $pagecount have value 2.
for($i=1; $i <= $pagecount ; $i++) {
$tplId = $mpdf->ImportPage($i);
$mpdf->addPage();
$mpdf->UseTemplate($tplId);
// store each page as pdf file
$new_file_name = "new-".$i.".pdf";
$mpdf->Output($new_file_name, \Mpdf\Output\Destination::FILE);
}
I am getting an error Class 'Mpdf\Output\Destination' not found. I have tried below things as second argument of Output();
$mpdf->Output($new_file_name, \PDF\Output\Destination::FILE);
$mpdf->Output($new_file_name, \Mpdf\Mpdf\Output\Destination::FILE);
But, it is not working. Please help to store fetch page store as PDF file direct on directory.
ZanySoft\LaravelPDF\PDF uses mPDF in version 6.1 which does not have output destination class constants yet.
Use a plain string:
$mpdf->Output($new_file_name, 'F');
Or use composer package mpdf/mpdf in version >=7 directly.

ClearCase : list the content of a directory (ls) using CAL

In ClearCase, you can list the content of a directory using "cleartool ls".
My question is how can I do the same thing using CAL (ClearCase Automation Layer). The reason I prefer the COM API is because I won't have to parse the output of "ls".
So far, I am able to get the VOB and the View successfully, but I didn't find any method for listing the content.
My code so far:
IClearCase cc = new ApplicationClass();
CCVOB vob = cc.get_VOB("\\VOB-name");
CCView view = cc.get_View("ViewTag");
Thank you for your help.
I wrote VonC's answer in C# for those interrested.
string[] files = Directory.GetFiles("View path here", "*.*", SearchOption.AllDirectories);
foreach (string file in files)
{
try
{
CCVersion ver = cc.get_Version(file);
Console.WriteLine(ver.Path);
}
catch(Exception) {/*the file is not versioned*/}
}
May be this is a good start:
Set CC = Wscript.CreateObject("ClearCase.Application")
Set DirVer = CC.Version(".")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(DirVer.Path)
Wscript.Echo "Files under source control: "
For Each File in Folder.Files
On Error Resume Next
Set Ver = CC.Version(File.Name)
If Err.Number = 0 Then
Wscript.Echo Ver.ExtendedPath
End If
Next
The idea being to use ICCVersion methods to try accessing the version of a file. If it does not return an error, it is indeed a versioned file.
Now I know the file is versioned, how can I remove it (rmname).
Do not use RemoveVersion():
Removes irretrievably the version (equivalent to cleartool rmver)
WARNING! This is a potentially destructive operation. Because CAL does not prompt the user for input under any circumstances, there is no confirmation step when RemoveVersion is invoked. Invoking RemoveVersion is equivalent to running cleartool rmver with the -force option.
Instead use the RemoveName from the ICCElement interface.