17from os.path
import join, exists, abspath, dirname
18sys.path.append(
join(dirname(__file__),
'..'))
20from shutil
import copyfile
24DART_DIR = abspath(
join(dirname(__file__),
'..',
'..'))
26GN_ARCH_TO_DEBIAN_ARCH = {
36 result = optparse.OptionParser()
37 result.add_option(
"--tar_filename",
39 help=
"The tar file to build from.")
40 result.add_option(
"--out_dir",
42 help=
"Where to put the packages.")
43 result.add_option(
"-a",
45 help=
'Target architectures (comma-separated).',
46 metavar=
'[all,ia32,x64,arm,arm64,riscv64]',
48 result.add_option(
"-t",
50 help=
'Cross-compilation toolchain prefix',
57 env = os.environ.copy()
59 env[
"TOOLCHAIN"] =
'--toolchain=' + toolchain
60 cmd = [
'dpkg-buildpackage',
'-j%d' % HOST_CPUS]
62 process = subprocess.check_call(cmd, cwd=cwd, env=env)
67 tarroot =
'dart-%s' % version
68 origtarname =
'dart_%s.orig.tar.gz' % version
70 if not exists(tarball):
71 print(
'Source tarball not found')
75 origtarball =
join(temp_dir, origtarname)
76 copyfile(tarball, origtarball)
78 with tarfile.open(origtarball)
as tar:
79 tar.extractall(path=temp_dir)
82 print(
"Building source package")
87 print(
"Building %s package" % arch)
89 [
'-B',
'-a', GN_ARCH_TO_DEBIAN_ARCH[arch],
'-us',
'-uc'],
90 join(temp_dir, tarroot))
93 debbase =
'dart_%s' % version
96 '%s.orig.tar.gz' % debbase,
97 '%s-1.debian.tar.xz' % debbase
99 for name
in source_package:
100 copyfile(
join(temp_dir, name),
join(out_dir, name))
102 name =
'%s-1_%s.deb' % (debbase, GN_ARCH_TO_DEBIAN_ARCH[arch])
103 copyfile(
join(temp_dir, name),
join(out_dir, name))
107 if HOST_OS !=
'linux':
108 print(
'Debian build only supported on linux')
112 out_dir = options.out_dir
113 tar_filename = options.tar_filename
114 if options.arch ==
'all':
115 options.arch =
'ia32,x64,arm,arm64,riscv64'
116 arch = options.arch.split(
',')
118 if not options.out_dir:
128if __name__ ==
'__main__':
def RunBuildPackage(opt, cwd, toolchain=None)
def BuildDebianPackage(tarball, out_dir, arches, toolchain)
def print(*args, **kwargs)
def GetVersion(no_git_hash=False, version_file=None, git_revision_file=None)
static SkString join(const CommandLineFlags::StringArray &)
static void parse_args(int argc, char *argv[], Args *args)