Where does makensis place the nsis outfile? - nsis

Where does makensis place the OutFile? Is it in the directory where the .nsi file is or is it the working directory where makensis was called?
For example:
command-line:
makensis .\dir\to\script.nsi
script.nsi:
OutFile setup.exe

From testing your script.nsi, it places it relative to the script.nsi file:
Processing config: ...\NSIS\nsisconf.nsh
Processing script file: "...\dir\to\script.nsi" (ACP)
Processed 1 file, writing output (x86-unicode):
Output: "...\dir\to\setup.exe"
...
1 warning:
9000: Insecure filename "setup.exe", Windows will unsafely load compatibility shims into the process.

The output is relative to the current directory. The current directory is set to the directory of the .nsi file unless you run MakeNSIS with the /NOCD switch. The current directory can be changed by the script with !cd.
OutFile Test.exe ; Written to same directory as the .nsi
or
!cd "c:\something"
OutFile Test.exe ; Written to c:\something\Test.exe

Related

File is not shown in the folder generated via tcl script

I am trying to write a file using tcl scripting (Via VMD). when I type command "dir" on tk/tcl console, it shows file name which I am trying to generate. But when I tried to open that file manually in that working directory folder, it is not even shown in it.
Here is the piece of code.
set fp [open "input.txt" w+]
puts $fp "test"
close $fp
Sometimes, Windows can be deeply tricky about what is going on with the actual folders.
If you do this in your script as well:
# This is quite an incantation!
exec {*}[auto_execok cmd] /c start "" [file nativename [file normalize .]]
then it should open an Explorer window on the actual current directory. That will let you check whether the file is actually there, and whether where you are is where you expect to be.
This should match up with what this says:
# Print the current working directory
puts [pwd]
# Print the names of text files in the current directory, with full names
puts [glob -directory [pwd] *.txt]
If it doesn't, that might point to your real problem…

vim change base of relative path to source to other dir

