Code Monkey home page Code Monkey logo

Comments (14)

unbornchikken avatar unbornchikken commented on May 8, 2024

It's not the addon's package.json is the right place to include cmake-js runtime setting. CMake.js based modules are compatible with every node runtime inherently. The root application's package.json file is the place of the runtime settings. See the readme, I hope it's clear: https://github.com/unbornchikken/cmake-js#important

from cmake-js.

hankbao avatar hankbao commented on May 8, 2024

@unbornchikken I've read the documentation twice. I'm pretty sure that I've put the cmake-js runtime setting in the root application's package.json.

from cmake-js.

unbornchikken avatar unbornchikken commented on May 8, 2024

Ok. What is the output of cmake-js rebuild -l=silly?

from cmake-js.

hankbao avatar hankbao commented on May 8, 2024

After run cmake-js rebuild -r electron -v 0.29.2 -a ia32 -l=silly In my addon folder, got some outputs:

sill CON argv:
sill CON { _: [ 'rebuild' ],
sill CON   version: false,
sill CON   h: false,
sill CON   help: false,
sill CON   D: false,
sill CON   debug: false,
sill CON   m: false,
sill CON   'prefer-make': false,
sill CON   preferMake: false,
sill CON   g: false,
sill CON   'prefer-gnu': false,
sill CON   preferGnu: false,
sill CON   o: false,
sill CON   prec11: false,
sill CON   r: 'electron',
sill CON   runtime: 'electron',
sill CON   v: '0.29.2',
sill CON   'runtime-version': '0.29.2',
sill CON   runtimeVersion: '0.29.2',
sill CON   a: 'ia32',
sill CON   arch: 'ia32',
sill CON   l: 'silly',
sill CON   'log-level': 'silly',
sill CON   logLevel: 'silly',
sill CON   '$0': '/usr/local/bin/cmake-js',
sill CON   d: undefined,
sill CON   c: undefined }
verb CON Parsing arguments
verb CON options:
verb CON { directory: null,
verb CON   debug: false,
verb CON   cmakePath: null,
verb CON   preferMake: false,
verb CON   preferGnu: false,
verb CON   forceNoC11: false,
verb CON   runtime: 'electron',
verb CON   runtimeVersion: '0.29.2',
verb CON   arch: 'ia32' }
verb CON Running command: rebuild
verb CFG Looking for application level CMake.js config in '/tmp/myapp/module/myaddon.
sill CFG Looking for package.json in: '/tmp/myapp/module/myaddon/package.json'.
sill CFG Loaded:
sill CFG {"name":"myaddon","version":"0.1.1","description":"A native addon","main":"addon.js","private":true,"scripts":{"install":"cmake-js rebuild"},"keywords":["myaddon"],"author":"Hank Bao","dependencies":{"nan":"^1.9.0","cmake-js":"^1.0.2"}}
sill CFG Config not found.
sill CFG Looking for parent path.
sill CFG Parent path: '/tmp/myapp/module'.
sill CFG Looking for package.json in: '/tmp/myapp/module/package.json'.
sill CFG 'package.json' not found.
sill CFG Looking for parent path.
sill CFG Parent path: '/tmp/myapp'.
sill CFG Looking for package.json in: '/tmp/myapp/package.json'.
sill CFG 'package.json' not found.
sill CFG Looking for parent path.
sill CFG Parent path: '/tmp'.
sill CFG Looking for package.json in: '/tmp/package.json'.
sill CFG 'package.json' not found.
sill CFG Looking for parent path.
sill CFG Parent path: '/'.
sill CFG Looking for package.json in: '/package.json'.
sill CFG 'package.json' not found.
sill CFG Looking for parent path.
sill CFG Parent path with package.json file doesn't exists. Done.
verb CFG Application level CMake.js config doesn't exists.
verb CFG Build system options:
verb CFG {"directory":"/tmp/myapp/module/myaddon","debug":false,"cmakePath":null,"preferMake":false,"preferGnu":false,"forceNoC11":false,"runtime":"electron","runtimeVersion":"0.29.2","arch":"ia32"}
info CMD CLEAN
info RUN cmake -E remove_directory "/tmp/myapp/module/myaddon/build"
info CMD CONFIGURE
info RUN cmake "/tmp/myapp/module/myaddon" --no-warn-unused-cli -GNinja -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/tmp/myapp/module/myaddon/build/Release" -DCMAKE_JS_INC="/Users/hankbao/.cmake-js/electron-ia32/v0.29.2/src;/Users/hankbao/.cmake-js/electron-ia32/v0.29.2/deps/v8/include;/Users/hankbao/.cmake-js/electron-ia32/v0.29.2/deps/uv/include;/tmp/myapp/module/myaddon/node_modules/nan" -DNODE_RUNTIME="electron" -DNODE_RUNTIMEVERSION="0.29.2" -DNODE_ARCH="ia32" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_CXX_FLAGS="-D_DARWIN_USE_64_BIT_INODE=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DBUILDING_NODE_EXTENSION -w -std=c++11" -DCMAKE_SHARED_LINKER_FLAGS="-undefined dynamic_lookup"
Not searching for unused variables given on the command line.
-- The C compiler identification is AppleClang 6.1.0.6020053
-- The CXX compiler identification is AppleClang 6.1.0.6020053
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/myapp/module/myaddon/build
info CMD BUILD
info RUN cmake --build "/tmp/myapp/module/myaddon/build" --config Release
[8/8] Linking CXX shared library Release/myaddon.node

