Update with more iOS details.
[pwl6.git] / rules / nwjs.mk
1 # This is free and unencumbered software released into the public
2 # domain. To the extent possible under law, the author of this file
3 # waives all copyright and related or neighboring rights to it.
4
5 $(call include-once.,programs.mk)
6
7 nwjs-platforms := \
8 osx-x64.zip osx-ia32.zip \
9 linux-x64.tar.gz linux-ia32.tar.gz \
10 win-ia32.zip
11
12 nwjs-pattern := $(addprefix nwjs-v%-,$(nwjs-platforms))
13
14 # These are like 30MB, don't download them every time.
15 .PRECIOUS: $(nwjs-pattern)
16
17 $(nwjs-pattern):
18 $(MKDIR) '$(@D)'
19 # HTTP-only - https://github.com/nwjs/nw.js/issues/3393
20 wget -O '$@'.inprogress 'http://dl.nwjs.io/v$(*F)/$(@F)'
21 mv '$@'.inprogress "$@"
22
23 nwjs-version ?= 0.12.0
24 nwjsdir ?= nwjs/
25 nwjs-directx = $(addprefix $(nwjsdir),d3dcompiler_43.dll d3dcompiler_46.dll)
26
27 nwjs = $(nwjsdir)nwjs-v$(firstword $(value nwjs-version-$1) $(nwjs-version))-$1
28
29 nwjs-archives = $(foreach p,$(nwjs-platforms),$(call nwjs,$(p)))
30
31 define nwjs-package-osx
32 $(RM) $@
33 $(RM) -r $(@:.zip=)
34 $(UNZIP) -d $(@D) $2
35 mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=)
36 tools/generate-osx-app $(@:.zip=) $1
37 $(RM) $(@:.zip=)/nwjc
38 mv $(@:.zip=)/credits.html $(@:.zip=)/nwjs\ credits.html
39 cd $(@D) && $(ZIP) -r $(@F) $(@F:.zip=)
40 $(RM) -r $(@:.zip=)
41 endef
42
43 %-osx-ia32.zip: %.nw $(call nwjs,osx-ia32.zip)
44 $(call nwjs-package-osx,$<,$(word 2,$^))
45
46 %-osx-x64.zip: %.nw $(call nwjs,osx-x64.zip)
47 $(call nwjs-package-osx,$<,$(word 2,$^))
48
49 define nwjs-package-linux
50 $(RM) $@
51 $(RM) -r $(@:.tar.gz=)
52 tar -C $(@D) -xzf $2
53 $(MKDIR) $(@:.tar.gz=)
54 mv $(@D)/$(notdir $(2:.tar.gz=)) $(@:.tar.gz=)/nw
55 cp -a $1 $(@:.tar.gz=)/nw/package.nw
56 cp -a tools/nw-linux-wrapper $(@:.tar.gz=)/`echo $(notdir $1) | sed -E 's/_.+//'`
57 $(RM) $(@:.tar.gz=)/nw/nwjc
58 mv $(@:.tar.gz=)/nw/credits.html $(@:.tar.gz=)/nw/nwjs\ credits.html
59 tar -czf $@ -C $(@D) $(@F:.tar.gz=)
60 $(RM) -r $(@:.tar.gz=)
61 endef
62
63 %-linux-ia32.tar.gz: %.nw $(call nwjs,linux-ia32.tar.gz)
64 $(call nwjs-package-linux,$<,$(word 2,$^))
65
66 %-linux-x64.tar.gz: %.nw $(call nwjs,linux-x64.tar.gz)
67 $(call nwjs-package-linux,$<,$(word 2,$^))
68
69 nwjs-icon = $(shell $(UNZIP) -p $1 package.json | grep -Eo '"[^"]+.ico"' -m 1)
70
71 define nwjs-package-win
72 $(RM) $@
73 $(RM) -r $(@:.zip=)
74 $(UNZIP) -d $(@D) $2
75 mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=)
76 $(RM) $(@:.zip=)/nwjc.exe
77 $(UNZIP) -p $< $(call nwjs-icon,$<) > $(@D)/icon.ico
78 $(WINE) tools/rcedit.exe $(@:.zip=)/nw.exe --set-icon $(@D)/icon.ico
79 $(RM) $(@D)/icon.ico
80 mv $(@:.zip=)/credits.html $(@:.zip=)/nwjs\ credits.html
81 cp -a $< $(@:.zip=)/package.nw
82 cp -a $(nwjs-directx) $(@:.zip=)
83 mv $(@:.zip=)/nw.exe $(@:.zip=)/`echo $(notdir $1) | sed -E 's/_.+/.exe/'`
84 cd $(@D) && $(ZIP) -r $(@F) $(@F:.zip=)
85 $(RM) -r $(@:.zip=)
86 endef
87
88 %-win-ia32.zip: %.nw $(call nwjs,win-ia32.zip) $(nwjs-directx)
89 $(call nwjs-package-win,$<,$(word 2,$^))
90
91 $(nwjs-directx):
92 wget -O $@ 'https://github.com/cefsharp/cef-binary/raw/1e51255cf77d267899bf7834768b8774affaad2d/cef_binary_3.y.z_windows32/Release/'$(notdir $@)
93
94 $(nwjsdir)dxwebsetup.exe:
95 wget -O $@ https://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe
96
97 distclean::
98 $(RM) $(nwjs-archives)
99 $(RM) $(nwjs-directx)
100 $(RM) $(nwjsdir)dxwebsetup.exe