Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
HarveyHunt committed Dec 29, 2015
2 parents fb8675e + f871440 commit 79f4476
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 193 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ language: c
compiler:
- clang
- gcc
before_script:
- wget https://raw.githubusercontent.com/torvalds/linux/master/scripts/checkpatch.pl
- wget https://github.com/torvalds/linux/blob/master/scripts/spelling.txt
- chmod +x checkpatch.pl
script: make debug && make check
script: make debug
notifications:
irc:
channels:
Expand All @@ -15,3 +11,4 @@ notifications:
- "%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}"
- "Build details : %{build_url}"
on_success: never
email: false
163 changes: 15 additions & 148 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,156 +1,23 @@
#### PROJECT SETTINGS ####
# The name of the executable to be created
BIN_NAME := cottage
# Compiler used
CC = gcc
# Extension of source files used in the project
SRC_EXT = c
# Path to the source directory, relative to the makefile
SRC_PATH = .
# General compiler flags
COMPILE_FLAGS = -std=c99 -Wall -Wextra
# Additional release-specific flags
RCOMPILE_FLAGS = -D NDEBUG
# Additional debug-specific flags
DCOMPILE_FLAGS = -g3
# Add additional include paths
INCLUDES = -I $(SRC_PATH)/
# General linker settings
LINK_FLAGS =
# Additional release-specific linker settings
RLINK_FLAGS =
# Additional debug-specific linker settings
DLINK_FLAGS =
# Destination directory, like a jail or mounted system
DESTDIR = /
# Install path (bin/ is appended automatically)
INSTALL_PREFIX = usr
#### END PROJECT SETTINGS ####
CFLAGS += -Wall -pedantic -std=c99
CC ?= clang
BIN_NAME ?= cottage
SRCS = cottage.c

# Generally should not need to edit below this line
all:
$(CC) $(SRCS) $(CFLAGS) -o $(BIN_NAME)

# Verbose option, to output compile and link commands
export V = false
export CMD_PREFIX = @
ifeq ($(V),true)
CMD_PREFIX =
endif
debug: CFLAGS += -O0 -g -DDEBUG
debug: all

# Combine compiler and linker flags
release: export CCFLAGS := $(CCFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS)
release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS)
debug: export CCFLAGS := $(CCFLAGS) $(COMPILE_FLAGS) $(DCOMPILE_FLAGS)
debug: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(DLINK_FLAGS)

# Build and output paths
release: export BUILD_PATH := build/release
release: export BIN_PATH := bin/release
debug: export BUILD_PATH := build/debug
debug: export BIN_PATH := bin/debug
install: export BIN_PATH := bin/release

# Find all source files in the source directory
SOURCES = $(shell find $(SRC_PATH)/ -name '*.$(SRC_EXT)')
# Set the object file names, with the source directory stripped
# from the path, and the build path prepended in its place
OBJECTS = $(SOURCES:$(SRC_PATH)/%.$(SRC_EXT)=$(BUILD_PATH)/%.o)
# Set the dependency files that will be used to add header dependencies
DEPS = $(OBJECTS:.o=.d)

# Macros for timing compilation
TIME_FILE = $(dir $@).$(notdir $@)_time
START_TIME = date '+%s' > $(TIME_FILE)
END_TIME = read st < $(TIME_FILE) ; \
$(RM) $(TIME_FILE) ; \
st=$$((`date '+%s'` - $$st - 86400)) ; \
echo `date -u -d @$$st '+%H:%M:%S'`

# Version macros
# Comment/remove this section to remove versioning
VERSION := $(shell git describe --tags --long --dirty --always | \
sed 's/v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)-\?.*-\([0-9]*\)-\(.*\)/\1 \2 \3 \4 \5/g')
VERSION_MAJOR := $(word 1, $(VERSION))
VERSION_MINOR := $(word 2, $(VERSION))
VERSION_PATCH := $(word 3, $(VERSION))
VERSION_REVISION := $(word 4, $(VERSION))
VERSION_HASH := $(word 5, $(VERSION))
VERSION_STRING := \
"$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH).$(VERSION_REVISION)"
override CCFLAGS := $(CCFLAGS) \
-D VERSION_MAJOR=$(VERSION_MAJOR) \
-D VERSION_MINOR=$(VERSION_MINOR) \
-D VERSION_PATCH=$(VERSION_PATCH) \
-D VERSION_REVISION=$(VERSION_REVISION) \
-D VERSION_HASH=\"$(VERSION_HASH)\"

