About Monkey 2 › Forums › Monkey 2 Programming Help › Module woes….
Tagged: mx2cc bug
This topic contains 3 replies, has 2 voices, and was last updated by
jondecker76
2 years, 9 months ago.
-
AuthorPosts
-
July 1, 2016 at 10:55 am #1543
I’ve been beating my face against the wall all night just trying to get a very simple module working.
Here is what I have:
monkey2/modules/sequence/sequence.monkey2:
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172Namespace sequence#rem monkeydoc\##Simple Sequencing EngineThis module provides a simple sequencing engine implementation. Each sequence isbuilt by any number of "steps" which can be handled in the order they were created.Each step has convenience methods to assign/track integer step identifiers, store and retrieve a data object,expire steps as well as track/set initialization of each sequence step. Steps operate on a simpleFIFO stack, and the functions and methods provided primarily work on the currently active step(which is on top of the stack).#end#Rem monkeydoc Sequence classThis is the main type you will be dealing with#end#Import "<std>"Using std..Class Sequence'List of sequence stepsField steps:List<SequenceStep> '= New List<SequenceStep>#Rem monkeydocCreate a new sequence#endMethod New()steps = New List<SequenceStep>End#Rem monkeydocAdd a new sequence to the stack#endMethod Add(stepNum:Int,thisDuration:Int=0,data:Object=Null)'If Not list Then list=CreateList()local a:= New SequenceStep(stepNum)a.data=dataa.duration=thisDurationsteps.AddLast(a)End Method#Rem monkeydocClear all the steps from the sequence#EndMethod Clear:void()If (Not steps=Null)steps.Clear()endifEnd#Rem monkeydocGet the current step of the sequence#EndMethod Get:Int()Return steps.First.infoEnd#Rem monkeydocGet assiciated data object for the current sequence step#EndMethod Data:Object()Return steps.First.dataEnd Method#Rem monkeydocMove to the next step of the sequence.#endMethod DoNext()steps.RemoveFirst()End Method#Rem monkeydocReturns true the first time this method is invoked, false otherwise. Useful forinitialization of the sequence step#EndMethod Init:Bool()If Not steps Return 0If(steps.First.init=True)Return FalseElsesteps.First.init=TrueReturn TrueEndifReturn trueEnd Method#Rem monkeydocReinitialize the sequence step#EndMethod ReInit()steps.First.init=FalseEnd Method#Rem monkeydocreturn the number of steps in the sequence#EndMethod Count:Int()Return steps.Count()End Method#Rem monkeydocThis will automatically load the next sequence step on expiration of a step#EndMethod AutoExpire()If Self.Expire() Then Self.DoNext()End Method#Rem monkeydocReturns true if the sequence step is expired#EndMethod Expire:Int()Local deltaT:Int=Millisecs()-steps.First.timestampLocal dur:Int = steps.First.durationIf deltaT > dur And dur>0Return TrueElseReturn FalseEndifReturn TrueEnd MethodEnd#rem monkeydoc SequenceStep classThis type is used behind the scenes by the #TSequence type to store information abouteach step in the sequence. You should never have to deal with this class directly.#endClass SequenceStep'Initialization tracking'Will return true the first time it is called only (unles it is reinitialized with ReInit())Field init:Bool'Step info (normally step number)Field info:Int'Additional data to store with stepField data:Object'Autotimeout, True/FalseField autotimeout:Bool'Millisecs timestamp at creation of stepField timestamp:Int'Duration of this step, in Millisecs.'<1 is infinite durationField duration:IntMethod New(_info:int)init=Falseinfo=_infodata=Nullautotimeout=Falsetimestamp=Millisecs()endEnd#remFunction Main:Void()Local seq:=New Sequence()seq.Add(1)seq.Add(2)seq.Add(3)Print "Count: " + seq.Count()Print "Current: " + seq.Get()seq.DoNext()Print "New count: " + seq.Count()Print "New current: " + seq.Get()End#end remmonkey2/modules/sequence/module.json:
Java123456{"module" : "sequence","version" : "1.0.0","depends" : ["std"]}I’ve run ‘mx2cc makemods sequence’ and the module build properly
Now, in
monkey2/projects/test/sequenceTest/sequenceTest.monkey2:
Monkey123456789101112131415161718192021#Import "<sequence>"#Import "<std>"Using sequence..Using std..Function Main:Void()Local seq:=New Sequence()seq.Add(1)seq.Add(2)seq.Add(3)Print "Count: " + seq.Count()Print "Current: " + seq.Get()seq.DoNext()Print "New count: " + seq.Count()Print "New current: " + seq.Get()EndWhen I build, i get the following error:
mx2cc version 1.0.0
***** Building app ‘/home/jondecker76/Downloads/monkey2-1.0.0/projects/test/sequenceTest/sequenceTest.monkey2’ *****
Parsing…
Semanting…
Translating…
Compiling….
Build error: System command ‘g++ -std=c++11 -O3 -DNDEBUG -I”/home/jondecker76/Downloads/monkey2-1.0.0/modules/monkey/native” -c -o “/home/jondecker76/Downloads/monkey2-1.0.0/projects/test/sequenceTest/sequenceTest.buildv1.0.0/build_cache/desktop_release_linux/sequenceTest_0sequenceTest.cpp.o” “/home/jondecker76/Downloads/monkey2-1.0.0/projects/test/sequenceTest/sequenceTest.buildv1.0.0/build_cache/desktop_release_linux/sequenceTest_sequenceTest.cpp”‘ failed.g++ -std=c++11 -O3 -DNDEBUG -I”/home/jondecker76/Downloads/monkey2-1.0.0/modules/monkey/native” -c -o “/home/jondecker76/Downloads/monkey2-1.0.0/projects/test/sequenceTest/sequenceTest.buildv1.0.0/build_cache/desktop_release_linux/sequenceTest_0sequenceTest.cpp.o” “/home/jondecker76/Downloads/monkey2-1.0.0/projects/test/sequenceTest/sequenceTest.buildv1.0.0/build_cache/desktop_release_linux/sequenceTest_sequenceTest.cpp”
/home/jondecker76/Downloads/monkey2-1.0.0/projects/test/sequenceTest/sequenceTest.buildv1.0.0/build_cache/desktop_release_linux/sequenceTest_sequenceTest.cpp:6:109: fatal error: ../../../../../../modules/sequence/sequence.buildv1.0.0/desktop_release_linux/sequence_sequence.h: No such file or directory
compilation terminated.
***** Fatal mx2cc error *****Build error.
However, if I build it manually with mx2cc it works!:
jondecker76@jondecker76-Inspiron-3520:~/Downloads/monkey2-1.0.0/bin$ ./mx2cc_linux makeapp ../projects/test/sequenceTest/sequenceTest.monkey2
mx2cc version 1.0.0***** Building app ‘/home/jondecker76/Downloads/monkey2-1.0.0/projects/test/sequenceTest/sequenceTest.monkey2’ *****
Parsing…
Semanting…
Translating…
Compiling….
Linking /home/jondecker76/Downloads/monkey2-1.0.0/projects/test/sequenceTest/sequenceTest.buildv1.0.0/desktop_debug_linux/sequenceTest
Running /home/jondecker76/Downloads/monkey2-1.0.0/projects/test/sequenceTest/sequenceTest.buildv1.0.0/desktop_debug_linux/sequenceTest
Count: 3
Current: 1
New count: 2
New current: 2So what is the problem? Is this a bug with Ted2?
July 1, 2016 at 11:03 am #1546I’ve had these strange issues and I think its down to sometimes when building the mods mx2cc only does debug or release, not both.
Notice in your outputs, the first is for release:
../../../../../../modules/sequence/sequence.buildv1.0.0/desktop_release_linux/sequence_sequence.h: No such file or directory
The second is for debug:
Linking /home/jondecker76/Downloads/monkey2-1.0.0/projects/test/sequenceTest/sequenceTest.buildv1.0.0/desktop_debug_linux/sequenceTest
When I’ve reported this and tried to repeat on demand it magically fixes itself!
July 1, 2016 at 11:22 am #1552So why would it work in debug and not release?
I see what you were saying – I added –config release and tried from the cli again, and it fails just the same as when invoked from Ted2
I guess I’ll report a bug on the issue, as I can reproduce it 100% of the time
July 1, 2016 at 11:42 am #1555aah, I get it
when I used mx2cc_linux without a -config parameter, it defalts to debug only, so release versions aren’t created
now that I’ve run mx2cc with both -config=release and -config=debug, everything works as it should
it makes sense now, looking at scripts/rebuildmods.sh it supplies commands with -config for both release and debug, so running mx2cc makemods will only do the debug version.
I would think that this behavior should be changed, and if no -config parameter is supplied it should build both debug and release versions.
-
AuthorPosts
You must be logged in to reply to this topic.