scons Command function not working - scons

I am trying to use the Command function form my SConscript in SCons but with no success. When I create a new SConstruct out of my project and put the same lines in the SConstuct it works.
env = Environment()
testing1= env.Command(None,None,'ls -l')
AlwaysBuild(testing1)
I do not understand why the simple Command is not working from my project SConscript and outside it does.
The output from my project is:
scons: done reading SConscript files.
scons: Building targets ...
scons: Nothing to be done for `/myproject/SConscript'.
scons: done building targets.
Thanks in advance for your help.

SCons is a "build" system, so it expects you to have something like a "target" file/folder that you want to create (=build). If in your SConscript you would call the Command builder as:
env.Command("mydummy", None, 'ls -l')
(without the AlwaysBuild call), SCons would try to build "mydummy" by calling the command "ls -l". It would do this over and over again, because "ls -l" never creates the requested target file...unless you change the Action to "ls -l > mydummy", or the file exists already.

Related

how to fix "cannot open shared object file" in Cshell script?

I am working on Linux system and have a Fortran executable e.g. a.exe successfully run by directly execute. I want to execute this a.exe inside a Cshell script, but is always report error as "error while loading shared libraries: libnetcdff.so.6: cannot open shared object file: No such file or directory"
when I do 'ldd a.exe', it report me some dependency of libraries for this executables.
libnetcdff.so.6 => /met5/ZR_LOCAL_LIBS/lib/libnetcdff.so.6 (0x00002ab536656000)
The library did existed, and I also have the path set as $LD_LIBRARY_PATH
the a.exe need two inputs $INFILE1, $INFILE2 and will generate the output at $OUTPUT
it can be executed by hand typing ./a.exe and providing the path of $INFILE1 and $INFILE2, however, when I write a simple Cshell script as the form:
#!/bin/csh
#
setenv BASE $PWD
setenv PROGNAME a.exe
cd $BASE
setenv INFILE1 $BASE/agtsc_ave_2017.nc
setenv INFILE2 $BASE/agtsc_ave_2029.nc
setenv OUTFILE $BASE/emis_pct_2029_relative_to_2017.nc
if ( -e $OUTFILE ) rm -f $OUTFILE
$BASE/$PROGNAME
it will report the error as:
a.exe: error while loading shared libraries: libnetcdff.so.6: cannot open shared object file: No such file or directory
I have no idea how to debug through this. Can anyone help me to fix it? Thanks a lot!
I think I found the problem. I use other people's .cshrc, so there is a $path issue causing the shell script can not find the corresponding libraries. I delete the older .cshrc file and create a new one based on my condition, the problem is gone. Thanks.

bash script uses gcc in a loop to compile all

I need write bash script that uses gcc in a loop to compile all .c source files in current directory into .o object files, and additionally creates .s assembly listings in Intel format. Then, the .o files are linked into run executable.
for i in *
do
gcc -type -f "*.c"
done
i just began that but I'm not sure I began it correctly
Rather them writing a bash script, it's acutally better to write a makefile which is specialised in automatizing this kind of things.

How to run .cc extension file in linux?

I have main.cc file and i would like to run this file in linux. May i know what would be the correct way of executing this file ? Is it
gcc -o x main.cc
? Any help or feedback is appreciated.
In your case it would be gcc main.cc -o main.ou where main.cc is your main-file and main.ou your output file.
You can also read more about executing c/c++ files here:
http://www.cyberciti.biz/faq/compiling-c-program-and-creating-executable-file/
The command you gave will compile the file. The resulting executable is put in x. To run it, you do:
./x

Using .sh file to compile commands in source code

I am using FORTRAN to solve partial differentiate equations. Main program and subroutines have been put in .f file. And I got a .sh file to compile the commands in source code in linux operating system. This file has been attached. But I failed to run this. After struggling for a week, I really need some help on this. Please any help would be greatly appreciated!!!
#!/bin/bash
#
mkdir temp
cd temp
rm *
~/binc/$ARCH/f77split ../fishpack.f
#
for FILE in `ls -1 *.f`;
do
gfortran -c -g $FILE >& compiler.txt
if [ $? -ne 0 ]; then
echo "Errors compiling " $FILE
exit
fi
rm compiler.txt
done
rm *.f
#
ar qc libfishpack.a *.o
rm *.o
#
mv libfishpack.a ~/libf77/$ARCH
cd ..
rmdir temp
#
echo "Library installed as ~/libf77/$ARCH/libfishpack.a."
This looks like the shell script is simply trying to compile a fortran file, but instead of using gfortran's internal toolchain, it is compiling parts manually then linking them together. I have a feeling (though I haven't confirmed) that the call to the program ar is bad, even if it got that far (I'm guessing it should be ar -qc instead of ar qc.).
Anyway, if all the source is in a single fortran file that someone else gave you (fishpack.f), you might be able to compile the whole thing with a single call to gfortran:
gfortran fishpack.f
It should create (by default) an output executable with a filename a.out. If the fortran code is not structured such that it can be lumped into a single file, you may need to work on separating some things out (--as well as updating to at least f90, though that's an aside--).
Good luck.

wildcard doesnot work for a new generated folder

I am trying to get a .tar.gz file name from a new generated folder (one step above).
I tried to use wildcard , but with no luck,
In my makefile, I tried:
...
...
...
other parts
...
deb:
python setup.py sdist --- this step will generate a new folder called dist
cd dist; ls -l --- from here, I see the file is shown.
echo $(wildcard dist/*.tar.gz) (also tried dist/pylink*.tar.gz, dist/*.gz) --fails!
I run it with make -f makefile deb.
I always got nothing from wildcard
But if I leave the folder generated by python, and rerun the file above, I can see the file name is written to the console. Anyone knows why? How should I do to get the file name? I need to use the filename and extend the filename to another one.
many many thanks!
You don't say so explicitly but I assume that, because you're using $(wildcard ...), the lines you provide are part of a GNU make makefile rule. It's best to provide a working example, when asking for help, not just a small bit of one.
The problem you're having is that make expands ALL variables and functions in ALL lines of the recipe, before it starts the first line of the recipe. So even though the $(wildcard ...) doesn't appear until the third line of the recipe, it's expanded before the first line is run. When the $(wildcard ...) function runs, those files don't yet exist so it expands to nothing.
Why don't you just use the shell globbing, since you're in a shell anyway?
python setup.py sdist
cd dist; ls -l
echo dist/*.tar.gz

Resources