Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
207 lines (201 loc) · 9.86 KB
/
Copy pathMakefile
File metadata and controls
207 lines (201 loc) · 9.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!make
.DEFAULT_GOAL := clean install build
# --- OS Environment Setup --- #
ifeq ($(OS),Windows_NT)
export PATH:=$(PATH);$(GOPATH)\bin;C:\Program Files\Go\bin;C:\Windows\System32;C:\Program Files\nodejs;C:\WINDOWS\System32\WindowsPowerShell\v1.0;
SHELL := powershell.exe
.SHELLFLAGS := -NoProfile -Command
VERSION := $(shell powershell -ExecutionPolicy Bypass -File resources\windows\get_version.ps1)
DETECTED_OS=Windows_NT
HELPER=src\core\host\bin\helper\win\YourPlaceHelper.exe
PACKAGER=resources\windows\windows_packager.ps1
NPM=npm.cmd
NPX=npx.cmd
export GOTMPDIR=C:\Users\$(USERNAME)\AppData\Local\Temp\go-yourplace-build
else
DETECTED_OS=$(shell uname -s)
GO=$(shell which go)
NODE=$(shell which node)
NPM=$(shell which npm)
NPX="$(shell which npx)"
endif
# --- Update Commands --- #
npm_update:
npm install -g npm-check-updates
ncu -u
npm install
go_update:
go get -u ./...
# --- Setup Commands --- #
clean:
ifeq ($(DETECTED_OS),Windows_NT)
-powershell -Command "Get-Process -Name 'YourPlace' -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue | Out-Null"
-powershell -Command "Get-Process -Name 'YourPlace-$(VERSION)' -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue | Out-Null"
-powershell -Command "Get-Process -Name 'YourPlaceHelper' -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue | Out-Null"
-powershell -Command "Get-Process -Name 'YourPlaceIpfs' -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue | Out-Null"
-powershell -Command "Get-Process -Name 'YourPlaceFfmpeg' -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue | Out-Null"
-powershell -Command "if (Test-Path 'target') { Remove-Item -Recurse -Force 'target' | Out-Null }"
-powershell -Command "if (Test-Path '$(HELPER)') { Remove-Item -Force '$(HELPER)' | Out-Null }"
-powershell -Command "if (Test-Path 'src\core\host\bin\helper\win\helper.version') { Remove-Item -Force 'src\core\host\bin\helper\win\helper.version' | Out-Null }"
-powershell -Command "if (Test-Path 'rsrc_windows_amd64.syso') { Remove-Item -Force 'rsrc_windows_amd64.syso' | Out-Null }"
go clean
else ifeq ($(DETECTED_OS),Darwin)
-pkill -f YourPlace 2>/dev/null || true
-pkill -f YourPlaceHelper 2>/dev/null || true
-pkill -f YourPlaceIpfs 2>/dev/null || true
-pkill -f YourPlaceFfmpeg 2>/dev/null || true
rm -rf target 2>/dev/null || true
rm -rf src/core/host/bin/helper/osx/* 2>/dev/null || true
go clean
else
-pkill -f YourPlace 2>/dev/null || true
rm -rf target 2>/dev/null || true
go clean
endif
install:
$(NPM) install --force
test:
$(which golangci-lint) run --enable-all
go test
# --- Build Commands --- #
build: clean
ifeq ($(DETECTED_OS),Windows_NT)
powershell -Command "if (-not (Test-Path 'target')) { New-Item -ItemType Directory -Path 'target' }"
powershell -Command "if (-not (Test-Path 'src\core\host\bin\helper\win')) { New-Item -ItemType Directory -Path 'src\core\host\bin\helper\win' -Force }"
powershell -Command "if (-not (Test-Path '$(GOTMPDIR)')) { New-Item -ItemType Directory -Path '$(GOTMPDIR)' -Force }"
powershell -Command "New-Item -ItemType File -Path 'src\core\host\bin\helper\win\YourPlaceHelper.exe' -Force"
powershell -ExecutionPolicy Bypass -File resources\windows\helper_build_setup.ps1
go build -ldflags "-H=windowsgui -s -w" -o target\YourPlaceHelper.exe helper\helper_win.go
powershell -Command "Copy-Item -Path 'target\YourPlaceHelper.exe' -Destination 'src\core\host\bin\helper\win\YourPlaceHelper.exe' -Force"
$(NPX) webpack --config "src\typescript\webpack.prod.js"
go build -ldflags "-H=windowsgui -s -w" -o target\YourPlace.exe .
resources\windows\upx.exe -f -o target\YourPlace-$(VERSION).exe target\YourPlace.exe
else ifeq ($(DETECTED_OS),Darwin)
$(NPX) webpack --config src/typescript/webpack.prod.js
mkdir -p src/core/host/bin/helper/osx/
go generate
touch src/core/host/bin/helper/osx/YourPlaceHelper
VERSION=$(shell grep 'version.*=.*"' helper/helper_osx.go | cut -d'"' -f2)
@echo $(VERSION) > src/core/host/bin/helper/osx/helper.version
go build -o target/YourPlaceHelper helper/helper_osx.go
cp -rf target/YourPlaceHelper src/core/host/bin/helper/osx/YourPlaceHelper
go build -o target/YourPlace .
chmod +x resources/osx/askpass.sh
chmod +x resources/osx/osx_packager.sh
./resources/osx/osx_packager.sh
else
mkdir -p target
$(NPX) webpack --config src/typescript/webpack.prod.js
@VERSION=$$(grep -oE '^\s*version\s*=\s*"[^"]*"' main.go | grep -oE '"[^"]*"' | tr -d '"') && \
CGO_ENABLED=1 go build -ldflags "-s -w" -o target/YourPlace-$$VERSION .
endif
gateway_build: clean
mkdir -p target
$(NPX) webpack --config src/typescript/webpack.prod.js
@VERSION=$$(grep -oE '^\s*version\s*=\s*"[^"]*"' main.go | grep -oE '"[^"]*"' | tr -d '"') && \
CGO_ENABLED=0 go build -tags gateway -ldflags "-s -w" -o target/YourPlace-$$VERSION .
dbg_build: clean
ifeq ($(DETECTED_OS),Windows_NT)
powershell -Command "if (-not (Test-Path 'target')) { New-Item -ItemType Directory -Path 'target' }"
powershell -Command "if (-not (Test-Path 'src\core\host\bin\helper\win')) { New-Item -ItemType Directory -Path 'src\core\host\bin\helper\win' -Force }"
powershell -Command "if (-not (Test-Path '$(GOTMPDIR)')) { New-Item -ItemType Directory -Path '$(GOTMPDIR)' -Force }"
powershell -Command "New-Item -ItemType File -Path 'src\core\host\bin\helper\win\YourPlaceHelper.exe' -Force"
powershell -ExecutionPolicy Bypass -File resources\windows\helper_build_setup.ps1
go build -ldflags "-s -w" -o target\YourPlaceHelper.exe helper\helper_win.go
powershell -Command "Copy-Item -Path 'target\YourPlaceHelper.exe' -Destination 'src\core\host\bin\helper\win\YourPlaceHelper.exe' -Force"
$(NPX) webpack --config "src\typescript\webpack.dev.js"
go build -ldflags "-s -w" -o target\YourPlace-$(VERSION).exe .
else ifeq ($(DETECTED_OS),Darwin)
$(NPX) webpack --config src/typescript/webpack.dev.js
mkdir -p src/core/host/bin/helper/osx/
go generate
touch src/core/host/bin/helper/osx/YourPlaceHelper
VERSION=$(shell grep 'version.*=.*"' helper/helper_osx.go | cut -d'"' -f2)
@echo $(VERSION) > src/core/host/bin/helper/osx/helper.version
go build -o target/YourPlaceHelper helper/helper_osx.go
cp -rf target/YourPlaceHelper src/core/host/bin/helper/osx/YourPlaceHelper
go build -o target/YourPlace .
chmod +x resources/osx/askpass.sh
chmod +x resources/osx/osx_packager.sh
./resources/osx/osx_packager.sh dev
endif
helper_build:
ifeq ($(DETECTED_OS),Windows_NT)
$(PS) -Command "if (!(Test-Path '$(HELPER)')) { New-Item -ItemType File -Path '$(HELPER)' -Force | Out-Null }"
$(GO) generate
type nul > "src\core\host\bin\helper\win\YourPlaceHelper.exe"
$(GO) build -ldflags '-s -w' -o target\YourPlaceHelper.exe helper\helper_win.go
copy /B /Y /V target\YourPlaceHelper.exe src\core\host\bin\helper\win\YourPlaceHelper.exe
else ifeq ($(DETECTED_OS),Darwin)
cp -rf helper/helper_osx.version src/core/host/bin/helper/osx/helper_osx.version
go generate
go build -o target/YourPlaceHelper helper/helper_osx.go
cp -rf target/YourPlaceHelper src/core/host/bin/helper/osx/YourPlaceHelper
endif
# --- Run Commands --- #
run:
ifeq ($(DETECTED_OS),Windows_NT)
target\\YourPlace-$(VERSION).exe
else ifeq ($(DETECTED_OS),Darwin)
rm -rf ~/YourPlace/debug # Ensure debug file is removed
@VERSION=$$(grep 'version.*=.*".*"' main.go | sed -E 's/.*version.*=.*"(.*)".*/\1/') && \
./target/YourPlace-$(VERSION)
endif
dbg_run:
ifeq ($(DETECTED_OS),Windows_NT)
target\\YourPlace-$(VERSION).exe -d -du
else ifeq ($(DETECTED_OS),Darwin)
mkdir -p ~/YourPlace && touch ~/YourPlace/debug # Add debug file flag
@VERSION=$$(grep 'version.*=.*".*"' main.go | sed -E 's/.*version.*=.*"(.*)".*/\1/') && \
SUDO_ASKPASS=resources/osx/askpass.sh sudo -A installer -pkg "target/YourPlace-$$VERSION.pkg" -target /
endif
dbg_gateway_run:
ifeq ($(DETECTED_OS),Windows_NT)
target\\YourPlace-$(VERSION).exe -d -du -g
else ifeq ($(DETECTED_OS),Darwin)
mkdir -p ~/YourPlace && touch ~/YourPlace/debug # Add debug file flag
@VERSION=$$(grep 'version.*=.*".*"' main.go | sed -E 's/.*version.*=.*"(.*)".*/\1/') && \
SUDO_ASKPASS=resources/osx/askpass.sh sudo -A installer -pkg "target/YourPlace-$$VERSION.pkg" -target /
endif
dbg_noindexer_run:
ifeq ($(DETECTED_OS),Windows_NT)
target\\YourPlace-$(VERSION).exe -d -du -di
else ifeq ($(DETECTED_OS),Darwin)
mkdir -p ~/YourPlace && touch ~/YourPlace/debug && touch ~/YourPlace/noindexer # Add debug file flag
@VERSION=$$(grep 'version.*=.*".*"' main.go | sed -E 's/.*version.*=.*"(.*)".*/\1/') && \
SUDO_ASKPASS=resources/osx/askpass.sh installer -pkg "target/YourPlace-$$VERSION.pkg" -target /
endif
dbg_noinstall_run:
ifeq ($(DETECTED_OS),Windows_NT)
target\\YourPlace-$(VERSION).exe -d -du
else ifeq ($(DETECTED_OS),Darwin)
@VERSION=$$(grep 'version.*=.*".*"' main.go | sed -E 's/.*version.*=.*"(.*)".*/\1/') && \
./target/YourPlace -d -du
endif
gateway_run:
@VERSION=$$(grep -oE '^\s*version\s*=\s*"[^"]*"' main.go | grep -oE '"[^"]*"' | tr -d '"') && \
./target/YourPlace-$$VERSION -g -d -du
dbg_gateway_noinstall_run:
ifeq ($(DETECTED_OS),Windows_NT)
target\\YourPlace-$(VERSION).exe -du -d -g
else ifeq ($(DETECTED_OS),Darwin)
@VERSION=$$(grep 'version.*=.*".*"' main.go | sed -E 's/.*version.*=.*"(.*)".*/\1/') && \
./target/YourPlace -du -d -g
endif
testing:
go run test.go
# --- Snapshot Service Commands --- #
snapshot_docker_build:
docker build --progress=plain --no-cache -f snapshot/Dockerfile -t yourplace-snapshot .
snapshot_build:
mkdir -p target/
GOOS=linux GOARCH=amd64 go build -tags gateway -ldflags "-s -w" -o target/YourPlaceSnapshot snapshot/snapshot.go
snapshot_run:
./target/YourPlaceSnapshot
snapshot_dbg_build:
mkdir -p target/
mkdir -p src/core/host/bin/helper/osx/
@if [ ! -f src/core/host/bin/helper/osx/helper.version ]; then echo "1.0.0" > src/core/host/bin/helper/osx/helper.version; fi
go build -o target/YourPlaceSnapshot snapshot/snapshot.go
snapshot_dbg_run:
./target/YourPlaceSnapshot -d