-
Notifications
You must be signed in to change notification settings - Fork 1
/
conanfile.py
110 lines (93 loc) · 4.65 KB
/
conanfile.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
from shutil import copyfile
import os
import struct
class AppImageServices(ConanFile):
name = "AppImageServices"
version = "0.1"
settings = "os", "compiler", "build_type", "arch"
requires = (("zlib/1.2.11@conan/stable"),
("OpenSSL/1.1.1b@conan/stable"),
("harfbuzz/2.4.0@appimage-conan-community/stable"),
("glib/2.40.0@appimage-conan-community/stable"),
("libpng/1.6.36@bincrafters/stable"),
("cairo/1.17.2@appimage-conan-community/stable"),
("librsvg/2.40.20@appimage-conan-community/stable"),
("qt/5.12.3@appimage-conan-community/stable"),
("xdg-utils-cxx/0.1.1@appimage-conan-community/stable"),
("freetype/2.9.1@appimage-conan-community/stable"),
("libappimage/1.0.2@appimage-conan-community/stable"),
("AppImageUpdaterBridge/1.1.2@appimage-conan-community/stable"),
("squashfuse/0.1.103@appimage-conan-community/stable"),
("gtest/1.8.1@bincrafters/stable"))
options = {"enable_tests": [True, False]}
default_options = {
"AppImageUpdaterBridge:shared": True,
"qt:shared": True,
"libappimage:shared": True,
"squashfuse:shared": False,
"libarchive:shared": False,
"xdg-utils-cxx:shared": False,
"xdg-utils-cxx:fPIC": True,
"cairo:shared": True,
"lzma:shared": True,
"pango:shared": True,
"librsvg:shared": True,
"fontconfig:shared": True,
"freetype:shared": False,
"glib:shared": True,
"enable_tests": False
}
build_requires = ("patchelf_installer/0.9@appimage-conan-community/stable",
"gtest/1.8.1@bincrafters/stable",
"glib/2.40.0@appimage-conan-community/stable",
"cmake_installer/3.14.3@conan/stable",
"linuxdeploy/continuous@appimage-conan-community/stable",
"linuxdeploy-plugin-qt/continuous@appimage-conan-community/stable",
"linuxdeploy-plugin-appimage/continuous@appimage-conan-community/stable")
generators = "cmake", "cmake_paths", "pkg_config"
def import_pkg_config_files(self, pkg, pkgconfig_path):
for root, dirs, files in os.walk(self.deps_cpp_info[pkg].rootpath):
for file in files:
if file.endswith("pc"):
source_path = os.path.join(root, file)
target_path = os.path.join(pkgconfig_path, file)
print("Importing pkg_config file: %s" % target_path)
copyfile(source_path, target_path)
tools.replace_prefix_in_pc_file(target_path, self.deps_cpp_info[pkg].rootpath)
def build(self):
appDirPath = self.build_folder + "/AppDir"
for lib in self.deps_cpp_info.deps:
self.import_pkg_config_files(lib, self.build_folder)
with tools.environment_append({'PKG_CONFIG_PATH': self.build_folder}):
cmake = CMake(self)
cmake.definitions["CMAKE_PROJECT_AppImageServices_INCLUDE"] = self.build_folder + "/conan_paths.cmake"
# Correct conan default installation paths
cmake.definitions["CMAKE_INSTALL_PREFIX"] = appDirPath
cmake.definitions["CMAKE_INSTALL_BINDIR"] = "usr/bin"
cmake.definitions["CMAKE_INSTALL_LIBDIR"] = "usr/lib"
cmake.definitions["CMAKE_INSTALL_INCLUDEDIR"] = "usr/include"
cmake.definitions["CMAKE_INSTALL_DATAROOTDIR"] = "usr/share"
cmake.definitions["CMAKE_INSTALL_SYSCONFDIR"] = "etc"
cmake.definitions["ENABLE_TESTING"] = self.options["enable_tests"]
cmake.configure()
cmake.build()
cmake.install()
self.run("linuxdeploy --appdir=%s --plugin qt --output appimage" % appDirPath, run_environment=True)
print('Removing AppImage magic bites to avoid being intercepted by the launchers')
appImagePath = self.findCreatedAppImage()
self.removeAppImageMagicBits(appImagePath)
def findCreatedAppImage(self):
appImagePath = ""
for root, dirs, files in os.walk("."):
for filename in files:
if 'appimage-services' in filename and filename.endswith("AppImage"):
appImagePath = filename
return appImagePath
def removeAppImageMagicBits(self, appImagePath):
fout = open(appImagePath, 'r+b')
fout.seek(8)
fout.write(struct.pack('<BBB', 0, 0, 0))
fout.close()