mx2cc command line for IDE

Community Forums/Monkey2 Talk/mx2cc command line for IDE

Tibit(Posted 2016) [#1]
I figured I would have a go at building a user-friendly IDE to match monkey2, and so far it is looking good!

1. How is best practice to deal with monkey updates & install path?
Are these the most likely options?
A. like in monkey1, a folder for each version: monkeyXPro85, monkeyXPro86, monkeyXPro86c.
B. a git clone with a branches for versions/dev/stable something?

Whatever is preferred I was thinking the IDE could make this user friendly, while I get it is "early" still, any thinking around this that would help IDE design or that can be implemented as a "test"?

For example is there benefits to:
* In the future to be able to run older "code" along with older monkey2 versions?
* See if the "new update" was what "broke" something, maybe being able to "revert" easily?

2. Your own modules
Any instructions? Guesses: Namespace must be at top of file? Folder same name as module? Only one namespace per file?

#Import "<test-mod>"

Using test

Function Main()
Print "Calling this "+TestModFunction("because");
End

I get this:
[1]: Error : Missing parameter identifier <--- could it say "Does that mean it is expecting Namespace at top of module?"

I just git updated to latest version I get "Uncaught Error" when calling mx2cc_macos. I figured I'd have to rebuild, but seems build-scripts are not working, says "command does not exist", anyone know what I am missing?

3. Module folder
In monkey1 I remember having some modules in a folder outside the monkeydir that was supplied using a "module-path" to mx2cc. Can mx2cc do something similar to avoid being overwritten with every git update? Other ideas? The editor could just as well pull that cart of course.

4. Module manager
I know I read Mark had a plan for this, or?

5. How to travel imports
To get all dependancies for an App and/or module, how does monkey2 go about searching for where the imported files are?

6. Improved meta-data
I would love for the build-process to return more data.

I experienced first the complexity of recreating Monkey1's Grammar in Antler, and I would not ask that of anyone! However maybe Monkey already have the name, row and char of every Class/Function/Field/Parameter/... in it's AST already? So maybe an option to return current AST as json, like this: https://astexplorer.net/ is not so far-fetched after all?

With that AST anyone making an IDE can tag up code - allowing for features such as go to source, find calling sources, autocomplete or inline documentation.

7. mx2cc documentation for reference:
#mx2cc compiler
mx2cc makeapp|makemods|makedocs [-run] [-clean] [-verbose] [-target=desktop|emscripten] [-config=debug|release] source|modules...

##Questions:
* What does clean do?
* What differs release from debug?

##makedocs
makedocs module-name-here
- For each module this creates 1-html-page for each function/exception/class/struct in that module's folder along with a index.js that contains all meta-data.

##makemods
makemods -verbose -clean -config=debug -target=desktop module-name-here
makemods -verbose -clean -config=release -target=desktop module-name-here
- How is module files and imports different from app-files?

##makeapp
makeapp -target=desktop -config=debug path/to/your-monkey-file.monkey2


Danilo(Posted 2016) [#2]
> I get this:
> [1]: Error : Missing parameter identifier <--- could it say "Does that mean it is expecting Namespace at top of module?“

How does your test-mod file look like? You use "<test-mod>“ (a module in the mx2/modules/ directory).
Did you add it to modules/modules.txt and rebuild modules? Did you try using "<test-mod.monkey2>“?


Tibit(Posted 2016) [#3]
Ah, I tough modules.txt was a "readme" file that explained the dependancy order. I'll add it there.

Added the module like this: /modules/test-mod/test-mod.monkey2
Namespace test-mod.test

Function TestModFunction(text:string)
  return text + " test works!"
End


#Import "<test-mod>"

Using test

Function Main()
	Print "Calling this "+TestModFunction("because");
End


Github instructions, these correct?
git fetch origin
git reset --hard origin/master
'Then on Mac go in command to monkey2/src/
Type:
sudo ./rebuildall.sh

I get "Command not found"


Danilo(Posted 2016) [#4]
@Tibit:
1.) Do you have Xcode command-line tools installed? (Install Instructions)
2.) I just run ./rebuildall.sh - without sudo
3.) "Namespace test-mod.test“ looks weird. Try without the minus sign (like variable names and other identifiers). For "Namespace test“ you use "Using test“
4.) Specify the return type of the function: Function TestModFunction:String(text:String)


