Qmake INSTALLS variable - create symbolic link to directory - qmake

I am trying to add an INSTALLS rule to my qmake .pro file that will create a symlink in the build directory to the config directory in my project. Here's how I've tried to do it using the 'extra' member:
config.path = $$top_builddir/
config.files = $$rootdir/config
config.extra = ln -sf $$config.files $$config.path
INSTALLS += config
where top_builddir and rootdir are of course the paths to the build directory and root project dir, respectively.
The generated Makefile rule is:
install_config: FORCE
#test -d $(INSTALL_ROOT)/home/greg/Desktop/mg_builds/MPI-Debug || mkdir -p $(INSTALL_ROOT)/home/greg/Desktop/mg_builds/MPI-Debug
ln -sf /home/greg/Desktop/mg/config /home/greg/Desktop/mg_builds/MPI-Debug/
-$(INSTALL_DIR) /home/greg/Desktop/mg/config $(INSTALL_ROOT)/home/greg/Desktop/mg_builds/MPI-Debug/
The extra command has been added but there is also the command to cp the directory too which is causing causing the error:
cp: '/home/greg/Desktop/mg/config' and '/home/greg/Desktop/mg_builds/MPI-Debug/config' are the same file
Makefile:580: recipe for target 'install_config' failed
How can I suppress this or tell qmake to make a symlink rather than a copy?

After a little experimenting I found this works quite nicely. You can leave the .files member empty (i.e. .files =) or just omit it entirely and no copy command will be generated in the Makefile. The target directory can be written directly in the extra command. However, a .path is still required for the rule to be generated.
config.path = $$top_builddir/
config.extra = ln -sf $$rootdir/config $$config.path
INSTALLS += config
Makefile:
install_config: FORCE
#test -d $(INSTALL_ROOT)/home/greg/Desktop/mg_builds/MPI-Debug/ || mkdir -p $(INSTALL_ROOT)/home/greg/Desktop/mg_builds/MPI-Debug/
ln -sf /home/greg/Desktop/mg/config /home/greg/Desktop/mg_builds/MPI-Debug/

Related

Godot Nix Expression Fails

I've added the following nix expression to my project (verbatem from nixpkgs) and tried to build it, but I get the following error message:
these derivations will be built:
/nix/store/l6l5j1gas74pnzc2pb8w9fv2namxpgki-godot-3.0.6.drv
building '/nix/store/l6l5j1gas74pnzc2pb8w9fv2namxpgki-godot-3.0.6.drv'...
unpacking sources
unpacking source archive /nix/store/mlbp5ibpyq2rd710fl43pwr6a03ysz57-source
source root is source
patching sources
applying patch /nix/store/yk47p909lklbcai94izb5dfqjqqnnxmc-pkg_config_additions.patch
patching file platform/x11/detect.py
applying patch /nix/store/sdr3xp65cibpd06vq4fg5czv2s3m6a3c-dont_clobber_environment.patch
patching file SConstruct
configuring
no configure script, doing nothing
building
no Makefile, doing nothing
installing
cp: missing destination file operand after '/nix/store/mxvinscpfbv3k5j7dvpa83pd4w1p1f4f-godot-3.0.6/bin/godot'
Try 'cp --help' for more information.
builder for '/nix/store/l6l5j1gas74pnzc2pb8w9fv2namxpgki-godot-3.0.6.drv' failed with exit code 1
What could be causing this? Note that when I simply add godot to my nix config (in NixOS using nixos-18.09 channel), it installs and runs just fine. Aren't these the same expressions? If so, why does it work globally and not locally?
NOTE: Here is the part of the nix expression that invokes the cp shell command (related to the error above):
installPhase = ''
mkdir -p "$out/bin"
cp bin/godot.* $out/bin/godot
mkdir "$dev"
cp -r modules/gdnative/include $dev
mkdir -p "$man/share/man/man6"
cp misc/dist/linux/godot.6 "$man/share/man/man6/"
mkdir -p "$out"/share/{applications,icons/hicolor/scalable/apps}
cp misc/dist/linux/godot.desktop "$out/share/applications/"
cp icon.svg "$out/share/icons/hicolor/scalable/apps/godot.svg"
cp icon.png "$out/share/icons/godot.png"
substituteInPlace "$out/share/applications/godot.desktop" \
--replace "Exec=godot" "Exec=$out/bin/godot"
'';

$(pkg_build_dir) value in OpenWrt

