Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build pxt-scrollbit against v3.1.17 / v6.4.13 #3494

Closed
Gadgetoid opened this issue Oct 27, 2020 · 7 comments
Closed

Unable to build pxt-scrollbit against v3.1.17 / v6.4.13 #3494

Gadgetoid opened this issue Oct 27, 2020 · 7 comments

Comments

@Gadgetoid
Copy link

Attempting to do a cloud build of pxt-scrollbit, I was running into an obtuse error:

TypeError: Cannot read property 'length' of null
    at compressHex (/home/phil/Development/pxt/pxt-scrollbit/node_modules/pxt-core/built/pxt.js:103646:37)
    at /home/phil/Development/pxt/pxt-scrollbit/node_modules/pxt-core/built/pxt.js:103575:36
    at tryCatcher (/home/phil/Development/pxt/pxt-scrollbit/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/phil/Development/pxt/pxt-scrollbit/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/phil/Development/pxt/pxt-scrollbit/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/phil/Development/pxt/pxt-scrollbit/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/phil/Development/pxt/pxt-scrollbit/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/home/phil/Development/pxt/pxt-scrollbit/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/phil/Development/pxt/pxt-scrollbit/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/phil/Development/pxt/pxt-scrollbit/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
{ sha:
   '08eb6b80026aa7260db0e25151435634e6b06694713c52895a397cce23c9d9df' }
test.ts(1,1): error TS9200: Cannot read property 'hex' of null

Scrolling up the backlog suggests this is probably because font.cpp is failing to compile. This file has not changed since the micro:bit V1.x, but the underlying DAL/Codal/PXT appears to have removed or omitted MicroBitFont.

/home/build/prjclone/pxtapp/scrollbit/font.cpp: In function 'int scrollbit::getFontDataByte(int)':
/home/build/prjclone/pxtapp/scrollbit/font.cpp:15:9: error: 'MicroBitFont' was not declared in this scope
         MicroBitFont font = MicroBitFont::getSystemFont();
         ^~~~~~~~~~~~
/home/build/prjclone/pxtapp/scrollbit/font.cpp:16:24: error: 'font' was not declared in this scope
         return (char)*(font.characters + index);
                        ^~~~
/home/build/prjclone/pxtapp/scrollbit/font.cpp: In function 'int scrollbit::getCharWidth(int)':
/home/build/prjclone/pxtapp/scrollbit/font.cpp:23:9: error: 'MicroBitFont' was not declared in this scope
         MicroBitFont font = MicroBitFont::getSystemFont();
         ^~~~~~~~~~~~
/home/build/prjclone/pxtapp/scrollbit/font.cpp:25:36: error: 'font' was not declared in this scope
         uint8_t width = (uint8_t)*(font.characters + offset)
                                    ^~~~
/home/build/prjclone/pxtapp/scrollbit/font.cpp: In function 'pxt::BoxedBuffer* scrollbit::getFontData(int)':
/home/build/prjclone/pxtapp/scrollbit/font.cpp:41:9: error: 'MicroBitFont' was not declared in this scope
         MicroBitFont font = MicroBitFont::getSystemFont();
         ^~~~~~~~~~~~
In file included from /home/build/prjclone/pxtapp/pxt.h:8:0,
                 from /home/build/prjclone/pxtapp/scrollbit/font.cpp:1:
/home/build/prjclone/pxtapp/scrollbit/font.cpp:44:46: error: 'font' was not declared in this scope
         return PXT_CREATE_BUFFER((uint8_t *)(font.characters + offset), 5);
                                              ^
/home/build/prjclone/pxtapp/pxtbase.h:797:52: note: in definition of macro 'PXT_CREATE_BUFFER'
 #define PXT_CREATE_BUFFER(data, len) pxt::mkBuffer(data, len)
                                                    ^~~~

I can't see any evidence that I was doing anything wrong by using MicroBitFont in the past, so I guess this should probably work?

Or- is there an alternative approach here?

Finally- is there any specific version of pxt-core and pxt-microbit I should be building against, currently? I assumed the latest for targeting V2.

@pelikhan
Copy link
Member

Your library is using C++ so you need to make it compatible with the micro:bit v1 stack (nrf51, microbit-dal) and v2 stack (nrf52, codal) stack.

In this case, the font class has moved and is now at https://github.com/lancaster-university/codal-core/blob/master/inc/types/BitmapFont.h -- in particular https://github.com/lancaster-university/codal-core/blob/9643ee76d2af1eb501f70d5d8cbc405ab7a42291/inc/types/BitmapFont.h#L96

In C++, use this preprocessor test to determine if you are building against CODAL (v2) or not (v1)

#if MICROBIT_CODAL
// v2 code
#else
// v1 code
#endif

@Gadgetoid
Copy link
Author

Thank you- this stack is so deep and dizzying that I didn't get close to finding where I was going wrong. Looks like ScrollBit is now working!

@pelikhan
Copy link
Member

A sandwich is only as good as how many layers its got squiched together.

@Gadgetoid
Copy link
Author

Having just thrown together a burger with more fillings than a Subway counter, I tend to agree. Though it doesn't lend itself well to peeling apart the layers of the sandwich and trying to figure out what's what 😆

With ^3.1.17 and ^6.0.0 am I targeting approximately the right pxt-microbit and pxt-core versions?

@pelikhan
Copy link
Member

The branch that will go live is stable3.0 https://github.com/microsoft/pxt-microbit/commits/stable3.0

The best is to look into the package.json in that branch to figure out precisely the branch of pxt-common-packages and pxt-core: https://github.com/microsoft/pxt-microbit/blob/stable3.0/package.json#L47

  • pxt-core: stable6.0
  • pxt-common-packages: stable7.0

@pelikhan
Copy link
Member

we are integrating the relevant fixes from pxt-microbit#master (v3.1) to v3.0

@pelikhan
Copy link
Member

I'm going to close this one since it seems that you've been unlocked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants