リポジトリはこちら。https://github.com/srz-zumix/wandbox-api/
言語は Python で PyPI に Publish してますので、 pip install wandbox-api ですぐに使えます!
PyPI に初めて Publish しました〜
この辺は「Github ActionsでPyPIにパッケージを公開する」を参考に、GitHub Actions で tag をトリガーに Publish されるようにしました。
name: PyPI Publish on: push: tags: - v* jobs: pypi: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@master - name: Set up Python 3.7 uses: actions/setup-python@v1 with: python-version: 3.7 - name: Init .pypirc env: PYPI_USERNAME: __token__ PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | echo -e '[pypi]' >> ~/.pypirc echo -e "username = ${PYPI_USERNAME}" >> ~/.pypirc echo -e "password = ${PYPI_PASSWORD}" >> ~/.pypirc - name: Publish run: | pip install twine wheel python setup.py sdist bdist_wheel twine upload --repository pypi dist/*
現在の機能は、Wandbox が対応している言語・コンパイラー・オプションのリストアップとコンパイル&実行です。また、C++ 用に特化した wandbox-cxx コマンドもあります。
使用例
言語リストを取得
$ wandbox lang Bash script C C# C++ CMake CPP CoffeeScript Crystal D Elixir Erlang F# Go Groovy Haskell Java JavaScript Lazy K Lisp Lua Nim OCaml OpenSSL PHP Pascal Perl Pony Python R Rill Ruby Rust SQL Scala Swift TypeScript Vim script
コンパイラーのリストを取得
-l オプションで言語を選択してリストアップします。言語指定がない場合はすべての言語のコンパイラーをリストアップします。
$ wandbox -l C++ compiler gcc-head gcc-9.3.0 gcc-9.2.0 gcc-9.1.0 gcc-8.3.0 gcc-8.2.0 gcc-8.1.0 gcc-7.3.0 gcc-7.2.0 gcc-7.1.0 gcc-6.3.0 gcc-6.2.0 gcc-6.1.0 gcc-5.5.0 gcc-5.4.0 gcc-5.3.0 gcc-5.2.0 gcc-5.1.0 gcc-4.9.3 gcc-4.9.2 gcc-4.9.1 gcc-4.9.0 gcc-4.8.5 gcc-4.8.4 gcc-4.8.3 gcc-4.8.2 gcc-4.8.1 gcc-4.7.4 gcc-4.7.3 gcc-4.6.4 gcc-4.5.4 gcc-4.4.7 clang-head clang-10.0.0 clang-9.0.0 clang-8.0.0 clang-7.0.0 clang-6.0.1 clang-6.0.0 clang-5.0.0 clang-4.0.1 clang-4.0.0 clang-3.9.1 clang-3.8.1 clang-3.7.1 clang-3.6.0 clang-3.5.0 clang-3.4 clang-3.3 clang-3.2 clang-3.1 zapcc-2017.08 zapcc-1.0.1
コンパイラーのオプションを取得
-c オプションでコンパイラーを選択すると、そのコンパイラーで使用できるオプションをリストアップします。指定がない場合はすべてのオプションをリストアップします。
$ wandbox -c clang-head option C++: warning (default) optimize cpp-verbose boost-1.73.0-clang-head (default) boost-nothing-clang-head boost-1.60.0-clang-head boost-1.61.0-clang-head boost-1.62.0-clang-head boost-1.63.0-clang-head boost-1.64.0-clang-head boost-1.65.0-clang-head boost-1.65.1-clang-head boost-1.66.0-clang-head boost-1.67.0-clang-head boost-1.68.0-clang-head boost-1.69.0-clang-head boost-1.70.0-clang-head boost-1.71.0-clang-head boost-1.72.0-clang-head boost-1.73.0-clang-head sprout msgpack gnu++2a (default) std-c++-default c++98 gnu++98 c++11 gnu++11 c++14 gnu++14 c++17 gnu++17 c++2a gnu++2a cpp-no-pedantic (default) cpp-no-pedantic cpp-pedantic cpp-pedantic-errors
C++ のコードをビルド・実行する
wandbox-api パッケージには C++ 用のコマンドとして、wandbox-cxx と wandbox-g++/wandbox-clang++ が含まれています。
cxx は wandbox コマンドに -l C++ を指定したのと同等です。wandbox-g++/wandbox-clang++ はさらに -c オプションでコンパイラーの指定をしたものになります
(バージョンはそれぞれ head)
また、これらは通常の wandbox コマンドのコマンドラインオプションに加えて、 C++ コンパイラー向けの Wandbox オプションがコマンドラインオプションで設定できるようになっています。
--std VERSION set --std options --boost VERSION set boost options version X.XX or nothing --optimize use optimization --cpp-verbose use cpp-verbose --sprout use sprout --msgpack use msgpack
run に続く引数は、コンパイラーへの引数としてそのまま渡されます。
$ wandbox-clang++ run main.cpp test.cpp program_message: Hello, Wandbox! test
$ wandbox-clang++ run main.cpp test.cpp -DTEST program_message: test test
-s オプションを付けると permlink を発行できます。
wandbox-clang++ -s run main.cpp test.cpp -DTEST program_message: test test permlink: TuvMXWckFrkxGPAs url: https://wandbox.org/permlink/TuvMXWckFrkxGPAs
[Wandbox]三へ( へ՞ਊ ՞)へ ハッハッ https://wandbox.org/permlink/6AGrKCojBOo1oCUv
使用したソースコードはこちらです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file is a "Hello, world!" in C++ language by GCC for wandbox. | |
#include <iostream> | |
#include <cstdlib> | |
#include "test.h" | |
int main() | |
{ | |
#if defined(TEST) | |
std::cout << "test" << std::endl; | |
#else | |
std::cout << "Hello, Wandbox!" << std::endl; | |
#endif | |
return test(); | |
} | |
// GCC reference: | |
// https://gcc.gnu.org/ | |
// C++ language references: | |
// https://cppreference.com/ | |
// https://isocpp.org/ | |
// http://www.open-std.org/jtc1/sc22/wg21/ | |
// Boost libraries references: | |
// https://www.boost.org/doc/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
#include "test.h" | |
int test() | |
{ | |
std::cout << "test" << std::endl; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int test(); |
今後
今後、ちまちまと他の言語のコマンドも追加していこうと思います。
もちろん PR 大歓迎です!
今回は以上です。では。