thegecko / webbluetooth

Node.js implementation of the Web Bluetooth Specification
https://thegecko.github.io/webbluetooth/
MIT License
141 stars 21 forks source link

Allow local build #180

Closed Apollon77 closed 2 months ago

Apollon77 commented 3 months ago

This PR adds the SimpleBLE directory and all sub dirs to the npm package. I verified with publish dry run" that it would be added to the package and validated that it can install on a raspi 4 with an "npm pack" version of that.

BTW: A GitHub install would not check the SimpleBLE directory out and so would not work here!

Means: I could test it only with npm pack

fixes #179

PS: The PR contains two extra commits from trying to get more debug infos, just squash&merge it ...

Apollon77 commented 3 months ago

@thegecko Hm .. Ok tried with a pack file ... error now on raspi is:

ingof@raspi16g:~/test$ npm i webbluetooth-3.2.1.tgz 
npm ERR! code 1
npm ERR! path /home/ingof/test/node_modules/webbluetooth
npm ERR! command failed
npm ERR! command sh -c prebuild-install --backend cmake-js --runtime napi || cmake-js rebuild
npm ERR! Not searching for unused variables given on the command line.
npm ERR! -- The C compiler identification is GNU 11.4.0
npm ERR! -- The CXX compiler identification is GNU 11.4.0
npm ERR! -- Detecting C compiler ABI info
npm ERR! -- Detecting C compiler ABI info - done
npm ERR! -- Check for working C compiler: /usr/bin/cc - skipped
npm ERR! -- Detecting C compile features
npm ERR! -- Detecting C compile features - done
npm ERR! -- Detecting CXX compiler ABI info
npm ERR! -- Detecting CXX compiler ABI info - done
npm ERR! -- Check for working CXX compiler: /usr/bin/c++ - skipped
npm ERR! -- Detecting CXX compile features
npm ERR! -- Detecting CXX compile features - done
npm ERR! -- Module support is disabled.
npm ERR! -- Version: 9.1.0
npm ERR! -- Build type: Release
npm ERR! -- CXX_STANDARD: 11
npm ERR! -- Performing Test has_std_11_flag
npm ERR! -- Performing Test has_std_11_flag - Success
npm ERR! -- Performing Test has_std_0x_flag
npm ERR! -- Performing Test has_std_0x_flag - Success
npm ERR! -- Required features: cxx_variadic_templates
npm ERR! -- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
npm ERR! -- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
npm ERR! -- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
npm ERR! -- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
npm ERR! -- Performing Test COMPILER_HAS_DEPRECATED_ATTR
npm ERR! -- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
npm ERR! -- Linux Host Detected
npm ERR! -- Configuring incomplete, errors occurred!
npm ERR! See also "/home/ingof/test/node_modules/webbluetooth/build/CMakeFiles/CMakeOutput.log".
npm ERR! prebuild-install warn install No prebuilt binaries found (target=6 runtime=napi arch=arm64 libc= platform=linux)
npm ERR! info TOOL Using Unix Makefiles generator.
npm ERR! info CMD CLEAN
npm ERR! info RUN [
npm ERR! info RUN   'cmake',
npm ERR! info RUN   '-E',
npm ERR! info RUN   'remove_directory',
npm ERR! info RUN   '/home/ingof/test/node_modules/webbluetooth/build'
npm ERR! info RUN ]
npm ERR! info CMD CONFIGURE
npm ERR! info RUN [
npm ERR! info RUN   'cmake',
npm ERR! info RUN   '/home/ingof/test/node_modules/webbluetooth',
npm ERR! info RUN   '--no-warn-unused-cli',
npm ERR! info RUN   '-G',
npm ERR! info RUN   'Unix Makefiles',
npm ERR! info RUN   '-DCMAKE_JS_VERSION=7.3.0',
npm ERR! info RUN   '-DCMAKE_BUILD_TYPE=Release',
npm ERR! info RUN   '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/ingof/test/node_modules/webbluetooth/build/Release',
npm ERR! info RUN   '-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>',
npm ERR! info RUN   '-DCMAKE_JS_INC=/home/ingof/test/node_modules/node-api-headers/include;/home/ingof/test/node_modules/node-addon-api',
npm ERR! info RUN   '-DCMAKE_JS_SRC=',
npm ERR! info RUN   '-DNODE_RUNTIME=node',
npm ERR! info RUN   '-DNODE_RUNTIMEVERSION=18.17.1',
npm ERR! info RUN   '-DNODE_ARCH=arm64',
npm ERR! info RUN   '-DCMAKE_JS_LIB=',
npm ERR! info RUN   '-DCMAKE_CXX_FLAGS=-DBUILDING_NODE_EXTENSION'
npm ERR! info RUN ]
npm ERR! CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
npm ERR!   Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
npm ERR! Call Stack (most recent call first):
npm ERR!   /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
npm ERR!   /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:99 (find_package_handle_standard_args)
npm ERR!   SimpleBLE/cmake/find/FindDBus1.cmake:7 (find_package)
npm ERR!   SimpleBLE/simpleble/CMakeLists.txt:161 (find_package)
npm ERR! 
npm ERR! 
npm ERR! ERR! OMG Process terminated: 1

