Open johnnyman727 opened 8 years ago
interesting, just tried that on an a small example to see what it does:
>> print json.dumps(ast.literal_eval(open("./node_modules/johnny-five/node_modules/serialport/binding.gyp").read()))
{"targets": [{"target_name": "serialport", "sources": ["src/serialport.cpp"], "conditions": [["OS==\"win\"", {"sources": ["src/serialport_win.cpp", "src/win/disphelper.c", "src/win/enumser.cpp"], "msvs_settings": {"VCCLCompilerTool": {"ExceptionHandling": "2", "DisableSpecificWarnings": ["4530", "4506"]}}}], ["OS==\"mac\"", {"sources": ["src/serialport_unix.cpp", "src/serialport_poller.cpp"], "xcode_settings": {"OTHER_LDFLAGS": ["-framework CoreFoundation -framework IOKit"]}}], ["OS!=\"win\"", {"sources": ["src/serialport_unix.cpp", "src/serialport_poller.cpp"]}]], "include_dirs": ["<!(node -e \"require('nan')\")"]}, {"target_name": "action_after_build", "dependencies": ["<(module_name)"], "type": "none", "copies": [{"files": ["<(PRODUCT_DIR)/<(module_name).node"], "destination": "<(module_path)"}]}]}
Interesting that this approach works better than say:
fs = require('fs');
JSON.parse(fs.readFileSync('some_gyp'))
But indeed, it is sometimes hard to keep up with the many languages around. I saw that Python tools are used quite a lot for ESP8266 programming.
But Python vs Node.js seems to get an important question when it comes to connected devices, e.g. this discussion is interesting too: https://www.reddit.com/r/IOT/comments/41q86h/what_programming_languages_would_you_learn_if_you/
@mulderp the main reason we have that line in Python is because of the variety of .gyp file formats in the wild. Many of them are non standard JSON so you can't use JSON.parse
reliably.
Or, why we use Python code in a JavaScript library to import an executable likely compiled from C++.
This talk walks through the Tessel Project's journey to build the best developer tools for running Node.js on embedded devices. Building Node capabilities into embedded devices empowers millions of web developers to get their hands dirty and solve problems in an entirely new and previously intimidating domain.
Over the past 3 years, the project has encountered countless roadblocks including but not limited to: embedded memory constraints, transpiling other languages, and the dreaded binary modules- all for the glory of running Node.js everywhere. This talk will walk through how we overcame those challenges and what's next for Node.js on embedded devices.