Giter VIP home page Giter VIP logo

Comments (10)

zhex900 avatar zhex900 commented on June 17, 2024

Hi @TingDaoK

Are you able to help me with this?

The basic problem is aws-crt uses cmake but electron uses node-gyp.

This issue seems to provide a workaround. But I have no idea how to follow it.
electron/rebuild#268

from aws-crt-nodejs.

zhex900 avatar zhex900 commented on June 17, 2024

I need a binding.gyp file for https://github.com/electron/electron-rebuild to rebuild the aws-crt.

But I don't know what to put inside the binding.gyp

Looks like blinding.gyp was once there. But it was deleted. Any chance someone can bring it back?

6101a0d

This is my first try. It doesn't work. But I can work it if I can get some direction.

# binding.gyp
{
    "variables": {
        "deps_install_dir": "'<!(node -p \"process.env.AWS_C_INSTALL ? process.env.AWS_C_INSTALL.replace(/\\\"+/g,'') : require('path').join(process.cwd(), 'deps_build', 'install')\")'",
        "build_args": "<!(node -p \"require('./package.json').debug ? \'--debug\' : \'--release\'\")"
    },
    "targets": [
        {
            "target_name": "aws-crt",
            "sources": [
                "<!@(node -p \"require('fs').readdirSync('./source/').map(f=>'source/'+f).join(' ')\")",
            ],
            "defines": [
                "NAPI_VERSION=<(napi_build_version)",
            ],
            "include_dirs": [
                "<!(node -p \"require('path').join(<(deps_install_dir),'include')\")",
            ],
            "library_dirs": [   
                "<!(node -p \"require('path').join(<(deps_install_dir),'lib')\")",
            ],
            "libraries": [
                "-laws-c-mqtt",
                "-laws-c-http",
                "-laws-c-io",
                "-laws-c-common",
                "-laws-c-cal",
            ],
            "conditions": [
                ["OS=='win'", {
                    "cflags": [
                        "/Wall",
                        "/WX",
                        "/NODEFAULTLIB:library",
                    ],
                    "libraries": [
                        "-lSecur32",
                        "-lCrypt32",
                        "-lAdvapi32",
                        "-lBCrypt",
                        "-lKernel32",
                        "-lWs2_32",
                        "-lLIBCMT",
                    ],
                }, {
                    "cflags": [
                        "-std=gnu99",
                        "-Wall",
                        "-Wextra",
                        "-pedantic",
                    ],
                }],
                ["OS=='linux'", {
                    "libraries": [
                        "-ls2n",
                        "-lcrypto",
                        "-lgcc",
                    ],
                }],
                ["OS=='mac'", {
                    "libraries": [
                        "-l/System/Library/Frameworks/Security.framework",
                    ],
                }],
            ],
        }
    ]
}

from aws-crt-nodejs.

zhex900 avatar zhex900 commented on June 17, 2024

I think I have made some progress.

Here is what I did.

First I build the aws-crt source in windows.

I copied the built code to node-modules/aws-crt in my electron app