I have a local Makefile which simply calls make -C ... As a result I get the output from the compiler with filenames and path to the directory relative to ...
Now vim isn't able to get the correct path for quickfix.
Q: How can I set the base path for vim quickfix to .. ?
My path structure:
<bla>/base/proj1/<localMakeFile>
<bla>/base/<globalMakefile>
<bla>/src/source1.cpp
I compile inside /base/proj1/
Compiler output for a error is like:
src/source1.cpp|141 col 54| Error: ....
But I am working in
/proj1/ so vim is unable to get the file src/source1.cpp
EDIT:
I see that the problem is basically related to the output of gnu make
make[4]: Entering directory '<bla>/...'
which is not parsed correctly if I use not an English environment. Setting the shell with export LANG= all works fine.
Q: Can vim parse also the German output of gnu make?
Appending the localized version with set errorformat+=<localized version> should work.
I am not aware that VIM supports it out of the box. After looking at the output of :set errorformat, which on my machine is a scary...
errorformat=%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l: %m,%-G%f:%l: (Ea
ch undeclared identifier is reported only once,%-G%f:%l: for ea
ch function it appears in.),%-GIn file included from %f:%l:%c:,
%-GIn file included from %f:%l:%c\,,%-GIn file included from %f
:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G
%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\,,%-G%*[ ]from %f:%l,%f:%l:
%c:%m,%f(%l):%m,%f:%l:%m,"%f"\, line %l%*\D%c%*[^ ] %m,%D%*\a[%
*\d]: Entering directory %*[`']%f',%X%*\a[%*\d]: Leaving direct
ory %*[`']%f',%D%*\a: Entering directory %*[`']%f',%X%*\a: Leav
ing directory %*[`']%f',%DMaking %*\a in %f,%f|%l| %m
...and by changing the output of the build process from
make: Entering directory `<directory>`
to
make: Entering `<directory>`
i got it to work by extending errorformat like this:
:set errorformat+=%D%*\\a:\ Entering\ %*[`']%f'

Execute program on Files in subDirectory

I have following architecture of files in a directory.
Directory
/A/abc.xyz
/B/abc.xyz
/C/abc.xyz
/D/abc.xyz
/E/abc.xyz
I want to execute a program on acb.xyz in each SubDirectory. Save Output files in different directory i.e. Directory/processed with the name of SubDirectory appended in the name of output files.
Can it be written in following way? Need corrections.
for i in `ls "Directory/"`
do
program.pl $i/abc.xyz > processed/$i-abc.xyz
done
for dir in Directory/*; do
program.pl "$dir/abc.xyz" > "processed/${dir##*/}-abc.xyz"
done
The ${dir##*/} part strips the leading directory names from $dir, so Directory/A becomes just A. I added quotes to ensure directory names with whitespace don't cause issue (a good habit, even if you know there are no spaces).
As an alternative to the string munging you could simplify this if you first change directory:
cd Directory
for dir in *; do
program.pl "$dir/abc.xyz" > "processed/$dir-abc.xyz"
done

how to expand directory with awk files

I have created a scriptdirectory
let $MYSCRIPTS = $VIM."/vimfiles/my_scripts-docs"
($VIM = C:\Program Files\Vim)
this works fine:
exe "e ".expand('$MYSCRIPTS/vim-calc_vb.txt')
This doesn't work and I can't find out why:
exe "!awk -f ".expand('$MYSCRIPTS/my-awk-script.awk')
exe "!awk -f ".expand('$MYSCRIPTS\my-awk-script.awk')
error:
awk: fatal: can't open source file 'C:/Program'
It works fine when I put the .awk file in the root but not when
I put it in a vim directory or whatever directory under C:\program files
Why does .txt files expand and .awk files not?
How can I let vim know where the awk file is under vimfiles?
Why do you need expand() and not just
fnameescape($MYSCRIPTS.'/vim-calc_vb.txt')
(for the exe "e") and
shellescape($MYSCRIPTS.'/my-awk-script.awk, 1)
(for !awk …)?
Based on your
awk: fatal: can't open source file 'C:/Program'
It works fine when I put the .awk file in the root but not when
I put it in a vim directory or whatever directory under C:\program files
I see that absence of shellescape() is the problem here, not expand(), but it does not make the former useful. It is useful for changing \ to / on windows. Just surround your expand() calls with fnameescape()/shellescape(…, 1):
" None is needed here: `:e` expands `$` on its own
e $MYSCRIPTS/vim-calc_vb.txt
exe "!awk -f ".shellescape(expand('$MYSCRIPTS\my-awk-script.awk'), 1)

zip files using CMake?

tl;dr version:
Is it possible with CMake (>= 2.8) to generate zip files from some files and put the packed zip file in a specific location?
longer version:
I have a CMakeLists.txt that builds my project into a .exe file, and this exe file will read data from a zip file. The content to be packed in the zip file is in my git repository so that it can be edited, too. But, the program needs this data in a zip file. So it would be good if the CMake script could take the data, put it in a zip file, and place it next to the exe. I already heard of CPack, but I did not find any easy examples and am not sure if this is even the right tool for my task.
Is this possible? If yes, how?
Since version 3.2 CMake has the functionality to generate a zip file built-in. The CMake command-line mode sub-command tar supports both the creation of zip and 7zip archives.
For example, if the current CMake source directory contains the file testfile.txt and the directory testdir, you can use the following CMake commands to create a zip file containing both items:
add_custom_target(create_zip COMMAND
${CMAKE_COMMAND} -E tar "cfv" "archive.zip" --format=zip
"${CMAKE_CURRENT_SOURCE_DIR}/testfile.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/testdir")
As a work-around for earlier CMake versions, you can use the jar command that is part of a standard Java JRE installation.
find_package(Java)
execute_process(
COMMAND
"${Java_JAR_EXECUTABLE}" "cfM" "archive.zip"
"-C" "${CMAKE_CURRENT_SOURCE_DIR}" "testfile.txt"
"-C" "${CMAKE_CURRENT_SOURCE_DIR}" "testdir"
RESULT_VARIABLE _result
)
The zip file will be generated in the current CMake binary dir (CMAKE_CURRENT_BINARY_DIR).
It's never late to show real answer:
function(create_zip output_file input_files working_dir)
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E tar "cf" "${output_file}" --format=zip -- ${input_files}
WORKING_DIRECTORY "${working_dir}"
OUTPUT "${output_file}"
DEPENDS ${input_files}
COMMENT "Zipping to ${output_file}."
)
endfunction()
Use like
file(GLOB ZIP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/zip/*")
create_zip("${CMAKE_CURRENT_BINARY_DIR}/native_data.zip" "${ZIP_FILES}" "${CMAKE_CURRENT_SOURCE_DIR}/zip")
This will pack all files from zip/ subdirectory into native_data.zip (in build directory). Then either include your archive (path will differ in different CMakeLists.txt!) as source file or add it as target:
add_custom_target("project-data" ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/native_data.zip")
Install will not differ a lot from usual:
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/native_data.zip" DESTINATION ${DATADIR} RENAME "data000.zip") # Install our zip (as data000.zip)
I assume you already have a zip-tool installed (WinZip or 7z, etc.). You could write a find_zip-tool script which will search for WinZip, or 7Z, etc...
Snippet for WinZip:
FIND_PROGRAM(ZIP_EXECUTABLE wzzip PATHS "$ENV{ProgramFiles}/WinZip")
IF(ZIP_EXECUTABLE)
SET(ZIP_COMMAND "\"${ZIP_EXECUTABLE}\" -P \"<ARCHIVE>\" #<FILELIST>")
ENDIF(ZIP_EXECUTABLE)
Snippet for 7-zip:
FIND_PROGRAM(ZIP_EXECUTABLE 7z PATHS "$ENV{ProgramFiles}/7-Zip")
IF(ZIP_EXECUTABLE)
SET(ZIP_COMMAND "\"${ZIP_EXECUTABLE}\" a -tzip \"<ARCHIVE>\" #<FILELIST>")
ENDIF(ZIP_EXECUTABLE)
Take a look at the file
<cmake-install-dir>\share\cmake-2.8\Modules\CPackZIP.cmake
it shows how CPack searches for a Zip_Executable and prepares some "useful" default flags.
After that, I would suggest to execute_process, similar to sakra's answer
As of version 3.18, CMake now directly supports creating zip or archive files using the file() command with ARCHIVE_CREATE:
file(ARCHIVE_CREATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/MyData.zip
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/data
FORMAT zip
)
Be sure to specify a full path for the OUTPUT zipped filename, or the file may not be generated. Also, the PATHS option accepts files or directories to be placed in the zip file, but it does not accept wildcards at the time of writing.
This command supports several archive formats and compression flavors. So, you can use the same command to create tarballs as well:
file(ARCHIVE_CREATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/MyData.tar.gz
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/data
FORMAT gnutar
COMPRESSION GZip
)
Since this is the top search result for creating zip files with CMake, here is a CPack solution for completeness. The basic idea is that you make calls to install() and then tell it what to name the resulting zip file. It will be placed in the build directory, though there may be a way to change that. Then you can create the zip file with make package or cpack.
# Version 1: Subtractive
# Include everything in the project source directory.
# Put it at the top level of the zip via `DESTINATION .`
# Subtract things we don't want.
# The trailing slash after "${PROJECT_SOURCE_DIR}/" prevents
# an extra layer of directories.
install(DIRECTORY "${PROJECT_SOURCE_DIR}/"
DESTINATION .
PATTERN ".git*" EXCLUDE
PATTERN ".DS_Store" EXCLUDE
PATTERN "examples" EXCLUDE
PATTERN "docs" EXCLUDE
PATTERN "README.md" EXCLUDE
)
# Version 2: Additive
# Include only the list of things we specify.
# Put it at the top level of the zip via `DESTINATION .`
# install(FILES
# ${SRCS}
# "Notes.txt"
# DESTINATION .
# )
# Tell CPack to create a zip file.
set(CPACK_GENERATOR "ZIP")
# Tell CPack what to name the zip file. It will append `.zip`.
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}")
# Tell CPack not to put everything inside an enclosing directory.
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
# Apparently this should be always on but isn't for backwards compatibility.
set(CPACK_VERBATIM_VARIABLES YES)
include(CPack)
Essentially what I did was create custom target
add_custom_target(STAGE_FILES)
With this target I copy the files and directories to the CMAKE_CURRENT_BINARY_DIR
add_custom_command(
TARGET STAGE_FILES
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/assets/video ${CMAKE_CURRENT_BINARY_DIR}/video
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/assets/data ${CMAKE_CURRENT_BINARY_DIR}/data
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/assets/strings_en.csv ${CMAKE_CURRENT_BINARY_DIR}/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/assets/strings_rules_en.csv ${CMAKE_CURRENT_BINARY_DIR}/
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "data.zip" --format=zip --files-from=${CMAKE_SOURCE_DIR}/assets/to_zip.txt
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/data
COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/data.zip ${CMAKE_CURRENT_BINARY_DIR}/data
)
The important line
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "data.zip" --format=zip --files-from=${CMAKE_SOURCE_DIR}/assets/to_zip.txt
inside my
to_zip.txt
I specify all the files I want to include in my zip
data/
video/
...
I can now execute the command
make STAGE_FILES
which will copy and zip everything i need

Resources