Ticket #40615: macports_clang-format.patch

File macports_clang-format.patch, 7.5 KB (added by hahn.seb@…, 10 years ago)
  • dports/lang/llvm-3.4/Portfile

    diff --git a/dports/lang/llvm-3.4/Portfile b/dports/lang/llvm-3.4/Portfile
    index fe2682f..ea9601c 100644
    a b if {${subport} == "llvm-${llvm_version}"} { 
    329329
    330330    variant analyzer description {Install clang static analyzer} {
    331331        if {[string equal "${pythonver}" ""]} {
    332             ui_error "You mush select a python variant to use the clang static analyzer (+analyzer)"
     332            ui_error "You must select a python variant to use the clang static analyzer (+analyzer)"
    333333            error "Invalid variant combination"
    334334        }
    335335
    if {${subport} == "llvm-${llvm_version}"} { 
    365365            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-view:" "${destroot}${prefix}/bin/scan-view-${suffix}"
    366366        }
    367367    }
     368
     369    variant format description {Install clang-format} {
     370
     371        patchfiles-append install_clang-format.patch clang-format_executable_bbedit.patch \
     372                          clang-format_executable_diff.patch clang-format_executable_el.patch \
     373                          clang-format_executable_py.patch clang-format_executable_sublime.patch
     374
     375        if {![string equal "${pythonver}" "27"]} {
     376            ui_error "You must select the python27 variant to use the clang-format support scripts"
     377            error "Invalid variant combination"
     378        }
     379
     380        depends_run-append port:python27
     381
     382        post-patch {
     383            reinplace "s|@CLANG_FORMAT_PATH@|${prefix}/bin/clang-format-${suffix}|g" \
     384                ${worksrcpath}/tools/clang/tools/clang-format/clang-format-bbedit.applescript \
     385                ${worksrcpath}/tools/clang/tools/clang-format/clang-format-diff.py            \
     386                ${worksrcpath}/tools/clang/tools/clang-format/clang-format-sublime.py         \
     387                ${worksrcpath}/tools/clang/tools/clang-format/clang-format.el                 \
     388                ${worksrcpath}/tools/clang/tools/clang-format/clang-format.py
     389        }
     390
     391        post-destroot {
     392            file mkdir ${destroot}${sub_prefix}/libexec
     393            file copy ${worksrcpath}/tools/clang/tools/clang-format ${destroot}${sub_prefix}/libexec/clang-format
     394
     395            file delete -force ${destroot}${sub_prefix}/libexec/clang-format/.svn
     396            file delete -force ${destroot}${sub_prefix}/libexec/clang-format/Makefile
     397            file delete -force ${destroot}${sub_prefix}/libexec/clang-format/Release+Debug+Asserts
     398            file delete -force ${destroot}${sub_prefix}/libexec/clang-format/CMakeLists.txt
     399            file delete -force ${destroot}${sub_prefix}/libexec/clang-format/ClangFormat.cpp
     400        }
     401    }
     402
    368403}
    369404
    370405livecheck.type          none
  • new file dports/lang/llvm-3.4/files/clang-format_executable_bbedit.patch

    diff --git a/dports/lang/llvm-3.4/files/clang-format_executable_bbedit.patch b/dports/lang/llvm-3.4/files/clang-format_executable_bbedit.patch
    new file mode 100644
    index 0000000..970a65b
    - +  
     1--- a/tools/clang/tools/clang-format/clang-format-bbedit.applescript    2011-07-09 14:35:58.000000000 -0700
     2+++ b/tools/clang/tools/clang-format/clang-format-bbedit.applescript    2012-04-20 10:09:40.000000000 -0700
     3@@ -15,7 +15,7 @@ ifeq ($(HOST_OS),Darwin)
     4 end tell
     5 
     6 set filePath to urlToPOSIXPath(fileURL)
     7-set newContents to do shell script "/path/to/clang-format -offset=" & selectionOffset & " -length=" & selectionLength & " " & quoted form of filePath
     8+set newContents to do shell script "@CLANG_FORMAT_PATH@ -offset=" & selectionOffset & " -length=" & selectionLength & " " & quoted form of filePath
     9 
     10 tell application "BBEdit"
     11        -- "set contents of text document 1 to newContents" scrolls to the bottom while
  • new file dports/lang/llvm-3.4/files/clang-format_executable_diff.patch

    diff --git a/dports/lang/llvm-3.4/files/clang-format_executable_diff.patch b/dports/lang/llvm-3.4/files/clang-format_executable_diff.patch
    new file mode 100644
    index 0000000..4f9daba
    - +  
     1--- a/tools/clang/tools/clang-format/clang-format-diff.py       2011-07-09 14:35:58.000000000 -0700
     2+++ b/tools/clang/tools/clang-format/clang-format-diff.py       2012-04-20 10:09:40.000000000 -0700
     3@@ -15,7 +15,7 @@ ifeq ($(HOST_OS),Darwin)
     4 
     5 
     6 # Change this to the full path if clang-format is not on the path.
     7-binary = 'clang-format'
     8+binary = '@CLANG_FORMAT_PATH@'
     9 
     10 
     11 def main():
     12 
  • new file dports/lang/llvm-3.4/files/clang-format_executable_el.patch

    diff --git a/dports/lang/llvm-3.4/files/clang-format_executable_el.patch b/dports/lang/llvm-3.4/files/clang-format_executable_el.patch
    new file mode 100644
    index 0000000..789c0f5
    - +  
     1--- a/tools/clang/tools/clang-format/clang-format.el    2011-07-09 14:35:58.000000000 -0700
     2+++ b/tools/clang/tools/clang-format/clang-format.el    2012-04-20 10:09:40.000000000 -0700
     3@@ -13,7 +13,7 @@ ifeq ($(HOST_OS),Darwin)
     4 
     5 ;; *Location of the clang-format binary. If it is on your PATH, a full path name
     6 ;; need not be specified.
     7-(defvar clang-format-binary "clang-format")
     8+(defvar clang-format-binary "@CLANG_FORMAT_PATH@")
     9 
     10 (defun clang-format-region ()
     11   "Use clang-format to format the currently active region."
  • new file dports/lang/llvm-3.4/files/clang-format_executable_py.patch

    diff --git a/dports/lang/llvm-3.4/files/clang-format_executable_py.patch b/dports/lang/llvm-3.4/files/clang-format_executable_py.patch
    new file mode 100644
    index 0000000..c59c3c2
    - +  
     1--- a/tools/clang/tools/clang-format/clang-format.py    2011-07-09 14:35:58.000000000 -0700
     2+++ b/tools/clang/tools/clang-format/clang-format.py    2012-04-20 10:09:40.000000000 -0700
     3@@ -24,7 +24,7 @@ ifeq ($(HOST_OS),Darwin)
     4 import vim
     5 
     6 # Change this to the full path if clang-format is not on the path.
     7-binary = 'clang-format'
     8+binary = '@CLANG_FORMAT_PATH@'
     9 
     10 # Change this to format according to other formatting styles. See the output of
     11 # 'clang-format --help' for a list of supported styles. The default looks for
     12 
  • new file dports/lang/llvm-3.4/files/clang-format_executable_sublime.patch

    diff --git a/dports/lang/llvm-3.4/files/clang-format_executable_sublime.patch b/dports/lang/llvm-3.4/files/clang-format_executable_sublime.patch
    new file mode 100644
    index 0000000..d244ec1
    - +  
     1--- a/tools/clang/tools/clang-format/clang-format-sublime.py2011-07-09 14:35:58.000000000 -0700
     2+++ b/tools/clang/tools/clang-format/clang-format-sublime.py    2012-04-20 10:09:40.000000000 -0700
     3@@ -18,7 +18,7 @@ ifeq ($(HOST_OS),Darwin)
     4 import subprocess
     5 
     6 # Change this to the full path if clang-format is not on the path.
     7-binary = 'clang-format'
     8+binary = '@CLANG_FORMAT_PATH@'
     9 
     10 # Change this to format according to other formatting styles. See the output of
     11 # 'clang-format --help' for a list of supported styles. The default looks for
  • new file dports/lang/llvm-3.4/files/install_clang-format.patch

    diff --git a/dports/lang/llvm-3.4/files/install_clang-format.patch b/dports/lang/llvm-3.4/files/install_clang-format.patch
    new file mode 100644
    index 0000000..8acb66d
    - +  
     1--- a/Makefile  2013-10-02 08:42:23.000000000 -0700
     2+++ b/Makefile  2013-10-24 10:57:33.000000000 -0700
     3@@ -70,8 +70,9 @@ ifeq ($(MAKECMDGOALS),install-clang)
     4   DIRS := tools/clang/tools/driver tools/clang/lib/Headers \
     5           tools/clang/tools/libclang \
     6           tools/clang/tools/c-index-test \
     7           tools/clang/runtime tools/clang/docs \
     8-          tools/clang/include tools/clang/lib
     9+          tools/clang/include tools/clang/lib \
     10+          tools/clang/tools/clang-format
     11   OPTIONAL_DIRS :=
     12   NO_INSTALL = 1
     13 endif