How do I call a theme function from Drush command? - drupal-8

I would like to use a function defined in (active) custom theme (i.e. mytheme.theme) in a Drush command which is defined in a custom module, but it does not seem to be available and I cannot find a way to access it.
Can this be done, and how?

Related

Visual Studio environmant variable not recognized by C++ stdlib getenv

I have a C++ project on windows, on which I use the getenv method from stdlib to get the value of an environment variable $MyVar
When I set the variable MyVar in a cmd and then call my program in the command line, everything works.
But when I call it from Visual Studio (2012), the program see $MyVar as unset.
To try and set it in Visual Studio I have tried to use a Property Sheet to define a macro MyVar as an environment variable (cf. image below) but the getenv method from stdlib doesn't see it.
Screenshot of the window where I tried to define the env variable in Visual Studio
Is there a way to define my environment variable in Visual Studio in a way that the getenv method from stdlib would recognize it ?
Thank you all in advance for your help
EDIT :
I know that the getenv method would recognize MyVar if I defined it as a global env variable, but that is not a solution for me because I want to be able to launch several instances of my program at the same time with different values for MyVar.
I need a way to define a local env variable in Visual Studio that would be recognized by my program when I launch it from Visual Studio.
The thing is: there are different environments, so once you create a var in one env it doesn't appear at others.
1) Once you create cmd session, OS creates a dedicated environment for it. So, once you create a var in the prompt any app launched in this cmd would be able to see that var. Once you kill that cmd all the vars are gone too.
2) If you need global change of environment vars, you have to visit "Advanced System Settings" dialog (Control Panel\System and Security\System) then click "Environment variables" button and do your edits. Note: you may need to restart child sessions to let them see a change in global env vars.
After latest updates described by you, I would advise to use command-line arguments instead of (or accompanied with) environment level vars. They're instance-specific, easy-to-implement etc.
And, more important, they're stateless.

Using Environment Variables in a TFS2015 build

I am trying to set up an API-key to be a global variable that is accessible across all of my TFS2015 Builds. Since TFS2015 seems to lack this feature, I am attempting to use a system environment variable on the build server that is then referenced in the build definitions.
According to Microsoft's documentation, this should be possible. So I have set up a system variable (call it APIKey) on the build server and referenced it within the arguments of a build step using the standard syntax (i.e. "ApiKey=$(APIKey)"). However, instead of replacing the variable with the API-key in the system variable it is trying to use $(APIKey) as the value and causing the build to fail.
It also occurred to me that this custom environment variable would instead be set somewhere in the build agent folder itself but, after some poking around, I'm not sure where or how I would do that.
Are either of these things actually doable?
Following are my steps to achieve this:
Create a system variable on build agent machine:
Restart the build agent machine.
Use the variable in build definition. Here I use cmd task as an example and use the $(testvar) as its argument:
The task will read the value from system variable as following:

How to create a python 2.7 environment variable?

I have multiple versions of python installed so I wanted to create a command for each of them. I created the variable "python27" as both a user and system variable with the path "C:\Python27" and also tried "C:\Python27\python.exe". In both cases cmd says 'python27' is not recognized as an internal or external command.
My batch file is simply "python27 path_to_py_file".
You need to create a batch file for this. For example:
#C:\Python27\python.exe %*
Save this as python27.bat in a directory referenced by the PATH environment variable and you are good to go.

Change Eclipse Dynamic Variable to build a single c++ class

I would like to change the dynamic variable ${selected_resource_loc} such that I get rid of the extension (and can add another one).
The purpose is to build the current selected file, but therefore I don't need the .cc-file in my command but the .o-file with the same name.
Detailed description:
I have a customized make command (lets say make) and would like to execute make selectedFileName.o, where the current selected file in eclipse is selectedFileName.cc. (I put the command as build command in project properties -> C/C++ Build.) With variable ${selected_resource_loc} in behaviour tab I get make selectedFileName.cc.
I solved my problem by writing a skript where I modify the ${selected_resource_loc} and included it via external tools in eclipse.

Is it possible to pass in command line variables to a bitbake build?

I have an OpenEmbedded environment using bitbake to do some builds. I wanted to get something "interactive" going on where bitbake would pause and ask for input then continue with the build but I've found out that's not possible.
Since I can't do that I'm looking for some way to pass in extra flags for the build. Is there any way to pass in flags to a bitbake build sort of like gcc's -D option?
ie:
bitbake -Dfoo=bar oe-myimage
Thus during the build process of oe-myimage the variable foo will be set to bar.
bitbake -Dfoo=bar oe-myimage
-D flag is not recognized by bitbake. So, using above method will not work. Instead you could specify flags from command line using following steps -
Say you want to export variable foo and expect it be recognized by bitbake.
export foo="foobar"
You will need to export this and inform bitbake via BB_ENV_EXTRAWHITE variable after sourcing oe-init-build-env. This means
. oe-init-build-env
export foo="foobar"
export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE foo"
This whitelists variable 'foo' for bitbake and thus makes it visible to any recipe and subprocess during the build.
After this you can invoke any bitbake operations using variable foo within bitbake via expressions like -
${foo}
While there is nothing wrong with the other answers bitbake does accept a --postread argument as documented here. That means that you can write as many bitbake variables as you want to some temporary configuration file and have it read after bitbake.conf by specifying the name of the file on the command-line. For example:
bitbake --postread=./extra.conf
I personally find this more convenient than dealing with environment variables.
There's also a convenient command-line way to do this, that's described in the bitbake manual using BB_ORIGENV:
Sometimes, it is useful to be able to obtain information from the original execution environment. Bitbake saves a copy of the original environment into a special variable named BB_ORIGENV.
To do so, you could read a variable exactly as they suggest (from a Python function):
origenv = d.getVar("BB_ORIGENV", False)
bar = origenv.getVar("BAR", False)
Then, the way to pass that from the command line is simply:
BAR=somevalue bitbake myimage
you can do:
export foo="bar"
export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE foo"
bitbake oe-myimage
No, I don't believe such a mechanism exists. But you could do something like
"echo "foo = \"bar\"" >local.conf
Not sure that will solve your particular problem or not. Also, there is a mechanism for local site-wide variables: if you have a 'site.conf' file in your home directory under a directory called .oe, bitbake will read that and apply those variables to the global environment for every build. Maybe that would help? You didn't specify exactly what problem you are trying to solve, there might be better ways.