0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

mrubyでTOMLをパースできるライブラリmruby-toml書いた

Last updated at Posted at 2016-03-29

経緯

  1. dein.vimを使い出して、TOMLという言語(?)を知る。
  2. mrubyにも興味があり、何かライブラリを書いてみたいと思っていた。
  3. libtomlというTOMLのC言語実装ライブラリが最近TOMLの言語仕様0.4.0(2016年3月30日現在の最新バージョン)に対応したっぽい
  4. mrubyの実装、ぱっと見無いし、作ってみるか!

意外とあっさりできた。

作り始めて6時間程度で出来ました。(libtomlのビルドではまった時間除く)

はまったポイント

libtomlのビルドにはまりました。C言語のビルドツールって使ったことがなかったので、セオリーがわからなかったというのが大きいと思います。ビルド可能なDockerfileを以下に示します。ただ、ビルドに結構な時間がかかるみたいで、私のマシンでは30分くらいかかりました。(何にそんなに時間くっているのか。。)
また、このDockerfileはmruby-tomlのビルド&テストも同時に実行します。

Dockerfile

FROM ubuntu:latest
MAINTAINER Yoshihiko Yamanaka
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN sed -i.bak -e "s%http://archive.ubuntu.com/ubuntu/%http://ftp.jaist.ac.jp/pub/Linux/ubuntu/%g" /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y --force-yes build-essential git zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt-dev ruby2.0 ruby2.0-dev rake bison curl
RUN apt-get install -y --force-yes libtool pkg-config autotools-dev autoconf automake cmake
RUN apt-get install -y --force-yes vim

# cunit install
WORKDIR /root
RUN curl -L https://sourceforge.net/projects/cunit/files/CUnit/2.1-3/CUnit-2.1-3.tar.bz2/download > CUnit-2.1-3.tar.bz2
RUN tar xjvf CUnit-2.1-3.tar.bz2
WORKDIR /root/CUnit-2.1-3
RUN libtoolize
RUN autoheader
RUN automake --add-missing 1>/dev/null 2>/dev/null | true
RUN autoreconf
RUN ./configure --prefix=/usr
RUN make && make install
RUN make install

# makeing libtoml
WORKDIR /root
RUN git clone https://github.com/ajwans/libtoml
WORKDIR /root/libtoml
RUN apt-get install -y --force-yes ragel libicu-dev
RUN cmake .
RUN make
RUN cp libtoml.so /usr/lib
RUN cp *.h /usr/include
RUN cp -r ccan /usr/include

# build mruby-toml
WORKDIR /root
RUN git clone https://github.com/bamchoh/mruby-toml
WORKDIR /root/mruby-toml
RUN ruby run_test.rb test

VOLUME /root/mruby-toml

今後の課題

  1. Object#to_toml の実装
  2. TOML_DATEのパース実装
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?