Hi there my project has job.sh in a root dir
the file contains
#!/bin/bash
#SBATCH --job-name=$(REPLACEME)
#SBATCH --tasks=4
#SBATCH --computers=1
run ./myApp
now I would like to somehow copy the file to builddir as well as replace $(REPLACEME) with Project name
not sure how to do the reeplacing part, as copying it easy
file(GENERATE OUTPUT job.sh INPUT job.sh)
Thanks for Anwsering and Best Regards
I figured it out, you create a template file like job.sh in root dir that contains what you want and some CMAKE variables like ${CMAKE_PROJECT_NAME} for example
#!/bin/bash
#SBATCH --job-name=${CMAKE_PROJECT_NAME}
#SBATCH --tasks=4
#SBATCH --computers=1
run ./myApp
then in your CMakeLists.txt just do this
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/job.sh ${CMAKE_CURRENT_BINARY_DIR}/job.sh)
Related
I want to run preprocessor and generate .i files using the following command
(I based on http://jkorpela.fi/html/cpre.html) :
gcc -Irange/v3/action -x c -P -C -E range/v3/action.hpp
but I have error:
range/v3/action.hpp:17:10: fatal error: range/v3/action/action.hpp: No such file or directory
#include <range/v3/action/action.hpp>
The command is called from include directory. Directories tree is shown below:
-include
-range
-v3
-action.hpp (file)
-action (directory)
-action.hpp
I've tried replace -I flag with other options, for example -Irange/**, but it did not work also.
I will be grateful for your solution or suggestion.
The path specified in #include is appended to the directory in -I. So it's looking for range/v3/action/range/v3/action/action.hpp. That's duplicating the directory path, because you have it in both -I and #include.
Either use -I. to start the search from the current directory, or use #include <action.hpp> to just search for the filename in the -I directory.
So I would like to create a Bash script that organizes my Drum Library. I would like to input the string 'kick' and have it recursively search a specified directory. It should find all directories within the directory with the string 'kick' and copy its contents to a separate directory. (Preferably emptying out the directory and not just copying the folder over). I am running on Mac Terminal and I have included the code I have come up with so far but It is not doing exactly what I would like. I think the problem lies in the line of code with 'find'
Also in the new directory I'm grouping the final files in new directories by 128.
#!/bin/bash
declare -i numFiles
declare -i numDirs
mkdir ./temp
ceildivide(){
local num
num=$1
echo $(( (num + 127) / 128 ))
}
find -E /Users/dot/Documents/_Sound\ Library/Drums\ \&\ Samples -regex ".*$1.*" -exec cp {} ./temp/ \;
numFiles=`ls ./temp | wc -l`
numDirs=$(ceildivide $numFiles)
for i in $(seq 1 $numDirs); do
mkdir $1_$i;
ls ./temp/ |head -n 128 > $1_$i/$1_$i.index
for x in `cat $1_$i/$1_$i.index`; do mv ./temp/$x $1_$i; done
done
rm -rf ./temp
I am trying to run some of my Go unit tests using "go test" but the test executable is built and run from my machine's %APPDATA%/local/temp directory. My PC has IT enforcement which blocks any unrecognized executable from being run other than from a pre-sanctioned directory (i.e C:/dev/projects"). All my Go source code are in that directory, including my *_test.go files. Is there a way to tell the Go test module to build and run from the current directory?
Yes you can.
Setting temp directory before executing the go test. By default temp directory environment variable gets evaluated in the order of TMP, TEMP, USERPROFILE, Windows directory; refer to msdn doc.
Basically it complies the go test under given temp directory and execute it.
C:\> cd dev\projects\src\mygotest
C:\dev\projects\src\mygotest>echo %CD%
C:\dev\projects\src\mygotest
C:\dev\projects\src\mygotest>set TMP=%CD%
C:\dev\projects\src\mygotest>go test -x
WORK=C:\dev\projects\src\mygotest\go-build306298926
mkdir -p $WORK\mygotest\_test\
mkdir -p $WORK\mygotest\_test\_obj_test\
cd C:\dev\projects\src\mygotest
"C:\\Go\\pkg\\tool\\windows_amd64\\compile.exe" -o "C:\\dev\\projects\\src\\mygotest\\go-build306298926\\mygotest\\_test\\mygotest.a" -trimpath "C:\\dev\\projects\\src\\mygotest\\go-build306298926" -p main -complete -buildid 86cb7a423d355c7468ad98c4f8bffe77b68d2265 -D _/C_/dev/projects/src/mygotest -I "C:\\dev\\projects\\src\\mygotest\\go-build306298926" -pack "C:\\dev\\projects\\src\\mygotest\\sample.go" "C:\\dev\\projects\\src\\mygotest\\sample_test.go"
cd $WORK\mygotest\_test
"C:\\Go\\pkg\\tool\\windows_amd64\\compile.exe" -o "C:\\dev\\projects\\src\\mygotest\\go-build306298926\\mygotest\\_test\\main.a" -trimpath "C:\\dev\\projects\\src\\mygotest\\go-build306298926" -p main -complete -D "" -I "C:\\dev\\projects\\src\\mygotest\\go-build306298926\\mygotest\\_test" -I "C:\\dev\\projects\\src\\mygotest\\go-build306298926" -pack "C:\\dev\\projects\\src\\mygotest\\go-build306298926\\mygotest\\_test\\_testmain.go"
cd .
"C:\\Go\\pkg\\tool\\windows_amd64\\link.exe" -o "C:\\dev\\projects\\src\\mygotest\\go-build306298926\\mygotest\\_test\\mygotest.test.exe" -L "C:\\dev\\projects\\src\\mygotest\\go-build306298926\\mygotest\\_test" -L "C:\\dev\\projects\\src\\mygotest\\go-build306298926" -w -extld=gcc -buildmode=exe "C:\\dev\\projects\\src\\mygotest\\go-build306298926\\mygotest\\_test\\main.a"
$WORK\mygotest\_test\mygotest.test.exe
Hello, playground
PASS
ok mygotest 0.526s
C:\dev\projects\src\mygotest>
Note: TMP set to current terminal session only, it doesn't affect system environment variable.
Important thing to note from above test output is WORK=C:\dev\projects\src\mygotest\go-build306298926.
Happy testing!
I'm using Makefiles for a Python project. There are some Python configuration variables that I need to include in every Makefile, and the Makefiles may reside in various subdirectories within the project's root (though not more than one level deep).
In the root of the project, I created a Makefile.inc with, for example, the following contents:
define PYSCRIPT
from lib.custommodule import VAR1
print(VAR1)
endef
VAR1 := $(shell python -c '$(PYSCRIPT)')
'custommodule' lives inside a Python lib directory root of the project, and all Makefiles at the top-level that include Makefile.inc execute without errors.
In 'subdirectory/Makefile', I have:
include ../Makefile.inc
echo $(VAR1)
When I cd subdirectory && make, I receive the error:
ImportError: No module named custommodule
I've tried prepending the Python path in 'Makefile.inc' (in the define PYSCRIPT block) to include the parent directory, thinking that 'subdirectory/Makefile' was executing '../Makefile.inc' in it's own path versus its parent path, but that didn't work either.
Am I missing something that's preventing this from working? Or is there a better way of achieving what I'm attempting to?
What about a Makefile.inc with:
ROOTDIR ?= .
define PYSCRIPT
from lib.custommodule import VAR1
print(VAR1)
endef
export PYSCRIPT
VAR1 := $(shell PYTHONPATH=$(ROOTDIR) python -c "$$PYSCRIPT")
and a subdirectory/Makefile with:
ROOTDIR = ..
include $(ROOTDIR)/Makefile.inc
all:
echo $(VAR1)
Not tested.
I am working on a project which requires the understanding of llvm compiler source-code. To browse source code of llvm, I tried to use cscope with following command in the root directory of the source:
cscope -R *
But it doesn't work. As there are mainly .cpp and .h files but some .c files are also there. So now I don't have a clue how to make cscope work? Can someone please help?
You can use following commands to do the required task from the root directory of llvm source tree:
touch tags.lst
find | grep "\.c$" >> tags.lst
find | grep "\.cpp$" >> tags.lst
find | grep "\.h$" >> tags.lst
cscope -i tags.lst
It would create cscope.out file which is used with cscope to browse the code. Hope it helps!
A convenient way to list all C++ files in a project is to use the ack tool: a grep-like command optimized for source code searching (In some distributions, for instance Ubuntu, the tool is called ack-grep). You can run it like this:
ack -f --cpp > cscope.files
The output are paths to all .cpp, .h, .cc .hpp files
Just because this is still the most popular entry. The stdin thingy may have been added in the meantime or not, but it makes it kind of elegant:
find -regex '.*\.\(c\|h\|cpp\|cxx\|hh\|hpp\|hxx\)$' | cscope -i- -b -q
I have following in my .bashrc which make things easier. Run cscope_build() to generate data base and cscope to start cscope tool.
# Use vim to edit files
export CSCOPE_EDITOR=`which vim`
# Generate cscope database
function cscope_build() {
# Generate a list of all source files starting from the current directory
# The -o means logical or
find . -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.h" -o -name "*.hh" -o -name "*.hpp" > cscope.files
# -q build fast but larger database
# -R search symbols recursively
# -b build the database only, don't fire cscope
# -i file that contains list of file paths to be processed
# This will generate a few cscope.* files
cscope -q -R -b -i cscope.files
# Temporary files, remove them
# rm -f cscope.files cscope.in.out cscope.po.out
echo "The cscope database is generated"
}
# -d don't build database, use kscope_generate explicitly
alias cscope="cscope -d"
To cover our large code base I have a script that looks a bit like this to build cscope indexes. The reason I change to / is so that I have full file paths to the source files which makes things work a little smoother.
cd /
find -L /home/adrianc/code -name "*.c" -o -name "*.cc" -o -name "*.h" > /home/adrianc/code/cscope.files
cd /home/adrianc/code
/usr/local/bin/cscope -b -icscope.files -q -u
Also it may be worth checking out
http://cscope.sourceforge.net/cscope_vim_tutorial.html