#binding.gyp
{
    "targets": [
        {
            "target_name": "aws-crt",
            "sources": [
                "<!@(node -p \"require('fs').readdirSync('./source/').map(f=>'source/'+f).join(' ')\")",
            ],
            "include_dirs": [
                "<!(node -p \"require('node-addon-api').include_dir\")",
                "<!(node -p \"require('path').join('dist/include')\")",
            ],
            "library_dirs": [   
                "<!(node -p \"require('path').join('dist/lib')\")",
            ],
            "libraries": [
                "-laws-c-mqtt",
                "-laws-c-http",
                "-laws-c-io",
                "-laws-c-common",
                "-laws-c-cal",
            ],
            "conditions": [
                ["OS=='win'", {
                    "cflags": [
                        "/Wall",
                        "/WX",
                        "/NODEFAULTLIB:library",
                    ],
                    "libraries": [
                        "-lSecur32",
                        "-lCrypt32",
                        "-lAdvapi32",
                        "-lBCrypt",
                        "-lKernel32",
                        "-lWs2_32",
                        "-lLIBCMT",
                    ],
                }, {
                    "cflags": [
                        "-std=gnu99",
                        "-Wall",
                        "-Wextra",
                        "-pedantic",
                    ],
                }],
                ["OS=='linux'", {
                    "libraries": [
                        "-ls2n",
                        "-lcrypto",
                        "-lgcc",
                    ],
                }],
                ["OS=='mac'", {
                    "libraries": [
                        "-l/System/Library/Frameworks/Security.framework",
                    ],
                }],
            ],
        }
    ]
}
PS C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt> ls .\dist\lib\


    Directory: C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\dist\lib


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         6/16/2021   9:38 PM                aws-c-auth
d-----         6/16/2021   9:38 PM                aws-c-cal
d-----         6/16/2021   9:38 PM                aws-c-common
d-----         6/16/2021   9:38 PM                aws-c-compression
d-----         6/16/2021   9:38 PM                aws-c-http
d-----         6/16/2021   9:38 PM                aws-c-io
d-----         6/16/2021   9:38 PM                aws-c-mqtt
d-----         6/16/2021   9:38 PM                cmake
-a----         6/16/2021   9:20 AM         637920 aws-c-auth.lib
-a----         6/16/2021   9:20 AM         102652 aws-c-cal.lib
-a----         6/16/2021   9:20 AM         626916 aws-c-common.lib
-a----         6/16/2021   9:20 AM          10162 aws-c-compression.lib
-a----         6/16/2021   9:20 AM        1096112 aws-c-http.lib
-a----         6/16/2021   9:20 AM         733968 aws-c-io.lib
-a----         6/16/2021   9:20 AM         298794 aws-c-mqtt.lib
PS C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt> ls .\dist\include\aws\


    Directory: C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\dist\include\aws


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         6/16/2021   9:38 PM                auth
d-----         6/16/2021   9:38 PM                cal
d-----         6/16/2021   9:38 PM                common
d-----         6/16/2021   9:38 PM                compression
d-----         6/16/2021   9:38 PM                http
d-----         6/16/2021   9:38 PM                io
d-----         6/16/2021   9:38 PM                mqtt
d-----         6/16/2021   9:38 PM                testing

C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): warning C4229: anachronism used
/* napi_value */ NAPI_MODULE_INIT() /* (napi_env env, napi_value exports) */ {

Something to do with napi. What am I missing?
I have already added

"<!(node -p \"require('node-addon-api').include_dir\")",

  C:\Users\jake\.electron-gyp\13.1.0\include\node" /I"C:\Users\jake\.electron-gyp\13.1.0\src" /I"C:\Users\jake\.electro
  n-gyp\13.1.0\deps\openssl\config" /I"C:\Users\jake\.electron-gyp\13.1.0\deps\openssl\openssl\include" /I"C:\Users\jak
  e\.electron-gyp\13.1.0\deps\uv\include" /I"C:\Users\jake\.electron-gyp\13.1.0\deps\zlib" /I"C:\Users\jake\.electron-g
  yp\13.1.0\deps\v8\include" /I..\undefined /I..\dist\include /Z7 /nologo /W3 /WX- /diagnostics:column /MP /Ox /Ob2 /Oi
   /Ot /Oy /GL /D "NODE_GYP_MODULE_NAME=aws-crt" /D USING_UV_SHARED=1 /D USING_V8_SHARED=1 /D V8_DEPRECATION_WARNINGS=1
   /D V8_DEPRECATION_WARNINGS /D V8_IMMINENT_DEPRECATION_WARNINGS /D V8_COMPRESS_POINTERS /D V8_31BIT_SMIS_ON_64BIT_ARC
  H /D V8_REVERSE_JSARGS /D WIN32 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _HAS_EXCEPTIONS=0 /D OPEN
  SSL_NO_PINSHARED /D OPENSSL_THREADS /D BUILDING_NODE_EXTENSION /D "HOST_BINARY=\"node.exe\"" /D _WINDLL /GF /Gm- /MT
  /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR- /Fo"Release\obj\aws-crt\\source\module.obj" /Fd"Release\
  obj\aws-crt\vc142.pdb" /external:env:EXTERNAL_INCLUDE /external:W3 /Gd /TC /wd4351 /wd4355 /wd4800 /wd4251 /wd4275 /w
  d4244 /wd4267 /FC /errorReport:queue ..\source\module.c
  module.c
| Preparing native dependencies: 0 / 1C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): warning C4229: anachronism used
: modifiers on data are ignored [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): error C2143: syntax error: miss
ing '{' before '-' [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): error C2059: syntax error: '-'
[C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): error C2143: syntax error: miss
ing ')' before '-' [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): error C2165: 'left-side modifie
r': cannot modify pointers to data [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxpro
j]
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): error C2059: syntax error: ')'
[C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
Done Building Project "C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj" (default t
argets) -- FAILED.

Done Building Project "C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\binding.sln" (default targe
ts) -- FAILED.


Build FAILED.

"C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\binding.sln" (default target) (1) ->
"C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj" (default target) (2) ->
(ClCompile target) ->
  C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): warning C4229: anachronism us
