R0.3 current Travis CI progress and issues

Creating an automated build system is becoming more and more important as the WebVTT parser continues to grow in size, as well as outside modules that we will be using to test our code. For our unit tests, we’ve decided to use node-ffi, which can call functions from dynamically linked libraries. In order to use this, we will create a shared library file of the WebVTT functions that have been written so far.

Seeing the need for automation, caitp (Caitlyn Potter) has already gone ahead and set up autoconf and libtool for our repository. As far as my understanding goes, autoconf automatically generates a configure script in order to aid in portability when building with different systems. Libtool helps in generating portable libraries. In our case, we will need to create a shared library for use with node-ffi.

To begin, I would have to install the modules of node-ffi, ref, and ref-struct. It’s a pretty simple one-liner to add to the .travis.yml file: npm install ref ffi ref-struct. And with the addition of autoconf and libtool, building the C parser and libraries is now simplified to running the standard ./configure && make commands. Once everything is built, the next step would be to run our unit tests with node-ffi.

At the moment, we only have code that defines the WebVTT structs we are using and a sample unit test to see if the shared library works. However, this is enough to test and see whether the soon-to-be-finished test suite can actually run on the Travis CI box. I’ve also included the example factorial.c and factorial.js files to ensure that at least node-ffi works if the libwebvtt.js file doesn’t. And sure enough, I can get the factorial.js example to work, but libwebvtt.js fails to find the libwebvtt.so file after libtool has completed successfully. The error generated mentions that it couldn’t find the .so file, so my guess was that I simply had to copy the .so file from wherever it was generated into the libwebvtt.js working directory. Unfortunately, it didn’t remedy the situation, and now I have a funny error:

721 $ cd ..
722 $ cd ./test/unit
723 $ gcc -shared -fpic factorial.c -o libfactorial.so
724 $ ls -lRa
725 .:
726 total 336
727 drwxrwxr-x 2 travis travis  4096 Nov 10 22:25 .
728 drwxrwxr-x 4 travis travis  4096 Nov 10 22:24 ..
729 -rw-rw-r-- 1 travis travis   151 Nov 10 22:24 factorial.c
730 -rw-rw-r-- 1 travis travis   354 Nov 10 22:24 factorial.js
731 -rwxrwxr-x 1 travis travis  6662 Nov 10 22:25 libfactorial.so
732 -rw-rw-r-- 1 travis travis 78272 Nov 10 22:25 libwebvtt.a
733 -rwxrwxr-x 1 travis travis 43880 Nov 10 22:24 libwebvtt.dylib
734 -rw-rw-r-- 1 travis travis  2714 Nov 10 22:24 libwebvtt.js
735 -rwxrwxr-x 1 travis travis 57654 Nov 10 22:25 libwebvtt.so
736 -rwxrwxr-x 1 travis travis 57654 Nov 10 22:25 libwebvtt.so.0
737 -rwxrwxr-x 1 travis travis 57654 Nov 10 22:25 libwebvtt.so.0.0.0
738 -rw-rw-r-- 1 travis travis   365 Nov 10 22:24 package.json
739 $ node factorial.js 8
740 Your output: 40320
741 $ node libwebvtt.js
743 /home/travis/builds/mafidchao/webvtt/node_modules/ffi/lib/dynamic_library.js:74
744     throw new Error('Dynamic Linking Error: ' + err)
745           ^
746 Error: Dynamic Linking Error: libwebvtt.so: cannot open shared object file: No such file or directory
747     at new DynamicLibrary (/home/travis/builds/mafidchao/webvtt/node_modules/ffi/lib/dynamic_library.js:74:11)
748     at Object.Library (/home/travis/builds/mafidchao/webvtt/node_modules/ffi/lib/library.js:43:12)
749     at Object. (/home/travis/builds/mafidchao/webvtt/test/unit/libwebvtt.js:90:21)
750     at Module._compile (module.js:446:26)
751     at Object..js (module.js:464:10)
752     at Module.load (module.js:353:31)
753     at Function._load (module.js:311:12)
754     at Array.0 (module.js:484:10)
755     at EventEmitter._tickCallback (node.js:190:38)
758 after_script: 'node libwebvtt.js' returned false.
759 Done. Build script exited with: 1

Interesting that I get a “no such file or directory” error for the libwebvtt.so file when libwebvtt.so is RIGHT THERE! And I don’t think it’s supposed to be in any other directory either, since the factorial.so was right there as well and the factorial.js code worked successfully. My guess is that I need to actually specify the location of the libwebvtt.so file in the libwebvtt.js file instead of copying it to the current directory; perhaps it depends on being in that location. I will have to ask someone with a Linux machine to help me along with this process. I can’t test it on my own machine, as I use Windows and node-ffi expects a .dll file.

That brings me to another issue: in order to be compatible with the OS X and Windows environments, we will need different types of dynamic link libraries. OS X uses .dylib, and Windows uses .dll. I will need to do more research on generating these file types, but some preliminary reading suggests that libtool can create these files with a bit of work.

Leave a Reply

Your email address will not be published.

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>