Command Substitution with Android.mk - bash

I have come across the command in an Android.mk file that I am working with:
include $(DEPENDENCIES_NANOBUFFERS_DIR)/android/jni/include.mk
I understand that $(command) is "command substitution". It runs a command, captures it's output, and inserts that into the command line that contains $( )
However I've searched the entire Android.mk file to find what the command DEPENDENCIES_NANOBUFFERS_DIR stands for and I haven't found any meaning for it.
I know that NANOBUFFERS is a file in my dependencies directory, since I manually searched through all the files contained in my root directory. The is a file named dependencies and within this file is my NANOBUFFERS file. However if DEPENDENCIES_NANOBUFFERS_DIR is not specified explicitly how is the compiler able to find the correct pathway to include.mk? Is this done automatically?
DEPENDENCIES_NANOBUFFERS_DIR occurs in only one other place and that is at the bottom of the Android.mk file.
$(call import-add-path,$(DEPENDENCIES_NANOBUFFERS_DIR)/..)
Can someone please explain how the compiler interprets DEPENDENCIES_NANOBUFFERS_DIR even when this command isn't specfied anywhere in the Android.mk file? Thank you in advance.

This following code links to another Android.mk file which is in a different file which is in a different module
include $(DIFFERENT_DIR)/buildtool/android_common.mk
Within this android_common.mk the variable DEPENDENCIES_NANOBUFFERS_DIR is assigned it's pathway

Related

solving Can't open perl script "all_gen_cmf_image": No such file or directory error

i work on image copy move forgery detection field. i downloaded GRIP dataset form https://www.grip.unina.it/, there is some modification needed for the images and can be done with perl functions downloaded with the dataset. it is the first time for me to work with .pl functions. i downloaded the program form this website https://platform.activestate.com/create-project?language=perl, and followed the setup steps.
now i have two problems: the first one, when i tried to run the function this error appeared "Can't open perl script "all_gen_cmf_image": No such file or directory", i have added the scripts directory using cd.
the second problem i don't know what he mean with this line "update the "vole" variable in the configuration file db_configs.pl, it should point to your vole binary of CMFD framework." in reedme file.
can any one helping me solving this problem?
Perl doesn't automatically try the .pl extension when you pass it the name of a script on the command line.[1] So, it fails because there isn't a script named "all_gen_cmf_image"; it's actually named "all_gen_cmf_image.pl". To run all_gen_cmf_image.pl you have to include the .pl part of the extension. Assuming you are in the scripts folder, the following should work:
perl all_gen_cmf_image.pl
or in the parent directory:
perl scripts/all_gen_cmf_image.pl
However, when Perl runs a use Module; statement, perl automatically adds .pm on the end and replaces any :: in the module name with a slash.

create requirement.txt file for virtualenv using Makefile not working

I'm trying to setup a makefile to create a virtual environment using Make in Windows.
I want to create an empty requirement.txt file from within the Makefile. This file shall be filled later with pip-package names.
The Code to create the empty file in windows looks like this:
build/requirements.txt:
echo >> //C:\Users\xxx\environments\venv\homepage\requirement.txt
When I run the Makefile no file is created. But when I use the command in Powershell directly, it creates the requirements.txt file.
I suppose it has something to do with Escaping the command. but I couldnt find any hint how to do this.
Has anyone an Idea, why the file is not created from the Makefile?
Merci A
I found out, that the syntax must be like that:
build/requirements.txt:
type nul >> environments/venv/homepage/requirements.txt
The reason is, that Make writes to the $USER folder as standard. So that is the starting point for any PATH used here.

Cmake add_custom_command misunderstanding