What does $(build_dir), $(pkg_build_dir) has in OpenWrt.
I have create the sample helloworld component and created the Makefile by following steps in openwrt.org.
When I try:
make package/helloworld/install -j1 V=s
it throws below error:
Warning: Your configuration is out of Sync, Please run make memuconfig, oldconfi or defconfig!
Entering Directory '.../openwrt'
***no rule to make target 'pckage/helloworld/install'. Stop
Leaving Directory .../openwrt
/home../toplevel.mk:216: recipe for target 'package/helloworld/install' failed.
Can someone help me in resolving this?
$(build_dir), $(pkg_build_dir) are variable defaults used by OpenWRT.
$(build_dir), is the directory that OpenWRT builds to and
$(pkg_build_dir) is a package build directory.
$(build_dir) does not need to be defined in the makefile
$(pkg_build_dir) can be defined in the makefile as:
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
With regards to your issue I would also try including the source directory in the makefile:
SOURCE_DIR:=/home/johndoe/helloworld
and updating the package feeds
cd /home/buildbot/source
./scripts/feeds update mypackages
./scripts/feeds install -a -p mypackag

Cmake zip folder but remove leading path

I would like to zip folder in my project from CMake. For that I use following code snippet:
ADD_CUSTOM_COMMAND (
TARGET ${PROJECT_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E tar cvf ${ZIP_OUT_DIR}/my_archive.zip --format=zip -- ${FOLDER_TO_ZIP}/another_folder/
)
The problem with this code is that the files after unzipping contain path component (../../my_file.txt in my case). I tried to use tar cvf -C ${FOLDER_TO_ZIP}/another_folder but unfortunatelly CMake doesn't accept this option.
How can I get rid of leading path from zip archive when using CMake ?
The paths are relative to the working directory. So you just need to specify the WORKING_DIRECTORY:
ADD_CUSTOM_COMMAND(
TARGET ${PROJECT_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E tar cvf ${ZIP_OUT_DIR}/my_archive.zip --format=zip -- .
WORKING_DIRECTORY ${FOLDER_TO_ZIP}/another_folder
)

Override scripts in nix derivations

Is there a way to override scripts and/or configs in an existing derivation without having to recompile the whole package?
I'd like to create a new version of gnome-session with modified $out/share/gnome-session/sessions/gnome.session modified. Using overridePackage I can change the preFixup phase, but this causes the whole gnome-session package to be recompiled.
A simple solution to problem is creating a new derivation without any sources. The trick is to create links to every file and directory in the base derivation, except for any file(s) in need of modification. These files are handled explicitly according to needs.
The snippet below shows how to create a new gnome-session with xmonad instead of gnome-shell.
{ nixpkgs ? import <nixpkgs> {} }:
let
inherit (nixpkgs) pkgs;
in
pkgs.stdenv.mkDerivation {
name = "gnome-session";
builder = pkgs.writeText "builder.sh" ''
# source standard environment
. $stdenv/setup
# shorthands
refpkg=${pkgs.gnome3.gnome_session}
file=share/gnome-session/sessions/gnome.session
# create output dirs for new derivation
mkdir -p $out/share
mkdir -p $out/share/gnome-session/sessions
# link unchanged files from the original gnome-session
ln -sf $refpkg/bin $out
ln -sf $refpkg/libexec $out
find $refpkg/share -maxdepth 1 \
-not -name gnome-session -exec ln -sf {} $out/share \;
# change gnome-shell to xmonad
sed 's/org.gnome.Shell/xmonad/' $refpkg/$file > $out/$file
'';
# make sure gnome-session is installed before deriving it!
buildInputs = [ pkgs.gnome3.gnome_session ];
}

Makefile error: "install 'filename' was not found anywhere!"

I am attempting to make a project and have run into this error when trying to issue an install command on a handful of executables. Looks something like this:
(in highest level dir:)
DIRS = \
dir1 \
dir2 \
... \
lastDir \
all clean release:
for x in $(DIRS); do cd $$x; make $#; cd ..; done
Then in dir1, for example:
all: $(PROG)
install $(PROG) ../../bin
and the same for each directory. Log looks like this:
[exec] install my_prog_name ../../bin
[exec] install: my_prog_name was not found anywhere!
[exec] make[1]: Leaving dir1
Neither makefile (in upper or lower directory) has been changed since the last successful build, same with the build file (using ant).
Kind of looks like either a pathing issue or a permissions issue. Permissions on destination directory are 777, though. Issuing the install command manually in dir1 works fine...
Thanks for the help!
Are you running this on Solaris? It seems the Solaris version of the install command is prone to generate this error.
I'm not sure what the root cause is, but you could try using /usr/ucb/install, plain cp or the GNU ginstall.

Resources