Tibit(Posted 2016) [#5]
Thanks Danilo, I doubel checked and I did have the xcode commands installed, what happened was that /.rebuildall.sh returns an error that I do not have permission.

It worked the first time and now that I updated the "current" branch with the new one it seems the cause was that I lost all file permissions. Sudo did not fix this, however after checking the /bin/ and /src/ directories using "ls - l", I saw all those files had -rw-r--r--, so I did a "chmod 755 *" in both directories and now it compiled fine when they have -rwxr-xr-x. So is this something I should need to do every update?

Anyhow also got the mod to work, renamed it to mymod.monkey2 in folder mymod, works with or without being added to modules.txt. It seems you where spot on that minus does not work in file name, tough other modules have it.

Minor bug: If you start #rem and then have a #rem inside before the #end it seems the parser gets stuck.

Working example for reference when building modules:

modules/mymod/mymod.monkey2
Namespace mymod

Function TestModFunction:string(text:String)
  return text + " Test works!"
End


App:
#Import "<mymod>"

Using mymod

Function Main()
	Print "Calling this "+TestModFunction("because")
End



marksibly(Posted 2016) [#6]
> It seems you where spot on that minus does not work in file name, tough other modules have it.

You can have a dash in the module name (which is really just a filename) but NOT in a namespace identifier (which is a normal language identifier).

So you could call the module 'my-mod', but not the namespace - that would have to be 'my_mod' or some other valid identifier.

Module names are never referenced 'in code' (that's why they're #imported - they're just files). Only the namespace(s) declared inside modules are.

I have been using the '-' in module names to indicate the namespace hierarchy of module contents. For example, the 'stb-image' module declares some stuff in the 'stb.image' namespace. Ditto 'stb-truetype' declares stuff in 'stb.truetype'. But feel free to abuse the dash for any purpose you want - it's just part of a filename.


Tibit(Posted 2016) [#7]
Does this mean every file is explicitly imported? If I traverse all imports from main recursively I get every file that contains code used by the app. Ex: import <"some-module"> the only thing to check is the module directory for /some-module/some-module.monkey2.

Or does it check the app folder as well?

Does does the import care about folder structure? Would Import <"some-framework/rendering/circe-rendering-mod"> be equal to Import <"circe-rendering-mod">?


marksibly(Posted 2016) [#8]
> Does this mean every file is explicitly imported?

Effectively, yes. The only exceptions are the monkey module, which is always imported, and the 'root' file you pass to mx2cc. Apart from that, there's at least one #import for every monkey2 file compiled.

> Or does it check the app folder as well?

Nope, all modules go in the modules folder. It may end up that I add something like monkey1's MODULES_PATH env var with a list of paths to search for modules, but this wont affect the syntax for #Import.

> "<some-framework/rendering/circe-rendering-mod>"

This is (will be!) illegal. Module names can't have '/' in them since they map to top level dirs in '/modules/'. And this more or less goes for all #imports that are enclosed in '<>'. This indicates a 'system import' and these imports are generally stored in 'magic' locations known to the compiler(s) - ie: the compiler is in charge of working out what dirs to search for the import file.

If you just want to import a money2 file at an arbitrary file location, use a simple relative import, eg:

#Import "../blah/etc/somefile.monkey2"

(I'll probably allow you to drop the .monkey2 extension as I have with modules too - I may have already!)

Same deal goes with namespaces though - somefile.monkey2 will need a Namespace at the top to say where it's decls end up. But the actual filename 'somefile.monkey2' is completely irrelevant except for when you're #importing it.


Tibit(Posted 2016) [#9]
Awesome, seems like several IDE things is going to be much easier in monkey2.