I'm learning CMake and struggling with learning the: add_custom_command function.
I'm sorry if this is a basic question but the online documentation didn't help me much.
For this snippet:
add_executable (creator creator.cpp)
get_target_property (creator EXE_LOC LOCATION) # get creator.cpp location
add_custom_command(
OUTPUT ./created.cpp # creates 'created.cpp' at the specified path
DEPENDS creator # specifies files on which the command depends
COMMAND ${EXE_LOC} # executes this command
ARGS ./created.cpp
)
add_executable(FOO ./created.c)
I can intuitively realise what's going on there, however, I do not understand why each instruction from the body of add_custom_command is needed. Here is how I understand it (please correct me where I'm wrong):
Executable creator is created in the current working dir using creator.cpp
EXE_LOC variable is used to store the path of the created executable
add_custom_command:
OUTPUT specifies that a created.cpp file will be created in the current
working directory.
DEPENDS: specifies that this newly created .cpp file depends on the
previously created executable. But why do we need to specify this? Is it
mandatory to do so and if not what happens if I don't specify this
COMMAND: ${EXE_LOC}: This I don't understand. I assume when the script
reaches this point some sort of command will be executed. But what exactly is going to get executed here? ./creator maybe? The documentation specifies that:
If COMMAND specifies an executable target (created by ADD_EXECUTABLE) it will automatically be replaced by the location of the executable created at build time.
But I don't really understand this.
ARGS: I don't understand what this is supposed to do and why do we need it.
It really confuses me that we pass the newly created file as an argument to a command whose purpose is to create that particular file.
Please clear this for me if possible.
Thank you for reading my long post.
It is convinient to think about COMMAND option as a command line:
First, you need to type the path to the program to be executed. In given case it is a path to creator executable. Then, you type arguments for given command. In given case, the only argument is a path to the created.cpp file. This is what will be executed:
<path-to-creator-executable> <path-to-cpp-file>
Option
DEPENDS creator
in given case is perfectly described in CMake documentation for add_custom_command:
If DEPENDS specifies any target (created by the add_custom_target(), add_executable(), or add_library() command) a target-level dependency is created to make sure the target is built before any target using this custom command. Additionally, if the target is an executable or library a file-level dependency is created to cause the custom command to re-run whenever the target is recompiled.
In short, this means that before creator executable will be run as specified in the COMMAND option, the executable will be created and updated if needed.

Compiling PDCurses into ".a", error with mingw command

I'm following this tutorial: https://www.youtube.com/watch?v=mYnfix8ruAo
for compiling PDCurses and linking it to a CodeBlocks project, but I keep getting an error ('mingw32-make' is not recognized as an internal or external command, operable program or batch file.)
The thing is, I definitely have mingw installed properly, and have a path pointing to it in the system environment variables.
http://puu.sh/id6nC/3ab670cbdc.png
In the terminal, I tried the command twice without specifying a target file to make sure it's recognized, and it is. It's not until after I get to the point that I want to build the library that it stops recognizing it as a command for some reason. I'd really appreciate any help.
This isn't a PDCurses issue, it's a PATH issue. The PATH is an environment variable that the command-line shell uses to locate the executables you type as commands, if they aren't in the current directory, or shell built-ins. It's a list of directories, separated by semi-colons. Each directory is checked in turn, until a match is found.
Specifcally, your problem is this line:
path=c:\CodeBlocks\mingw\bin
Apparently, mingw32-make is not in that location. But, since it was found without that line, you clearly don't need the line -- at least not for that. So, just take it out.
Now, if it later turns out that you do need to add \CodeBlocks\mingw\bin to your PATH for some other reason, then the way to do it is like this:
path=%PATH%;c:\CodeBlocks\mingw\bin
This appends your new path to the existing PATH, instead of wiping out the existing PATH and replacing it with that directory alone.

Using Script to Execute C File in Different Directory

I am new to C, so apologies if this is a naive question. I have been given a script to execute C programs. The first line has the format:
./directory_name program_name program_parameter_1 program_parameter_2
When I execute the script from a different directory I get the following error:
No such file or directory.
When I execute the script from the named directory, I get a different type of error:
directory_name is a directory.
Does someone know what the script file is trying to accomplish?
I have read about commands that change directories through script files, but they don't seem to have this format (i.e. directory name following ./), so I am confused.
Thanks!
If the script is presenting a different behavior depending on the directory you are running it, that means the code inside the file is referencing some dependency that is mapped from a specific location.
Why don't you check the source and learn more about what the script is doing?
Are you confused about "./"? That's how you execute a script, you don't have to worry about what kind of interpreter will process this code, that's defined in the shebang (#!).
You can read more about it here:
http://en.wikibooks.org/wiki/C_Shell_Scripting/Hello

Resources