├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md └── bin-build.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac Finder 2 | .DS_Store 3 | Icon? 4 | 5 | # Thumbnails 6 | ._* 7 | 8 | # Files that might appear on external disk 9 | .Spotlight-V100 10 | .Trashes 11 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | xs-labs.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Jean-David Gadina - www.xs-labs.com 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | - Neither the name of 'Jean-David Gadina' nor the names of its 13 | contributors may be used to endorse or promote products derived from 14 | this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Bin-Build 2 | ========= 3 | 4 | [![Issues](http://img.shields.io/github/issues/macmade/Bin-Build.svg?style=flat)](https://github.com/macmade/Bin-Build/issues) 5 | ![Status](https://img.shields.io/badge/status-inactive-lightgray.svg?style=flat) 6 | ![License](https://img.shields.io/badge/license-bsd-brightgreen.svg?style=flat) 7 | [![Contact](https://img.shields.io/badge/contact-@macmade-blue.svg?style=flat)](https://twitter.com/macmade) 8 | [![Donate-Patreon](https://img.shields.io/badge/donate-patreon-yellow.svg?style=flat)](https://patreon.com/macmade) 9 | [![Donate-Gratipay](https://img.shields.io/badge/donate-gratipay-yellow.svg?style=flat)](https://www.gratipay.com/macmade) 10 | [![Donate-Paypal](https://img.shields.io/badge/donate-paypal-yellow.svg?style=flat)](https://paypal.me/xslabs) 11 | 12 | About 13 | ----- 14 | 15 | Bin-Build is a small shell script to simplify compiling source file in C, C++ and Objective-C. 16 | 17 | Documentation 18 | ------------- 19 | 20 | ### Overview 21 | 22 | The purpose of this script is to provide a simplified compilation command. 23 | 24 | When compiling a source file, the invocation of the compiler is often a painful task, especially when specific options need to be passed, like compiler flags, error level, etc. 25 | 26 | For instance, in order to compile a C file with GCC, you need to type the following kind of command: 27 | 28 | gcc -Wall -Werror -Wextra -pedantic -std=c89 -Os -o file file.c 29 | 30 | It can be a lot worse if using specific options. 31 | 32 | With Bin-Build, you can replace the previous command with: 33 | 34 | bin-build file.c 35 | 36 | It will generate a 'file' executable, from the 'file.c' source file, using the C compiler. 37 | You will see the following kind of output: 38 | 39 | /usr/local/bin/bin-build: compiling file file.c 40 | 41 | Settings: 42 | 43 | - Language: C 44 | - Compiler: /usr/bin/gcc 45 | - Input file: /Users/macmade/Desktop/test.c 46 | - Output file: /Users/macmade/Desktop/test 47 | 48 | Compiler options: 49 | - std=c99 - Os - pedantic 50 | - Werror - Wall - Wextra 51 | - Wbad-function-cast - Wdeclaration-after-statement - Werror-implicit-function-declaration 52 | - Wmissing-braces - Wmissing-declarations - Wmissing-field-initializers 53 | - Wmissing-prototypes - Wnested-externs - Wold-style-definition 54 | - Wparentheses - Wreturn-type - Wshadow 55 | - Wsign-compare - Wstrict-prototypes - Wswitch 56 | - Wuninitialized - Wunknown-pragmas - Wunused-function 57 | - Wunused-label - Wunused-parameter - Wunused-value 58 | - Wunused-variable 59 | 60 | Compiling file... 61 | 62 | Compilation successfull 63 | Do you want to execute the produced binary now? [y/N] 64 | 65 | -------------------------------------------------------------------------------- 66 | Executing /Users/macmade/Desktop/test 67 | -------------------------------------------------------------------------------- 68 | 69 | -------------------------------------------------------------------------------- 70 | Process exit code: 0 71 | -------------------------------------------------------------------------------- 72 | 73 | As you can see, once the compilation is complete, the script ask you if you want to execute the produced program, and gives you the program's exit code, once executed. 74 | 75 | ### Language detection 76 | 77 | Bin-Build can be used seamlessly with C, C++ and Objective-C. 78 | 79 | The script automatically detects the programming language, based on the file extension: 80 | 81 | C: .c 82 | C++: .cpp 83 | Objective-C: .m 84 | 85 | Specific compiler settings will be used for each language. 86 | 87 | ### Language settings 88 | 89 | Settings can be configured for each language, trough environment variables: 90 | 91 | C: $BIN_BUILD_C 92 | C++: $BIN_BUILD_CPP 93 | Objective-C: $BIN_BUILD_OBJC 94 | 95 | Settings consist of the compiler arguments, separated by a `:` sign. 96 | For instance: 97 | 98 | export BIN_BUILD_C=-Wall:-Werror:-O2 99 | bin-build file.c 100 | 101 | Settings can be set for the session, as in the previous example, or globally, in your `.bash_rc` or '.profile' file. 102 | 103 | ### Installation 104 | 105 | Simply copy the script in a directory that's included in your executable path (like `/usr/local/bin/`), and make sure the executable flag is set. 106 | For instance: 107 | 108 | sudo cp bin-build.sh /usr/local/bin/bin-build 109 | sudo chmod 755 /usr/local/bin/bin-build 110 | 111 | You'll then be able to call the script as a normal executable: 112 | 113 | svn-util ~/file.c 114 | 115 | ### Default settings 116 | 117 | Here are the default settings, used for each language. 118 | 119 | #### C 120 | 121 | * std=c99 122 | * Os 123 | * pedantic 124 | * Werror 125 | * Wall 126 | * Wextra 127 | * Wbad-function-cast 128 | * Wdeclaration-after-statement 129 | * Werror-implicit-function-declaration 130 | * Wmissing-braces 131 | * Wmissing-declarations 132 | * Wmissing-field-initializers 133 | * Wmissing-prototypes 134 | * Wnested-externs 135 | * Wold-style-definition 136 | * Wparentheses 137 | * Wreturn-type 138 | * Wshadow 139 | * Wsign-compare 140 | * Wstrict-prototypes 141 | * Wswitch 142 | * Wuninitialized 143 | * Wunknown-pragmas 144 | * Wunused-function 145 | * Wunused-label 146 | * Wunused-parameter 147 | * Wunused-value 148 | * Wunused-variable 149 | 150 | #### C++ 151 | 152 | * Os 153 | * pedantic 154 | * Werror 155 | * Wall 156 | * Wextra 157 | * Wmissing-braces 158 | * Wmissing-field-initializers 159 | * Wmissing-prototypes 160 | * Wparentheses 161 | * Wreturn-type 162 | * Wshadow 163 | * Wsign-compare 164 | * Wswitch 165 | * Wuninitialized 166 | * Wunknown-pragmas 167 | * Wunused-function 168 | * Wunused-label 169 | * Wunused-parameter 170 | * Wunused-value 171 | * Wunused-variable 172 | 173 | #### Objective-C 174 | 175 | * framework Cocoa 176 | * std=c99 177 | * Os 178 | * pedantic 179 | * Werror 180 | * Wall 181 | * Wextra 182 | * Wbad-function-cast 183 | * Wdeclaration-after-statement 184 | * Werror-implicit-function-declaration 185 | * Wmissing-braces 186 | * Wmissing-declarations 187 | * Wmissing-field-initializers 188 | * Wmissing-prototypes 189 | * Wnested-externs 190 | * Wold-style-definition 191 | * Wparentheses 192 | * Wreturn-type 193 | * Wshadow 194 | * Wsign-compare 195 | * Wstrict-prototypes 196 | * Wstrict-selector-match 197 | * Wswitch 198 | * Wundeclared-selector 199 | * Wuninitialized 200 | * Wunknown-pragmas 201 | * Wunused-function 202 | * Wunused-label 203 | * Wunused-parameter 204 | * Wunused-value 205 | * Wunused-variable 206 | 207 | License 208 | ------- 209 | 210 | Bin-Build is released under the terms of the BSD license. 211 | 212 | Repository Infos 213 | ---------------- 214 | 215 | Owner: Jean-David Gadina - XS-Labs 216 | Web: www.xs-labs.com 217 | Blog: www.noxeos.com 218 | Twitter: @macmade 219 | GitHub: github.com/macmade 220 | LinkedIn: ch.linkedin.com/in/macmade/ 221 | StackOverflow: stackoverflow.com/users/182676/macmade 222 | -------------------------------------------------------------------------------- /bin-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################################################################ 4 | # Copyright (c) 2010, Jean-David Gadina - www.xs-labs.com # 5 | # All rights reserved. # 6 | # # 7 | # Redistribution and use in source and binary forms, with or without # 8 | # modification, are permitted provided that the following conditions are met: # 9 | # # 10 | # - Redistributions of source code must retain the above copyright notice, # 11 | # this list of conditions and the following disclaimer. # 12 | # - Redistributions in binary form must reproduce the above copyright # 13 | # notice, this list of conditions and the following disclaimer in the # 14 | # documentation and/or other materials provided with the distribution. # 15 | # - Neither the name of 'Jean-David Gadina' nor the names of its # 16 | # contributors may be used to endorse or promote products derived from # 17 | # this software without specific prior written permission. # 18 | # # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # 22 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # 23 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # 24 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # 25 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # 26 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # 27 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # 28 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # 29 | # POSSIBILITY OF SUCH DAMAGE. # 30 | ################################################################################ 31 | 32 | BuildBin() 33 | { 34 | EXEC=$0 35 | 36 | DIR=`dirname $1` 37 | ABS_PATH=`cd $DIR; pwd` 38 | FILE=`basename $1` 39 | IN="$ABS_PATH/$FILE" 40 | OUT="$ABS_PATH/${FILE%.*}" 41 | EXT=${FILE##*.} 42 | 43 | if [ $EXT == "c" ]; then 44 | 45 | LANG="C" 46 | CC=`which clang` 47 | CC_ARGS="-std=c99:-Os:-Wabi:-Waddress-of-temporary:-Waddress:-Waggregate-return:-Wall:-Wambiguous-member-template:-Warc-abi:-Warc-non-pod-memaccess:-Warc-retain-cycles:-Warc-unsafe-retained-assign:-Warc:-Watomic-properties:-Wattributes:-Wavailability:-Wbad-function-cast:-Wbind-to-temporary-copy:-Wbitwise-op-parentheses:-Wbool-conversions:-Wbuiltin-macro-redefined:-Wc++-compat:-Wc++0x-compat:-Wc++0x-extensions:-Wcast-align:-Wcast-qual:-Wchar-align:-Wchar-subscripts:-Wcomment:-Wcomments:-Wconditional-uninitialized:-Wconversion:-Wctor-dtor-privacy:-Wcustom-atomic-properties:-Wdeclaration-after-statement:-Wdefault-arg-special-member:-Wdelegating-ctor-cycles:-Wdelete-non-virtual-dtor:-Wdeprecated-declarations:-Wdeprecated-implementations:-Wdeprecated-writable-strings:-Wdeprecated:-Wdisabled-optimization:-Wdiscard-qual:-Wdiv-by-zero:-Wduplicate-method-arg:-Weffc++:-Wempty-body:-Wendif-labels:-Wexit-time-destructors:-Wextra-tokens:-Wextra:-Wformat-extra-args:-Wformat-nonliteral:-Wformat-zero-length:-Wformat:-Wformat=2:-Wfour-char-constants:-Wglobal-constructors:-Wgnu-designator:-Wgnu:-Wheader-hygiene:-Widiomatic-parentheses:-Wignored-qualifiers:-Wimplicit-atomic-properties:-Wimplicit-function-declaration:-Wimplicit-int:-Wimplicit:-Wimport:-Wincompatible-pointer-types:-Winit-self:-Winitializer-overrides:-Winline:-Wint-to-pointer-cast:-Winvalid-offsetof:-Winvalid-pch:-Wlarge-by-value-copy:-Wliteral-range:-Wlocal-type-template-args:-Wlogical-op-parentheses:-Wlong-long:-Wmain:-Wmicrosoft:-Wmismatched-tags:-Wmissing-braces:-Wmissing-declarations:-Wmissing-field-initializers:-Wmissing-format-attribute:-Wmissing-include-dirs:-Wmissing-noreturn:-Wmost:-Wmultichar:-Wnested-externs:-Wnewline-eof:-Wnon-gcc:-Wnon-virtual-dtor:-Wnonfragile-abi2:-Wnonnull:-Wnonportable-cfstrings:-Wnull-dereference:-Wobjc-nonunified-exceptions:-Wold-style-cast:-Wold-style-definition:-Wout-of-line-declaration:-Woverflow:-Woverlength-strings:-Woverloaded-virtual:-Wpacked:-Wpadded:-Wparentheses:-Wpointer-arith:-Wpointer-to-int-cast:-Wprotocol:-Wreadonly-setter-attrs:-Wredundant-decls:-Wreorder:-Wreturn-type:-Wself-assign:-Wsemicolon-before-method-body:-Wsequence-point:-Wshadow:-Wshorten-64-to-32:-Wsign-compare:-Wsign-promo:-Wsizeof-array-argument:-Wstack-protector:-Wstrict-aliasing:-Wstrict-overflow:-Wstrict-prototypes:-Wstrict-selector-match:-Wsuper-class-method-mismatch:-Wswitch-default:-Wswitch-enum:-Wswitch:-Wsynth:-Wtautological-compare:-Wtrigraphs:-Wtype-limits:-Wundeclared-selector:-Wuninitialized:-Wunknown-pragmas:-Wunnamed-type-template-args:-Wunneeded-internal-declaration:-Wunneeded-member-function:-Wunused-argument:-Wunused-exception-parameter:-Wunused-function:-Wunused-label:-Wunused-member-function:-Wunused-parameter:-Wunused-value:-Wunused-variable:-Wunused:-Wused-but-marked-unused:-Wvariadic-macros:-Wvector-conversions:-Wvla:-Wvolatile-register-var:-Wwrite-strings" 48 | CC_ARGS_OUT="-o $OUT $IN" 49 | 50 | if [ ! $CC ]; then 51 | 52 | CC=`which gcc` 53 | CC_ARGS="-std=c99:-Os:-pedantic:-Werror:-Wall:-Wextra:-Wbad-function-cast:-Wdeclaration-after-statement:-Werror-implicit-function-declaration:-Wmissing-braces:-Wmissing-declarations:-Wmissing-field-initializers:-Wmissing-prototypes:-Wnested-externs:-Wold-style-definition:-Wparentheses:-Wreturn-type:-Wshadow:-Wsign-compare:-Wstrict-prototypes:-Wswitch:-Wuninitialized:-Wunknown-pragmas:-Wunused-function:-Wunused-label:-Wunused-parameter:-Wunused-value:-Wunused-variable" 54 | 55 | fi 56 | 57 | elif [ $EXT == "cpp" ]; then 58 | 59 | LANG="C++" 60 | CC=`which clang++` 61 | CC_ARGS="-Os:-Wabi:-Waddress-of-temporary:-Waddress:-Waggregate-return:-Wall:-Wambiguous-member-template:-Warc-abi:-Warc-non-pod-memaccess:-Warc-retain-cycles:-Warc-unsafe-retained-assign:-Warc:-Watomic-properties:-Wattributes:-Wavailability:-Wbad-function-cast:-Wbind-to-temporary-copy:-Wbitwise-op-parentheses:-Wbool-conversions:-Wbuiltin-macro-redefined:-Wc++-compat:-Wc++0x-compat:-Wc++0x-extensions:-Wcast-align:-Wcast-qual:-Wchar-align:-Wchar-subscripts:-Wcomment:-Wcomments:-Wconditional-uninitialized:-Wconversion:-Wctor-dtor-privacy:-Wcustom-atomic-properties:-Wdeclaration-after-statement:-Wdefault-arg-special-member:-Wdelegating-ctor-cycles:-Wdelete-non-virtual-dtor:-Wdeprecated-declarations:-Wdeprecated-implementations:-Wdeprecated-writable-strings:-Wdeprecated:-Wdisabled-optimization:-Wdiscard-qual:-Wdiv-by-zero:-Wduplicate-method-arg:-Weffc++:-Wempty-body:-Wendif-labels:-Wexit-time-destructors:-Wextra-tokens:-Wextra:-Wformat-extra-args:-Wformat-nonliteral:-Wformat-zero-length:-Wformat:-Wformat=2:-Wfour-char-constants:-Wglobal-constructors:-Wgnu-designator:-Wgnu:-Wheader-hygiene:-Widiomatic-parentheses:-Wignored-qualifiers:-Wimplicit-atomic-properties:-Wimplicit-function-declaration:-Wimplicit-int:-Wimplicit:-Wimport:-Wincompatible-pointer-types:-Winit-self:-Winitializer-overrides:-Winline:-Wint-to-pointer-cast:-Winvalid-offsetof:-Winvalid-pch:-Wlarge-by-value-copy:-Wliteral-range:-Wlocal-type-template-args:-Wlogical-op-parentheses:-Wlong-long:-Wmain:-Wmicrosoft:-Wmismatched-tags:-Wmissing-braces:-Wmissing-declarations:-Wmissing-field-initializers:-Wmissing-format-attribute:-Wmissing-include-dirs:-Wmissing-noreturn:-Wmost:-Wmultichar:-Wnested-externs:-Wnewline-eof:-Wnon-gcc:-Wnon-virtual-dtor:-Wnonfragile-abi2:-Wnonnull:-Wnonportable-cfstrings:-Wnull-dereference:-Wobjc-nonunified-exceptions:-Wold-style-cast:-Wold-style-definition:-Wout-of-line-declaration:-Woverflow:-Woverlength-strings:-Woverloaded-virtual:-Wpacked:-Wpadded:-Wparentheses:-Wpointer-arith:-Wpointer-to-int-cast:-Wprotocol:-Wreadonly-setter-attrs:-Wredundant-decls:-Wreorder:-Wreturn-type:-Wself-assign:-Wsemicolon-before-method-body:-Wsequence-point:-Wshadow:-Wshorten-64-to-32:-Wsign-compare:-Wsign-promo:-Wsizeof-array-argument:-Wstack-protector:-Wstrict-aliasing:-Wstrict-overflow:-Wstrict-prototypes:-Wstrict-selector-match:-Wsuper-class-method-mismatch:-Wswitch-default:-Wswitch-enum:-Wswitch:-Wsynth:-Wtautological-compare:-Wtrigraphs:-Wtype-limits:-Wundeclared-selector:-Wuninitialized:-Wunknown-pragmas:-Wunnamed-type-template-args:-Wunneeded-internal-declaration:-Wunneeded-member-function:-Wunused-argument:-Wunused-exception-parameter:-Wunused-function:-Wunused-label:-Wunused-member-function:-Wunused-parameter:-Wunused-value:-Wunused-variable:-Wunused:-Wused-but-marked-unused:-Wvariadic-macros:-Wvector-conversions:-Wvla:-Wvolatile-register-var:-Wwrite-strings" 62 | CC_ARGS_OUT="-o $OUT $IN" 63 | 64 | if [ ! $CC ]; then 65 | 66 | CC=`which g++` 67 | CC_ARGS="-Os:-pedantic:-Werror:-Wall:-Wextra:-Wmissing-braces:-Wmissing-field-initializers:-Wmissing-prototypes:-Wparentheses:-Wreturn-type:-Wshadow:-Wsign-compare:-Wswitch:-Wuninitialized:-Wunknown-pragmas:-Wunused-function:-Wunused-label:-Wunused-parameter:-Wunused-value:-Wunused-variable" 68 | 69 | fi 70 | 71 | elif [ $EXT == "m" ]; then 72 | 73 | LANG="Objective-C" 74 | CC=`which clang` 75 | CC_ARGS="-std=c99:-Os:-Wabi:-Waddress-of-temporary:-Waddress:-Waggregate-return:-Wall:-Wambiguous-member-template:-Warc-abi:-Warc-non-pod-memaccess:-Warc-retain-cycles:-Warc-unsafe-retained-assign:-Warc:-Watomic-properties:-Wattributes:-Wavailability:-Wbad-function-cast:-Wbind-to-temporary-copy:-Wbitwise-op-parentheses:-Wbool-conversions:-Wbuiltin-macro-redefined:-Wc++-compat:-Wc++0x-compat:-Wc++0x-extensions:-Wcast-align:-Wcast-qual:-Wchar-align:-Wchar-subscripts:-Wcomment:-Wcomments:-Wconditional-uninitialized:-Wconversion:-Wctor-dtor-privacy:-Wcustom-atomic-properties:-Wdeclaration-after-statement:-Wdefault-arg-special-member:-Wdelegating-ctor-cycles:-Wdelete-non-virtual-dtor:-Wdeprecated-declarations:-Wdeprecated-implementations:-Wdeprecated-writable-strings:-Wdeprecated:-Wdisabled-optimization:-Wdiscard-qual:-Wdiv-by-zero:-Wduplicate-method-arg:-Weffc++:-Wempty-body:-Wendif-labels:-Wexit-time-destructors:-Wextra-tokens:-Wextra:-Wformat-extra-args:-Wformat-nonliteral:-Wformat-zero-length:-Wformat:-Wformat=2:-Wfour-char-constants:-Wglobal-constructors:-Wgnu-designator:-Wgnu:-Wheader-hygiene:-Widiomatic-parentheses:-Wignored-qualifiers:-Wimplicit-atomic-properties:-Wimplicit-function-declaration:-Wimplicit-int:-Wimplicit:-Wimport:-Wincompatible-pointer-types:-Winit-self:-Winitializer-overrides:-Winline:-Wint-to-pointer-cast:-Winvalid-offsetof:-Winvalid-pch:-Wlarge-by-value-copy:-Wliteral-range:-Wlocal-type-template-args:-Wlogical-op-parentheses:-Wlong-long:-Wmain:-Wmicrosoft:-Wmismatched-tags:-Wmissing-braces:-Wmissing-declarations:-Wmissing-field-initializers:-Wmissing-format-attribute:-Wmissing-include-dirs:-Wmissing-noreturn:-Wmost:-Wmultichar:-Wnested-externs:-Wnewline-eof:-Wnon-gcc:-Wnon-virtual-dtor:-Wnonfragile-abi2:-Wnonnull:-Wnonportable-cfstrings:-Wnull-dereference:-Wobjc-nonunified-exceptions:-Wold-style-cast:-Wold-style-definition:-Wout-of-line-declaration:-Woverflow:-Woverlength-strings:-Woverloaded-virtual:-Wpacked:-Wpadded:-Wparentheses:-Wpointer-arith:-Wpointer-to-int-cast:-Wprotocol:-Wreadonly-setter-attrs:-Wredundant-decls:-Wreorder:-Wreturn-type:-Wself-assign:-Wsemicolon-before-method-body:-Wsequence-point:-Wshadow:-Wshorten-64-to-32:-Wsign-compare:-Wsign-promo:-Wsizeof-array-argument:-Wstack-protector:-Wstrict-aliasing:-Wstrict-overflow:-Wstrict-prototypes:-Wstrict-selector-match:-Wsuper-class-method-mismatch:-Wswitch-default:-Wswitch-enum:-Wswitch:-Wsynth:-Wtautological-compare:-Wtrigraphs:-Wtype-limits:-Wundeclared-selector:-Wuninitialized:-Wunknown-pragmas:-Wunnamed-type-template-args:-Wunneeded-internal-declaration:-Wunneeded-member-function:-Wunused-argument:-Wunused-exception-parameter:-Wunused-function:-Wunused-label:-Wunused-member-function:-Wunused-parameter:-Wunused-value:-Wunused-variable:-Wunused:-Wused-but-marked-unused:-Wvariadic-macros:-Wvector-conversions:-Wvla:-Wvolatile-register-var:-Wwrite-strings" 76 | CC_ARGS_OUT="-o $OUT $IN" 77 | 78 | if [ ! $CC ]; then 79 | 80 | CC=`which gcc` 81 | CC_ARGS="-framework Cocoa:-std=c99:-Os:-pedantic:-Werror:-Wall:-Wextra:-Wbad-function-cast:-Wdeclaration-after-statement:-Werror-implicit-function-declaration:-Wmissing-braces:-Wmissing-declarations:-Wmissing-field-initializers:-Wmissing-prototypes:-Wnested-externs:-Wold-style-definition:-Wparentheses:-Wreturn-type:-Wshadow:-Wsign-compare:-Wstrict-prototypes:-Wstrict-selector-match:-Wswitch:-Wundeclared-selector:-Wuninitialized:-Wunknown-pragmas:-Wunused-function:-Wunused-label:-Wunused-parameter:-Wunused-value:-Wunused-variable" 82 | 83 | fi 84 | 85 | else 86 | 87 | echo "" 88 | echo "$EXEC - error: unknown language ($EXT)." 89 | echo "" 90 | echo "Available languages are:" 91 | echo "" 92 | echo " - C .c" 93 | echo " - C++ .cpp" 94 | echo " - Objective-C .m" 95 | echo "" 96 | exit 97 | 98 | fi 99 | 100 | IFS_OLD=$IFS 101 | IFS=":" 102 | read -ra CC_ARGS_A <<< "$CC_ARGS" 103 | IFS=$IFS_OLD 104 | 105 | echo "" 106 | echo "$EXEC: compiling file $1" 107 | echo "" 108 | echo "Settings:" 109 | echo "" 110 | echo " - Language: $LANG" 111 | echo " - Compiler: $CC" 112 | echo " - Input file: $IN" 113 | echo " - Output file: $OUT" 114 | echo "" 115 | echo "Compiler options:" 116 | echo "" 117 | 118 | for (( i = 0; i < ${#CC_ARGS_A[@]}; i += 4 )); do 119 | 120 | ARG1=${CC_ARGS_A[$i]} 121 | ARG2=${CC_ARGS_A[$i+1]} 122 | ARG3=${CC_ARGS_A[$i+2]} 123 | ARG4=${CC_ARGS_A[$i+3]} 124 | 125 | ARG1=${ARG1:1} 126 | ARG2=${ARG2:1} 127 | ARG3=${ARG3:1} 128 | ARG4=${ARG4:1} 129 | 130 | let "PAD1_LENGTH=40 - ${#ARG1}" 131 | let "PAD2_LENGTH=40 - ${#ARG2}" 132 | let "PAD3_LENGTH=40 - ${#ARG3}" 133 | 134 | PAD1=$( printf "%${PAD1_LENGTH}s" ' ' ) 135 | PAD2=$( printf "%${PAD2_LENGTH}s" ' ' ) 136 | PAD3=$( printf "%${PAD3_LENGTH}s" ' ' ) 137 | 138 | PAD1=${PAD1//?/ } 139 | PAD2=${PAD2//?/ } 140 | PAD3=${PAD3//?/ } 141 | 142 | if [ "$ARG1" ]; then ARG1="- $ARG1"; fi 143 | if [ "$ARG2" ]; then ARG2="- $ARG2"; fi 144 | if [ "$ARG3" ]; then ARG3="- $ARG3"; fi 145 | if [ "$ARG4" ]; then ARG4="- $ARG4"; fi 146 | 147 | echo " $ARG1 $PAD1 $ARG2 $PAD2 $ARG3 $PAD3 $ARG4" 148 | 149 | done 150 | 151 | echo "" 152 | echo "Compiling file..." 153 | echo "" 154 | 155 | if [ -f $OUT ]; then 156 | 157 | rm $OUT 158 | 159 | fi 160 | 161 | $CC $CC_ARGS_OUT ${CC_ARGS_A[*]} 162 | 163 | if [ ! -f $OUT ]; then 164 | 165 | echo "Compilation failed" 166 | echo "" 167 | exit 168 | 169 | fi 170 | 171 | echo "Compilation successfull" 172 | echo "Do you want to execute the produced binary now? [y/N]" 173 | 174 | read RUN 175 | 176 | if [ "$RUN" == "y" ] || [ "$RUN" == "Y" ] || [ "$RUN" == "yes" ] || [ "$RUN" == "Yes" ] || [ "$RUN" == "YES" ]; then 177 | 178 | echo "" 179 | echo "--------------------------------------------------------------------------------" 180 | echo "Executing $OUT" 181 | echo "--------------------------------------------------------------------------------" 182 | echo "" 183 | 184 | PROCESS=exec $OUT 185 | 186 | STATUS=$? 187 | 188 | echo "" 189 | echo "--------------------------------------------------------------------------------" 190 | echo "Process exit code: $STATUS" 191 | echo "--------------------------------------------------------------------------------" 192 | echo "" 193 | 194 | fi 195 | } 196 | 197 | if [ ! $1 ]; then 198 | 199 | echo "" 200 | echo "Usage: $EXEC source-file" 201 | echo "" 202 | exit 203 | 204 | elif [ ! -f $1 ]; then 205 | 206 | echo "" 207 | echo "$EXEC - error: input file does not exist ($1)" 208 | echo "" 209 | exit 210 | 211 | else 212 | 213 | BuildBin $1 214 | 215 | fi 216 | --------------------------------------------------------------------------------