This repository has been archived by the owner on Jun 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: objective-c | ||
before_install: | ||
- brew update | ||
install: | ||
- mkdir -p $(brew --repo)/Library/Taps/travis | ||
- ln -s $PWD $(brew --repo)/Library/Taps/travis/homebrew-testtap | ||
- brew tap --repair | ||
script: | ||
- brew audit iwyu | ||
- brew install -v iwyu | ||
- brew test iwyu |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
### homebrew-iwyu v0.9 (November 19, 2014) ### | ||
|
||
* Initial release | ||
|
||
* Builds `clang_3.5` tag from Subversion | ||
|
||
* Compiles against LLVM 3.5 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,39 @@ | ||
homebrew-iwyu | ||
Homebrew IWYU | ||
============= | ||
|
||
Use the Homebrew package manager to easily install include-what-you-use | ||
[![Build Status](https://img.shields.io/travis/jasonmp85/homebrew-iwyu/master.svg)][status] | ||
[![Release](https://img.shields.io/github/release/jasonmp85/homebrew-iwyu.svg)][release] | ||
[![License](https://img.shields.io/:license-mit-blue.svg)][license] | ||
|
||
This formula makes it easy to install `include-what-you-use` on any modern OS X system. | ||
|
||
Just `brew tap jasonmp85/iwyu` and then `brew install iwyu`. Be patient: `include-what-you-use` depends on LLVM, which will take a while to build. | ||
|
||
Using `iwyu` | ||
------------ | ||
|
||
The [project's page][iwyu-page] goes into more detail, but there are three basic ways to use `iwyu`… | ||
|
||
### Directly | ||
|
||
Invoke it on a single file, as you would a compiler: `iwyu hello_world.c`. Messages about what includes to add or remove will be printed to standard output. | ||
|
||
### From `make` | ||
|
||
Tell make to use it as the C compiler: `make -k CC=iwyu`. It's necessary to use the `-k` flag to continue after errors (`iwyu` always errors to signal that no compilation has actually taken place). | ||
|
||
### Using `fix_include` | ||
|
||
`include-what-you-use` bundles a Python script capable of parsing its output in order to automatically fix any include problems, in-place if you desire. It's not perfect, but something like `fix_include hello_world.c < iwyu hello_world.c` should work to update a file named _hello_world.c_ with the suggestions made by `iwyu`. | ||
|
||
Copyright | ||
--------- | ||
|
||
Copyright (c) 2014 Jason Petersen | ||
|
||
Code released under the [MIT License](LICENSE). | ||
|
||
[status]: https://travis-ci.org/jasonmp85/homebrew-iwyu | ||
[release]: https://github.com/jasonmp85/homebrew-iwyu/releases/latest | ||
[license]: LICENSE | ||
[iwyu-page]: http://include-what-you-use.com |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'English' | ||
require 'formula' | ||
|
||
# This formula provides an easy way to install include-what-you-use, a tool for | ||
# automatically managing include directives within C and C++ projects. It will | ||
# build and install include-what-you-use, symlink it as iwyu, and install a | ||
# Python wrapper to automatically correct includes (fix_include). | ||
class Iwyu < Formula | ||
CLANG_VERSION = '3.5' | ||
|
||
homepage 'https://code.google.com/p/include-what-you-use/' | ||
url 'http://include-what-you-use.googlecode.com/svn/tags/clang_' + | ||
"#{Iwyu::CLANG_VERSION}", revision: '590' | ||
version '0.3' | ||
|
||
depends_on 'cmake' => :build | ||
depends_on 'llvm' => [:build, 'with-clang'] | ||
|
||
def install | ||
clang_path = "#{HOMEBREW_PREFIX}/Cellar/llvm/#{Iwyu::CLANG_VERSION}.0/" | ||
|
||
system 'cmake', "-DLLVM_PATH=#{clang_path}", | ||
"-DCMAKE_CXX_FLAGS='-stdlib=libc++'", | ||
"-DCMAKE_EXE_LINKER_FLAGS='-stdlib=libc++'", | ||
"-DCMAKE_INSTALL_PREFIX=#{prefix}/", | ||
buildpath, *std_cmake_args | ||
system 'make', 'install' | ||
|
||
bin.install('fix_includes.py' => 'fix_include') | ||
bin.install_symlink('include-what-you-use' => 'iwyu') | ||
prefix.install_symlink "#{clang_path}/lib" | ||
end | ||
|
||
test do | ||
# write out a header and a C file relying on transitive dependencies | ||
(testpath / 'demo.h').write('#include <stdio.h>') | ||
(testpath / 'demo.c').write <<-EOS.undent | ||
#include "demo.h" | ||
int main(void) | ||
{ printf("hello world"); } | ||
EOS | ||
|
||
# iwyu always exits with status 1 so assert that and capture output | ||
fixes = shell_output "iwyu #{testpath}/demo.c 2>&1", 1 | ||
|
||
# pass the output to the fixer script and assert that it fixed one file | ||
results = pipe_output 'fix_include', fixes | ||
|
||
assert_match /IWYU edited 1 file/, results | ||
|
||
# sigh. they use the status code to signal how many files were edited | ||
assert_equal 1, $CHILD_STATUS.exitstatus | ||
end | ||
end |