qmake generated target_wrapper.sh fails on make check - bash

I have a qmake project with a subdirs template and two child projects.
The subdir projects are two testcases. The project is built with on mingw64.
When I run "mingw32-make check", the process fails when the first testcase is called by the target_wrapper.sh:
cd && /C/JENKINS/workspace/MyProject/tests/test1/target_wrapper.sh release/test1.exe
/C/JENKINS/workspace/MyProject/tests/test1/target_wrapper.sh: Zeile 6: /home/jenluelokal/release/test1.exe: No such file or directory
mingw32-make[2]: *** [Makefile.Release:82: check] Error 127
The Makefile.Release calls the following line for the check target:
check: first
cd && /C/JENKINS/workspace/MyProject/tests/test1/target_wrapper.sh $(TESTRUNNER) release/$(TARGET) $(TESTARGS)
By request the target_wrapper.sh:
#!/bin/sh
PATH=/C/Qt/Qt5.9.2/5.9/mingw64/bin:$PATH
export PATH
QT_PLUGIN_PATH=/C/Qt/Qt5.9.2/5.9/mingw64/share/qt5/plugins${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}
export QT_PLUGIN_PATH
exec "$#"
The first cd changes into the homedir of the current user and calls target_wrapper.sh. The target_wrapper.sh script tries to execute the
test1 binary - which is not inside the home directory.
What am I doing wrong?

DESTDIR needs be set, so the make check target knows where to look for the test executables. The "cd" changes into this directory before trying to run the target_wrapper.sh.

Related

Makefile error (e=2): The system cannot find the file specified

