Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepak Rajamohan committed Oct 17, 2021
1 parent 2d70c10 commit e5611ba
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 16 deletions.
10 changes: 10 additions & 0 deletions unit-test/binding-file-template.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const path = require('path');
const fs = require('fs');

/**
* @param bindingConfigurations
* This method acts as a template to generate the content of binding.cc file
Expand Down Expand Up @@ -27,3 +30,10 @@ module.exports.generateFileContent = function (bindingConfigurations) {

return Promise.resolve(content.join('\r\n'));
};

module.exports.writeToBindingFile = function writeToBindingFile (content) {
const generatedFilePath = path.join(__dirname, 'generated', 'binding.cc');
fs.writeFileSync(generatedFilePath, '');
fs.writeFileSync(generatedFilePath, content, { flag: 'a' });
console.log('generated binding file ', generatedFilePath, new Date());
};
1 change: 1 addition & 0 deletions unit-test/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'includes': ['../common.gypi'],
'include_dirs': ['../test/common', "./generated"],
'variables': {
'setup': ["<!@(node -p \"require('./setup')\")"],
'build_sources': [
"<!@(node -p \"require('./injectTestParams').filesToCompile()\")",
]
Expand Down
8 changes: 3 additions & 5 deletions unit-test/exceptions.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
*
* This file points out anamolies/exceptions in test files when generating the binding.cc file
* This file points out anomalies/exceptions in test files when generating the binding.cc file
*
* nouns: words in file names that are misspelled
* *NOTE: a 'constructor' property is explicitly added to override javascript object constructor
*
* exportNames: anamolies in init function names
* exportNames: anomalies in init function names
*
* propertyNames: anamolies in exported property name of init functions
* propertyNames: anomalies in exported property name of init functions
*
* skipBinding: skip including this file in binding.cc
*
*/
module.exports = {
nouns: {
Expand Down
11 changes: 1 addition & 10 deletions unit-test/generate-binding-cc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const fs = require('fs');
const path = require('path');
const listOfTestModules = require('./listOfTestModules');
const exceptions = require('./exceptions');
const generateFileContent = require('./binding-file-template').generateFileContent;
const { generateFileContent, writeToBindingFile } = require('./binding-file-template');

const buildDirs = listOfTestModules.dirs;
const buildFiles = listOfTestModules.files;
Expand Down Expand Up @@ -36,13 +34,6 @@ function generateBindingConfigurations () {
return Promise.resolve(configs);
}

function writeToBindingFile (content) {
const generatedFilePath = path.join(__dirname, 'generated', 'binding.cc');
fs.writeFileSync(generatedFilePath, '');
fs.writeFileSync(generatedFilePath, content, { flag: 'a' });
console.log('generated binding file ', generatedFilePath, new Date());
}

generateBindingConfigurations().then(generateFileContent).then(writeToBindingFile);

/**
Expand Down
4 changes: 3 additions & 1 deletion unit-test/injectTestParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const listOfTestModules = require('./listOfTestModules');
const buildDirs = listOfTestModules.dirs;
const buildFiles = listOfTestModules.files;

if (!fs.existsSync('./generated/')) { fs.mkdirSync('./generated/'); }
if (!fs.existsSync('./generated')) {
fs.mkdirSync('./generated');
}

/**
* @returns : list of files to compile by node-gyp
Expand Down
6 changes: 6 additions & 0 deletions unit-test/node_api.Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is generated by gyp; do not edit.

export builddir_name ?= ./build/../.
.PHONY: all
all:
$(MAKE) -C build nothing
184 changes: 184 additions & 0 deletions unit-test/nothing.target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# This file is generated by gyp; do not edit.

TOOLSET := target
TARGET := nothing
DEFS_Debug := \
'-DNODE_GYP_MODULE_NAME=nothing' \
'-DUSING_UV_SHARED=1' \
'-DUSING_V8_SHARED=1' \
'-DV8_DEPRECATION_WARNINGS=1' \
'-DV8_DEPRECATION_WARNINGS' \
'-DV8_IMMINENT_DEPRECATION_WARNINGS' \
'-D_DARWIN_USE_64_BIT_INODE=1' \
'-D_LARGEFILE_SOURCE' \
'-D_FILE_OFFSET_BITS=64' \
'-DOPENSSL_NO_PINSHARED' \
'-DOPENSSL_THREADS' \
'-DDEBUG' \
'-D_DEBUG' \
'-DV8_ENABLE_CHECKS'

# Flags passed to all source files.
CFLAGS_Debug := \
-O0 \
-gdwarf-2 \
-mmacosx-version-min=10.10 \
-arch x86_64 \
-Wall \
-Wendif-labels \
-W \
-Wno-unused-parameter

# Flags passed to only C files.
CFLAGS_C_Debug := \
-fno-strict-aliasing

# Flags passed to only C++ files.
CFLAGS_CC_Debug := \
-std=gnu++1y \
-stdlib=libc++ \
-fno-rtti \
-fno-exceptions \
-fno-strict-aliasing

# Flags passed to only ObjC files.
CFLAGS_OBJC_Debug :=

# Flags passed to only ObjC++ files.
CFLAGS_OBJCC_Debug :=

INCS_Debug := \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/include/node \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/src \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/deps/openssl/config \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/deps/openssl/openssl/include \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/deps/uv/include \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/deps/zlib \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/deps/v8/include

DEFS_Release := \
'-DNODE_GYP_MODULE_NAME=nothing' \
'-DUSING_UV_SHARED=1' \
'-DUSING_V8_SHARED=1' \
'-DV8_DEPRECATION_WARNINGS=1' \
'-DV8_DEPRECATION_WARNINGS' \
'-DV8_IMMINENT_DEPRECATION_WARNINGS' \
'-D_DARWIN_USE_64_BIT_INODE=1' \
'-D_LARGEFILE_SOURCE' \
'-D_FILE_OFFSET_BITS=64' \
'-DOPENSSL_NO_PINSHARED' \
'-DOPENSSL_THREADS'

# Flags passed to all source files.
CFLAGS_Release := \
-O3 \
-gdwarf-2 \
-mmacosx-version-min=10.10 \
-arch x86_64 \
-Wall \
-Wendif-labels \
-W \
-Wno-unused-parameter

# Flags passed to only C files.
CFLAGS_C_Release := \
-fno-strict-aliasing

# Flags passed to only C++ files.
CFLAGS_CC_Release := \
-std=gnu++1y \
-stdlib=libc++ \
-fno-rtti \
-fno-exceptions \
-fno-strict-aliasing

# Flags passed to only ObjC files.
CFLAGS_OBJC_Release :=

# Flags passed to only ObjC++ files.
CFLAGS_OBJCC_Release :=

INCS_Release := \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/include/node \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/src \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/deps/openssl/config \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/deps/openssl/openssl/include \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/deps/uv/include \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/deps/zlib \
-I/Users/t_rajad/Library/Caches/node-gyp/12.19.0/deps/v8/include

OBJS := \
$(obj).target/$(TARGET)/../nothing.o

# Add to the list of files we specially track dependencies for.
all_deps += $(OBJS)

# CFLAGS et al overrides must be target-local.
# See "Target-specific Variable Values" in the GNU Make manual.
$(OBJS): TOOLSET := $(TOOLSET)
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))
$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))

# Suffix rules, putting all outputs into $(obj).

$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)

# Try building from generated source, too.

$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)

$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)

# End of this set of suffix rules
### Rules for final target.
LDFLAGS_Debug := \
-mmacosx-version-min=10.10 \
-arch x86_64 \
-L$(builddir) \
-stdlib=libc++

LIBTOOLFLAGS_Debug :=

LDFLAGS_Release := \
-mmacosx-version-min=10.10 \
-arch x86_64 \
-L$(builddir) \
-stdlib=libc++

LIBTOOLFLAGS_Release :=

LIBS :=

$(builddir)/nothing.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
$(builddir)/nothing.a: LIBS := $(LIBS)
$(builddir)/nothing.a: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))
$(builddir)/nothing.a: TOOLSET := $(TOOLSET)
$(builddir)/nothing.a: $(OBJS) FORCE_DO_CMD
$(call do_cmd,alink)

all_deps += $(builddir)/nothing.a
# Add target alias
.PHONY: nothing
nothing: $(builddir)/nothing.a

# Add target alias to "all" target.
.PHONY: all
all: nothing

# Add target alias
.PHONY: nothing
nothing: $(builddir)/nothing.a

# Short alias for building this static library.
.PHONY: nothing.a
nothing.a: $(builddir)/nothing.a

# Add static library to "all" target.
.PHONY: all
all: $(builddir)/nothing.a

13 changes: 13 additions & 0 deletions unit-test/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require('fs');
const { generateFileContent, writeToBindingFile } = require('./binding-file-template');

/**
* @summary setup script to execute before node-gyp begins target actions
*/
if (!fs.existsSync('./generated')) {
// create generated folder
fs.mkdirSync('./generated');
// create empty binding.cc file
generateFileContent([]).then(writeToBindingFile);
// FIX: Its necessary to have an empty bindng.cc file, otherwise build fails first time
}

0 comments on commit e5611ba

Please sign in to comment.