{"action":"created","issue":{"url":"https://api.github.com/repos/luapower/luapower/issues/7","repository_url":"https://api.github.com/repos/luapower/luapower","labels_url":"https://api.github.com/repos/luapower/luapower/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/luapower/luapower/issues/7/comments","events_url":"https://api.github.com/repos/luapower/luapower/issues/7/events","html_url":"https://github.com/luapower/luapower/issues/7","id":299081179,"number":7,"title":"Windows build problem and possible fix (luapower_cli related)","user":{"login":"radioflash","id":2119776,"avatar_url":"https://avatars2.githubusercontent.com/u/2119776?v=4","gravatar_id":"","url":"https://api.github.com/users/radioflash","html_url":"https://github.com/radioflash","followers_url":"https://api.github.com/users/radioflash/followers","following_url":"https://api.github.com/users/radioflash/following{/other_user}","gists_url":"https://api.github.com/users/radioflash/gists{/gist_id}","starred_url":"https://api.github.com/users/radioflash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radioflash/subscriptions","organizations_url":"https://api.github.com/users/radioflash/orgs","repos_url":"https://api.github.com/users/radioflash/repos","events_url":"https://api.github.com/users/radioflash/events{/privacy}","received_events_url":"https://api.github.com/users/radioflash/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-21T18:36:38Z","updated_at":"2018-02-21T18:47:16Z","closed_at":"2018-02-21T18:47:16Z","author_association":"NONE","body":"Luapower (C-) modules can not be built because the output of luapower_cli can not be parsed correctly.\r\n\r\nThis is because the output of luapower_cli contains CRLF instead of just LF as newline characters, which breaks the bash-scripts for building (because of stray CR characters):\r\n\r\n```bash\r\nfor pkg in $packages; do\r\n    echo\r\n    echo \"-----------------------------------------------------------\"\r\n    echo\r\n    echo \"*** Building $pkg for $platform ***\"\r\n    echo\r\n    (cd csrc/$pkg && ./build-$platform.sh)\r\ndone\r\n```\r\nNote the stray `\\r` in the output: \r\n```bash\r\n[...]\r\n.mgit/build-all.sh: line 36: cd: $'csrc/pixman\\r': No such file or directory`\r\n[...]\r\n```\r\n\r\n## Possible solution\r\nSwitching Lua stdout to binary mode: \r\nThis is simple with LuaJIT (can be directly inserted into luapower_cli.lua and fixes the issue):\r\n\r\n```lua\r\n--try and set file mode to binary to avoid writing out CR's\r\nlocal suc, s = pcall(function()\r\n  local ffi = require 'ffi'\r\n  if ffi.os == \"Windows\" then\r\n    ffi.cdef[[\r\n      int _setmode(int, int);\r\n      int _fileno(void *);\r\n    ]]\r\n    local _O_BINARY = 0x8000\r\n    ffi.C._setmode(ffi.C._fileno(io.stdout), _O_BINARY)\r\n  end\r\nend)\r\nif not suc then\r\n  error('Unable to try and set stdout mode to binary: \\n' .. tostring(s))\r\nend\r\n```\r\n\r\n### Alternative\r\nPossibly strip out the carriage returns in the bash scripts? Requires (possibly arcane) changes to every build scripts, though.\r\n\r\n## Affected\r\nAny build process that feeds output from luapower_cli into bash scripts.\r\nExample: `./mgit build-all --all`\r\n\r\n## Tested on\r\nWindows 10, Mingw toolchain 64bit (gcc 7.3.0 binaries from MSYS2 package manager, MINGW64 bash shell)\r\n\r\nPlease tell me if I can somehow help with getting this fixed/integrated.\r\nLuapower is awesome btw., thx for all the good work!"},"comment":{"url":"https://api.github.com/repos/luapower/luapower/issues/comments/367429417","html_url":"https://github.com/luapower/luapower/issues/7#issuecomment-367429417","issue_url":"https://api.github.com/repos/luapower/luapower/issues/7","id":367429417,"user":{"login":"capr","id":131660,"avatar_url":"https://avatars1.githubusercontent.com/u/131660?v=4","gravatar_id":"","url":"https://api.github.com/users/capr","html_url":"https://github.com/capr","followers_url":"https://api.github.com/users/capr/followers","following_url":"https://api.github.com/users/capr/following{/other_user}","gists_url":"https://api.github.com/users/capr/gists{/gist_id}","starred_url":"https://api.github.com/users/capr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capr/subscriptions","organizations_url":"https://api.github.com/users/capr/orgs","repos_url":"https://api.github.com/users/capr/repos","events_url":"https://api.github.com/users/capr/events{/privacy}","received_events_url":"https://api.github.com/users/capr/received_events","type":"User","site_admin":false},"created_at":"2018-02-21T18:47:16Z","updated_at":"2018-02-21T18:47:16Z","author_association":"OWNER","body":"Thanks for the report and the fix. And for the good words :)\r\nClosing this (reopen if needed)."}}
{"actor":{"display_login":"capr"}}