diff options
author | Camil Staps | 2017-10-05 22:37:37 +0200 |
---|---|---|
committer | Camil Staps | 2017-10-05 22:42:40 +0200 |
commit | e3535240d9e268595989785475738271486ce593 (patch) | |
tree | b6a8e3880431d08f120aafcd4e6a0dc3792bceca |
Initial commit
-rw-r--r-- | LICENSE | 21 | ||||
-rw-r--r-- | README.md | 44 | ||||
-rwxr-xr-x | iclm | 77 |
3 files changed, 142 insertions, 0 deletions
@@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Camil Staps + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..14edc07 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# iclm +Interactive Clean Make + +This is an `expect` wrapper around `clm`, the [Clean][] make tool. +It assumes you have a tagfile built by [`cloogletags -c`][tags] in +`$CLEAN_HOME/lib/tags`. It attempts to guess which libraries must be added by +looking at the compiler errors. + +## Usage + +Simply use `iclm` instead of `clm`. If you want that arguments are stored, such +that `iclm` does not have to guess every time again, use `iclm -P`. This stores +arguments in `.iclmargs`. + +## Example run + +``` +spawn clm test +Compiling Data.Maybe +Can't find Data.Maybe.icl + --> Adding /opt/clean/lib/Platform to libraries. +spawn clm -I /opt/clean/lib/Platform test +Compiling GenEq +Can't find GenEq.icl + --> Adding /opt/clean/lib/Generics to libraries. +spawn clm -I /opt/clean/lib/Platform -I /opt/clean/lib/Generics test +Linking test +/usr/bin/ld: /tmp/linkerXQR2I8: relocation R_X86_64_32S against `.data' can not be used when making a shared object; recompile with -fPIC +/usr/bin/ld: final link failed: Nonrepresentable section on output +collect2: error: ld returned 1 exit status + --> Using -l -no-pie. +spawn clm -I /opt/clean/lib/Platform -I /opt/clean/lib/Generics -l -no-pie test +Linking test + --> Done. +``` + +## Author, copyright & license + +Copyright © 2017-present [Camil Staps][cs]. Licensed under MIT, see the +`LICENSE` file. + +[Clean]: http://clean.cs.ru.nl +[tags]: https://github.com/clean-cloogle/cloogle-tags +[cs]: https://camilstaps.nl @@ -0,0 +1,77 @@ +#!/usr/bin/expect +# vim: syntax=expect: + +### Settings + +set cleanhome "$env(CLEAN_HOME)" +set cleanlib "$cleanhome/lib" +set tagfile "$cleanlib/tags" + +set usecolours 1 +array set colours { success "32" error "31" info "33" } + +set argfile ".iclmargs" + +### End settings + +set args "" +set storeargs 0 +if {[lindex $argv 0] == "-P"} { + if {[file exists $argfile] == 1} { + set fp [open $argfile r] + set args [read $fp] + close $fp + } + set argv [lrange $argv 1 end] + set storeargs 1 +} + +proc feedback { type msg } { + global colours usecolours + if {$usecolours} { + send_user "\033\[0;$colours($type)m --> $msg\033\[0m\n" + } else { + send_user " --> $msg\n" + } +} + +proc tryImport { name } { + global args tagfile + + log_user 0 + spawn -noecho grep -P "^$name\\t.*\\tmodule:" "$tagfile" + + expect -re "$name\t(.*)/$name\.dcl\t1;" { + set args "$args -I $expect_out(1,string)" + feedback "info" "Adding $expect_out(1,string) to libraries." + tryCompile + } +} + +proc tryCompile { } { + global args argv storeargs argfile + + if {$storeargs} { + set fp [open $argfile w] + puts $fp $args + } + + log_user 1 + spawn clm {*}$args {*}$argv + + expect { + -re "Error \\\[.*\\\]: (.*)\.dcl could not be imported" { + tryImport $expect_out(1,string) + } -re "Can't find (.*)\.icl" { + tryImport $expect_out(1,string) + } "Nonrepresentable section on output" { + set args "$args -l -no-pie" + feedback "info" "Using -l -no-pie." + tryCompile + } eof { + feedback "success" "Done." + } + } +} + +tryCompile |