from cmake-js.

unbornchikken avatar unbornchikken commented on May 8, 2024

In this case, passing runtime argument explicitily, it builds the right binary definitely. But I've asked for the output of:

cmake-js rebuild -l=silly

Because it runs when the modules gets installed by the npm.

from cmake-js.

hankbao avatar hankbao commented on May 8, 2024

The problem is that even the module built by specifying runtime arguments explicitily still can't be required by the js run in electron 0.29.2. Got the same exception. I suspect the problem may related to my CMakeLists.txt.

from cmake-js.

unbornchikken avatar unbornchikken commented on May 8, 2024

Do you have a repo url or sumthin' that I can take a look at?

from cmake-js.

hankbao avatar hankbao commented on May 8, 2024

Thanks for your help. Here's my CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

# Name of the project (will be the name of the plugin)
project(addon)

# Essential include files to build a node addon,
# you should add this line in every CMake.js based project.
include_directories(${CMAKE_JS_INC})

# Declare the source files location
file(GLOB SOURCE_FILES "src/addon.cc" "src/sound.h")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
        file(GLOB SOURCE_FILES
                ${SOURCE_FILES}
                "src/mac/addon1.*"
                "src/mac/addon_mac.*"
                "src/mac/Addon.*"
                "src/mac/addon2.*"
                "src/mac/addon3.*"
                "src/mac/addon4.*"
                "src/mac/addon5.*")

        find_library(FOUNDATION_LIBRARY Foundation)
        find_library(APPKIT_LIBRARY AppKit)
        find_library(APP_SERVICES_LIBRARY ApplicationServices)
        find_library(CORE_GRAPHICS_LIBRARY CoreGraphics)
        mark_as_advanced(FOUNDATION_LIBRARY
                        APPKIT_LIBRARY
                        APP_SERVICES_LIBRARY
                        CORE_GRAPHICS_LIBRARY)
        set(EXTRA_LIBS ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY} ${APP_SERVICES_LIBRARY} ${CORE_GRAPHICS_LIBRARY})

        set(ENV{MACOSX_DEPLOYMENT_TARGET} "10.7.0")
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-arc")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -std=c++11 -stdlib=libc++")

        set(CMAKE_MACOSX_RPATH FALSE)
        set(CMAKE_FIND_FRAMEWORK ONLY)
elseif(WIN32)
        file(GLOB SOURCE_FILES
                ${SOURCE_FILES}
                "src/win/addon_win.*"
                "src/win/Addon.*")
endif()

# This line will tell CMake that we're building a shared library
# from the above source files
# named after the project's name
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})

# This line will give our library file a .node extension without any "lib" prefix
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")

# Essential library files to link to a node addon,
# you should add this line in every CMake.js based project.
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} ${EXTRA_LIBS})

from cmake-js.

unbornchikken avatar unbornchikken commented on May 8, 2024

I believe that your gnu C++ toolchain is not for x86 architecture.

https://github.com/unbornchikken/cmake-js#runtimes

arch: architecutre of application's target runtime (eg: x64, ia32, arm). Notice: on non-Windows systems the C++ toolset's architecture's gonna be used despite of this setting. If you don't specify this on Windows, then architecture of the main node/io.js runtime is gonna be used, so you have to choose a matching nw.js runtime.

What is the output of:

g++ -v

or

g++ -dumpmachine

from cmake-js.

hankbao avatar hankbao commented on May 8, 2024
$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix

from cmake-js.

unbornchikken avatar unbornchikken commented on May 8, 2024

Yes, that is the case. Unfortunatelly on non Windows systems, build architecture is cannot be specified, it given by the actual GNU C++ toolchain. Which electron release package are you using exatly from there: https://github.com/atom/electron/releases ?

from cmake-js.

hankbao avatar hankbao commented on May 8, 2024

electron-prebuilt: ^0.29.2

from cmake-js.

unbornchikken avatar unbornchikken commented on May 8, 2024

So it's a node application that installs electron-prebuilt as a dev dependency. Lemme see your app's package.json!

from cmake-js.

hankbao avatar hankbao commented on May 8, 2024

Oops... silly me. I found out that I've installed electron from homebrew cask & electron-prebuilt from npm. After uninstalling the homebrew one, the problem is gone. Thanks anyway.

from cmake-js.

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.