How to add conditional statements on android.bp - android-soong

I'm custom a module.
Android.bp
cc_binary{
name:"gzip",
default:["gzip_default"],
static_libs:[...]
}
Android.bp don't support if statement.
How I can make like this on android.bp?
If target_build a
cc_binary{
name:"gzip",
default:["gzip_default"],
static_libs:[...]
}
Endif
Please help. Thank you

What does target_build mean for you? Show example.
You just add this module in device tree configuration file as "PRODUCT_PACKAGES += gzip" or not whether you do not need this one.

Related

Can I use var(--my-color) in #if condition in scss?

I set a style property on body when the page loaded. Just like:
document
.getElementsByTagName("body")[0]
.style.setProperty("--is-app", isApp ? 1 : 2);
And in my .scss file, I write this:
$isApp: var(--is-app);
#if $isApp == 1 {
do something...
}
#else{
do something...
}
But it did't work as I want.
Is this because of that the scss is pre-processor not runtime one?
Finally I change it by using different class name.
But I wonder if I missed something in scss? Is it possible to make it work just by scss syntax?
Sass is compiled on the server before it's sent to the browser. When it's being compiled, there is no document and front-end javascript doesn't run, so --is-app isn't defined.

Dynamic Path is not working in require react native

Below is the code
require("index/components/" + name); //fails
require("index/components/myComponent"); //work fine
any good solution ?
Dynamic paths in require are not currently supported.
Please check this answer
This is covered in the documentation under the section "Static Resources":
The only allowed way to refer to an image in the bundle is to literally write require('name-of-the-asset') in the source.
You can use a switch statement to implement this.
I'm not sure about it but you can try to write it in ES6
require(`index/components/${name}`);

CodedUI TestCaseFilter

I'm using a CSV file as a DataSource in my CodedUI tests. The file looks like so:
Environment,URL
Live,www.example.com
Stage,stage.example.com
Test,test.example.com
I'd like to be able to setup my TestCaseFilter to selectively run the tests on only one of the environments when running the vstest.console.exe commandline. I can't seem to find any way to do that, i.e. it looks like the TestCaseFilter commandline parameter only supports specific properties. Am I wrong? Is there a way to pass a custom property to TestCaseFilter so that only the tests that pertain to a specific DataRow are executed?
The DataSource in my tests is setup like so:
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\environments.csv", "environments#csv", DataAccessMethod.Sequential)]
And I am referencing the environment in each test like so:
var url = TestContext.DataRow["URL"].ToString();
Thanks for any insight.
The simple and best way is to add another column next to the environment column in your testdata file. Say the column name is RunStatus. The values should either be 'Yes' or 'No', the logic is that the URL which has Runstatus as Yes should be included for the execution.
Before the TestMethod, have a condition to check the Runstatus of the row is Yes. If it's Yes, then Run the TestMethod.
[TestMethod]
public void RunTheTest(TestContext testcontext)
{
if(testcontext.DataRow["RunStatus"].ToString()=="Yes")
{
TestMethod1();
}
}
Hope it helps. Good luck !!

Xtext get the absolute path of the generated files

I want to access the file generated by Xtext to compile it automatically. So I need its absolute path. It's enough to get the absolute path of the current project at run-time. Any idea how I can get it?
I am working inside the "MyDslGenerator" Class. I tried to get it from the "resource" in
override void doGenerate(Resource resource, IFileSystemAccess fsa)
but couldn't find it.
Help is highly appreciated.
I ended up using this code:
var uri = (fsa as IFileSystemAccessExtension2).getURI(fileName)
maybe you can use the Interface org.eclipse.xtext.generator.IFileSystemAccessExtension2. the passed IFileSystemAccess may implement this interface too.

Jenkins: how to make parameters required in a parameterized build?

In Jenkins is there a plugin for parameterized builds to make the parameters required? The fields under the standard "This build is parameterized" option do not seem to provide that.
Clarification: by "required" I mean that the build will not execute until the field is populated with a value. This would obviously preclude automated triggers.
The accepted answer is no longer valid.
There was a plugin that did that but is no longer maintained.
There's an open bug to support it.
In the mean time what you can do is check if your parameter is present and if not throw an error like:
if (!params.SomeParam) {
error("Build failed because of this and that..")
}
This is the plugin i use to do this type of stuff: link...
You can set a regular expression to validate the input against
Couldn't comment to answer Miguel's question, so answering here:
To fail a build if a parameter is not set, one could do something like this:
stage('Checkout')
{
steps
{
checkout scm
script
{
if (params.myParam == '') { // and/or whatever condition you want
currentBuild.result = 'ABORTED'
error('myParam not set')
}
}
}
}
There's a plugin called "Validating String Parameter". When you install this plugin in your project, you see an additional option of Validating String Parameter while adding parameters. Using this option will show an additional column of Regular expression.
For non-empty string parameter write this inside Regular Expression field:
^(?!\s*$).+
This will finally make your string parameter mandatory.

Resources