Skip to content
This repository was archived by the owner on Mar 12, 2022. It is now read-only.

Commit 8e397f2

Browse files
committed
update build/doc process
1 parent eedc00c commit 8e397f2

File tree

4 files changed

+397
-17
lines changed

4 files changed

+397
-17
lines changed

Diff for: Makefile

+36-15
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@ current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
33

44
MODULE := $(current_dir)
55
PREFIX ?= ~/.hammerspoon
6+
MODPATH = hs/_asm/undocumented
67
VERSION ?= 0.x
78
HS_APPLICATION ?= /Applications
89

10+
# get from https://github.com/asmagill/hammerspoon-config/blob/master/utils/docmaker.lua
11+
# if you want to generate a readme file similar to the ones I generally use. Adjust the copyright in the file and adjust
12+
# this variable to match where you save docmaker.lua relative to your hammerspoon configuration directory
13+
# (usually ~/.hammerspoon)
14+
MARKDOWNMAKER = utils/docmaker.lua
15+
916
OBJCFILE = ${wildcard *.m}
1017
LUAFILE = ${wildcard *.lua}
1118
HEADERS = ${wildcard *.h}
1219

20+
# swap if all objective-c files should be compiled into one target -- this is necessary if you organize your code in
21+
# multiple files but need them to access functions/objects defined in different files -- each dynamic library is loaded
22+
# individually by Hammerspoon so they can't see the exports of each other directly.
1323
SOFILE := $(OBJCFILE:.m=.so)
1424
# SOFILE := internal.so
1525
DEBUG_CFLAGS ?= -g
@@ -36,40 +46,51 @@ all: verify $(SOFILE)
3646
release: clean all
3747
HS_APPLICATION=$(HS_APPLICATION) PREFIX=tmp make install ; cd tmp ; tar -cf ../$(MODULE)-v$(VERSION).tar hs ; cd .. ; gzip $(MODULE)-v$(VERSION).tar
3848

49+
releaseWithDocs: clean all docs
50+
HS_APPLICATION=$(HS_APPLICATION) PREFIX=tmp make install ; cd tmp ; tar -cf ../$(MODULE)-v$(VERSION).tar hs ; cd .. ; gzip $(MODULE)-v$(VERSION).tar
51+
52+
# swap if all objective-c files should be compiled into one target
3953
.m.so: $(HEADERS) $(OBJCFILE)
4054
$(CC) $< $(CFLAGS) $(LDFLAGS) -o $@
4155

4256
# internal.so: $(HEADERS) $(OBJCFILE)
4357
# $(CC) $(OBJCFILE) $(CFLAGS) $(LDFLAGS) -o $@
4458

4559
install: verify install-objc install-lua
60+
test -f docs.json && install -m 0644 docs.json $(PREFIX)/$(MODPATH)/$(MODULE) || echo "No docs.json file to install"
4661

4762
verify: $(LUAFILE)
4863
@if $$(hash lua-5.3 >& /dev/null); then (luac-5.3 -p $(LUAFILE) && echo "Lua Compile Verification Passed"); else echo "Skipping Lua Compile Verification"; fi
4964

5065
install-objc: $(SOFILE)
51-
mkdir -p $(PREFIX)/hs/_asm/undocumented/$(MODULE)
52-
install -m 0644 $(SOFILE) $(PREFIX)/hs/_asm/undocumented/$(MODULE)
53-
cp -vpR $(OBJCFILE:.m=.so.dSYM) $(PREFIX)/hs/_asm/undocumented/$(MODULE)
54-
# cp -vpR $(SOFILE:.so=.so.dSYM) $(PREFIX)/hs/_asm/undocumented/$(MODULE)
66+
mkdir -p $(PREFIX)/$(MODPATH)/$(MODULE)
67+
install -m 0644 $(SOFILE) $(PREFIX)/$(MODPATH)/$(MODULE)
68+
# swap if all objective-c files should be compiled into one target
69+
cp -vpR $(OBJCFILE:.m=.so.dSYM) $(PREFIX)/$(MODPATH)/$(MODULE)
70+
# cp -vpR $(SOFILE:.so=.so.dSYM) $(PREFIX)/$(MODPATH)/$(MODULE)
5571

