Skip to content
This repository has been archived by the owner on Jun 22, 2019. It is now read-only.

Commit

Permalink
Merge branch 'release/5.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmp85 committed Jan 12, 2017
2 parents 3c86dab + 8663b54 commit 84256e7
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 59 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ sudo: false
language: objective-c
matrix:
include:
- osx_image: xcode7.1
- osx_image: xcode7.2
- osx_image: xcode7.3
- osx_image: xcode8
- osx_image: xcode8.1
- osx_image: xcode8.2
before_install:
- brew update; brew update
install:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
### homebrew-iwyu v5.0.0 (January 11, 2017) ###

* Installs include-what-you-use 0.7 (based on clang 3.8.0)

* Removes brittle Xcode-symlink workaround

* Relies on compiler builtin headers included in iwyu

* Relies on iwyu's new macOS header path logic

* Adds Xcode 8.0, 8.1, and 8.2 to build matrix

* Removes pre-7.3 Xcode versions from build matrix

### homebrew-iwyu v4.0.0 (June 16, 2016) ###

* Installs include-what-you-use 0.6 (based on clang 3.8.0)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014–2016 Jason Petersen
Copyright (c) 2014–2017 Jason Petersen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Tell make to use it as the C compiler: `make -k CC=iwyu`. It's necessary to use
Copyright
---------

Copyright © 2014–2016 Jason Petersen
Copyright © 2014–2017 Jason Petersen

Code released under the [MIT License](LICENSE).

Expand Down
68 changes: 13 additions & 55 deletions iwyu.rb
Original file line number Diff line number Diff line change
@@ -1,63 +1,27 @@
require "English"
require "formula"

# include-what-you-use needs access to headers included with LLVM 3.8, which
# is only present in Xcode version 7.0 or higher.
class Xcode70 < Requirement
fatal true

satisfy { MacOS::Xcode.version >= "7.0" }

def message
"Xcode 7.0 or newer is required for this package."
end
end

# 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
# iwyu 0.6 based on clang 3.8
CLANG_VERSION = "3.8".freeze

version "0.6"
homepage "http://include-what-you-use.org"
url "http://include-what-you-use.org/downloads/" \
"include-what-you-use-#{version}-x86_64-apple-darwin.tar.gz"
sha256 "46a7e579ad17441ba8b23fe105400565ff978cc61957c19291563912d1f4638d"

depends_on Xcode70
desc "analyze includes in C and C++ source files"
homepage "https://include-what-you-use.org"
url "https://include-what-you-use.org/downloads/include-what-you-use-0.7-x86_64-apple-darwin.tar.gz"
version "0.7"
sha256 "ba343d452b5d7b999c85387dff1750ca2d01af0c4e5a88a2144b395fa22d1575"

def install
# include-what-you-use needs lib and include directories one level
# up from its bindir, but putting them in the homebrew directories
# results in them getting linked in /usr (interfering with e.g. the
# /usr/local/include dirs added by gcc).
# include-what-you-use looks for a lib directory one level up from its bin-
# dir, but putting it directly in prefix results in it getting linked in
# /usr/local/lib
#
# To solve this, we put iwyu in a custom dir and make bin links.
iwyu_subdir_path = (prefix / "iwyu")
iwyu_subdir_path.mkpath

clang_version = `clang --version`.each_line.first
apple_llvm_version = clang_version[/\AApple LLVM version (\d+(?:\.\d+)+)/, 1]

clang_libs = "#{MacOS::Xcode.toolchain_path}/usr/lib/clang/#{apple_llvm_version}"
cpp_includes = "#{MacOS::Xcode.toolchain_path}/usr/include/c++"
# just copy everything from the tarball's lib directory
iwyu_subdir_path.install("lib")

# selectively include certain binaries; give them better names
iwyu_bindir = (iwyu_subdir_path / "bin")
iwyu_libdir = (iwyu_subdir_path / "lib")
iwyu_includes = (iwyu_subdir_path / "include")

iwyu_bindir.mkpath
iwyu_libdir.mkpath
iwyu_includes.mkpath

iwyu_clang_lib_path = (iwyu_libdir / "clang")
iwyu_clang_lib_path.mkpath
iwyu_clang_lib_path.install_symlink(clang_libs => "#{Iwyu::CLANG_VERSION}.0")

iwyu_includes.install_symlink(cpp_includes => "c++")

iwyu_bindir.install("bin/fix_includes.py" => "fix_include")
iwyu_bindir.install("bin/include-what-you-use")
Expand All @@ -82,20 +46,14 @@ def install
EOS

# iwyu exits with a code equal to the number of suggested edits + 2
fixes = shell_output "iwyu #{testpath}/demo.cpp 2>&1", 6
fixes = shell_output "#{bin}/iwyu #{testpath}/demo.cpp 2>&1", 6
assert_not_match(/file not found/, fixes)

# pass the output to the fixer script and assert that it fixed two files
results = pipe_output "fix_include", fixes
results = pipe_output "#{bin}/fix_include", fixes
assert_match(/IWYU edited 2 files/, results)

# sigh. they use the status code to signal how many files were edited
assert_equal 2, $CHILD_STATUS.exitstatus
end

def caveats; <<-EOS.undent
This package will break after an Xcode upgrade. Fixing it is as simple as:
brew reinstall iwyu
EOS
end
end

0 comments on commit 84256e7

Please sign in to comment.