npm ERR! A complete log of this run can be found in: /home/ingof/.npm/_logs/2024-03-25T14_14_05_824Z-debug-0.log

PS: the /home/ingof/test/node_modules/webbluetooth/build/CMakeFiles/CMakeOutput.log does not exist, I assume because npm cleans that up gg

Apollon77 commented 3 months ago

Ok ... I installed pkg-config package ... now it tells me it can not find dbus-1 .. but it seems there ... at least the only package I could install "libdbus-1-3" ... aahh needs tio be libdbus-1-dev

Apollon77 commented 3 months ago

now I get

ingof@raspi16g:~/test$ npm i webbluetooth-3.2.1.tgz 
npm ERR! code 1
npm ERR! path /home/ingof/test/node_modules/webbluetooth
npm ERR! command failed
npm ERR! command sh -c prebuild-install --backend cmake-js --runtime napi || cmake-js rebuild
npm ERR! Not searching for unused variables given on the command line.
npm ERR! -- The C compiler identification is GNU 11.4.0
npm ERR! -- The CXX compiler identification is GNU 11.4.0
npm ERR! -- Detecting C compiler ABI info
npm ERR! -- Detecting C compiler ABI info - done
npm ERR! -- Check for working C compiler: /usr/bin/cc - skipped
npm ERR! -- Detecting C compile features
npm ERR! -- Detecting C compile features - done
npm ERR! -- Detecting CXX compiler ABI info
npm ERR! -- Detecting CXX compiler ABI info - done
npm ERR! -- Check for working CXX compiler: /usr/bin/c++ - skipped
npm ERR! -- Detecting CXX compile features
npm ERR! -- Detecting CXX compile features - done
npm ERR! -- Module support is disabled.
npm ERR! -- Version: 9.1.0
npm ERR! -- Build type: Release
npm ERR! -- CXX_STANDARD: 11
npm ERR! -- Performing Test has_std_11_flag
npm ERR! -- Performing Test has_std_11_flag - Success
npm ERR! -- Performing Test has_std_0x_flag
npm ERR! -- Performing Test has_std_0x_flag - Success
npm ERR! -- Required features: cxx_variadic_templates
npm ERR! -- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
npm ERR! -- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
npm ERR! -- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
npm ERR! -- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
npm ERR! -- Performing Test COMPILER_HAS_DEPRECATED_ATTR
npm ERR! -- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
npm ERR! -- Linux Host Detected
npm ERR! -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
npm ERR! -- Applying definition: SIMPLEBLE_LOG_LEVEL=SIMPLEBLE_LOG_LEVEL_INFO
npm ERR! -- Applying definition: SIMPLEDBUS_LOG_LEVEL=FATAL
npm ERR! -- Applying definition: SIMPLEBLUEZ_LOG_LEVEL=FATAL
npm ERR! -- Applying definition: SIMPLEBLE_LOG_LEVEL=SIMPLEBLE_LOG_LEVEL_INFO
npm ERR! -- Applying definition: SIMPLEDBUS_LOG_LEVEL=FATAL
npm ERR! -- Applying definition: SIMPLEBLUEZ_LOG_LEVEL=FATAL
npm ERR! -- Configuring done
npm ERR! prebuild-install warn install No prebuilt binaries found (target=6 runtime=napi arch=arm64 libc= platform=linux)
npm ERR! info TOOL Using Unix Makefiles generator.
npm ERR! info CMD CLEAN
npm ERR! info RUN [
npm ERR! info RUN   'cmake',
npm ERR! info RUN   '-E',
npm ERR! info RUN   'remove_directory',
npm ERR! info RUN   '/home/ingof/test/node_modules/webbluetooth/build'
npm ERR! info RUN ]
npm ERR! info CMD CONFIGURE
npm ERR! info RUN [
npm ERR! info RUN   'cmake',
npm ERR! info RUN   '/home/ingof/test/node_modules/webbluetooth',
npm ERR! info RUN   '--no-warn-unused-cli',
npm ERR! info RUN   '-G',
npm ERR! info RUN   'Unix Makefiles',
npm ERR! info RUN   '-DCMAKE_JS_VERSION=7.3.0',
npm ERR! info RUN   '-DCMAKE_BUILD_TYPE=Release',
npm ERR! info RUN   '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/ingof/test/node_modules/webbluetooth/build/Release',
npm ERR! info RUN   '-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>',
npm ERR! info RUN   '-DCMAKE_JS_INC=/home/ingof/test/node_modules/node-api-headers/include;/home/ingof/test/node_modules/node-addon-api',
npm ERR! info RUN   '-DCMAKE_JS_SRC=',
npm ERR! info RUN   '-DNODE_RUNTIME=node',
npm ERR! info RUN   '-DNODE_RUNTIMEVERSION=18.17.1',
npm ERR! info RUN   '-DNODE_ARCH=arm64',
npm ERR! info RUN   '-DCMAKE_JS_LIB=',
npm ERR! info RUN   '-DCMAKE_CXX_FLAGS=-DBUILDING_NODE_EXTENSION'
npm ERR! info RUN ]
npm ERR! CMake Error at SimpleBLE/simpleble/CMakeLists.txt:72 (add_library):
npm ERR!   Cannot find source file:
npm ERR! 
npm ERR!     /home/ingof/test/node_modules/webbluetooth/SimpleBLE/simpleble/src/frontends/base/Adapter.cpp
npm ERR! 
npm ERR! 
npm ERR! CMake Error at SimpleBLE/simpleble/CMakeLists.txt:72 (add_library):
npm ERR!   No SOURCES given to target: simpleble
npm ERR! 
npm ERR! 
npm ERR! CMake Generate step failed.  Build files cannot be regenerated correctly.
npm ERR! ERR! OMG Process terminated: 1

