Uno-Platform: Cross Platform Library, #if conditional for WASM? - uno-platform

In pre 4.0 Uno-Platform, I was able to use the #if __WASM__ compiler directive for WebAssembly specific code in a cross platform class library. This was very useful for creating WASM specific widgets using the WASM specific SetHtmlAttribute method.
However, in version 4.0 Uno-Platform, my code isn't building because the compiler isn't finding the __WASM__ constant. I hesitate adding it manually to the libraries *.csproj file ...
<DefineConstants Condition="$(TargetFramework.StartsWith('netstandard'))">__WASM__;$(DefineConstants);</DefineConstants>
... because I'm afraid it will build if the target is WPF. So, is there a better approach?

While your approach covers the scenario where a given API is available on all Uno targets, it will not work in case it really is WASM or Skia specific, unfortunately. For those cases though we have another type of library - cross-runtime library (see docs). Currently this kind of library can only be created via dotnet command-line tooling:
dotnet new unolib-crossruntime -o MyCrossRuntimeLibrary
By default it generates the following solution layout:
Both projects are pointing to the same source-code files, however the ".Wasm" one is specifically referencing the WebAssembly runtime and will correctly adhere to #if __WASM__ declarations. Similarly you could create another project for ".Skia" to have Skia-specific declarations.

Doh! I don't know why I had not noticed this before! Looks like SetHtmlAttribute is implemented on all Uno target platforms! So, rather than using the #if __WASM__ compiler directive, I can use #if !WINDOWS_UWP and implemented my WASM code knowing it will be ignored on the other Uno target platforms.
Very clever, Uno Team!

Related

ModelSim LAttice FPGA edition and library file inclusion

This might seem a rhetorical question but is there a way to "include" by default the desired search path or actual library(ies) in the active work project library that instantiates other modules in precompiled libraries ?
I have looked in the provided **ModelSim **user guide and it is not mentioned anywhere how this might be achieved by a simple `include or otherwise preference setting for the **work **project ....
When starting a simulation, it looks like for the moment, the only way to include an external library that contains precompiled components modules instantiated in my verilog code is by specifying the library in the Libraries pane under the -Lf options like shown below. This then compiles and starts the simulation correctly, having resolved all external module references being instantiated in my project.
[Start Simulation ...](https://i.stack.imgur.com/8ER4b.jpg)
This works as is, but I would prefer not having to do this every time I start a simulation session, and especially if I happen to be working with the same project and associated external libraries for an extended period, and I keep restarting simulation sesions etc.
I cannot see how this is done like it is on most other type of compilers with an #include directive or similar ? Can anybody suggest an easy way this is done either by a `include directive or by some default path preference settings for my default "work" library project ?
Thanks in advance for your suggestions...
PS : I did read the User Guide and followed the most basic instructions to get the project to compile and to simulate. I was expecting a more conventional and simplified means to include external libraries into the default "work" project, other than to keep having to re-enter the "ice_vlg" -Lf option every session.

How to Blazor compile multi file c code to wasm

THe blazor docs show a trivial example https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-native-dependencies?view=aspnetcore-6.0 where the c code is in one file. I made my own version of that and got it to work, but now I want to compile something that has multiple files, has non trivial source tree structure, makefile etc.
You have to use Emscripten (version 2.0.23) to compile all dependencies to wasm, and then link them, which is the tool that NET also uses to compile your C source.
Emscripten supports make & cmake so you can change the make files to use emcc instead and rebuild the project.
Im also asking about similar issue but more library specific, perhaps the sources there can provide you with some help.

Include SASS compiler in build definition in Visual Studio? (and avoid merging the CSS files when using TFS)

