Humanity

Edit the world by your favorite way

macOS Mojave で Vim のソースコード (C 言語) のデバッグをする (clang, lldb)

  1. src/MakefileCC, CFLAGS を変更
diff --git a/src/Makefile b/src/Makefile
index 9c4a42893..d62c21b59 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -586,14 +586,14 @@ CClink = $(CC)
 # again.
 #CC = cc
 #CC = gcc
-#CC = clang
+CC = clang
 
 # COMPILER FLAGS - change as you please. Either before running {{{1
 # configure or afterwards. For examples see below.
 # When using -g with some older versions of Linux you might get a
 # statically linked executable.
 # When not defined, configure will try to use -O2 -g for gcc and -O for cc.
-#CFLAGS = -g
+CFLAGS = -g
 #CFLAGS = -O
 
 # Optimization limits - depends on the compiler.  Automatic check in configure

2. make clean distclean all で再度ビルド 3. lldb ./vim して r --clean で実行

$ lldb ./vim
(lldb) target create "./vim"
Current executable set to './vim' (x86_64).
(lldb) r --clean

TODO: leak detector 試す

macOS に Homebrew から phpMyAdmin をインストール

インストール

$ brew install phpmyadmin

Apache の設定変更

$ sudo vim /etc/apache2/httpd.conf

して

#LoadModule php7_module libexec/apache2/libphp7.so

のコメントを外します。

LoadModule php7_module libexec/apache2/libphp7.so

次に brew install phpmyadmin した時に言われているかと思いますが、追加の設定を入れます。

/etc/apache2/other/phpmyadmin.conf を新規作成して以下をコピペ。

Alias /phpmyadmin /usr/local/share/phpmyadmin
<Directory /usr/local/share/phpmyadmin/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_authz_core.c>
        Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Allow from all
    </IfModule>
</Directory>

.phpphp module で処理する設定も必要ですが、自分の場合 /etc/apache2/other/php7.conf にデフォルトで入ってたので必要ありませんでした。

<IfModule php7_module>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    <IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>
</IfModule>

phpMyAdmin の設定変更

$ sudo vim /usr/local/etc/phpmyadmin.config.inc.php

して MySQL のホスト、ポート番号等に合わせて変更します。 MySQL のデフォルトパスワード (ID: root, PW: (空)) のように、空のパスワードを許可する場合 $cfg['Servers'][$i]['AllowNoPassword']true にする必要があります。

--- /usr/local/etc/phpmyadmin.config.inc.php.bak 2019-06-20 20:43:46.000000000 +0900
+++ /usr/local/etc/phpmyadmin.config.inc.php  2019-06-20 20:46:50.000000000 +0900
@@ -28,9 +28,9 @@
 /* Authentication type */
 $cfg['Servers'][$i]['auth_type'] = 'cookie';
 /* Server parameters */
-$cfg['Servers'][$i]['host'] = 'localhost';
+$cfg['Servers'][$i]['host'] = 'localhost:3306';
 $cfg['Servers'][$i]['compress'] = false;
-$cfg['Servers'][$i]['AllowNoPassword'] = false;
+$cfg['Servers'][$i]['AllowNoPassword'] = true;
 
 /**
  * phpMyAdmin configuration storage settings.

おわり

http://localhost/phpmyadmin/ で見れるようになります。

macOS で Vim をソースコードからインストールする備忘録 (with LuaJIT)

--enable-lua しなければソースコードからもスルっと入ったけど +lua 付きがほしかった *1 ので。

ソースコードからインストールする

ここら辺見て関連しそうなもの入れた。 余計なもの入ってたらすいません。 あと gpm 入れて再ビルドしてみたけど -mouse_gpm のままだったからここには入れてないです…

--with-lua-prefix のパスは ichizok さんから教えてもらった (ありがとうございます)。

$ brew install gettext libiconv lua luajit
$ git clone https://github.com/vim/vim.git
$ cd vim

LuaJIT の場合
$ ./configure --enable-luainterp --with-luajit --with-lua-prefix=/usr/local/opt/luajit

Lua の場合
$ ./configure --enable-luainterp --with-lua-prefix=/usr/local/opt/lua

以下は自分が実際に使ってるビルドスクリプトです (config スクリプトから起動されるやつなのでこのスクリプト単体では動きません)。

config/PKGBUILD at 16b392b6e7c82623d33df16ec46ce33245d51b19 · tyru/config · GitHub

おまけ: Homebrew からインストールする

ちなみに itchyny さんからも Homebrew はデフォルトで +lua 付きの Vim が手に入ると教えてもらった (ありがとうございます)。 それに 8.1.1509 が最新版の現状、Homebrew の Vim のバージョンは 8.1.1500 と十分新しい。 Vim のパッチに一喜一憂する変態達でなければ普通にこれでいいと思う。

$ brew install vim

追記 (2019/06/10 22:12): macvim パッケージも +lua 付いてるらしいです。

*1:Lua (特に LuaJIT) は Vim script に比べて実行速度が速いので +lua がある場合はそっちで実行される Vim プラグイン等がある