rev: tip jasm/release.py -rw-r--r-- 2.9 KiB View raw Log this file
24ac64361fa3Jonas Hultén Workaround for swedish output from the hg command. a month ago
                                                                                
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
# This script packages a release of jAsm by building and compressing the relevant files.

import os
import shutil
import subprocess

def run(prog_and_args):
	"Run arguments and return the error code"

	process = subprocess.Popen(prog_and_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	out, err = process.communicate()
	error_code = process.returncode

	return error_code

def read_version():

	with open("jasm/version.h", "r") as f:
		version = f.readline()

	version = version.replace(",", ".").strip()
	return version

def build_mingw(version):
	print("MingW building")
	# remove build directory contents
	print("  cleaning")
	os.makedirs("build", exist_ok=True)
	shutil.rmtree("build")

	# make sure there is a build directory
	os.makedirs("build", exist_ok=True)
	old_dir = os.getcwd()

	try:
		os.chdir("build")

	    # generate cmake make file
		print("  generating")
		error_code = run(["cmake", "-DCMAKE_TOOLCHAIN_FILE=../win64_cross_compile_toolchain.txt", "-DCMAKE_BUILD_TYPE=Release",  ".."])
		if error_code != 0:
			raise Exception("Failed to build makefile")

		# make
		print("  compiling")
		error_code = run(["make", "-j4"])
		if error_code != 0:
			raise Exception("Failed to build executable")

		# create an archive and add the relevant files
		print("  compressing")
		os.makedirs("../jasm/website/site/binaries", exist_ok=True)
		os.chdir("jasm")
		error_code = run(["7z", "a", "../../jasm/website/site/binaries/jasm_%s_win64.7z" % version, "jasm.exe"])
		if error_code != 0:
			raise Exception("Failed to compress")
		os.chdir("..")
		error_code = run(["7z", "a", "../jasm/website/site/binaries/jasm_%s_win64.7z" % version, "/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libgcc_s_seh-1.dll", "/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++-6.dll"])
		if error_code != 0:
			raise Exception("Failed to compress")
	finally:
		os.chdir(old_dir)


def build_linux(version):
	print("Linux building")
	# remove build directory contents
	print("  cleaning")
	os.makedirs("build", exist_ok=True)
	shutil.rmtree("build")

	# make sure there is a build directory
	os.makedirs("build", exist_ok=True)
	old_dir = os.getcwd()

	try:
		os.chdir("build")

	    # generate cmake make file
		print("  generating")
		error_code = run(["cmake", "-DCMAKE_BUILD_TYPE=Release",  ".."])
		if error_code != 0:
			raise Exception("Failed to build makefile")

		# make
		print("  compiling")
		error_code = run(["make", "-j4"])
		if error_code != 0:
			raise Exception("Failed to build executable")

		# create an archive and add the relevant files
		print("  compressing")
		os.makedirs("../jasm/website/site/binaries", exist_ok=True)
		os.chdir("jasm")
		error_code = run(["7z", "a", "../../jasm/website/site/binaries/jasm_%s_linux64.7z" % version, "jasm"])
		if error_code != 0:
			raise Exception("Failed to compress")
	finally:
		os.chdir(old_dir)


version = read_version()
build_mingw(version)
build_linux(version)