What's the best Pigweed variable to check against in a debug build? - pigweed

In the Cortex-M toolchain I'm trying to do something like this:
config("sf2_bootloader") {
if (debug_build != "") {
defines = ["SF2_MSS_NO_BOOTLOADER=1"]
}
}
Does Pigweed have a variable like debug_build?

Pigweed doesn't provide a Pigweed macro.
You can add a define to a config, and then list it in default_configs for your debug toolchain/target to set one up.
There's a few modules that check against NDEBUG, but Pigweed doesn't provide a "debug build" that defines it.
Source: https://discord.com/channels/691686718377558037/691686718377558040/955856186748592178

Related

How can I read a property from the command line and use it in my Gradle build.gradle.kts?

Sorry if this is obvious, I'm new to Gradle and I'd like to include the latest git commit tag in my builds.
So far I have this task that simply outputs the string I want to save.
tasks.register<Exec>("get-git-latest") {
executable("git")
args("log", "--oneline", "-1", "--format=format:%h", ".")
}
Ideally I'd like to get this output into a variable that can be reused by other Gradle tasks, what is the best way to do this with Kotlin DSL? Any suggestions are welcome.
Upon revisitng the question that #aSemy linked, I was able to get the value into a variable in my Kotlin DSL like so:
val gitLatestCommit: String = ByteArrayOutputStream().use { outputStream ->
project.exec {
executable("git")
args("log", "--oneline", "-1", "--format=format:%h", ".")
standardOutput = outputStream
}
outputStream.toString()
}
I still need to figure out how to inject this into certain property files, but this is a great start. Thank You.

Checking that Gradle system properties have been set

The Question
How do I check to see if a System property has been properly set from within a build.gradle file?
The Situation
I have a gradle.properties file in my root directory that looks something like this:
systemProp.user=exampleUsername
systemProp.password=examplePassword
I would like to validate the existence of these properties, something like:
if (!System.hasProperty('user')) {
throw new InvalidUserDataException("No user found in `gradle.properties`; please set one.")
}
Some Code
I've tried the following:
project.hasProperty('user') returns false
System.properties.get('user') returns exampleUsername
System.hasProperty('user') returns null
System.properties.get('user') == true returns true for non-falsey
values
You can use System.properties.containsKey('your_property') for your purpose. It returns true if a property with the provided key exists, false otherwise. An implementation of this could look like the following:
if (!System.properties.containsKey('user')) {
throw new InvalidUserDataException("No user found in `gradle.properties`; please set one.")
}

How to create local variables at runtime for any keyword test in TestComplete

I need to create a set of local variables at the beginning of a Keyword test and then use them later while executing the Test.
Is there any possibility to create local variables dynamically as like project variables which can be created dynamically.
Project.variables.<variable_name> = "project_variable_value"
in the similar fashion can we create any variable associated to any keyword test
Keywordtests.<generic_keyword_test_name>.variables.<variable_name> = "local_variable_value"
Sure, you can do this. Please see this example:
function Test11()
{
if (KeywordTests.Test1.Variables.VariableExists("MyVariable") == false) {
KeywordTests.Test1.Variables.AddVariable("MyVariable", "String");
}
KeywordTests.Test1.Variables.MyVariable = "test value";
Log.Message(KeywordTests.Test1.Variables.MyVariable);
}
Information on the AddVariable method can be found in the AddVariable Method help topic.

puppet variables overriding fails

I am a newbie on puppet and met some issues as subject, googled for some time but failed with an matched answer. Mys issues is as:
I defined global variables $puppetserver in /etc/puppet/manifests/site.pp as below:
case $domain {
/domain2/:{
$puppetserver = "puppetserver2"
include migrate
}
default:{
$puppetserver = "puppetserver3"
}
}
in node definition of the servers in domain2 in manifests/labs/domain2/nodes.pp
node 'server1.domain2.com' {
$puppetserver = "puppetserver3"
}
the migrate module is used for puppet migration, got from internet as below:
in /etc/puppet/modules/migrate/manifests/config.pp
class migrate::config {
if $puppetserver == undef {
fail('You must define the targeted Puppet master to perform the migration')
}
augeas { 'puppet.conf.migrate':
context => '/files/etc/puppet/puppet.conf/main',
changes => [
"set server $puppetserver",
]
}
}
Since the node 'server1.domain2.com' can match the domain2 setting in site.pp, so it applies the migrate module,what I expected is: it should get the 'puppetserver3' for $puppetserver defined in node block and then be updated in '/etc/puppet/puppet.conf' by the Augeas, but actual result is : it use 'puppetserver2' which was defined in site.pp. I cannot figure out why overriding is not working. Can you kindly help to check what's wrong?
And as a test:
When I tried to move the 'include migrate' module from site.pp to node 'server1.domain2.com' {} block of nodes.pp, it can work as expected.
it seems some order when puppet applying manifests, but what I got is that local scope variables will always overrides the variables, is that correct?
Thanks a lot for your kindly help.
When you include a class at top scope as you do, no node block is in scope during its evaluation. That's a good reason to avoid such shenanigans.
Put the include statement inside the node block, use an ENC to designate the class for inclusion, or maybe use hiera_include() inside your node block to include it indirectly. Alternatively, use hiera at top scope to set the correct value for the $puppetserver variable, and thereby take variable shadowing out of the picture.

custom war tasks and applying custom resources within Gradle

i want to have dynamic WAR tasks based on customer configuration. I created an array with the configuration names and tried to apply custom behavior as so:
ext.customerBuilds = ['customer1', 'customer2', 'customer3']
ext.customerBuilds.eachWithIndex() {
obj, i ->
task "dist_${obj}" (type:War) << {
from "etc/customers/${obj}/deploy"
println "I'm task number $i"
}
};
This creates my three tasks like dist_customer1, etc. Now i want that gradle uses the normal resources under src/main/webapp AND also my customer based ones under etc/customers/XXXX/deploy as stated in the from property.
But it doesnt pick up any file in this folder.
What i am doing wrong here? Thanks.
when setting up your War task ensure you don't accidently use the '<<' notation.
'<<' is just a shortcut for 'Task#doLast'. so instead do:
ext.customerBuilds = ['customer1', 'customer2', 'customer3']
ext.customerBuilds.eachWithIndex() { obj, i ->
task("dist_${obj}", type:War){
from "etc/customers/${obj}/deploy"
println "I'm task number $i"
}
};
You can just add more from statements to pickup stuff from 'src/main/webapp'.

Resources