ed: modifiers on data are ignored [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj
]


"C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\binding.sln" (default target) (1) ->
"C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj" (default target) (2) ->
(ClCompile target) ->
  C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): error C2143: syntax error: mi
ssing '{' before '-' [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
  C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): error C2059: syntax error: '-
' [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
  C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): error C2143: syntax error: mi
ssing ')' before '-' [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
  C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): error C2165: 'left-side modif
ier': cannot modify pointers to data [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxp
roj]
  C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(543,18): error C2059: syntax error: ')
' [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]

    1 Warning(s)
    5 Error(s)

Time Elapsed 00:00:02.70
× Preparing native dependencies: 0 / 1

An unhandled error has occurred inside Forge:
node-gyp failed to rebuild 'C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt'.
Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1


Error: node-gyp failed to rebuild 'C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt'.
Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1


    at ModuleRebuilder.rebuildNodeGypModule (C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\electron-rebuild\src\module-rebuilder.ts:231:13)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at Rebuilder.rebuildModuleAt (C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\electron-rebuild\src\rebuild.ts:283:5)
    at Rebuilder.rebuild (C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\electron-rebuild\src\rebuild.ts:189:9)
    at C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\@electron-forge\core\src\util\rebuild.ts:33:5
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `electron-forge start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jake\AppData\Roaming\npm-cache\_logs\2021-06-16T12_05_30_460Z-debug.log

from aws-crt-nodejs.

TingDaoK avatar TingDaoK commented on June 17, 2024

Just checked with the team, referring to @justinboswell. We don't really support electron now, and binding.gyp will not work on Windows, we remove it as it is a bad solution. So, basically rebuild for electron will not work with our codebase.

A possible workaround is you can build aws-crt from source and link electron with the binary instead of rebuild. Possible reference here
I don't really have a good suggestion as I am super unfamiliar with electron...

from aws-crt-nodejs.

zhex900 avatar zhex900 commented on June 17, 2024

@TingDaoK
Why binding.gyp is a bad solution? I still want to try to rebuild with binding.gyp. Can you help me with my error message. I want to try it out.

from aws-crt-nodejs.

TingDaoK avatar TingDaoK commented on June 17, 2024

I read through the error message and have no clear idea. Did you follow the steps there?
I was told binding.gyp will not work on Windows, but I haven't tested it myself.
Feel free to try it out, but I don't know how I can help there.

from aws-crt-nodejs.

zhex900 avatar zhex900 commented on June 17, 2024

Yes. You have no idea too?

I don't understand the syntax error:

PS C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt> node-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
  module.c
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(542,1): warning C4229: anachronism used:
 modifiers on data are ignored [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(542,1): error C2143: syntax error: missi
ng '{' before '-' [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(542,1): error C2059: syntax error: '-' [
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(542,1): error C2143: syntax error: missi
ng ')' before '-' [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(542,1): error C2165: 'left-side modifier
': cannot modify pointers to data [C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj
]
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\source\module.c(542,1): error C2059: syntax error: ')' [
C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt\build\aws-crt.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\jake\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:376:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Windows_NT 10.0.19043
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\jake\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\Code\mir-kiosk-electron\electron-kiosk\node_modules\aws-crt
gyp ERR! node -v v14.17.0
gyp ERR! node-gyp -v v8.1.0
gyp ERR! not ok

from aws-crt-nodejs.

zhex900 avatar zhex900 commented on June 17, 2024

I will close this issue for now.

It is not resolved. But I have managed to use node-gyp to build this module. However, I still cannot use electron-rebuild to build this module.

https://github.com/zhex900/aws-crt-nodejs

from aws-crt-nodejs.

steveswinbank avatar steveswinbank commented on June 17, 2024

@zhex900 - Hey, I'm hitting this same issue when using the AWS IOT Javascript V2 SDK (which depends on aws-crt) in Electron on Windows.

Are you able to share the steps that you followed to build the module using node-gyp? The link you shared above goes to 404.

from aws-crt-nodejs.

zhex900 avatar zhex900 commented on June 17, 2024

HI @steveswinbank ,

I have spent a long time trying to work out a solution for this. In the end AWS said they don't support window build.

My work around was to use AWS IoT V1 SDK. Since it only uses MQTT. There is no need to use V2.

from aws-crt-nodejs.

Related Issues (20)

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.