-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.json
1 lines (1 loc) · 8.38 KB
/
content.json
1
{"meta":{"title":"extratype's blog","subtitle":"coding, math, etc.","description":"coding, math, etc.","author":"extratype","url":"https://extratype.github.io"},"pages":[{"title":"","date":"2016-11-06T12:46:32.658Z","updated":"2016-11-06T12:46:32.658Z","comments":false,"path":"categories/index.html","permalink":"https://extratype.github.io/categories/index.html","excerpt":"","text":""},{"title":"","date":"2016-11-06T12:46:32.660Z","updated":"2016-11-06T12:46:32.660Z","comments":false,"path":"tags/index.html","permalink":"https://extratype.github.io/tags/index.html","excerpt":"","text":""}],"posts":[{"title":"Rust 개발 환경 세팅","slug":"Rust-개발-환경-세팅","date":"2016-10-22T03:47:41.000Z","updated":"2016-11-06T12:46:32.657Z","comments":true,"path":"2016/10/22/Rust-개발-환경-세팅/","link":"","permalink":"https://extratype.github.io/2016/10/22/Rust-개발-환경-세팅/","excerpt":"","text":"나의 Rust 개발 환경을 정리해서 적어둔다. Windows 10 x64 MSYS2 + rustup Rust stable x86_64 GNU ABI MSYS2 설치하기리눅스스러운 환경을 구축하고 MinGW GCC 툴체인을 쓰기 위해서 MSYS2를 먼저 설치한다. Rust와 GCC를 함께 설치할 수도 있지만 문제가 있어 따로 설치한다. MSYS2 인스톨러를 실행하고 난 다음엔 사이트에 나와있는 대로 업그레이드를 해주도록 하자. msys2_shell.cmd 스크립트를 돌려서 MSYS2나 MinGW-w64 환경 쉘을 띄울 수 있다. -where 옵션을 주면 작업 디렉토리를 지정할 수 있다. 다른 옵션은 스크립트 파일을 참고하기 바란다. 탐색기의 컨텍스트 메뉴에 MSYS2 쉘을 추가하려면 여기를 참고. MSYS2 환경은 윈도우와 독립된 POSIX 환경처럼 보이는데, 실제로는 MSYS2 툴체인으로 컴파일된(MSYS2 DLL을 사용하는) 프로그램에 한해서 그러하다. MinGW-w64 툴체인으로 컴파일된 프로그램들은 MSYS2 DLL을 거치지 않고 native로 동작한다. 이런 이유로 MSYS2를 분리된 POSIX 개발 환경으로 꾸밀 수는 없다. 나는 아예 윈도우와 MSYS2 환경을 통합해서 사용하기로 결정했다. PATH 환경 변수에 C:\\msys64\\mingw64\\bin과 C:\\msys64\\usr\\bin을 순서대로 추가한다. 단, 충돌을 방지하기 위해 %SystemRoot%\\system32 보다 아래에 둔다. MSYS2 쉘에서 다른 윈도우용 툴들을 쓰기 위해 msys2_shell.cmd에서 MSYS2_PATH_TYPE=inherit를 설정한다. 이렇게 하면 MSYS2 쉘에서는 MSYS2 바이너리들을 system32 바이너리보다 우선하되 다른 툴들도 사용할 수 있게 된다. Rust 설치하기인스톨러보다 Rust 툴체인 관리가 편해지는 rustup을 권장한다. 인스톨러로 Rust를 설치해도 되는데 MSYS2와 같이 쓰려면 ‘Linker and platform libraries’ 옵션을 해제하고 설치하면 된다. rustup으로 Rust를 설치하면 최소한의 MinGW 툴체인이 같이 설치되며 제거할 수 있는 옵션이 아직 없다. 임시방편으로 이렇게 제거하면 된다. MinGW 툴체인이 설치된 디렉토리(예: %USERPROFILE%\\.multirust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu)로 이동한다. bin 폴더의 이름을 bin~로 바꾼다. lib~ 폴더를 만들고 lib 폴더 안의 *.a 파일들을 lib~로 모두 옮긴다. 나중에 Rust 툴체인을 삭제하거나 업그레이드할 일이 생기면 이렇게 백업해둔 파일들을 복원한 다음 rustup을 실행하면 된다. 여기를 참고하여 MinGW 툴체인을 설치한다. IDE 선택하기여기에서 IDE들을 비교해볼 수 있다. 나는 VS Code와 Eclipse를 선택했다. VS Code는 outline 창이 없다(Go to Symbol이나 Fold All로 흉내는 낼 수 있다)는 점만 빼면 가장 쓸만했다. 디버깅도 되는데 멀티스레드를 지원하지 않는 문제가 있다. 반대로 RustDT는 outline 기능도 있고 멀티스레드 디버깅도 지원하지만 매개변수 툴팁이 안 나오는 등 편집기가 마음에 들지 않았다. 다른 편집기도 조금씩 써보기는 했다. Atom은 UI가 VS Code만큼 깔끔하지 않았다. IntelliJ는 racer에 기반을 두지 않고 자체적으로 자동 완성을 지원하고, outline 기능도 있다. 매개변수 툴팁이 없고 디버깅도 지원하지 않는다. Visual Studio는 cargo로 빌드가 되지 않았다(지금은 되는 듯 하다). VS Code는 이렇게 세팅했다. Rust 소스 코드 다운로드: rustup component add rust-src RustyCode, Native Debug, TOML Language Support 확장 설치 rustup 설치시 PATH를 등록하지 않았다면(예: %USERPROFILE%\\.cargo\\bin) rust.cargoHomePath 설정 Eclipse는 이렇게 세팅했다. Eclipse Java Neon 설치 CDT 설치, Marketplace에서 RustDT 설치 설정에서 각종 경로 지정. Download 버튼으로 쉽게 설치할 수는 있는데 기본 bin 폴더가 아니라 RustDT 폴더에 설치된다. 나는 Rainicorn까지 bin 폴더에 직접 설치했다. Racer는 릴리즈된 버전이 오래되었으니 Git 저장소에서 설치하는 것을 추천한다:1cargo install --git https://github.com/phildawes/racer 디버깅은 gdb로 이루어진다. Rust 소스 코드에 포함된 pretty printer를 쓰면 변수를 깔끔하게 볼 수 있다. 단 디버깅이 느려지거나 가끔 멈추는 문제가 있다. Pretty printer를 쓰려면 우선 .gdbinit 파일을 만든다. 123456789pythonprint('Loading Rust pretty-printers...')import sysimport osimport subprocess sys.path.append(os.path.join(subprocess.check_output(['rustc', '--print=sysroot']).decode(sys.stdout.encoding).strip(), 'lib', 'rustlib', 'src', 'rust', 'src', 'etc'))import gdb_rust_pretty_printinggdb_rust_pretty_printing.register_printers(gdb)end VS Code의 경우 launch.json을 수정한다. (예시)12345678910111213{ \"version\": \"0.2.0\", \"configurations\": [{ \"name\": \"Debug\", \"type\": \"gdb\", \"request\": \"launch\", \"autorun\": [ \"source .gdbinit\" ], \"target\": \"./target/debug/hello_rust.exe\", \"cwd\": \"${workspaceRoot}\" }]} Eclipse에서는 Debug Configuration에서 Rust Application을 만들면 된다. 기본적으로 .gdbinit를 실행하게 되어 있다.","categories":[{"name":"coding","slug":"coding","permalink":"https://extratype.github.io/categories/coding/"},{"name":"Rust","slug":"coding/Rust","permalink":"https://extratype.github.io/categories/coding/Rust/"}],"tags":[],"keywords":[{"name":"coding","slug":"coding","permalink":"https://extratype.github.io/categories/coding/"},{"name":"Rust","slug":"coding/Rust","permalink":"https://extratype.github.io/categories/coding/Rust/"}]},{"title":"MSYS2 Git 사용하기","slug":"MSYS2-Git-사용하기","date":"2016-10-15T15:59:55.000Z","updated":"2017-01-01T13:03:36.340Z","comments":true,"path":"2016/10/16/MSYS2-Git-사용하기/","link":"","permalink":"https://extratype.github.io/2016/10/16/MSYS2-Git-사용하기/","excerpt":"","text":"주의: 언급한 에러 외에도 잔버그가 여럿 있으니 권장하지 않음!! Windows에서 Git 사용하기Git for Windows를 설치하면 자체 MSYS2 환경도 같이 설치된다. Git Bash가 바로 이 환경에서 동작한다. 이미 MSYS2를 설치했다면 기존 MSYS2 환경에 덮어서 설치할 수 있다. 이 issue에 따르면 두 환경이 아직 통합되지 않은 것 같다. 나는 아예 MSYS2 Git(git)을 설치해서 사용하고 있는데, Git 공식이 아니어서 그런지 Git을 쓰는 다른 프로그램들이 오류를 뱉는 경우가 있었다. 대처법을 여기에 정리해 올린다. Visual Studio CodeGit을 쓰려고 하면 ENOENT 에러를 뱉는다. 관련 issue는 여기. 링크엔 Cygwin 얘기만 나오는데 MSYS2에선 아래처럼 symlink를 만들면 된다.1C:\\> mklink c c:\\ /D나 /J 옵션을 붙여주지 않아도 MSYS2라 그런지 잘 된다. Atlassian SourceTree[터미널]을 누르면 뻗어버린다. [옵션]->[Git]에서 Git Bash 사용 옵션을 끄면 된다. HTTPS로 푸시하려고 하면 잘 안 되는데 MSYS2에서 OpenSSH 설치해서 쓰면 잘 된다. GitHub에 푸시하는 방법은 여기를 참고.","categories":[{"name":"coding","slug":"coding","permalink":"https://extratype.github.io/categories/coding/"}],"tags":[{"name":"MSYS2","slug":"MSYS2","permalink":"https://extratype.github.io/tags/MSYS2/"},{"name":"Git","slug":"Git","permalink":"https://extratype.github.io/tags/Git/"}],"keywords":[{"name":"coding","slug":"coding","permalink":"https://extratype.github.io/categories/coding/"}]}]}