-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 292e067
Showing
523 changed files
with
89,062 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.conf text eol=lf | ||
*.tmpl text eol=lf | ||
*.json text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/bin | ||
/app | ||
/deb | ||
/exe | ||
*.syso | ||
*.gen.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2024 k2u2 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE | ||
OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Special Thx <3 | ||
- [f3lvx](https://github.com/f3lvx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/bin/bash | ||
set -eu | ||
export GO111MODULE=on | ||
|
||
APP_DIR=$(pwd)/app | ||
ICON_DIR=$(pwd)/icons | ||
|
||
SUFFIX="" | ||
MD_APP="CatPrMd.app" | ||
TMPL_APP="CatPrTmpl.app" | ||
|
||
if [[ $# -gt 1 ]]; then | ||
echo "Usage: $0 [<appname suffix>]" | ||
exit 1 | ||
fi | ||
|
||
if [[ $# -eq 1 ]]; then | ||
SUFFIX="$1" | ||
fi | ||
|
||
if [[ $# -gt 1 ]]; then | ||
echo "Usage: $0 [<appname suffix>]" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -z $SUFFIX ]]; then | ||
MD_APP="CatPrMd-${SUFFIX}.app" | ||
TMPL_APP="CatPrTmpl-${SUFFIX}.app" | ||
fi | ||
|
||
declare -a APP_LIST=( | ||
"cat_pr_md ${MD_APP} cat_pr_md.icns cat_pr_md_24x24.png" | ||
"cat_pr_tmpl ${TMPL_APP} cat_pr_tmpl.icns cat_pr_tmpl_24x24.png" | ||
) | ||
|
||
function build_app () { | ||
set -eu | ||
local cmd="$1" | ||
local app="$2" | ||
local bin_dir=${APP_DIR}/${app}/Contents/MacOS | ||
mkdir -p "${bin_dir}" | ||
echo "build ${cmd}" | ||
( | ||
cd "src/${cmd}" | ||
go build -o "${bin_dir}" | ||
) | ||
} | ||
|
||
function mk_app () { | ||
set -eu | ||
local CMD="$1" | ||
local APP="$2" | ||
local ICNS="$3" | ||
local PNG="$4" | ||
|
||
local APP_ID="com.github.1f408.cats_pr_dogs.${APP}" | ||
|
||
echo "build app: ${CMD} ${APP} ${ICNS}" | ||
test -d "${APP_DIR}/${APP}" && rm -r "${APP_DIR}/${APP}" | ||
mkdir -p "${APP_DIR}/${APP}"/Contents/{MacOS,Resources} | ||
cp ${ICON_DIR}/${ICNS} "${APP_DIR}/${APP}"/Contents/Resources/${CMD}.icns | ||
cp ${ICON_DIR}/${PNG} "${APP_DIR}/${APP}"/Contents/Resources/${CMD}.png | ||
|
||
build_app ${CMD} "${APP}" || { rm -fr "${APP_DIR}/${APP}"; return; } | ||
|
||
cat > "${APP_DIR}/${APP}"/Contents/Info.plist << EOF | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleName</key> | ||
<string>${APP}</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>${APP}</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>${APP_ID}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${CMD}</string> | ||
<key>CFBundleIconFile</key> | ||
<string>${ICNS}</string> | ||
</dict> | ||
</plist> | ||
EOF | ||
|
||
} | ||
|
||
echo "build: ${APP_DIR}" | ||
if [ -d "${APP_DIR}" ]; then | ||
rm -rf "${APP_DIR}" | ||
fi | ||
mkdir -p "${APP_DIR}" | ||
|
||
echo "go generate" | ||
./generate.sh | ||
|
||
for param in "${APP_LIST[@]}"; do | ||
mk_app ${param} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
#!/bin/bash | ||
set -eu | ||
export GO111MODULE=on | ||
|
||
SRC_DIR=$(pwd)/src | ||
DEB_DIR=$(pwd)/deb | ||
ICON_DIR=$(pwd)/icons | ||
|
||
SUFFIX="" | ||
|
||
if [[ $# -gt 1 ]]; then | ||
echo "Usage: $0 [<appname suffix>]" | ||
exit 1 | ||
fi | ||
|
||
if [[ $# -eq 1 ]]; then | ||
SUFFIX="$1" | ||
fi | ||
|
||
if [[ $# -gt 1 ]]; then | ||
echo "Usage: $0 [<appname suffix>]" | ||
exit 1 | ||
fi | ||
|
||
MD_APP="CatPrMd" | ||
TMPL_APP="CatPrTmpl" | ||
MD_CMD="cat_pr_md" | ||
TMPL_CMD="cat_pr_tmpl" | ||
MD_PKG="cat-pr-md" | ||
TMPL_PKG="cat-pr-tmpl" | ||
if [[ ! -z $SUFFIX ]]; then | ||
MD_APP="${MD_APP}-${SUFFIX}" | ||
TMPL_APP="${TMPL_APP}-${SUFFIX}" | ||
MD_CMD="${MD_CMD}-${SUFFIX}" | ||
TMPL_CMD="${TMPL_CMD}-${SUFFIX}" | ||
MD_PKG="${MD_PKG}-${SUFFIX}" | ||
TMPL_PKG="${TMPL_PKG}-${SUFFIX}" | ||
fi | ||
|
||
declare -a DEB_LIST=( | ||
"cat_pr_md ${MD_CMD} ${MD_PKG} ${MD_APP}" | ||
"cat_pr_tmpl ${TMPL_CMD} ${TMPL_PKG} ${TMPL_APP}" | ||
) | ||
|
||
for cmd in go desktop-file-validate dpkg-deb fakeroot; do | ||
type -P ${cmd} >/dev/null || { | ||
echo "${cmd} is not installed" | ||
exit 2 | ||
} | ||
done | ||
|
||
case $(uname -m) in | ||
"x86_64") | ||
ARCH=amd64;; | ||
"aarch64") | ||
ARCH=arm64;; | ||
*) | ||
echo "unknown machine architecture." | ||
exit 2 | ||
esac | ||
|
||
function build_cmd () { | ||
set -eu | ||
local srcname="$1" | ||
local cmd="$2" | ||
local dir="$3" | ||
|
||
local src="${SRC_DIR}/${srcname}" | ||
if [ ! -d "${dir}" ]; then | ||
return 1 | ||
fi | ||
echo "build cmd: ${dir}/${cmd}" | ||
( | ||
cd "${src}" | ||
go build -o "${dir}/${cmd}" | ||
) | ||
} | ||
|
||
function mk_deb () { | ||
set -eu | ||
local SRC="$1" | ||
local CMD="$2" | ||
local PKG="$3" | ||
local APP="$4" | ||
TMP_ROOT="${DEB_DIR}/${PKG}_1.0.0" | ||
|
||
echo "build deb: ${PKG} ${APP}" | ||
if [ -d "${TMP_ROOT}" ]; then | ||
rm -r "${TMP_ROOT}" | ||
fi | ||
mkdir -p ${TMP_ROOT}/usr/bin | ||
mkdir -p ${TMP_ROOT}/usr/share/applications | ||
mkdir -p ${TMP_ROOT}/DEBIAN | ||
build_cmd ${SRC} "${CMD}" ${TMP_ROOT}/usr/bin | ||
|
||
mkdir -p ${TMP_ROOT}/usr/share/icons/hicolor/scalable/apps | ||
cp ${ICON_DIR}/${SRC}.svg ${TMP_ROOT}/usr/share/icons/hicolor/scalable/apps/${PKG}.svg | ||
|
||
cat > ${TMP_ROOT}/usr/share/applications/${APP}.desktop << EOF | ||
[Desktop Entry] | ||
Version=1.0 | ||
Type=Application | ||
Name=${APP} | ||
Exec=${CMD} | ||
Icon=${PKG} | ||
Terminal=false | ||
StartupWMClass=${APP} | ||
EOF | ||
|
||
cat > ${TMP_ROOT}/DEBIAN/control << EOF | ||
Package: ${PKG} | ||
Version: 1.0-0 | ||
Section: base | ||
Priority: optional | ||
Architecture: ${ARCH} | ||
Maintainer: 1f408 GitHub Organization https://github.com/1f408 | ||
Description: ${APP} for previewing cats_dogs Markdown | ||
EOF | ||
|
||
fakeroot dpkg-deb --build ${TMP_ROOT} | ||
rm -rf ${TMP_ROOT} | ||
} | ||
|
||
echo "build: ${DEB_DIR}" | ||
if [ -d "${DEB_DIR}" ]; then | ||
rm -rf "${DEB_DIR}" | ||
fi | ||
mkdir -p "${DEB_DIR}" | ||
|
||
echo "go generate" | ||
./generate.sh | ||
|
||
for param in "${DEB_LIST[@]}"; do | ||
mk_deb ${param} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
set -eu | ||
export GO111MODULE=on | ||
export GOOS=${GOOS:-windows} | ||
export GOARCH=${GOARCH:-$(go env GOARCH)} | ||
|
||
EXE_DIR=$(pwd)/exe | ||
|
||
SUFFIX="" | ||
MD_CMD="cat_pr_md.exe" | ||
TMPL_CMD="cat_pr_tmpl.exe" | ||
|
||
|
||
if [[ $# -gt 1 ]]; then | ||
echo "Usage: $0 [<appname suffix>]" | ||
exit 1 | ||
fi | ||
|
||
if [[ $# -eq 1 ]]; then | ||
SUFFIX="$1" | ||
fi | ||
|
||
if [[ $# -gt 1 ]]; then | ||
echo "Usage: $0 [<appname suffix>]" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -z $SUFFIX ]]; then | ||
MD_CMD="cat_pr_md-${SUFFIX}.exe" | ||
TMPL_CMD="cat_pr_tmpl-${SUFFIX}.exe" | ||
fi | ||
|
||
declare -a CMD_LIST=( | ||
"cat_pr_md ${MD_CMD}" | ||
"cat_pr_tmpl ${TMPL_CMD}" | ||
) | ||
|
||
type -P go >/dev/null || { | ||
echo "go is not installed" | ||
exit 2 | ||
} | ||
|
||
type -P go-winres >/dev/null || { | ||
echo "go-winres is not installed" | ||
echo "install command: go install github.com/tc-hib/go-winres@latest" | ||
exit 2 | ||
} | ||
|
||
function build_exe () { | ||
set -eu | ||
local cmd="$1" | ||
local cmdname="$2" | ||
mkdir -p "${EXE_DIR}" | ||
echo "build exe: ${cmd}" | ||
( | ||
cd "src/${cmd}" | ||
go-winres make | ||
echo go build -o "${EXE_DIR}/${cmdname}" -ldflags="-H windowsgui" | ||
go build -o "${EXE_DIR}/${cmdname}" -ldflags="-H windowsgui" | ||
rm -f *.syso | ||
) | ||
} | ||
|
||
echo "build: ${EXE_DIR}" | ||
if [ -d "${EXE_DIR}" ]; then | ||
rm -rf "${EXE_DIR}" | ||
fi | ||
mkdir -p "${EXE_DIR}" | ||
|
||
echo "go generate" | ||
./generate.sh | ||
|
||
for param in "${CMD_LIST[@]}"; do | ||
build_exe ${param} | ||
done | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
set -eu | ||
export GO111MODULE=on | ||
OUT_DIR=$(pwd)/bin | ||
|
||
function build () { | ||
local cmd="$1" | ||
echo "build ${cmd}: " | ||
( | ||
cd "src/${cmd}" || exit 1 | ||
#go build -o "${OUT_DIR}" -ldflags '-s -w' || exit 2 | ||
go build -o "${OUT_DIR}" || exit 2 | ||
) | ||
} | ||
|
||
echo "build bin: ${OUT_DIR}" | ||
mkdir -p "${OUT_DIR}" | ||
|
||
echo "go generate" | ||
./generate.sh | ||
|
||
if [ $# -eq 0 ]; then | ||
ls -1 src | while read cmd ; do | ||
build "${cmd}" | ||
done | ||
else | ||
for cmd in "$@"; do | ||
build "${cmd}" | ||
done | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package conf | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
var BuildTime = time.UnixMicro({{.BuildMicroSeconds}}) |
Oops, something went wrong.