# Standard, non-optimized release build
.PHONY: release
release: dirs
@echo "Beginning release build v$(VERSION_STRING)"
@$(START_TIME)
@$(MAKE) all --no-print-directory
@echo -n "Total build time: "
@$(END_TIME)

# Debug build for gdb debugging
.PHONY: debug
debug: dirs
@echo "Beginning debug build v$(VERSION_STRING)"
@$(START_TIME)
@$(MAKE) all --no-print-directory
@echo -n "Total build time: "
@$(END_TIME)

# Create the directories used in the build
.PHONY: dirs
dirs:
@echo "Creating directories"
@mkdir -p $(dir $(OBJECTS))
@mkdir -p $(BIN_PATH)
clean:
@rm -f ./*.o
@rm -f $(BIN_NAME)

# Installs to the set path
.PHONY: install
install:
@echo "Installing to $(DESTDIR)$(INSTALL_PREFIX)/bin"
@install -m 0755 $(BIN_PATH)/$(BIN_NAME) $(DESTDIR)$(INSTALL_PREFIX)/bin
@install -m 0755 $(BIN_NAME) /usr/bin

.PHONY: check
check:
@echo "Using checkpatch.pl to check style."
@./checkpatch.pl --no-tree --ignore LONG_LINE,NEW_TYPEDEFS,UNNECESSARY_ELSE, -f cottage.c

# Removes all build files
.PHONY: clean
clean:
@echo "Deleting $(BIN_NAME) symlink"
@$(RM) $(BIN_NAME)
@echo "Deleting directories"
@$(RM) -r build
@$(RM) -r bin

# Main rule, checks the executable and symlinks to the output
all: $(BIN_PATH)/$(BIN_NAME)
@echo "Making symlink: $(BIN_NAME) -> $<"
@$(RM) $(BIN_NAME)
@ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME)

# Link the executable
$(BIN_PATH)/$(BIN_NAME): $(OBJECTS)
@echo "Linking: $@"
@$(START_TIME)
$(CMD_PREFIX)$(CC) $(OBJECTS) $(LDFLAGS) -o $@
@echo -en "\t Link time: "
@$(END_TIME)

# Add dependency files, if they exist
-include $(DEPS)
@./checkpatch.pl --no-tree --ignore LONG_LINE,NEW_TYPEDEFS,UNNECESSARY_ELSE,MACRO_WITH_FLOW_CONTROL -f cottage.c

# Source file rules
# After the first compilation they will be joined with the rules from the
# dependency files to provide header dependencies
$(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_EXT)
@echo "Compiling: $< -> $@"
@$(START_TIME)
$(CMD_PREFIX)$(CC) $(CCFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@
@echo -en "\t Compile time: "
@$(END_TIME)
analyse:
@scan-build -v -o analyse make debug
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,21 @@ Calling one of howm's functions is done in the following manner:
cottage -f function_name <args>
```

It is possible to call operators using cottage, but it requires you call functions to set the operator, the count and finally the motion. Here is an example:
It is possible to call operators using cottage by calling functions to set the operator, the count and finally the motion. Here is an example:

```
cottage -f op_kill
cottage -f set_count 2
cottage -f count 2
cottage -f motion w
```

Alternatively, it is possible to execute a complete operation using a single
command:

```
cottage -o op_kill 2 w
```

## Errors

Upon error, howm will return a response code. Cottage will print a relevant error message and return the error number to its caller.
Upon error, howm will return a response code. Cottage will print a relevant error message and return ```EXIT_FAILURE```.
Loading

0 comments on commit 79f4476

Please sign in to comment.