5672
install-lua: $(LUAFILE)
57-
mkdir -p $(PREFIX)/hs/_asm/undocumented/$(MODULE)
58-
install -m 0644 $(LUAFILE) $(PREFIX)/hs/_asm/undocumented/$(MODULE)
73+
mkdir -p $(PREFIX)/$(MODPATH)/$(MODULE)
74+
install -m 0644 $(LUAFILE) $(PREFIX)/$(MODPATH)/$(MODULE)
75+
76+
docs:
77+
hs -c "require(\"hs.doc\").builder.genJSON(\"$(dir $(mkfile_path))\")" > docs.json
5978

6079
markdown:
61-
hs -c "dofile(\"utils/docmaker.lua\").genMarkdown([[$(dir $(mkfile_path))]])" > README.tmp.md
80+
hs -c "dofile(\"$(MARKDOWNMAKER)\").genMarkdown([[$(dir $(mkfile_path))]])" > README.tmp.md
6281

6382
markdownWithTOC:
64-
hs -c "dofile(\"utils/docmaker.lua\").genMarkdown([[$(dir $(mkfile_path))]], true)" > README.tmp.md
83+
hs -c "dofile(\"$(MARKDOWNMAKER)\").genMarkdown([[$(dir $(mkfile_path))]], true)" > README.tmp.md
6584

6685
clean:
67-
rm -rf $(SOFILE) *.dSYM tmp
86+
rm -rf $(SOFILE) *.dSYM tmp docs.json
6887

6988
uninstall:
70-
rm -v -f $(PREFIX)/hs/_asm/undocumented/$(MODULE)/{$(subst $(space),$(comma),$(ALLFILES))}
71-
(pushd $(PREFIX)/hs/_asm/undocumented/$(MODULE)/ ; rm -v -fr $(OBJCFILE:.m=.so.dSYM) ; popd)
72-
# (pushd $(PREFIX)/hs/_asm/undocumented/$(MODULE)/ ; rm -v -fr $(SOFILE:.so=.so.dSYM) ; popd)
73-
rmdir -p $(PREFIX)/hs/_asm/undocumented/$(MODULE) ; exit 0
74-
75-
.PHONY: all clean uninstall verify install install-objc install-lua
89+
rm -v -f $(PREFIX)/$(MODPATH)/$(MODULE)/{$(subst $(space),$(comma),$(ALLFILES))}
90+
# swap if all objective-c files should be compiled into one target
91+
(pushd $(PREFIX)/$(MODPATH)/$(MODULE)/ ; rm -v -fr $(OBJCFILE:.m=.so.dSYM) ; popd)
92+
# (pushd $(PREFIX)/$(MODPATH)/$(MODULE)/ ; rm -v -fr $(SOFILE:.so=.so.dSYM) ; popd)
93+
rm -v -f $(PREFIX)/$(MODPATH)/$(MODULE)/docs.json
94+
rmdir -p $(PREFIX)/$(MODPATH)/$(MODULE) ; exit 0
95+
96+
.PHONY: all clean uninstall verify install install-objc install-lua docs markdown markdownWithTOC

