Skip to content

Commit 40a210c

Browse files
committed
seeing what it takes to use node as a dynamic lib
1 parent 03399b8 commit 40a210c

File tree

698 files changed

+233102
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

698 files changed

+233102
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"targets": [
3+
{
4+
"target_name": "hello",
5+
"sources": [ "hello.mm" ]
6+
}
7+
]
8+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// hello.mm
2+
3+
#import <Foundation/Foundation.h>
4+
#import <Cocoa/Cocoa.h>
5+
6+
#include <node.h>
7+
#include <v8.h>
8+
9+
v8::Handle<v8::Value> Method(const v8::Arguments& args) {
10+
v8::HandleScope scope;
11+
NSAlert *alert = [[NSAlert alloc] init];
12+
[alert addButtonWithTitle:@"OK"];
13+
[alert addButtonWithTitle:@"Cancel"];
14+
[alert setMessageText:@"Delete the record?"];
15+
[alert setInformativeText:@"Deleted records cannot be restored."];
16+
[alert setAlertStyle:NSWarningAlertStyle];
17+
[alert runModal];
18+
return scope.Close(v8::String::New("world shmirld"));
19+
}
20+
21+
void init(v8::Handle<v8::Object> target) {
22+
target->Set(v8::String::NewSymbol("hello"),
23+
v8::FunctionTemplate::New(Method)->GetFunction());
24+
}
25+
NODE_MODULE(hello, init)
26+

src/mac/node-shell-lib/node-hello/hello.xcodeproj/project.pbxproj

Lines changed: 2553 additions & 0 deletions
Large diffs are not rendered by default.

