Giter VIP home page Giter VIP logo

dukluv's Introduction

dukluv

LibUV bindings for duktape JS engine

The goal of this project is to make a node.js-like environment that's ultra lean for tiny devices.

http://dukluv.io/

Prerequisites

Linux:

$ sudo apt-get build-essential
$ sudo apt-get install cmake

OS X (using Brew)

$ brew install cmake

Windows

  • Install cmake manually
  • Use cygwin or start an MSVC command prompt

Compiling

$ git submodule init; git submodule update
$ mkdir build
$ cd build
$ cmake ..
$ make

The result is ./dukluv, a standalone binary which you can add to PATH or copy to e.g. /usr/local/bin/.

dukluv's People

Contributors

aseaday avatar avih avatar creationix avatar fabiopolimeni avatar fatcerberus avatar freshxopensource avatar jerrysievert avatar mamod avatar svaarala avatar topelinux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dukluv's Issues

NOT AN ISSUE : build on windows with cmake 3.4 and mingw32

Actually not an issue but a solution :

Building with MinGW

> git clone https://github.com/creationix/dukluv.git
> cd dukluv
> git submodule init
> git submodule update
> mkdir build
> cd build
> cmake -G "MSYS Makefiles" ..
> mingw32-make

Binary download

Hi, its possible release a final binary?

I'm using cygwin and fail on generate executable.

thanks

Check if it need rt library.

I find a problem when build dukluv in different platform.

if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
  target_link_libraries(duktape
    m dl
  )
endif()

It will met some problems when I need to build it with library rt. In unix like system and openwrt, you needn't to state the it needs librt. But in some platform like raspberry. It need it.

dukluv binding for duktape 2.6.0 is throwing an uncaught execption

We have updated the version of duktape from 1.5 to 2.6.0, re-compiled dukluv , compilation passed after below changes

src/main.c (added one more argument called args, while calling duk_safe_call)

typedef struct {} my_safe_args;
my_safe_args args;

if (duk_safe_call(ctx, duv_stash_argv, (void *) &args, 2, 1))

schema.c

changed duk_dump_context_stderr(ctx) to duk_push_context_dump(ctx)

Later while running the executable (i.e. ./dukluv test-require.js) we got below error

TypeError: cannot read property '/home/ubuntu20/dukluv_lates/dukl...' of undefined
at [anon] (duk_hobject_props.c:2548) internal
at [anon] () native strict preventsyield
at [anon] () native strict preventsyield

Could you please help us what might be the issue

or

do you have code for dukluv binding for latest duktape?

Thanks in advance.

Best Regards,
Phanendra

Passing on C argv to the script environment

Are there plans to pass on the C argv into the script environment to allow scripts to do command line parsing? This would be quite useful for e.g. Duktape's DukLuv based JSON proxy.

I tried to figure out if there's any binding currently and it seems src/main.c gives argc/argv to uv_setup_args() but I guess it's not passed on otherwise?

I'll be happy to contribute a pull if necessary.

Cross compiling to windows using mingw fails

I found some issues when cross compiling for windows on linux using MINGW (specifically, using MXE):

  1. At duv.h some of the S_ISDIR, S_ISREG etc are already defined in MINGW, so probably best to define each of those only if it's not defined already.
  2. At uv.cmake, there's Userenv.lib. While this is the correct windows name, MINGW has a convention to use lower-case only file names and so on linux it fails to find it. I suggest to change that to userenv.lib. This will work on linux, and on windows it won't matter since on windows the names are case-insensitive.
  3. At miniz.c there are some functions which are static __forceinline, which is apparently bad in MINGW since it defines forceinline to also be extern. This is the same as this: nothings/stb#116 and apparently for now it's not being fixed in upstream MINGW.

Since miniz.c is not an upstream git repo, this seems to solve it. At line 888 add these (undefine forceinline on anything windows. Regardless, I think the compiler should be able to decide itself what to inline):

#else
  #define __forceinline

TCP Server fails with uncaught exception

Taking the tcp-echo.js example and removing the line

//client = new Client("127.0.0.1", 1337);

gives me a TCP echo server listening on Port 1337.

If i run now a telnet against this server, everything works fine.
If i run now a an automatic connection closing netcat with

echo Hello Server | nc -c localhost 1337

against the server, it breaks down with

"server" [Server 0x7fce50501950]
"server.onconnection"
"socket" [ClientHandler 0x7fce50422cf0]
"server.accept" [ClientHandler 0x7fce50422cf0]
"socket.readStart"
"socket.onread" [Buffer 61 62 63 0a]
"socket.write" [Buffer 61 62 63 0a]

Uncaught Exception:

(null)

Any suggestions, what could be the reason? Thanks in advance!

documentation of the js builtin API

Hello,
I tried to implement a setTimeout function.
I couldn't find any documentation on the js built-in functions. so i startedto poke around through repl.js to see what's in there as far as built-in functions are concerned.

Is there any js specific documentation for these ones ?

I see that there are some bindings to libuv (through uv.) and to duktape (through Duktape.)
I suppose one could always start with that, but from the point of view of a javascripter it is not very straight-forward.

Do you think it would be of any use to start and compile some documentation / cookbook for the js built-in API ?

best wishes,
alfu32

Build error on macOS

I followed your instructions to build and got the following:

Undefined symbols for architecture x86_64:
  "_pthread_barrier_destroy", referenced from:
      _uv_barrier_destroy in libuv.a(thread.c.o)
  "_pthread_barrier_init", referenced from:
      _uv_barrier_init in libuv.a(thread.c.o)
  "_pthread_barrier_wait", referenced from:
      _uv_barrier_wait in libuv.a(thread.c.o)

Am I missing something?
Thanks!

Tiny devices

It seems libuv runs only on unixes and Windows. Are you still aiming at small devices running these operating systems (say OpenWRT), or are you aiming also at embedded devices?

Anyway, I'm in. I see a big potential in this!

Integer-to-NULL comparison in dukluv/fs.c

It would appear that the dukluv/fs.c file contains a integer-to-NULL comparison in line 61: https://github.com/creationix/dukluv/blob/master/src/fs.c#L61

static int duv_string_to_flags(duk_context *ctx, const char* string) {
    bool read = false;
    bool write = false;
    int flags = 0;
    while (string && string[0] != NULL) { //< line 61
        switch (string[0]) {

Type of string[0] is char, but it is being compared with NULL (which is used for pointers, and may be (void*)0 in some compilers).

There maybe similar problems elsewhere, but I didn't check. Compiling with -Wall in GCC or CLang should emit a warning about this.

Bug with absolute filepath in argument

Calling DukLuv with an absolute filepath give me this error:

~/ $ ~/dukluv/build/dukluv /tmp/test.js

Uncaught Exception:

Error: ENOENT: no such file or directory: /home/tberthe/tmp/test.js
        /home/tberthe/dukluv/src/main.c:32
        anon  native strict preventsyield
        anon  native strict preventsyield
        anon  native strict preventsyield
        anon  native strict preventsyield

Failure in window operation

TypeError: cannot read property 'D:\x5cZUI\x5cTool/tcp-echo.js' of undefined
at [anon] (d:\zui\zui\duktape\duk_hobject_props.c:2336) internal

DukLuv fails to compile using VS2015

I was unable to build dukluv from a fresh checkout using Visual Studio 2015. After running CMake and opening the resulting solution file, I get the following syntax error when attempting to compile it:

4>c:\src\dukluv\src\duv.h(12): error C2059: syntax error: 'constant'

On this line:

typedef enum { false, true } bool;

I believe VS2013 and later include C99 bool via stdint.h, so that's likely the cause of this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.