Diff for: Makefile.2

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
2+
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
3+
4+
MODULE := $(current_dir)
5+
PREFIX ?= ~/.hammerspoon
6+
VERSION ?= 0.x
7+
HS_APPLICATION ?= /Applications
8+
9+
OBJCFILE = ${wildcard *.m}
10+
LUAFILE = ${wildcard *.lua}
11+
HEADERS = ${wildcard *.h}
12+
13+
SOFILE := $(OBJCFILE:.m=.so)
14+
# SOFILE := internal.so
15+
DEBUG_CFLAGS ?= -g
16+
17+
# special vars for uninstall
18+
space :=
19+
space +=
20+
comma := ,
21+
ALLFILES := $(LUAFILE)
22+
ALLFILES += $(SOFILE)
23+
24+
.SUFFIXES: .m .so
25+
26+
#CC=cc
27+
CC=@clang
28+
WARNINGS ?= -Weverything -Wno-objc-missing-property-synthesis -Wno-implicit-atomic-properties -Wno-direct-ivar-access -Wno-cstring-format-directive -Wno-padded -Wno-covered-switch-default -Wno-missing-prototypes -Werror-implicit-function-declaration
29+
EXTRA_CFLAGS ?= -F$(HS_APPLICATION)/Hammerspoon.app/Contents/Frameworks -mmacosx-version-min=10.10
30+
31+
CFLAGS += $(DEBUG_CFLAGS) -fmodules -fobjc-arc -DHS_EXTERNAL_MODULE $(WARNINGS) $(EXTRA_CFLAGS)
32+
LDFLAGS += -dynamiclib -undefined dynamic_lookup $(EXTRA_LDFLAGS)
33+
34+
all: verify $(SOFILE)
35+
36+
release: clean all
37+
HS_APPLICATION=$(HS_APPLICATION) PREFIX=tmp make install ; cd tmp ; tar -cf ../$(MODULE)-v$(VERSION).tar hs ; cd .. ; gzip $(MODULE)-v$(VERSION).tar
38+
39+
.m.so: $(HEADERS) $(OBJCFILE)
40+
$(CC) $< $(CFLAGS) $(LDFLAGS) -o $@
41+
42+
# internal.so: $(HEADERS) $(OBJCFILE)
43+
# $(CC) $(OBJCFILE) $(CFLAGS) $(LDFLAGS) -o $@
44+
45+
install: verify install-objc install-lua
46+
47+
verify: $(LUAFILE)
48+
@if $$(hash lua-5.3 >& /dev/null); then (luac-5.3 -p $(LUAFILE) && echo "Lua Compile Verification Passed"); else echo "Skipping Lua Compile Verification"; fi
49+
50+
install-objc: $(SOFILE)
51+
mkdir -p $(PREFIX)/hs/_asm/undocumented/$(MODULE)
52+
install -m 0644 $(SOFILE) $(PREFIX)/hs/_asm/undocumented/$(MODULE)
53+
cp -vpR $(OBJCFILE:.m=.so.dSYM) $(PREFIX)/hs/_asm/undocumented/$(MODULE)
54+
# cp -vpR $(SOFILE:.so=.so.dSYM) $(PREFIX)/hs/_asm/undocumented/$(MODULE)
55+
56+
install-lua: $(LUAFILE)
57+
mkdir -p $(PREFIX)/hs/_asm/undocumented/$(MODULE)
58+
install -m 0644 $(LUAFILE) $(PREFIX)/hs/_asm/undocumented/$(MODULE)
59+
60+
markdown:
61+
hs -c "dofile(\"utils/docmaker.lua\").genMarkdown([[$(dir $(mkfile_path))]])" > README.tmp.md
62+
63+
markdownWithTOC:
64+
hs -c "dofile(\"utils/docmaker.lua\").genMarkdown([[$(dir $(mkfile_path))]], true)" > README.tmp.md
65+
66+
clean:
67+
rm -rf $(SOFILE) *.dSYM tmp
68+
69+
uninstall:
70+
rm -v -f $(PREFIX)/hs/_asm/undocumented/$(MODULE)/{$(subst $(space),$(comma),$(ALLFILES))}
71+
(pushd $(PREFIX)/hs/_asm/undocumented/$(MODULE)/ ; rm -v -fr $(OBJCFILE:.m=.so.dSYM) ; popd)
72+
# (pushd $(PREFIX)/hs/_asm/undocumented/$(MODULE)/ ; rm -v -fr $(SOFILE:.so=.so.dSYM) ; popd)
73+
rmdir -p $(PREFIX)/hs/_asm/undocumented/$(MODULE) ; exit 0
74+
75+
.PHONY: all clean uninstall verify install install-objc install-lua

0 commit comments

Comments
 (0)