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

intro module nactive success #4

Merged
merged 9 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/**/.vscode/**
/**/build/**
node_modules/
package-lock.json
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# bscan


Configure boilerplate to module

`node-gyp configure`

Run command to building the module

`node-gyp build`
62 changes: 61 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"target_name": "bscan",
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
"cflags_cc": [ "-std=c++17" ],
# sources: arquivoc C/C++ a ser compilados
"sources": [
"./src/libs/info/scan_battery.cpp",
Expand Down Expand Up @@ -38,12 +39,71 @@
"./src/libs/info/windows/scan_mainboard.cpp",
"./src/libs/info/windows/scan_os.cpp",
"./src/libs/info/windows/scan_ram.cpp",
# index bscan
"./src/libs/info/bscan.cpp",
],
# localizando node-api
# localizando include
"include_dirs": [
"include",
"<!@(node -p \"require('node-addon-api').include\")"
],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
'conditions': [
['OS=="linux"',
{
'defines': [

]
}
],
['OS=="win"',
{
'msvs_settings': {
'VCCLCompilerTool': {
"AdditionalOptions": [
"-std:c++17",
],
'WarningLevel': 4,
'BufferSecurityCheck': 'true',
'WarnAsError': 'false',
'ExceptionHandling': 1,
'DisableSpecificWarnings': [
4100, 4127, 4201, 4244, 4267, 4506, 4611, 4714, 4512
]
},
'VCLibrarianTool': {
},
'VCLinkerTool': {
'GenerateDebugInformation': 'true',
"AdditionalOptions": [ '/ignore:4267' ],
'DisableSpecificWarnings': [ '4990', '4530' ],
},
},
'defines': [
'WINDOWS_SPECIFIC_DEFINE',
],
}
],
['OS=="mac"',
{
'xcode_settings': {
'OTHER_LDFLAGS': [
'-fsanitize=address',
'-Wl,-bind_at_load'
],
'GCC_ENABLE_CPP_RTTI': 'YES',
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'MACOSX_DEPLOYMENT_TARGET':'10.8',
'CLANG_CXX_LIBRARY': 'libc++',
'CLANG_CXX_LANGUAGE_STANDARD':'c++17',
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0'
},
'defines': [
'NON_WINDOWS_DEFINE',
],
}
],
]
}
]
}
1 change: 0 additions & 1 deletion include/bscan.h → include/hwares/hwares.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
#include "hwares/scan_disk.h"
#include "hwares/scan_gpu.h"
#include "hwares/scan_mainboard.h"
#include "swares/scan_os.h"
#include "hwares/scan_ram.h"
2 changes: 1 addition & 1 deletion include/hwares/scan_battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string>
#include <vector>

#include "platform.h"
#include "../platform.h"

namespace bscan {

Expand Down
2 changes: 1 addition & 1 deletion include/hwares/scan_cpuid.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "platform.h"
#include "../platform.h"

#if defined(BSCAN_X86)

Expand Down
2 changes: 1 addition & 1 deletion include/hwares/scan_mainboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string>
#include <vector>

#include "platform.h"
#include "../platform.h"

namespace bscan {

Expand Down
4 changes: 4 additions & 0 deletions include/swares/swares.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

#include "swares/scan_system.h"
#include "swares/scan_os.h"
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
"name": "bscan",
"version": "0.0.1",
"description": "A Node.js library to capture important information from the Computing Device Hardwares & Softwares",
"keywords": ["node-api", "cplsplus", "modules", "hardware", "software", "scan-dev", "scan-tool"],
"keywords": [
"node-api",
"cplsplus",
"modules",
"hardware",
"software",
"scan-dev",
"scan-tool"
],
"author": "BWC @BarcaWebCloud <contact@barca.com>",
"license": "ISC",
"dependencies": {
"node-addon-api": "^6.0.0"
},
"devDependencies": {
"node-gyp": "^9.3.1"
}
}
26 changes: 26 additions & 0 deletions src/libs/info/bscan.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <napi.h>
#include <string>
#include "../../../include/hwares/hwares.h"
#include "../../../include/swares/swares.h"

Napi::String cpu(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
bscan::CPU cpu;

std::string result = cpu.vendor();

return Napi::String::New(env, result);
}

// callback of function when module is registered with Node.js
Napi::Object Init(Napi::Env env, Napi::Object exports) {
// set a key on `exports`object
exports.Set(
Napi::String::New(env, "cpu"),
Napi::Function::New(env, cpu)
);

return exports;
}

NODE_API_MODULE(bscan, Init)
4 changes: 2 additions & 2 deletions src/libs/info/scan_cpu.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "hwares/scan_cpu.h"
#include "hwares/scan_cpuid.h"
#include "../../../include/hwares/scan_cpu.h"
#include "../../../include/hwares/scan_cpuid.h"
#include <string>
#include <vector>
#include "platform.h"
Expand Down