swig bridge i'd like to checkin
As a new version of: http://pub.vestasys.org/cgi-bin/vestaweb?path=/vesta/vestasys.org/bridges/swig
current version: http://pub.vestasys.org/cgi-bin/vestaweb?path=/vesta/vestasys.org/bridges/swig/2
Just the diffs: SwigBridgeJohnDiff
// Created: Thu Aug 26 1999 // Author: Kenneth C. Schalk // The SWIG bridge (for running swig as a tool under Vesta). // For information on SWIG, see: http://www.swig.org/ // Last modified on Fri Jan 7 16:33:53 EST 2005 by ken@xorian.net { // The command to invoke. command = ./command; // The root filesystem to use for this platform (which must include // the executable named by "command"). root = ./root; bridge_name = "swig"; // SWIG will always produce a C/C++ source file of glue code, and // may also produce a file of automaticall generated // documentation. type SWIGResult = binding( output: NamedFile, // The glue source generated by SWIG ); // Functions exported by the bridge ------------------------------------------- // ./swig/compile(name, input, [target_lang, [swiglibs]]) // name - The name for the output source and documentation files. // input - A single input source file for SWIG. // target_lang [optional] - One the target languages SWIG supports // (tcl, perl, python). Defaults to "perl". // swiglibs [optional] - A list of text values naming standard // SWIG library includes to use (i.e. "itclsh.i" or "itkwish.i"). // These affect the behavior and output of SWIG. compile(name: text, // Name of resulting glue source file /**pk**/ input: NamedFile, // SWIG input file includes: NamedFiles, // Additional SWIG files which may be // included by the input file. target_lang: text = "perl", // Name of the target language (i.e. // "tcl") libs: libFuncs = <>, // Libraries whose headers should be made // available to SWIG /**pk**/ swiglibs: list(text) = <> // Standard SWIG library code // to include (alters SWIG behavior // and output) ): SWIGResult { // Set up the shared files in the filesystem where SWIG will // expect them; root can be a function . ++= [ root = (if _is_closure(root) then root() else root) ]; // Add input file to "." . ++= [ root/.WD = _append(input,includes) ]; // Make the library header files available . ++= [ root/.WD = ./Cxx/expert/lib_headers(libs) ]; // Figure out what the output filename should be based on // whether we're including C++ support. output_name = name + "." + (if ./$bridge_name/options/enable_Cxx then ./$bridge_name/options/output_extensions/Cxx else ./$bridge_name/options/output_extensions/C); // Form the command-line (a list of texts) cmd = (<command> // executable name + <"-" + target_lang> // target scripting language + <"-o", output_name> // Result file name + ./generic/binding_values(./$bridge_name/switches)); // Add any SWIG libraries used foreach lib in swiglibs do { cmd += <"-l" + lib>; }; // Tell SWIG to support C++ if necessary. cmd += if ./$bridge_name/options/enable_Cxx then <"-c++"> else <>; // Tell SWIG to a Tcl8 namespace if necessary. cmd += if ((target_lang == "tcl") && ./$bridge_name/options/tcl/namespace) then <"-namespace"> else <>; // Tell SWIG to generate perl proxy classes, if necessary. cmd += if ((target_lang == "perl") && ./$bridge_name/options/perl/proxy) then <"-proxy"> else <>; // Last argument is always the input file. cmd += <_n(input)>; // Invoke SWIG r = _run_tool(./target_platform, cmd); value if r == ERR || r/code != 0 || r/signal != 0 then ERR else // As long as we didn't fail, return single C/C++ source // file created by tool, and the generated documentation // (if any). [ output = [ $output_name = r/root/.WD/$output_name ] ] + (if (target_lang == "perl") then [ pm = { // Extract out any .pm files that were generated. // The name of the file is determined by the Module name // in the .i file, so we iterate over the working directory // and search for any files that have the .pm extension // and include them in the return value. tmp_pm = []; foreach [n = v] in r/root/.WD do { tmp_pm += (if ./generic/extension(n) == "pm" then [$n=v] else []); }; value tmp_pm; }] else []) + (if (target_lang == "python") then [ py = { // Extract out any .py files that were generated. // The name of the file is determined by the Module name // in the .i file, so we iterate over the working directory // and search for any files that have the .py extension // and include them in the return value. tmp_py = []; foreach [n = v] in r/root/.WD do { tmp_py += (if ./generic/extension(n) == "py" then [$n=v] else []); }; value tmp_py; }] else []) + (if (target_lang == "java") then [ java = { // Extract out any .java files that were generated. // The name of the file is determined by the Module name // in the .i file, so we iterate over the working directory // and search for any files that have the .java extension // and include them in the return value. tmp_java = []; foreach [n = v] in r/root/.WD do { tmp_java += (if ./generic/extension(n) == "java" then [$n=v] else []); }; value tmp_java; }] else []); }; // The bridge result itself -------------------------------------------------- // default command-line args switches = [ Wall = "-Wall", ]; // Options affecting the way the bridge works options = [ // Enable handling of C++ constructs in the input (on by // default). enable_Cxx = TRUE, output_extensions = [ Cxx = "C", C = "c" ], // Options specific to the tcl8 language target tcl = [ // Build module into a Tcl 8 namespace. (on by default for // Tcl8). namespace = TRUE ], // Options specific to the perl language target perl = [ // Generate proxy classes proxy = TRUE ] ]; return [ $bridge_name = [ switches, options, root, // SWIG binary and associated data files. // exported function(s) compile ]]; } // end common/swig/build.ves