src/mac/node-shell-lib/node-hello/hello.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
{
2+
'variables': {
3+
'strict_aliasing%': 'false', # turn on/off -fstrict-aliasing
4+
'visibility%': 'hidden', # V8's visibility setting
5+
'target_arch%': 'ia32', # set v8's target architecture
6+
'host_arch%': 'ia32', # set v8's host architecture
7+
'want_separate_host_toolset': 0, # V8 should not build target and host
8+
'library%': 'static_library', # allow override to 'shared_library' for DLL/.so builds
9+
'component%': 'static_library', # NB. these names match with what V8 expects
10+
'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way
11+
},
12+
13+
'target_defaults': {
14+
'default_configuration': 'Release',
15+
'configurations': {
16+
'Debug': {
17+
'defines': [ 'DEBUG', '_DEBUG' ],
18+
'cflags': [ '-g', '-O0' ],
19+
'conditions': [
20+
['target_arch=="x64"', {
21+
'msvs_configuration_platform': 'x64',
22+
}],
23+
],
24+
'msvs_settings': {
25+
'VCCLCompilerTool': {
26+
'RuntimeLibrary': 1, # static debug
27+
'Optimization': 0, # /Od, no optimization
28+
'MinimalRebuild': 'true',
29+
'OmitFramePointers': 'false',
30+
'BasicRuntimeChecks': 3, # /RTC1
31+
},
32+
'VCLinkerTool': {
33+
'LinkIncremental': 2, # enable incremental linking
34+
},
35+
},
36+
},
37+
'Release': {
38+
'cflags': [ '-O3', '-fdata-sections', '-ffunction-sections' ],
39+
'conditions': [
40+
['target_arch=="x64"', {
41+
'msvs_configuration_platform': 'x64',
42+
}],
43+
['OS=="solaris"', {
44+
'cflags': [ '-fno-omit-frame-pointer' ],
45+
}],
46+
['strict_aliasing!="true"', {
47+
'cflags': [ '-fno-strict-aliasing' ],
48+
}],
49+
],
50+
'msvs_settings': {
51+
'VCCLCompilerTool': {
52+
'RuntimeLibrary': 0, # static release
53+
'Optimization': 3, # /Ox, full optimization
54+
'FavorSizeOrSpeed': 1, # /Ot, favour speed over size
55+
'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
56+
'WholeProgramOptimization': 'true', # /GL, whole program optimization, needed for LTCG
57+
'OmitFramePointers': 'true',
58+
'EnableFunctionLevelLinking': 'true',
59+
'EnableIntrinsicFunctions': 'true',
60+
'RuntimeTypeInfo': 'false',
61+
'ExceptionHandling': '0',
62+
'AdditionalOptions': [
63+
'/MP', # compile across multiple CPUs
64+
],
65+
},
66+
'VCLibrarianTool': {
67+
'AdditionalOptions': [
68+
'/LTCG', # link time code generation
69+
],
70+
},
71+
'VCLinkerTool': {
72+
'LinkTimeCodeGeneration': 1, # link-time code generation
73+
'OptimizeReferences': 2, # /OPT:REF
74+
'EnableCOMDATFolding': 2, # /OPT:ICF
75+
'LinkIncremental': 1, # disable incremental linking
76+
},
77+
},
78+
}
79+
},
80+
'msvs_settings': {
81+
'VCCLCompilerTool': {
82+
'StringPooling': 'true', # pool string literals
83+
'DebugInformationFormat': 3, # Generate a PDB
84+
'WarningLevel': 3,
85+
'BufferSecurityCheck': 'true',
86+
'ExceptionHandling': 1, # /EHsc
87+
'SuppressStartupBanner': 'true',
88+
'WarnAsError': 'false',
89+
},
90+
'VCLibrarianTool': {
91+
},
92+
'VCLinkerTool': {
93+
'conditions': [
94+
['target_arch=="x64"', {
95+
'TargetMachine' : 17 # /MACHINE:X64
96+
}],
97+
],
98+
'GenerateDebugInformation': 'true',
99+
'RandomizedBaseAddress': 2, # enable ASLR
100+
'DataExecutionPrevention': 2, # enable DEP
101+
'AllowIsolation': 'true',
102+
'SuppressStartupBanner': 'true',
103+
'target_conditions': [
104+
['_type=="executable"', {
105+
'SubSystem': 1, # console executable
106+
}],
107+
],
108+
},
109+
},
110+
'conditions': [
111+
['OS == "win"', {
112+
'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
113+
'defines': [
114+
'WIN32',
115+
# we don't really want VC++ warning us about
116+
# how dangerous C functions are...
117+
'_CRT_SECURE_NO_DEPRECATE',
118+
# ... or that C implementations shouldn't use
119+
# POSIX names
120+
'_CRT_NONSTDC_NO_DEPRECATE',
121+
'BUILDING_V8_SHARED=1',
122+
'BUILDING_UV_SHARED=1',
123+
],
124+
}, {
125+
'defines': [
126+
'_LARGEFILE_SOURCE',
127+
'_FILE_OFFSET_BITS=64',
128+
],
129+
}],
130+
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
131+
'cflags': [ '-Wall', '-pthread', ],
132+
'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
133+
'ldflags': [ '-pthread', ],
134+
'conditions': [
135+
[ 'target_arch=="ia32"', {
136+
'cflags': [ '-m32' ],
137+
'ldflags': [ '-m32' ],
138+
}],
139+
[ 'OS=="linux"', {
140+
'cflags': [ '-ansi' ],
141+
'ldflags': [ '-rdynamic' ],
142+
}],
143+
[ 'OS=="solaris"', {
144+
'cflags': [ '-pthreads' ],
145+
'ldflags': [ '-pthreads' ],
146+
'cflags!': [ '-pthread' ],
147+
'ldflags!': [ '-pthread' ],
148+
}],
149+
],
150+
}],
151+
['OS=="mac"', {
152+
'xcode_settings': {
153+
'ALWAYS_SEARCH_USER_PATHS': 'NO',
154+
'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
155+
'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
156+
# (Equivalent to -fPIC)
157+
'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
158+
'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
159+
'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
160+
'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
161+
'GCC_VERSION': '4.2',
162+
'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', # -Wnewline-eof
163+
'PREBINDING': 'NO', # No -Wl,-prebind
164+
'MACOSX_DEPLOYMENT_TARGET': '10.5',
165+
'USE_HEADERMAP': 'NO',
166+
'OTHER_CFLAGS': [
167+
'-fno-strict-aliasing',
168+
],
169+
'WARNING_CFLAGS': [
170+
'-Wall',
171+
'-Wendif-labels',
172+
'-W',
173+
'-Wno-unused-parameter',
174+
],
175+
},
176+
'target_conditions': [
177+
['_type!="static_library"', {
178+
'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
179+
}],
180+
],
181+
'conditions': [
182+
['target_arch=="ia32"', {
183+
'xcode_settings': {'ARCHS': ['i386']},
184+
}],
185+
['target_arch=="x64"', {
186+
'xcode_settings': {'ARCHS': ['x86_64']},
187+
}],
188+
],
189+
}],
190+
],
191+
}
192+
}

0 commit comments

Comments
 (0)