binding.gyp (7567B)
1 # @license Apache-2.0 2 # 3 # Copyright (c) 2018 The Stdlib Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # A `.gyp` file for building a Node.js native add-on. 18 # 19 # [1]: https://gyp.gsrc.io/docs/InputFormatReference.md 20 # [2]: https://gyp.gsrc.io/docs/UserDocumentation.md 21 { 22 # List of files to include in this file: 23 'includes': [ 24 './include.gypi', 25 ], 26 27 # Define variables to be used throughout the configuration for all targets: 28 'variables': { 29 # Target name should match the add-on export name: 30 'addon_target_name%': 'addon', 31 32 # Fortran compiler (to override -Dfortran_compiler=<compiler>): 33 'fortran_compiler%': 'gfortran', 34 35 # Fortran compiler flags: 36 'fflags': [ 37 # Specify the Fortran standard to which a program is expected to conform: 38 '-std=f95', 39 40 # Indicate that the layout is free-form source code: 41 '-ffree-form', 42 43 # Aggressive optimization: 44 '-O3', 45 46 # Enable commonly used warning options: 47 '-Wall', 48 49 # Warn if source code contains problematic language features: 50 '-Wextra', 51 52 # Warn if a procedure is called without an explicit interface: 53 '-Wimplicit-interface', 54 55 # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): 56 '-fno-underscoring', 57 58 # Warn if source code contains Fortran 95 extensions and C-language constructs: 59 '-pedantic', 60 61 # Compile but do not link (output is an object file): 62 '-c', 63 ], 64 65 # Set variables based on the host OS: 66 'conditions': [ 67 [ 68 'OS=="win"', 69 { 70 # Define the object file suffix: 71 'obj': 'obj', 72 }, 73 { 74 # Define the object file suffix: 75 'obj': 'o', 76 } 77 ], # end condition (OS=="win") 78 ], # end conditions 79 }, # end variables 80 81 # Define compile targets: 82 'targets': [ 83 84 # Target to generate an add-on: 85 { 86 # The target name should match the add-on export name: 87 'target_name': '<(addon_target_name)', 88 89 # Define dependencies: 90 'dependencies': [], 91 92 # Define directories which contain relevant include headers: 93 'include_dirs': [ 94 # Local include directory: 95 '<@(include_dirs)', 96 ], 97 98 # List of source files: 99 'sources': [ 100 '<@(src_files)', 101 ], 102 103 # Settings which should be applied when a target's object files are used as linker input: 104 'link_settings': { 105 # Define libraries: 106 'libraries': [ 107 '<@(libraries)', 108 ], 109 110 # Define library directories: 111 'library_dirs': [ 112 '<@(library_dirs)', 113 ], 114 }, 115 116 # C/C++ compiler flags: 117 'cflags': [ 118 # Enable commonly used warning options: 119 '-Wall', 120 121 # Aggressive optimization: 122 '-O3', 123 ], 124 125 # C specific compiler flags: 126 'cflags_c': [ 127 # Specify the C standard to which a program is expected to conform: 128 '-std=c99', 129 ], 130 131 # C++ specific compiler flags: 132 'cflags_cpp': [ 133 # Specify the C++ standard to which a program is expected to conform: 134 '-std=c++11', 135 ], 136 137 # Linker flags: 138 'ldflags': [], 139 140 # Apply conditions based on the host OS: 141 'conditions': [ 142 [ 143 'OS=="mac"', 144 { 145 # Linker flags: 146 'ldflags': [ 147 '-undefined dynamic_lookup', 148 '-Wl,-no-pie', 149 '-Wl,-search_paths_first', 150 ], 151 }, 152 ], # end condition (OS=="mac") 153 [ 154 'OS!="win"', 155 { 156 # C/C++ flags: 157 'cflags': [ 158 # Generate platform-independent code: 159 '-fPIC', 160 ], 161 }, 162 ], # end condition (OS!="win") 163 ], # end conditions 164 165 # Define custom build actions for particular inputs: 166 'rules': [ 167 { 168 # Define a rule for processing Fortran files: 169 'extension': 'f', 170 171 # Define the pathnames to be used as inputs when performing processing: 172 'inputs': [ 173 # Full path of the current input: 174 '<(RULE_INPUT_PATH)' 175 ], 176 177 # Define the outputs produced during processing: 178 'outputs': [ 179 # Store an output object file in a directory for placing intermediate results (only accessible within a single target): 180 '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' 181 ], 182 183 # Define the rule for compiling Fortran based on the host OS: 184 'conditions': [ 185 [ 186 'OS=="win"', 187 188 # Rule to compile Fortran on Windows: 189 { 190 'rule_name': 'compile_fortran_windows', 191 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', 192 193 'process_outputs_as_sources': 0, 194 195 # Define the command-line invocation: 196 'action': [ 197 '<(fortran_compiler)', 198 '<@(fflags)', 199 '<@(_inputs)', 200 '-o', 201 '<@(_outputs)', 202 ], 203 }, 204 205 # Rule to compile Fortran on non-Windows: 206 { 207 'rule_name': 'compile_fortran_linux', 208 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', 209 210 'process_outputs_as_sources': 1, 211 212 # Define the command-line invocation: 213 'action': [ 214 '<(fortran_compiler)', 215 '<@(fflags)', 216 '-fPIC', # generate platform-independent code 217 '<@(_inputs)', 218 '-o', 219 '<@(_outputs)', 220 ], 221 } 222 ], # end condition (OS=="win") 223 ], # end conditions 224 }, # end rule (extension=="f") 225 ], # end rules 226 }, # end target <(addon_target_name) 227 228 # Target to copy a generated add-on to a standard location: 229 { 230 'target_name': 'copy_addon', 231 232 # Declare that the output of this target is not linked: 233 'type': 'none', 234 235 # Define dependencies: 236 'dependencies': [ 237 # Require that the add-on be generated before building this target: 238 '<(addon_target_name)', 239 ], 240 241 # Define a list of actions: 242 'actions': [ 243 { 244 'action_name': 'copy_addon', 245 'message': 'Copying addon...', 246 247 # Explicitly list the inputs in the command-line invocation below: 248 'inputs': [], 249 250 # Declare the expected outputs: 251 'outputs': [ 252 '<(addon_output_dir)/<(addon_target_name).node', 253 ], 254 255 # Define the command-line invocation: 256 'action': [ 257 'cp', 258 '<(PRODUCT_DIR)/<(addon_target_name).node', 259 '<(addon_output_dir)/<(addon_target_name).node', 260 ], 261 }, 262 ], # end actions 263 }, # end target copy_addon 264 ], # end targets 265 }