npm ERR! A complete log of this run can be found in: /home/ingof/.npm/_logs/2024-03-25T14_30_57_923Z-debug-0.log

Any idea?

thegecko commented 2 months ago

If the source isn't coming from the package (this PR isnt released yet) then you need to clone it in. As SimpleBLE is a submodule, you'll need to clone it recursively.

Apollon77 commented 2 months ago

Iiinteresting ... yes now I see that really files are missing ... grmpff ... ok will pay areound further

Apollon77 commented 2 months ago

Ahhhh ... I found it ... the "src" in npmignore caused the SimpleBLE/simpleble/src* to be excluded from the npm pack ... I will verify

Apollon77 commented 2 months ago

@thegecko ok with these changes I was able to install it via an "npm pack" version on my raspi

ingof@raspi16g:~/test$ npm i webbluetooth-3.2.1.tgz

added 98 packages in 12m

Took ages, but worked :-)

I updated the first comment her ein this PR

thegecko commented 2 months ago

The '/' you've added forces the ignore match to only see the ones in the root folder.

I think your change only needs to remove the src and SimpleBLE entries.

Apollon77 commented 2 months ago

I added the "/" because I assumed that these folders should only exist on root level and so this should be more accurate to prevent the case that there are unwanted sub dirs excluded. And removing src from the list the src on root would been included in the resulting package which I also thought that ot is a reason that this should not be.

I can adjust as you said if you want that way, but maybe reconsider with infos above.

thegecko commented 2 months ago

Please keep this PR for the original intent. Changing other inclusions may have undesired side effects and requires further testing

Apollon77 commented 2 months ago

Allright, adjusted, if you are ok with the side effect now that Typescript files in src on root will now also be published on npm (that lso has it's benefits in my eyes) ;-)

Apollon77 commented 2 months ago

PS: Depending what you want we could also just use /src to still exclude src on root level as it was before. your decision

thegecko commented 2 months ago

LGTM, thanks!