I'm completely new to Makefile (and to Docker), and I'm struggling with understanding how to point to a subdirectory.
This is the file structure:
project
[...docker
[ [...Dockerfile
[
[...client
[ [...docker
[ [...Dockerfile
[...api
(Sorry, can't find the pipe on my keyboard)
The Makefile includes two builds.
# Makefile
build_api:
# docker compose build
build_client:
# client/docker compose build
up: build_api build_client
# docker compose up -d
The api image gets created and launched, but the client image fails with this error:
make (e=2): The system cannot find the file specified.
make: *** [Makefile:5: build_client] Error 2
How can I point to a subdirectory inside the Makefile?
The format of your Makefile as of now is set up to try to run the folder client/docker as a command.
Instead, try # cd client ; docker compose build
This should then enter the client folder and then run the docker command there.

build command need to be executed inside a specific named directory "./package" from child folder or parent folder script terminal (cd) loop or regex

how to write cd NAME_FOLDER and recursively search for it by name and then go to it if necessary (see below for more details).
the NAME_OF_FOLDER is unique so no worried about that.
but the challenging things are:
that it needs to search from the PARENT to the CHILD,
and if it didn't find it that way, search from CHILD to PARENT.
(or you can use any other logic if you think my logic is slow)
example folder
here is an example image of my folder:
possible scenarios
here are some scenarios:
if I am inside
./package -> don't run cd
./test -> cd ./package
./src -> cd ../ && cd ./package
./lib -> cd ../../ && cd ./package
and so on for every deep folder structure
docs:
../ means go from child to parent
./ means go from parent to child
why do I need it?
I am a javascript developer,
and I am using the sveltekit framework
to create a svelte package library.
and I need to publish that library to npm.
and this is ok.
but since I write a lot the same CLI codes.
I am changing the package.json's scripts object,
so I write only one time npm run build to run 6+ commands
{
...
"build": "
svelte-kit sync
&& svelte-package
&& npm version patch
&& cd ./package # only this I need to solve this (the others are solved)
&& npm publish
&& git commit
"
}
this is in one line, but for making you read it easily the code in multiple lines
here how it is in my code:
what does the build command should do?
the command generates a ./package folder always on the root of the folder
(where we can find package.json, .gitignore, ./src, etc...)
increase the number of versions automatically when we use the build command,
then... TODO:
do the script I need to access the ./package folder from every folder I am in now. (like cd ./package)
npm publish
my os?
windows 11 (but using bash with vscode) or also powershell will be good but prefer bash
any other details, I will tell you. thanks
For testing, I created this structure:
test/
package/
src/
lib/
routes/
Then I created that script:
#!/bin/bash
topdir="test"
while [[ $(basename "$(pwd)") != "$topdir" ]]
do
if [[ -d package ]]
then
cd package
pwd
else
cd ..
pwd
fi
done
if [[ -d package ]]
then
cd package
pwd
fi
This script "climbs" the directories until it finds a "package" directory. It the cd into it.
To use the script, you have to source it. If you execute it, it will change directories while the script is running, but it will not affect your current terminal.
So, lets assume the script is ~/bin/cd_package.bash
You would call it like this: . ~/bin/cd_package.bash
Note the pwd commands are just so you can follow what is going on and can be removed once you are convinced it works.

path in makefile not working

Im running the following makefile
which needs to change dir to specific target and run there npm install
The problem is that I was able to see in the output that it print the directory (project/app) to the right directory but the installation (npm install) run on level up (project), why ?
For example
When I run it I see from cd $(DIR)/app
/Users/i03432/go/src/project/app
Now the second command is
npm install
And I got error that id doesn’t find the package json in the project path which is right... it’s only in the app path. Why the cd is not working ?
it try to find it here
/Users/i03432/go/src/project/package.json
and here is the package.json
/Users/i03432/go/src/project/app/package.json
The makefile is
module:
DIR=$(PWD)
#echo $(DIR)
cd $(DIR)/app
npm install
Every command in a rule is run in a single process (sub-shell). Every change you perform on the environment is hence tied to that particular line. You want to change your snippet to
cd $(PWD)/app && npm install
This command runs in a single subprocess and should yield the desired result. Note that this problem occurs for the definition of DIR, too, so you might want to move this a few lines up:
DIR = $(PWD)
module:
cd $(DIR) && npm install
This way, you are referring to a variable that make provides, and you don't rely upon subprocesses here.

Prevent running cmake in the root directory

Sometimes I forget I'm in the build folder and I run the command in the root directory. Well, maybe some of you have experienced that this creates a mess in the entire file hierarchy, as you have to delete CMakeFiles/ folder, config files, and files related to CPack and CTest. Is there a way I can add something to the Makefile at the root directory that prevents me from running cmake accidentally? I tried to add a target 'cmake' but this didn't work.
aa
UPDATE
I found the same question posted in here. I ended up adopting to put a function in my .bashrc file as suggested in that page:
function cmake() {
# Don't invoke cmake from the top-of-tree
if [ -e "CMakeLists.txt" ]
then
echo "CMakeLists.txt file present, cowardly refusing to invoke cmake..."
else
/usr/bin/cmake $*
fi
}
You can check in your CMakeLists.txt if the source and binary directories are the same. Put something like this as the very first thing in your CMakeLists.txt:
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Source and build directories cannot be the same.")
endif()

Build gcc on linux script

Good day, i write script for building gcc on linux, my code is:
#!/bin/bash
export INSTALLATION_GCC=/opt
cd $INSTALLATION_GCC
tar xjvf gcc-4.7.0.tar.bz2
export srcdir="$INSTALLATION_GCC/gcc-4.7.0"
export objdir="$INSTALLATION_GCC/gcc-bin"
export insdir="$INSTALLATION_GCC/usr/local"
mkdir -p $srcdir
mkdir -p $objdir
mkdir -p $insdir
cd $objdir
$srcdir/configure --prefix=$insdir
make bootstrap
make install
but when i run this script i get errors:
No such file or directoryopt
tar (child): gcc-4.7.0.tar.bz2\r: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
/configure: No such file or directory
'. Stop. No rule to make target `bootstrap
'. Stop. No rule to make target `install
Why cd not work successful, if i execute my script (if i input this command in interactive mode all ok)?After building and installing gcc why my version of gcc not changing, how can i replace old version gcc properly?
I think my comment about a backspace being part of the directory name is relevant:
"There is something strange here, the error message No such file or directoryopt is missing a space and a /. It looks to me like your code did not generate this error message, are you sure that $INSTALLATION_GCC is /opt with the leading /? It almost appears that the first character of $INSTALLATION_GCC is a backspace."
I also spied gcc-4.7.0.tar.bz2\r in one of the error messages. A \r would give these effects. The most common unwanted source of \r (carriage-return) is Windows. Are you using something like Notepad on Windows to edit your scripts? If Windows is involved, convert your script using dos2unix.

Resources