forked from asmotor/asmotor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.justfile
151 lines (119 loc) · 4.27 KB
/
.justfile
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
# "just" scripts
initialized_marker := ".initialized"
version_file := join(invocation_directory(), "build/version")
version := `cat build/version`
package_base_name := ("asmotor-" + version)
source_name := (package_base_name + "-src.tar.gz")
binary_name := (package_base_name + "-bin-" + os() + ".tar.gz")
binary_windows_name := (package_base_name + "-bin-windows.zip")
source_pkg_dir := join("build", package_base_name)
initialized := path_exists(initialized_marker)
tar := if path_exists("/opt/local/bin/gnutar") == "true" { "/opt/local/bin/gnutar" } else { "tar" }
# Show all recipes
@default:
just --list
# Clean directory forcing a new build
@clean: _clean_src_dir
rm -rf build/cmake {{initialized_marker}} makedeb
# Initialize repository for use
@init toolchain="":
if ! {{initialized}}; then \
mkdir -p build/cmake/debug; \
cd build/cmake/debug; \
cmake -DCMAKE_TOOLCHAIN_FILE={{toolchain}} -DASMOTOR_VERSION={{version}}.next -DCMAKE_BUILD_TYPE=Debug ../../..; \
cd ../../..; \
touch {{initialized_marker}}; \
fi
# Build the project in Debug mode
@build: init
cmake --build build/cmake/debug
# Build and install the project in Release mode, defaulting to $HOME/.local
@install directory="$HOME/.local" sudo="" toolchain="":
rm -rf build/cmake/release
mkdir -p build/cmake/release
cd build/cmake/release; cmake -DCMAKE_TOOLCHAIN_FILE={{toolchain}} -DASMOTOR_VERSION={{version}} -DCMAKE_INSTALL_PREFIX={{directory}} -DCMAKE_BUILD_TYPE=Release ../../..; cd ../../..
cmake --build build/cmake/release -- -j
{{sudo}} cmake --install build/cmake/release
# Set the ASMotor version number to use when building
@set-version new_version:
echo -n {{new_version}} >{{version_file}}
rm -f {{initialized_marker}}
@binary: (install join(invocation_directory(), "_binary"))
cd _binary/bin; {{tar}} -cvzf "../../{{binary_name}}" *
rm -rf _binary
@binary_windows: (install join(invocation_directory(), "_binary_windows") "" "build/mingw64.cmake")
cd _binary_windows/bin; zip "../../{{binary_windows_name}}" *
rm -rf _binary
# Build source package
@source: _clean_src_dir (_copy_dir_to_src "util" "xasm/6502" "xasm/6809" "xasm/680x0" "xasm/motor" "xasm/dcpu-16" "xasm/mips" "xasm/rc8" "xasm/schip" "xasm/z80" "xlink" "xlib")
cp xasm/CMakeLists.txt {{source_pkg_dir}}/xasm
cp .justfile CMakeLists.txt CHANGELOG.md LICENSE.md README.md ucm.cmake *.sh *.ps1 {{source_pkg_dir}}
mkdir -p {{source_pkg_dir}}/build
cp -rf build/*.cmake build/version build/Modules {{source_pkg_dir}}/build
{{tar}} -C build -cvzf {{source_name}} {{package_base_name}}
rm -rf {{source_pkg_dir}}
# Tag, build and release a source package to github
@publish: source binary binary_windows deb
git tag -f {{version}} -m "Tagged {{version}}"
git push
git push --force --tags
gh release create "{{version}}" {{binary_name}} {{source_name}} *.deb -d -n "Version {{version}}" -p -t "Version {{version}}"
# Build a .deb distribution package
deb: source
#!/bin/sh
set -eu
rm -f *.deb
rm -rf _makedeb
mkdir -p _makedeb
cp {{source_name}} _makedeb
cat >_makedeb/PKGBUILD <<EOF
# Maintainer: Carsten Elton Sorensen <[email protected]>
pkgname=asmotor
pkgver={{version}}
pkgrel=1
pkgdesc="Cross assembler package for several CPUs"
arch=("{{arch()}}")
url="https://github.com/asmotor/asmotor"
license=("GPL-3")
makedepends=("cmake" "build-essential")
minimum_libc=2.14
depends=("libc6>=\${minimum_libc}")
source=("{{source_name}}")
md5sums=("SKIP")
prepare() {
echo "Checking if \"just\" installed"
command -v just >/dev/null
}
package() {
cd "\${pkgname}-\${pkgver}"
just install "\${pkgdir}/"
cd "\${pkgdir}/bin"
_used_libc=\$(ldd -v * 2>/dev/null | grep GLIBC | sed 's/.*GLIBC_//' | sed 's/).*//' | sort -t "." -k1,1n -k2,2n -k3,3n | tail -n 1)
if [ \${minimum_libc} != \${_used_libc} ]; then
echo "Compiled tools will require libc6>=\${_used_libc} which is not equal to \${minimum_libc}"
exit 1
fi
}
EOF
cd _makedeb
makedeb
mv *.deb ..
cd ..
rm -rf _makedeb
ls -1 *.deb
test: build
#!/bin/sh
cd test
for i in *; do
cd $i
./run.sh
cd ..
done
@_copy_dir_to_src +DIRS:
for dir in {{DIRS}}; do \
mkdir -p {{source_pkg_dir}}/$dir; \
cp $dir/*.[ch] $dir/CMake* {{source_pkg_dir}}/$dir; \
done
@_clean_src_dir:
rm -rf asmotor-*.tar.bz2 asmotor-*.tgz {{source_pkg_dir}}
mkdir {{source_pkg_dir}}