Configuration-specific resw resource string variants - visual-studio

Been trying to set up configuration-specific variants of resource .resw files in my project, so I could have have different resource string values in Debug and in Release (and in other configurations).
There are standard facilities in VS to have files conditionally included or excluded from build depending on selected Configuration. I have set up file properties to be Content=Yes and Excluded From Build=No for a file that must be included in a configuration, and the other way around for the other file.
The variants appear as expected in the IDE - only one matching current configuration is active, and another one is shown with Content=False in the Properties view, and with a red icon in the files list. The vcxproj also contains correct PRIResource nodes for .resw files with DeploymentContent and ExcludedFromBuild set:
<ItemGroup>
<PRIResource Include="Debug\Strings.resw">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">false</ExcludedFromBuild>
<DeploymentContent...
Building this project however fails with a message
error PRI277: 0xdef00532 - Conflicting values for resource 'resw
name/resource name'
Examining intermediate files reveals that both .resw variants are listed in resources.resfiles that is then fed into MakePri.exe . The ExcludedFromBuild setting appears to be ignored.
How would I get this to work? Is there a special way to control the inclusion of resw files? Maybe a different approach to having string variants altogether?

There are apparently "qualifiers" for organizing resource variants, and a naming scheme (https://learn.microsoft.com/en-us/windows/uwp/app-resources/tailor-resources-lang-scale-contrast). There is even a "Configuration" qualifier, though it is not entirely clear which configuration that is, and where at run time I am supposed to take an identifier to select a resource variant I want.
Adding this as an answer for the sake of completeness, as this is relevant and might even be useful to someone. But I am not happy with project configuration concerns being displaced to runtime, with unneeded and possibly sensitive values being added to the package. So I decided to force-emulate ExcludedFromBuild and am picking and copying the single .resw variant I need into build via a Custom Build Step. Shout out to whoever is responsible for this awkward mess at Microsoft.

Related

sonar-maven-plugin: How to use project-relative paths in inclusion patterns?

I have quite a large multi-module multi-language maven project (~100 modules in total), which I want to analyze using SonarQube and since the scanner doesn't automatically discover all files in all languages (i.e. not for Groovy and Kotlin), I have to tell it where to look for the files.
Most module contain the typical combination of a src/main/ and a src/test/ directory but not necessarily both, which makes it impossible to simply declare <sonar.sources>pom.xml,src/main/</sonar.sources> and <sonar.tests>src/test/</sonar.tests> as properties in the top level pom, since the missing directory causes maven to abort with an error.
According to https://stackoverflow.com/a/37545474 one possible solution to this problem is to
set ...
sonar.sources to be .
sonar.inclusions to be src/main/**
=> this will include all the known files that SQ finds in your modules in the src/main folder if it exists
and using just
<sonar.sources>.</sonar.sources>
<sonar.tests>.</sonar.tests>
<sonar.inclusions>pom.xml,src/main/**</sonar.inclusions>
<sonar.test.inclusions>src/test/**</sonar.test.inclusions>
in the top level pom indeed works as expected (all files, that are supposed to be analyzed, are found and no errors are reported because of missing directories) but it also causes the following warning, which shows up in SonarQube as well:
[WARNING] Specifying module-relative paths at project level in the property 'sonar.inclusions' is deprecated. To continue matching files like 'frontend/pom.xml', update this property so that patterns refer to project-relative paths.
All paths I tried so far either cause less files to be analyzed in total or result in an error because individual files would be indexed multiple times, due to non disjoint sets produced by the inclusion patters. Thus the question ...
How do I have to use the *.inclusions properties to get rid of the warning, while still analyzing all files in all submodules?
gresens,
I have the same problem using Jenkins pipeline. I resolved including the "projectBaseDir" parameter, like this:
<properties>
<sonar.projectBaseDir>.</sonar.projectBaseDir>
</properties>
Reference: https://community.sonarsource.com/t/relationship-between-projectbasedir-sources-and-exclusions/12785

How to keep CMake-QT generated MOCs in individual obj files?

Is it possible to have CMake-QT generate individual .obj files during AUTOMOC thus allowing for Whole Program Optimization during link time?
If yes - how?
TLDR - Pseudologic:
CMAKE_AUTOMOC ON => [mocs_compilation.obj != (moc_a.obj moc_b.obj)] => linker(one_instead_of_many.obj)? dependency missing : no dependency missing
Situation
When I set CMAKE_AUTOMOC ON in a Project, a file named mocs_compilation.cpp is created in the <project_name>_autogen folder which includes the AUTOMOCed files and thus creates one object instead of several individual files.
Why I think it is important?
Using Link Time Code Generation/Whole Program Optimization in Visual Studio 2015 our build (with custom moc-generation steps and individual .boj files) works without problems - possibly getting rid of unnecessary .obj files thus even eliminating a dependency to an extra LIB/DLL.
PS: By the way I really think there should be a cmake-qt tag if anyone cares to create one.
Seems it is a general issue with CMake:
https://gitlab.kitware.com/cmake/cmake/issues/17277

add only certain rules for sonar scanner instead of excluding

Instead of excluding or ignore rules in sonar's property file, I'd like to have only a few certain rules for sonar to analyse, so I don't need to exclude a large number of rules out of 344 rules for c++. How can I do that? (I'm not adding customized rules)
I imageine the syntax would be: (in .properties file)
sonar.issue.include.multicriteria=***
sonar.issue.include.multicriteria.***.ruleKey=cpp:S984
....
EDIT:
1, I need to configure this in a CLI environment.
2, It's about one project, two rule sets. one rule sets for local use and the other one for CI/CD use.
You need to craft a Quality Profile that contains only your rules of interest, and then either make it the default profile for C++, or explicitly assign your project to it.
BTW, correctly setting exclusions in properties (versus through the UI) is quite tricky. I'm not sure about the correctness of the ruleKey field name, and you're probably missing another field in there, but your syntax seems to be on the right track.

Expressions in a build rule "Output Files"?

Can you include expressions in the "Output Files" section of a build rule in Xcode? Eg:
$(DERIVED_FILE_DIR)$(echo "/dynamic/dir")/$(INPUT_FILE_BASE).m
Specifically, when translating Java files with j2objc, the resulting files are saved in subfolders, based on the java packages (eg. $(DERIVED_FILE_DIR)/com/google/Class.[hm]). This is without using --no-package-directories, which I can't use because of duplicate file names in different packages.
The issue is in Output Files, because Xcode doesn't know how to search for the output file at the correct location. The default location is $(DERIVED_FILE_DIR)/$(INPUT_FILE_BASE).m, but I need to perform a string substitution to insert the correct path. However any expression added as $(expression) gets ignored, as it was never there.
I also tried to export a variable from the custom script and use it in Output Files, but that doesn't work either because the Output Files are transformed into SCRIPT_OUTPUT_FILE_X before the custom script is ran.
Unfortunately, Xcode's build support is pretty primitive (compared to say, make, which is third-odd years older :-). One option to try is splitting the Java source, so that the two classes with the same names are in different sub-projects. If you then use different prefixes for each sub-project, the names will be disambiguated.
A more fragile, but maybe simpler approach is to define a separate rule for the one of the two classes, so that it can have a unique prefix assigned. Then add an early build phase to translate it before any other Java classes, so the rules don't overlap.
For me, the second alternative does work (Xcode 7.3.x) - to a point.
My rule is not for Java, but rather for Google Protobuf, and I tried to maintain the same hierarchy (like your Java package hierarchy) in the generated code as in the source .proto files. Indeed files (.pb.cc and .pb.h) were created as expected, with their hierarchies, inside the Build/Intermediates/myProject.build/Debug/DerivedSources directory.
However, Xcode usually knows to continue and compile the generated output into the current target - but that breaks as it only looks for files in the actual ${DERIVED_FILE} - not within sub-directories underneath.
Could you please explain better "Output Files are transformed into SCRIPT_OUTPUT_FILE_X" ? I do not understand.

Reference custom table in WiX fragment file

I want to create a fragment file that will only contain a CustomTable in the file. This is easy enough, but I do not know how to link/include it back into the main product.wxs file.
The fragment file is in the same project as the product file, and I have also tried adding an include tag for the file without success, and even putting the custom table into a WiX include file.
Is there a way to do this? Or is it going to have to live in the product file?
The WiX toolset compiles and links in a similar manner to the C/C++ compiler. The linker starts at the "main" entry point (Product element, in your case) then follows the references from there, which in turn follows references from there until all are resolved.
Part of your question is missing but based on the title I'm going to guess that you want a CustomTable element. Typically that CustomTable is processed by a CustomAction. There are a couple good ways to reference a CustomAction.
I would not use an include file.
You could try using EnsureTable if you'd like to make sure the table is created whether or not there is data in it. If you'd like to separate the custom table's schema definition from the data I believe you can just define them in separate fragments and reference the schema definition from the data definition fragment by opening with <CustomTable Id="your table name"> and defining the rows of data within it.
In general Wix won't pull fragments into the main authoring unless they contain elements that are referred to somewhere and since there is currently no such thing as CustomTableRef you may opt to use other elements such as an empty PayloadGroup or ComponentGroup that you can refer to (using a PayloadGroupRef or ComponentGroupRef respectively) from your main Bundle, Product or Module element as the case may be.

Resources