Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make 'nothing' target a static library #348

Conversation

gabrielschulhof
Copy link
Contributor

This avoids the creation of nothing.node files in other projects.
These files will otherwise be identified as non-N-API modules, even
though they are empty.

This avoids the creation of `nothing.node` files in other projects.
These files will otherwise be identified as non-N-API modules, even
though they are empty.
@NickNaso
Copy link
Member

NickNaso commented Sep 18, 2018

Hi @gabrielschulhof I tried this update, but when I launch the tests I will get an error. I attach you the screenshot.
This happens on macOs 10.13.6 and Node.js 10.10.

screen shot 2018-09-19 at 00 35 29

@NickNaso
Copy link
Member

Hi @gabrielschulhof for curiosity I tried to do a little experiment and it works now.
These are the steps that I did:

  • Created an empty C file named nothing.c in the folder src
  • Updated the node_api.gyp as reported below:
{
  'targets': [
    {
      'target_name': 'nothing',
      'type': 'static_library',
      'sources': [
        'nothing.c'
      ],
    },
    {
      'target_name': 'node-api',
      'type': 'static_library',
      'sources': [
        'node_api.cc',
        'node_internals.cc',
      ],
      'defines': [
         'EXTERNAL_NAPI',
      ],
      'cflags_cc': ['-fvisibility=hidden']
    }
  ]
}

Searching on the web I found this:

Xcode requires at least one source file (it can be empty) in a target in order to produce any output at all. Without this, it doesn’t even know what language runtimes (C++ or Objective-C) are required.

Maybe we can use some flags to do the same.

@gabrielschulhof
Copy link
Contributor Author

@NickNaso we can definitely change it to be like that, as long as it doesn't produce a nothing.node file.

@NickNaso
Copy link
Member

NickNaso commented Sep 19, 2018

@gabrielschulhof It produces nothing.a as reported below:

screen shot 2018-09-19 at 11 19 34

@gabrielschulhof
Copy link
Contributor Author

@NickNaso that's fine. It's nothing.node that we want to avoid, because that looks like an addon, but isn't.

@mhdawson mhdawson mentioned this pull request Sep 24, 2018
6 tasks
@gabrielschulhof
Copy link
Contributor Author

@NickNaso I added an empty nothing.c file and I referenced it from the binding.gyp target. Can you please check that that fixes the build failure on OSX?

@NickNaso
Copy link
Member

@gabrielschulhof It worked!

Copy link
Member

@NickNaso NickNaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gabrielschulhof
Copy link
Contributor Author

Excellent!

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

mhdawson pushed a commit that referenced this pull request Sep 28, 2018
This avoids the creation of `nothing.node` files in other projects.
These files will otherwise be identified as non-N-API modules, even
though they are empty.

PR-URL: #348
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
@mhdawson
Copy link
Member

Landed as 211ed38

@mhdawson mhdawson closed this Sep 28, 2018
@gabrielschulhof gabrielschulhof deleted the change-nothing-target-type branch October 2, 2018 18:03
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
This avoids the creation of `nothing.node` files in other projects.
These files will otherwise be identified as non-N-API modules, even
though they are empty.

PR-URL: nodejs/node-addon-api#348
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
This avoids the creation of `nothing.node` files in other projects.
These files will otherwise be identified as non-N-API modules, even
though they are empty.

PR-URL: nodejs/node-addon-api#348
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
This avoids the creation of `nothing.node` files in other projects.
These files will otherwise be identified as non-N-API modules, even
though they are empty.

PR-URL: nodejs/node-addon-api#348
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
This avoids the creation of `nothing.node` files in other projects.
These files will otherwise be identified as non-N-API modules, even
though they are empty.

PR-URL: nodejs/node-addon-api#348
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants