For my NSIS uninstaller, I want to check if a process is running. FindProcDLL is not working under Windows 7 x64, so I tried nsProcess.
I've downloaded the version 1.6 from the website: http://nsis.sourceforge.net/NsProcess_plugin
If I start the nsProcessTest.nsi in the Example folder, I get the following errors:
Section: "Find process" ->(FindProcess)
!insertmacro: nsProcess::FindProcess
Invalid command: nsProcess::_FindProcess
Error in macro nsProcess::FindProcess on macroline 1
Error in script "C:\Users\Sebastian\Desktop\nsProcess_1_6\Example\nsProcessTest.nsi" on line 14 -- aborting creation process
This is line 14 of the example script:
${nsProcess::FindProcess} "Calc.exe" $R0
Do somebody know what is wrong? How can I check if a process is running with NSIS?
NSIS does not find the plug-in, so make sure you copied its files to the correct folder.
NSIS 2.x:
NSIS/
├── Include/
│ └── nsProcess.nsh
└── Plugins/
└── nsProcess.dll
NSIS 3.x:
NSIS/
├── Include/
│ └── nsProcess.nsh
└── Plugins/
├── x86-ansi/
│ └── nsProcess.dll
└── x86-unicode/
└── nsProcess.dll
The file inside Plugins\x86-unicode is nsProcessW.dll renamed to nsProcess.dll (blame the author for making it overly complicated!)
More generally, refer to How can I install a plugin? on the NSIS Wiki.
Related
I have two separate projects, but one of them must now incorporate aspects of the other, including the generation of some code, which done by a Python script which is called by CMake.
Here is my project structure:
repo/
├── project_top/
│ ├── stuff_and_things.cpp
│ └── CMakeLists.txt
│
└── submods/
└── project_bottom/
├── CMakeLists.txt
└── tools/
├── build_scripts
│ └── cmake_bits.cmake
└── generator
└── gen_code.py
In repo/submods/project_bottom/tools/build_scripts/cmake_bits.cmake there is a macro set_up_additional_targets(), which includes a custom target which runs repo/submods/project_bottom/tools/generator/gen_code.py in that directory. This is based on project_bottom being its own project.
add_custom_target(gen_code
COMMAND echo "Generating code"
COMMAND python3 gen_code.py args
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools/generator
)
Now, I need to make a new target in project_top dependent upon the gen_code target in project_bottom. How do I do this? The gen_code target needs to be run as part of the project_top build, but within the context of project_bottom, because for that target, ${CMAKE_CURRENT_SOURCE_DIR} needs to be repo/submods/project_bottom, not repo/project_top.
I'm trying to build a helloworld package example with a cmake recipe. My problem is bitbake give me an error because it can't find CMakeLists.txt in the /tmp/work/core2-64-poky-linux/helloworld/0.1-r0 folder.
The error :
helloworld-0.1-r0 do_configure: Execution of '/path-to-tmp/tmp/work/core2-64-poky-linux/helloworld/0.1-r0/temp/run.do_configure.28001' failed with exit code 1:
CMake Error: The source directory "/path-to-tmp/tmp/work/core2-64-poky-linux/helloworld/0.1-r0/files" does not appear to contain CMakeLists.txt.
My package is in my layer meta-mylayer/recipes-core/helloworld :
meta-mylayer/
├── conf
│ └── layer.conf
├── COPYING.MIT
├── README
└── recipes-core
└── helloworld
├── files
│ ├── CMakeLists.txt
│ └── main_helloworld.c
└── helloworld_0.1.bb
My CMakeLists.txt :
cmake_minimum_required(VERSION 2.4)
project(helloworld)
file(GLOB_RECURSE files/*.c)
add_executable(app ${src_files})
install(TARGETS helloworld DESTINATION bin)
My helloworld_0.1.bb :
PN="helloworld"
PV="0.1"
P="${PN}-${PV}"
DESCRIPTION="This is my package helloworld"
LICENSE="CLOSED"
FILESEXTRAPATHS_prepend:="${THISDIR}/${PN}:"
RDEPENDS_${PN}+=""
DEPENDS+=""
DEPENDS+="cmake"
SRC_URI+="file://CMakeLists.txt file://main_helloworld.c"
S="${WORKDIR}/files"
inherit pkgconfig cmake
I can't find my files in /path-to-tmp/tmp/work/core2-64-poky-linux/helloworld/0.1-r0/*
Why files are not copied? I'm using yocto Dunfell.
Thanks for your help.
When you have files in SRC_URI they are installed in ${WORKDIR}.
The following recipe will do the trick:
DESCRIPTION="This is my package helloworld"
LICENSE="CLOSED"
SRC_URI+="file://CMakeLists.txt file://main_helloworld.c"
S="${WORKDIR}"
inherit pkgconfig cmake
Also, your CMakeLists.txt should not find files in files directory.
S is set to ${WORKDIR} because this is where the files from the file:// fetcher are put by default.
DEPENDS already has cmake-native in it from the cmake bbclass you inherited. You don't need to depends on cmake, because you depends on cmake-native (you need to execute cmake at build time, you don't need cmake headers or sources).
The FILESEXTRAPATHS that was added is already by default used by bitbake (and it's also not matching your directory layout).
PN and PV are gotten from the filename of the bb recipe, no need to set them again.
How to copy a whole directory recursively with an npm script on Windows 10 Powershell?
Right now I have the following tree:
test
├───1
│ package.json
│
└───2
└───src
│ asd.txt
│
└───asd
asd - Copy (2).txt
asd - Copy.txt
asd.txt
What I want is a script that when run in dir 1 it goes to dir 2 and copies the whole dir src recursively from there to dir 1. So in the end I would have a similar src in 1 as there is in 2.
When I cd to the directory 1 and run npm run build:ui which is defined in package.json as
"scripts": {
"build:ui": "cd ..\\2 && copy src ..\\1"
}
it starts doing kind of what I want but not quite; it copies stuff from directory 2 to 1. The problem is it doesn't copy the whole directory with all of its subdirectories and all the possible contents, instead it just copies the files from directly inside 2/src/. In other words, here's what the tree looks like after the operation:
test
├───1
│ asd.txt
│ package.json
│
└───2
└───src
│ asd.txt
│
└───asd
asd - Copy (2).txt
asd - Copy.txt
asd.txt
So only the file asd.txt got copied.
Other configurations I have tried without success include:
"scripts": {
"build:ui": "cd ..\\2 && copy -r src ..\\1"
}
"scripts": {
"build:ui": "cd ..\\2 && Copy-Item -Recursive src ..\\1"
}
"scripts": {
"build:ui": "cd ..\\2 && cp -r src ..\\1"
}
...none of which are even valid.
Consider utilizing the xcopy command instead of copy as it better suits your requirement.
Redefine your build:ui script in the scripts section of your package.json file as follows:
Scripts section of package.json:
"scripts": {
"build:ui": "xcopy /e/h/y/q \"../2/src\" \"./src\\\" > nul 2>&1"
}
Running:
When you cd to the directory named 1, (i.e. the directory that contains the package.json with the aforementioned build:ui script defined in it), and then run:
npm run build:ui
it will produce the resultant directory structure:
test
├── 1
│ ├── package.json
│ └── src
│ ├── asd
│ │ ├── asd - Copy (2).txt
│ │ ├── asd - Copy.txt
│ │ └── asd.txt
│ └── asd.txt
└── 2
└── src
├── asd
│ ├── asd - Copy (2).txt
│ ├── asd - Copy.txt
│ └── asd.txt
└── asd.txt
As you can see, the src folder inside folder 2, and all of it's contents, has been copied to folder 1.
Explanation:
The following provides a detailed breakdown of the aforementioned xcopy command:
Options:
/e - Copy folders and subfolders, including empty folders.
/h - Copy hidden and system files and folders.
/y - Suppress prompt to confirm overwriting a file.
/q - Do not display file names while copying.
Notes:
Each pathname has been encased in JSON escaped double quotes, i.e. \"...\"
The ./src\\ part has a trailing backslash (\), which has been JSON escaped (\\), to inform xcopy that the destination is a directory. This also ensures the src directory is created if it doesn't already exist.
The > nul 2>&1 part suppresses the confirmation log that states how many files were copied.
Related information:
It's worth noting that on Windows npm utilizes cmd.exe as the default shell for running npm scripts - regardless of the CLI tool you're using, e.g. PowerShell. You can verify this by utilizing the npm-config command to check the script-shell setting. For instance run the following command:
npm config get script-shell
Edit:
If you want your resultant directory structure to be like this:
test
├── 1
│ ├── asd
│ │ ├── asd - Copy (2).txt
│ │ ├── asd - Copy.txt
│ │ └── asd.txt
│ ├── asd.txt
│ └── package.json
└── 2
└── src
├── asd
│ ├── asd - Copy (2).txt
│ ├── asd - Copy.txt
│ └── asd.txt
└── asd.txt
This time the contents of the src folder inside the folder named 2 has been copied to folder 1 - but not the actual containing src folder itself.
Then you need to define your npm script as follows:
"scripts": {
"build:ui": "xcopy /e/h/y/q \"../2/src\" \".\" > nul 2>&1"
}
Note: the destination path has been changed from \"./src\\\" to \".\".
For something like this, I might use an approach similar to the below.
Modify your NPM script (build:ui) to call a Powershell script(build.ui.ps1) that is located in the same dir as the package.json file.
"scripts": {
"build:ui": "#powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./build.ui.ps1"
},
Create the aforementioned Powershell script with the following contents.
param(
$srcParentDir = '2',
$srcDir = 'src',
$srcDestDir = '1'
)
Set-Location (get-item $PSScriptRoot).parent.FullName
Copy-Item -Path "$srcParentDir\$srcDir" -Destination $srcDestDir -Recurse
Run the npm script
npm run build:ui
The above code displays the following error:
cmd.exe /D /C call C:/Users/<user>/AppData/Roaming/npm/lessc.cmd --no-color style.less
FileError: '/styles/vars.less' wasn't found. Tried - /styles/vars.less,D:\projects\ui\themes\default\styles\vars.less in D:\projects\ui\themes\default\style.less on line 1, column 1:
1 #import "/styles/vars.less";
2
Process finished with exit code 1
But if I change the path to something invalid:
Now I see "Cannot resolve file" as well as the unresolved variable. Is this a bug or something I'm doing wrong?
Here is the folder structure of the relevant files:
(root)/
├── styles/
│ ├── vars.less
├── themes/
│ ├── default/
│ └── style.less (the file with the error)
I have a project with the following structure:
linalg
├── build
├── CMakeLists.txt
├── docs
│ └── Doxyfile
├── include
│ └── linalg
│ └── vector3.hpp
├── src
│ ├── CMakeLists.txt
│ └── linalg
│ └── vector3.cpp
└── test
├── CMakeLists.txt
└── linalg
└── test_vector3.cpp
The file test_vector3.cpp is a gtest unit test file which provides two simple tests. The top level CMakeLists.txt simply sets up the includes and adds the src and test subdirectories:
cmake_minimum_required(VERSION 2.8)
project(linalg)
include_directories(include)
add_subdirectory(src)
add_subdirectory(test)
The src/CMakeLists.txt file compiles vector3.cpp into a static library:
cmake_minimum_required(VERSION 2.8)
add_library(linalg linalg/vector3.cpp)
The test/CMakeLists.txt file is based on the example provided in /usr/share/cmake-2.8/Modules/FindGTest.cmake:
cmake_minimum_required(VERSION 2.8)
enable_testing()
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
add_executable(test_vector3 linalg/test_vector3.cpp)
target_link_libraries(test_vector3 linalg ${GTEST_BOTH_LIBRARIES} pthread)
add_test(test_vector3 test_vector3)
I then run the following:
cd build
cmake ..
make
I get the liblinalg.a library compiled correctly in to build/src and I get the test_vector3 executable compiled correctly in to build/test. I can run the test_vector3 executable and I get the output from googletest saying that all tests have passed, however if I run make test I get no output whatsoever and if I run ctest .. I get a message saying:
Test project /home/ryan/GitHub/linalg/build
No tests were found!!!
Is there something I am missing? Or have I just misunderstood how ctest works with gtest?
The crux of the problem is that enable_testing should be called from your top-level CMakeLists.txt in this case. Adding include(CTest) to your top-level CMakeLists.txt should fix this for you.
This would allow you to remove the enable_testing call in test/CMakeLists.txt, since the CTest submodule calls enable_testing internally.
Just to update this.
cmake in version 3.9 added support for GoogleTest integration with CTest.
So you can now get CTest to scrape all of the test macros in your test executable, not just the whole executable.
Example here:
https://gist.github.com/johnb003/65982fdc7a1274fdb023b0c68664ebe4