We plan on using SASS instead of plain CSS for our SharePoint project very soon. While testing and trying to set everything up, I ran into some problems:
We're using Visual Studio 2015 and on my developer machine I installed the Web Compiler Extension to compile the .scss-files and partial files to a regular .css-file.
That worked very nicely but the problem is, that there will be a few developers working simultaneously on the styles. I want to avoid merging the resulting css-file each time someone tries to check in something into source control (we're using Team Foundation Server).
Since there is a build running every time someone is checking in their changes, and to deploy the resulting solution to the nightly build machine, the idea was to somehow include the SASS compiler in the build definition. This way the more readable scss-files get merged and the build creates the resulting css-file to include it in the solution.
Maybe I'm thinking too complicated, but I just couldn't get that to work so far.
Any ideas how I can achieve that?
(Maybe I should also mention that none of the dev machines got any internet connection)
If you're building an MVC app, you can use MVC's bundling feature along with the SASS NuGet package. And, be sure to enable minification. There's a UseNativeMinification property on SassAndScssSettings. That way you don't need to deal with merging the css file when you get latest or check in. Reference this thread: SASS/TFS best practice
Another way is running a script (e.g with PowerShell task) on the server that to install the gulp components and then call the sass compile task to compile the SASS. Refer to Powershell build - compiling SASS for details.

Stuck with creating Keyword library using Java in Eclipse and using that JAR file in RIDE

I'm new to ROBOT framework and must create library keyword using java and utilize the JAR files in RIDE editor. I have followed the below steps. But still have confusions in where to start up. Please help me to achieve this.
Steps:
1) Installed Python, wxPython, pybot, RIDE, selenium2library successfully and I'm able to work with RIDE using predefined keywords.
2) For creating own java library, Installed Eclipse Mars, Java, ROBOT IDE manually using the link https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Installation
The question here is,
Anything i'm missing to install?
How to proceed further with Robot Framework coding?
Note: I'm reading many materials in parts to proceed things. But that is confusing me what are the steps to be followed. Is there any single material that i can get having the sequences of steps that need to be followed for my requirements?
The below links I referred with,
https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Usage
Maven error "Failure to transfer..."
Create a Maven project in Eclipse complains "Could not resolve archetype"
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-set-test-suite-global-variable-keywords
Let's start with the basics. RIDE is an editor for Robot Script files. Robot Script files are executed by the Robot Framework robot application. It is important to understand the difference between these two applications. One creates files and the other uses them.
Assuming for a moment here that you have some custom functionality in a Jar file that you would like to make available inside the Robot Script files test cases. If this is indeed the case then your focus should be on create Robot Test Libraries. In the documentation there are numerous java examples given for basing your own library on.
This means that you do not need Maven, unless you want to, to create your library. Also Eclipse IDE is not needed nor is RIDE. The library you create can be used by Robot Framework even when it's run from the command line. Feel free to use them for what they are good at: writing Robot Scripts efficiently and running Robot through menu options instead of command line windows.
When you are familiar with Eclipse and comfortable with it's features, then I can also recommend using the Eclipse Application RED which is a mature Eclipse add on for creating, running and debugging Robot scripts.
There are two ways of implementing a Java routine in Robot Framework and it depends a bit on how you run Robot Framework: Python or Jython. Running Python means that you need to run the Java in a separate JVM container and connect to it. The simplest way is via Command Line interaction. This may cause some security concerns. The second approach is to use the Remote Library approach. A good example of this is the Robot Framework Sikuli Library. An added bonus is that you can run Robot and your Java application on two separate machines/servers.
The Jython way has been discussed on StackOverflow before and I gladly refer to it. Please bear in mind that although the examples refer to RIDE, the Library org.company.Keywordlibrary works in all IDE's, provided robot framework is run using Jython.
In the Jython documentation it clearly explains how to setup an Eclipse based IDE with Jython. Do keep in mind that it's recommended to use the same interpreter in development and production. I.e. if you create your scripts in Jython, do run them in 'production' also using Jython. Otherwise you open yourself up to interpreter differences where functionality does not work or behaves differently then expected.
An alternative approach with Jython is the all-in-one Robot Framework Maven JAR plugin. Adding a custom Java Library in this setup is not too difficult. A nice short tutorial can be found on the blog of Valerio Bruno. If this is your preferred route for development, then you may want to read the RED howto on integrating the Robot Framework Maven jar.
Working on your custom functionality is likely going to be a independent project in Eclipse, but can be linked to an Robot project via the Class Path settings in red.xml if you use RED or the CLASS_PATH environment variable.
Done! I have installed RED and required add on using following below steps. It worked successfully with predefined keywords. Now I'm gonna create user defined keywords/libraries using the same editor. I don't know where to start up. Will it work creating just a java project? Should I need to include any additional libraries?
Steps followed to proceed with RED:
1. RED Version Conclusion: https://github.com/nokia/RED/blob/master/release.md
2. RED Installation Instructions: https://github.com/nokia/RED/blob/master/installation.md
3. ROBOT Framework prerequisites using RED: https://github.com/nokia/RED/blob/master/red_help/first_steps/download_install.html.md
4. To verify Installations in Eclipse: Help -> Installation Details to check if RED is visible on installed features list
5. Create Project and Tests using RED in Eclipse: https://github.com/nokia/RED/blob/master/red_help/first_steps/create_run.html.md
6. RED Steps: https://github.com/nokia/RED/blob/master/First_steps.md
7. Quick STart: https://github.com/nokia/RED/blob/master/red_help/user_guide/quick_start.html.md

Make a phone call with qt 4.6.3

I need to trigger a phone call from a Qt application. I looked to previous post without find a complete answer.
I need to make it with qt 4.6.3. I'm quite new to symbian development, I'm using the last nokiaSDK.
It MUST work ONLY on n97 and E71.
Can Anybody provide a solution?
May be a solution exec an extenal process using QProcess?
It seems like currently none of Qt APIs (including QtMobility) allows to do it. However, you can use native Symbian C++ API - CTelephony class. There are some examples showing how to make a phone call using this class. The obvious disadvantage is that it won't work on any other platform than Symbian.
You may be interested in this example: http://library.forum.nokia.com/topic/Qt_for_Symbian_Developers_Library/GUID-B4DA6005-3037-4FF8-82D5-BA748532E648.html#GUID-B4DA6005-3037-4FF8-82D5-BA748532E648. It shows how to mix Symbian C++ code with Qt code, and it also uses CTelephony, so you just need to change method call from GetPhoneId() to DialNewCall(). Don't forget to add appropriate library (etel3rdparty.lib) in your .pro file.

Resources