Skip to content

Commit

Permalink
New build system
Browse files Browse the repository at this point in the history
  • Loading branch information
Greenek committed Mar 9, 2016
1 parent f29b029 commit ee9d3bc
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 54 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/Polymain.iconset
/Polymail.icns
/Polymail.iconset
Binary file removed Icon1024.png
Binary file not shown.
40 changes: 40 additions & 0 deletions Icon1024.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Icon64.png
Binary file not shown.
40 changes: 40 additions & 0 deletions Icon64.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
INKSCAPE=$(shell which inkscape)

define print_header
@echo
@echo "==> $(1)"
@echo
endef

define svg_to_png
@$(INKSCAPE) -z -e $(CURDIR)/$1/$(2).png -w $(3) -h $(3) $(CURDIR)/$(4) 1>/dev/null
@echo "convert $(4) to $(2).png"

endef

define convert
$(call svg_to_png,$(1),icon_$(2)x$(2),$(2),$(3))
$(call svg_to_png,$(1),icon_$(2)x$(2)@2x,$(shell echo $$(($2*2))),$(3))

endef

all: build install clean

Polymail.icns: Polymail.iconset
$(call print_header,"Create icon resource")
rm -f Polymail.icns
iconutil -c icns -o $@ $^

Polymail.iconset:
$(call print_header,"Convert svg to pngs")
mkdir -p $@
$(foreach size,16 32,$(call convert,$@,$(size),Icon64.svg))
$(foreach size,128 256 512,$(call convert,$@,$(size),Icon1024.svg))

build: clean Polymail.icns

clean:
rm -rf Polymail.iconset

install:
$(call print_header,"Install icns")
./install.sh Polymail.icns

.PHONY: all build clean install
Binary file added Polymail.icns
Binary file not shown.
26 changes: 0 additions & 26 deletions Polymail.svg

This file was deleted.

69 changes: 69 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash

# Exit on errors
set -o errexit
set -o nounset

# Constants
URL=https://raw.githubusercontent.com/Greenek/polymail.icns/master/Polymail.icns

# Check if operating system is supported
if [[ $OSTYPE != "darwin"* ]]; then
echo "This script requires OSX system to run."
exit 1
fi

# Check if Polymail.app is installed
: ${POLYMAIL_PATH:="/Applications/Polymail.app"}

if [ ! -d "$POLYMAIL_PATH" ]; then
echo "Polymail.app not found."
exit 1
fi

# Initialize temporary files paths
TMPICNS=$TMPDIR"Polymail.icns"
TMPRSRC=$TMPDIR"icon.rsrc"

if [ $# -eq 0 ]; then
# Download icon file if path has not been passed in argument
curl -L -o $TMPICNS $URL
else
cp -f $1 $TMPICNS
fi

# Add icon to image file
sips -i $TMPICNS >> /dev/null

# Take icon and put into a rsrc file
DeRez -only icns $TMPICNS > $TMPRSRC

# Apply the rsrc file
SetFile -a C $POLYMAIL_PATH

# Remove old resource
rm -f $POLYMAIL_PATH/Icon?

# Append icon resource
Rez $TMPRSRC -o $POLYMAIL_PATH/$'Icon\r'
SetFile -a V $POLYMAIL_PATH/Icon?

# Clean
rm $TMPRSRC $TMPICNS

# Success output
cat << EOF
New icon for Polymail.app has been successfully installed.
TO COMPLETE INSTALLATION:
1) Restart application
or
2) Clear system icon cache
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
sudo find /private/var/folders -name com.apple.iconservices -exec rm -rf {} \;
killall Dock
EOF
26 changes: 0 additions & 26 deletions make.sh

This file was deleted.

0 comments on commit ee9d3bc

Please sign in to comment.