Skip to content

Instantly share code, notes, and snippets.

@jin
Created July 10, 2019 01:00
Show Gist options
  • Save jin/e5f17e4ff222f7f46382ae84e363c26f to your computer and use it in GitHub Desktop.
Save jin/e5f17e4ff222f7f46382ae84e363c26f to your computer and use it in GitHub Desktop.
bazel and swig
$ cat WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_tweag_rules_nixpkgs",
urls = ["https://github.com/tweag/rules_nixpkgs/archive/v0.5.2.tar.gz"],
strip_prefix = "rules_nixpkgs-0.5.2",
sha256 = "5a384daa57b49abf9f0b672852f1a66a3c52aecf9d4d2ac64f6de0fd307690c8",
)
load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_git_repository", "nixpkgs_package", "nixpkgs_cc_configure")
nixpkgs_git_repository(
name = "nixpkgs",
revision = "7b8a7cee78468919b98cc4c8694d84165f28ef68", # Any tag or commit hash
sha256 = "" # optional sha to verify package integrity!
)
PACKAGES = ["gcc", "bazelisk", "swig"]
[nixpkgs_package(
name = package,
repositories = { "nixpkgs": "@nixpkgs//:default.nix" },
) for package in PACKAGES]
nixpkgs_cc_configure(
nix_file = "//nixpkgs:cc-toolchain.nix",
repository = "@nixpkgs",
)
08:59:54 {master} ~/code/bazel-nix-demo
$ bazel query @swig//...:*
@swig//:lib
@swig//:include
@swig//:bin
@swig//:bin/swig
@swig//:bin/ccache-swig
@swig//:BUILD
Loading: 0 packages loaded
08:59:57 {master} ~/code/bazel-nix-demo
$ bazel run @swig//:bin/swig -- -help
INFO: Analyzed target @swig//:bin/swig (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
INFO: Elapsed time: 0.095s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
Target Language Options
-allegrocl - Generate ALLEGROCL wrappers
-chicken - Generate CHICKEN wrappers
-clisp - Generate CLISP wrappers
-cffi - Generate CFFI wrappers
-csharp - Generate C# wrappers
-d - Generate D wrappers
-go - Generate Go wrappers
-guile - Generate Guile wrappers
-java - Generate Java wrappers
-javascript - Generate Javascript wrappers
-lua - Generate Lua wrappers
-modula3 - Generate Modula 3 wrappers
-mzscheme - Generate Mzscheme wrappers
-ocaml - Generate Ocaml wrappers
-octave - Generate Octave wrappers
-perl - Generate Perl wrappers
-php5 - Generate PHP5 wrappers
-php7 - Generate PHP7 wrappers
-pike - Generate Pike wrappers
-python - Generate Python wrappers
-r - Generate R (aka GNU S) wrappers
-ruby - Generate Ruby wrappers
-scilab - Generate Scilab wrappers
-sexp - Generate Lisp S-Expressions wrappers
-tcl - Generate Tcl wrappers
-uffi - Generate Common Lisp / UFFI wrappers
-xml - Generate XML wrappers
General Options
-addextern - Add extra extern declarations
-c++ - Enable C++ processing
-co <file> - Check <file> out of the SWIG library
-copyctor - Automatically generate copy constructors wherever possible
-cpperraswarn - Treat the preprocessor #error statement as #warning (default)
-cppext <ext> - Change file extension of generated C++ files to <ext>
(default is cxx, except for PHP5 which uses cpp)
-copyright - Display copyright notices
-debug-classes - Display information about the classes found in the interface
-debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages
-debug-symtabs - Display symbol tables information
-debug-symbols - Display target language symbols in the symbol tables
-debug-csymbols - Display C symbols in the symbol tables
-debug-lsymbols - Display target language layer symbols
-debug-tags - Display information about the tags found in the interface
-debug-template - Display information for debugging templates
-debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages
-debug-typedef - Display information about the types and typedefs in the interface
-debug-typemap - Display typemap debugging information
-debug-tmsearch - Display typemap search debugging information
-debug-tmused - Display typemaps used debugging information
-directors - Turn on director mode for all the classes, mainly for testing
-dirprot - Turn on wrapping of protected members for director classes (default)
-D<symbol> - Define a symbol <symbol> (for conditional compilation)
-E - Preprocess only, does not generate wrapper code
-external-runtime [file] - Export the SWIG runtime stack
-fakeversion <v>- Make SWIG fake the program version number to <v>
-fcompact - Compile in compact mode
-features <list>- Set global features, where <list> is a comma separated list of
features, eg -features directors,autodoc=1
If no explicit value is given to the feature, a default of 1 is used
-fastdispatch - Enable fast dispatch mode to produce faster overload dispatcher code
-Fmicrosoft - Display error/warning messages in Microsoft format
-Fstandard - Display error/warning messages in commonly used format
-fvirtual - Compile in virtual elimination mode
-help - This output
-I- - Don't search the current directory
-I<dir> - Look for SWIG files in directory <dir>
-ignoremissing - Ignore missing include files
-importall - Follow all #include statements as imports
-includeall - Follow all #include statements
-l<ifile> - Include SWIG library file <ifile>
-macroerrors - Report errors inside macros
-makedefault - Create default constructors/destructors (the default)
-M - List all dependencies
-MD - Is equivalent to `-M -MF <file>', except `-E' is not implied
-MF <file> - Generate dependencies into <file> and continue generating wrappers
-MM - List dependencies, but omit files in SWIG library
-MMD - Like `-MD', but omit files in SWIG library
-module <name> - Set module name to <name>
-MP - Generate phony targets for all dependencies
-MT <target> - Set the target of the rule emitted by dependency generation
-nocontract - Turn off contract checking
-nocpperraswarn - Do not treat the preprocessor #error statement as #warning
-nodefault - Do not generate default constructors nor default destructors
-nodefaultctor - Do not generate implicit default constructors
-nodefaultdtor - Do not generate implicit default destructors
-nodirprot - Do not wrap director protected members
-noexcept - Do not wrap exception specifiers
-nofastdispatch - Disable fast dispatch mode (default)
-nopreprocess - Skip the preprocessor step
-notemplatereduce - Disable reduction of the typedefs in templates
-O - Enable the optimization options:
-fastdispatch -fvirtual
-o <outfile> - Set name of C/C++ output file to <outfile>
-oh <headfile> - Set name of C++ output header file for directors to <headfile>
-outcurrentdir - Set default output dir to current dir instead of input file's path
-outdir <dir> - Set language specific files output directory to <dir>
-pcreversion - Display PCRE version information
-small - Compile in virtual elimination & compact mode
-swiglib - Report location of SWIG library and exit
-templatereduce - Reduce all the typedefs in templates
-v - Run in verbose mode
-version - Display SWIG version number
-Wall - Remove all warning suppression, also implies -Wextra
-Wallkw - Enable keyword warnings for all the supported languages
-Werror - Treat warnings as errors
-Wextra - Adds the following additional warnings: 202,309,403,512,321,322
-w<list> - Suppress/add warning messages, eg -w401,+321 - see Warnings.html
-xmlout <file> - Write XML version of the parse tree to <file> after normal processing
Options can also be defined using the SWIG_FEATURES environment variable, for example:
$ SWIG_FEATURES="-Wall"
$ export SWIG_FEATURES
$ swig -python interface.i
is equivalent to:
$ swig -Wall -python interface.i
Tcl 8 Options (available with -tcl)
-itcl - Enable ITcl support
-nosafe - Leave out SafeInit module function.
-prefix <name> - Set a prefix <name> to be prepended to all names
-namespace - Build module into a Tcl 8 namespace
-pkgversion - Set package version
Note: 'swig -<lang> -help' displays options for a specific target language.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment