minko / lua issue : premake5.lua:3: attempt to index global 'minko' (a nil value) - linux

I am working with minko and managed to compile MINKO SDK properly for 3 platforms (Linux, Android, HTML5) and build all tutorials / examples. Moving on to create my own project, I followed the instructions on how to use the existing skeleton project, then using an existing example project.
(I believe there is an error in the skeleton code at this line :
auto sceneManager = SceneManager::create(canvas->context()); //does not compile
where as the example file look like this :
auto sceneManager = SceneManager::create(canvas); //compile and generate binary
I was able to do so by modifying premake5.lua (to include more plugins) and calling script/solution_gmake_gcc.sh
to generate the make solution a week ago. Today, I tried to make a new project in a new folder but calling
script/solution_gmake_gcc.sh and script/clean failed with this error:
minko-master/skel_tut/mycode/premake5.lua:3: attempt to index global 'minko' (a nil value)
Now at premake5.lua line 3 there is this line : minko.project.solution(PROJECT_NAME),
however sine i am not familiar with lua at all, can anyone shed any light on the issue ?
What is supposed to be declared here, why is it failing suddenly... ?
(I can still modify,compile and run the code but i can't for example add more plug-ins)
PS: weirdly enough, the previously 'working' project is also failing at this point.
Thanks.

PROJECT_NAME = path.getname(os.getcwd())
minko.project.application("minko-tutorial-" .. PROJECT_NAME)
files { "src/**.cpp", "src/**.hpp", "asset/**" }
includedirs { "src" }
-- plugins
minko.plugin.enable("sdl")
minko.plugin.enable("assimp")
minko.plugin.enable("jpeg")
minko.plugin.enable("bullet")
minko.plugin.enable("png")
--html overlay
minko.plugin.enable("html-overlay")
Assuming that's indeed your project premake5.lua file (please us the code tags next time), you should have include "script" at the beginning of the file:
https://github.com/aerys/minko/blob/master/skeleton/premake5.lua#L1
If you don't have this line, it will not include script/premake5.lua which is in charge of including the SDK build system files that defines everything inside the minko Lua namespace/table. That's why you get that error.
I think you copy pasted one of the examples/tutorials premake5.lua file instead of modifying the one provided by the skeleton. The premake conf file of the examples/tutorials are different since they are included from the SDK premake files. But your app premake5.lua does the "opposite": it includes the SDK conf files rather than being included by them.
The best practice is to edit your app's copy of the skeleton's premake5.lua (instead of copy/pasting one from the examples/tutorials).

(I believe there is an error in the skeleton code at this line :
That's possible. Our build server doesn't test the skeleton code. That's a mistake we will fix ASAP to make sure it works properly.
script/solution_gmake_gcc.sh and script/clean failed with this error:
minko-master/skel_tut/mycode/premake5.lua:3: attempt to index global 'minko' (a nil value)
Could you copy/paste your premake5.lua file?
Also, what's the value you set for the MINKO_HOME env var? Maybe you've moved the SDK...
Note that instead of setting a global MINKO_HOME env var, you can also set the corresponding LUA constant at the very begining of your premake5.lua file.

Related

Phaser 3 - Images not showing

After searching for a bit and finding others having somewhat of the same problem, but no solution for me, I figured it was my turn to seek help.
I have npm along with parceljs setup for webserving (I'm new to these but I'm quite confident it's working as you can see some output in the image I've posted)
I have the typical problem of images not displaying.
Status code of the image is returning 304 OK, and is it normal to not see the the image listed in the directory under the 'Sources' tab in Developer tools?...
The issue is with the way you are loading the image urls as hard-coded strings, for example, you wrote this:
this.load.image('sz','./src/assets/gfx/sz0001.png`)
The way this is written, parcel doesn't know that this string is actually a reference to an image file, so it doesn't know to copy over the image into your output folder and ensure that the path ends up matching the actual output location.
The way parcel works, if you want to include an asset (like an image) into your bundle and reference it by URL in some other javascript context (like the this.load.image function), you should use an import statement or a URL constructor (see docs).
So you would instead write:
import myImageUrl from './src/assets/gfx/sz0001.png`;
// 'myImageUrl' will be a string that points to the location of the image
// This will also tell parcel that sz0001.png is a dependency of this project
// so that it can take care of copying it over to the dist output.
this.load.image('sz',myImageUrl)
Another tip is that the template you referenced uses parcel-bundler which the old, unmaintained 1.x version of parcel. I'd recommend upgrading your project to parcel 2, which on npm is simply parcel (see migration guide).
The green box, is shown if the asset is not found, or some other error.
Since I'm not 100% sure how parcel works and I don't know your parcel configuration and which parcel plugins you are using (I'm assuming parcel can be configured).
You could solve the problem by: manually copying the assets folder from src/ to dist/, than it should work. (atleast this work for me, when using this parcel template, to test the issue)
Maybe a parcel - plugin like parcel-plugin-static-files-copy, could also solve the problem, and/or be useful to keep the static files up-to-date.

Merge schemas of custom dialog - Error conflicting definitions

I am following the steps of this page:
https://learn.microsoft.com/en-us/composer/how-to-create-custom-actions
and have reached to the part where it is required to merge the two schemas: bots and your custom one. However when running the powershell script found inside the created project template (CoreAssistant template) I have the following error:
Error conflicting definitions of HelpDialog.dialog :
C:\Users\user\source\repos\AvanadeCoreAssistant\AvanadeCoreAssistant\dialogs\imported\Microsoft.Bot.Components.HelpAndCancel\HelpDialog\HelpDialog.dialog
Microsoft.Bot.Components.HelpAndCancel:
C:\Users\user.nuget\packages\microsoft.bot.components.helpandcancel\1.1.2\exported\HelpDialog\HelpDialog.dialog
Error conflicting definitions of HelpDialog.en-us.lu.dialog :
C:\Users\user\source\repos\AvanadeCoreAssistant\AvanadeCoreAssistant\dialogs\imported\Microsoft.Bot.Components.HelpAndCancel\HelpDialog\recognizers\HelpDialog.en-us.lu.dialog
Microsoft.Bot.Components.HelpAndCancel:
C:\Users\user.nuget\packages\microsoft.bot.components.helpandcancel\1.1.2\exported\HelpDialog\recognizers\HelpDialog.en-us.lu.dialog
Error conflicting definitions of HelpDialog.lu.dialog
HelpDialog is a predefined dialog that was already present. I have installed NodeJs and #botframework-cli package because it was required from the powershell script in order to run bf dialog:merge and now it seems these two sources have some kind of conflict.
To add to other answers, changes that worked for me are as follows:
update-schema.ps1, line 11, change "!**/generated" to "!../generated" and add "!../dialogs/imported"
Also, make sure that your custom action project is INSIDE of your bot directory, it should be a folder next to the "schemas" folder for the script to find it.
Note/Edit: Having the project nested inside the bot works to get the script working, though I do not recommend it due to causing other errors. Oddly, I found it was best to move the whole custom solution up a level, next to the bot project. You may have to edit the [botName].sln file in notepad to reference the location of the project, as well as editing the bot project's project reference.
I fixed it by changing the script. I noticed the script was trying to ignore the folder imported and generated but the error message indicated it was not doing so. So I changed it from !**/generated to !../generated.
I experienced the same issue.
To fix this problem you could simply delete the corresponding dialogs in the "imported" folder. Note that this will, however, delete these dialogs in your bot, which is not optimal but should be of little concern for a sample application.

Suave with netcoreapp2.0

I've been following this Suave tutorial:
https://legacy.gitbook.com/book/theimowski/suave-music-store/details
And in general this looks good. However, I was trying to make it work with Linux and for some reason I was unable to compile it with code when TargetFramework was set to "net461" (Target Framework not found), so I tried changing it to "netcoreapp2.0". It compiled, but I hit a problem later on:
https://theimowski.gitbooks.io/suave-music-store/content/en/css.html
At the end it says to add a WebPart:
pathRegex "(.*)\.(css|png)" >=> Files.browseHome
which fails for me. All compiles, but I get
This page isn’t working
localhost didn’t send any data.
I took a look at Suave's source code and it turned out that "Files.browseHome" searches for a file under "ctx.runtime.homeDirectory".
I noticed that this is set on my machine to:
/home/<my_user_name>/.nuget/packages/suave/2.2.1/lib/netstandard1.6
and obviously, that's not my project directory, so no wonder it couldn't find the file.
My question here is: what shall I do in order to make my Suave app handle my css/png files correctly using Files.browseHome ?
EDIT:
Just found out that replacing the WebPart with:
pathRegex "(.*)\.(css|png)" >=> Files.browse "/home/<my_username>/<path_to_my_project>/bin/Debug/netcoreapp2.0/"
works fine, but it looks ugly. Any idea how to make it better ? Basically I don't want to be forced to hardcode the absolute path anywhere.
I think the answer is to be found in https://suave.io/files.html, which suggests creating a config as follows:
let config =
{ defaultConfig with homeFolder = Some (Path.GetFullPath "./public") }
The path returned by Path.GetFullPath will depend on the current working directory that your app sees when it's started (which will, in turn, depend on how you start the app: from the command line, from a systemd unit file, etc.) There are too many possible variables here for me to be able to give you exact instructions, but if your startup method can cd into an appropriate folder before starting your Suave server, then that should solve your problem.
If you run into difficulties with getting the current working directory set correctly, then you could just hardcode the full path in the config:
let config =
{ defaultConfig with homeFolder = Some "/home/<your_username>/<path_to_your_project>/bin/Debug/netcoreapp2.0/" }
But that's kind of ugly, and not really portable (you'd have to modify that path again once you deploy the app). So I'd recommend the approach of making sure your start script does a cd to the right location, then using Path.GetFullPath with a relative path. Alternately, you could have a config file that gets read in at app startup where you specify the home path, or pass it in as an environment variable... All kinds of possibilities. Just make sure that your code can be handed some information on startup that specifies the correct "home" folder, and then put that in your Suave config as I've shown, and that should solve it.

How to copy files as templates, injecting values to them, to a different folder?

I used this library, mem-fs-editor (https://github.com/sboudrias/mem-fs-editor), in a Yeoman generator a few weeks ago. It worked nicely, but now I tried to use it again in a different scope and I couldn't do anything. Obs: I used it because this is the library Yeoman provides to handle the file system.
In Yeoman Generators we can copy files from a template folder, passing values to inject in the code, to a different folder. And that's precisely what I need, but I can't use Yeoman this time.
I tried the same code I used in my Yo Generator, but it don't work. So I'm not sure how mem-fs works. No errors are thrown and even the code provided by the author of the project don't work to me.
I tried this (and some other things with copyTpl) with no success
var memFs = require('mem-fs');
var editor = require('mem-fs-editor');
var store = memFs.create();
var fs = editor.create(store);
console.log(fs.write('./somefile.js', 'var a = 1;'));
Anyone knows how it works or what else I can do to make this happen?
mem-fs-editor author here.
mem-fs stands for memory file-system. All the files you creates are stored in memory and won't get written to disk until you call:
editor.commit(callback);
Yeoman does that automatically for you. It is this way with Yeoman to collide every file changes together and then being able to only prompt for file conflicts once (rather than everytime a single file is being written to).

ANTLR4 Generating Lexer in JAVA instead of C Sharp

When doing
java -cp C:\Tools\Libraries\antlr4-csharp-complete.jar org.antlr.v4.Tool Hello.g4
I get the following files:
HelloBaseListener.cs
Hello.tokens
HelloListener.cs
HelloParser.cs
HelloLexer.tokens
HelloLexer.java
My question is about the last file. Why is it .java instead of .cs?
I'm using antlr4-csharp-4.0.1-SNAPSHOT-complete.jar
Grammar is:
grammar Hello; // Define a grammar called Hello
options
{
language=CSharp_v4_0;
}
r : 'hello' ID ; // match keyword hello followed by an identifier
ID : [a-z]+ ; // match lower-case identifiers
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines, \r (Windows)
Hello Sam! I only have visual studio express so I can't install the extension. This is the code that I'm using but it is still generating the HelloLexer.java.
AntlrClassGenerationTaskInternal a = new AntlrClassGenerationTaskInternal();
List<String> files = new List<string>();
files.Add(#"C:\Tools\Grammars\Hello.g4");
a.JavaVendor = "JavaSoft";
a.ToolPath = #"C:\Tools\Libraries\antlr4-csharp-complete.jar";
a.JavaInstallation = "Java Development Kit";
a.SourceCodeFiles = files;
a.OutputPath = #"C:\Tools\Grammars\CSharp\";
a.Execute();
By the way, visual studio complained because it was not able to find Antlr4ClassGenerationTask.IsFatalException(ex)
I appreciate your help on this.
Regards,
Omar.
I think it's a bug, I had got the same problem, but there is a solution.
1) If you want you can remove
options
{
language=CSharp_v4_0;
}
I think is ignored by the code generator
2) create a BAT file with the follow code
#echo OFF
IF "%CLASSPATH%" == "" (SET CLASSPATH=.;.\antlr4-csharp-4.0.1-SNAPSHOT-complete.jar;%CLASSPATH%)
java org.antlr.v4.Tool %* -Dlanguage=CSharp_v4_5
put antlr4-csharp-4.0.1-SNAPSHOT-complete.jar in the same path, now you can use this file to comile. To resolve the issue the magic command line argument is "-Dlanguage=CSharp_v4_5" or the version of C# you are using.
The generated files now have inside the Lexer.cs
Edit 11/20/13: Updated instructions are now available on the project wiki
https://github.com/sharwell/antlr4cs/wiki/Installation
Here are a few messages I sent over the past few months related to this issue. If you don't want to install the Visual Studio extension described below, you'll need to use the source code of Antlr4ClassGenerationTaskInternal.cs to determine a set of command line options that will work.
Also, you can remove the language=CSharp_v4_0; option because it's passed on the command line now.
The C# target wasn't designed for command line usage. You will need to integrate the code generation into your project file according to the instructions on the following page, and the parsers will be generated automatically when you build your project.
https://github.com/sharwell/antlr4cs
You do need to include the .g4 file in your project and configure a few properties of the file. If you install the following extension before adding the grammar to your project, all the other options will be configured for you automatically.
ANTLR Language Support for Visual Studio 2010-
2012
If you already have the .g4 file in your project, and want to still use the extension to automatically configure the proper settings, you can do the following:
Install the extension.
Click the project in Solution Explorer and enable Show All Files (button on the Solution Explorer toolbar). This step greatly simplifies step 4.
Right click the .g4 file in the project, and select Exclude From Project.
Right click the .g4 file again and select Include In Project.
(Optional) You can disable Show All Files when you no longer need it.

Resources