Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
shenmo7192 committed Dec 6, 2024
1 parent 821fed5 commit 61cd8cf
Show file tree
Hide file tree
Showing 1,017 changed files with 130,808 additions and 0 deletions.
48 changes: 48 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Build instructions

linglong use [cmake presets], you can build and install linglong by running:

```bash
cmake --workflow --preset release
sudo cmake --install build-release
```

For developing or debugging linglong:

```bash

# Use ccache and ninja if available.
# You might want add this to the rc file of your shell.
export CMAKE_CXX_COMPILER_LAUNCHER=="$(command -v ccache 2>/dev/null)"
if command -v ninja &>/dev/null; then
export CMAKE_GENERATOR="Ninja"
fi

# configure, build and test
cmake --workflow --preset debug

# configure only
cmake --preset debug

# build only
cmake --build --preset debug

# test only
ctest --preset debug
```

[cmake presets]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html

## Packaging

linglong use [CPM.cmake] to download dependencies not found locally.

For packager want to disable this feature:

```bash
export CPM_USE_LOCAL_PACKAGES=1
```

For further information, check README of [CPM.cmake].

[CPM.cmake]: https://github.com/cpm-cmake/CPM.cmake
42 changes: 42 additions & 0 deletions BUILD.zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 构建指南

玲珑使用 [cmake 预设],你可以通过运行以下命令来构建和安装玲珑:

```bash
cmake --workflow --preset release
sudo cmake --install build-release
```

如果你想开发或调试玲珑:

```bash
export CMAKE_CXX_COMPILIER_LAUNCHER="$(command -v ccache)"

# 配置,构建然后运行测试
cmake --workflow --preset debug

# 仅配置
cmake --preset debug

# 仅构建
cmake --build --preset debug

# 仅运行测试
ctest --preset debug
```

[cmake 预设]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html

## 打包

玲珑使用 [CPM.cmake] 来下载本地找不到的依赖项。

如果你想禁用这个功能:

```bash
export CPM_USE_LOCAL_PACKAGES=1
```

更多信息,请查看 [CPM.cmake] 的 README。

[CPM.cmake]: https://github.com/cpm-cmake/CPM.cmake
209 changes: 209 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: LGPL-3.0-or-later

cmake_minimum_required(VERSION 3.11.4)

project(
linglong
VERSION 1.6.1
DESCRIPTION "a container based application package manager for Linux desktop"
HOMEPAGE_URL "https://github.com/OpenAtom-Linyaps/linyaps"
LANGUAGES CXX)

set(LINGLONG_VERSION
""
CACHE STRING "The version of linglong project.")

if(NOT ("${LINGLONG_VERSION}" STREQUAL ""))
message(STATUS "Project version has been overridden to ${LINGLONG_VERSION}")
set(PROJECT_VERSION ${LINGLONG_VERSION})
endif()

set(ENABLE_UAB
OFF
CACHE BOOL "enable building UAB")
set(ENABLE_LINGLONG_INSTALLER
OFF
CACHE BOOL "enable linglong installer")

set(LINGLONG_USERNAME
"deepin-linglong"
CACHE STRING "The username for linglong package manager")
set(LINGLONG_ROOT
"/var/lib/linglong"
CACHE STRING "The location where linglong related program puts their data")
set(LINGLONG_HOST_PATH
"/run/host"
CACHE STRING "The location where linglong host path mapping")
set(LINGLONG_DEFAULT_OCI_RUNTIME
"ll-box"
CACHE STRING "The oci runtime which linglong use by default")

set(LINGLONG_CLI_BIN
"ll-cli"
CACHE STRING "The client of package management.")
set(GETTEXT_DOMAIN_NAME
"linyaps"
CACHE STRING "The name of gettext domain.")
set(QT_VERSION_MAJOR
5
CACHE STRING "The major version of qt.")

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(PFL)

if(${QT_VERSION_MAJOR} EQUAL 6)
include(Qt6DBusMacro)
endif()

set(ENABLE_CPM YES)

if(CMAKE_VERSION VERSION_LESS "3.14")
set(ENABLE_CPM NO)
message(
STATUS "cmake version ${CMAKE_VERSION} not compatible with CPM.cmake.")
endif()

if(CPM_LOCAL_PACKAGES_ONLY)
set(ENABLE_CPM NO)
endif()

if(ENABLE_CPM)
include(CPM)
CPMFindPackage(
NAME tl-expected
VERSION 1.0.0 # NOTE: Upstream cmake version doesn't match git tag, we need
# https://github.com/TartanLlama/expected/pull/62 in v1.1.0,
# but cmake version of v1.1.0 is 1.0.0.
GITHUB_REPOSITORY TartanLlama/expected
GIT_TAG v1.1.0
GIT_SHALLOW ON
OPTIONS "EXPECTED_BUILD_TESTS OFF"
EXCLUDE_FROM_ALL ON)
CPMFindPackage(
NAME yaml-cpp
VERSION 0.6.2
GITHUB_REPOSITORY jbeder/yaml-cpp
GIT_TAG 0.8.0 # NOTE: When use this project with CPM.cmake(FetchContent), we
# need https://github.com/jbeder/yaml-cpp/pull/583 in v0.8.0
EXCLUDE_FROM_ALL ON
OPTIONS "YAML_CPP_INSTALL ON" "YAML_CPP_BUILD_TESTS OFF")
CPMFindPackage(
NAME nlohmann_json
VERSION 3.5.0
URL "https://github.com/nlohmann/json/archive/refs/tags/v3.5.0.tar.gz"
EXCLUDE_FROM_ALL ON
OPTIONS "JSON_BuildTests OFF")
CPMFindPackage(
NAME CLI11
VERSION 2.4.1
GITHUB_REPOSITORY CLIUtils/CLI11
GIT_TAG v2.4.1
EXCLUDE_FROM_ALL ON
OPTIONS "CLI11_BUILD_TESTS OFF")
endif()

set(linglong_EXTERNALS "ytj ytj::ytj")

# NOTE: UOS v20 do not have tl-expected packaged.
find_package(tl-expected 1.0.0 QUIET)
if(NOT tl-expected_FOUND)
# list(APPEND linglong_EXTERNALS tl-expected) # tl-expected requires 3.14
add_library(tl-expected INTERFACE)
add_library(tl::expected ALIAS tl-expected)
target_include_directories(tl-expected
INTERFACE ./external/tl-expected/include)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake.external)
endif()

find_package(nlohmann_json 3.5.0 QUIET)
if(NOT nlohmann_json_FOUND)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake.fix)
find_package(nlohmann_json 3.5.0 REQUIRED)
endif()

# NOTE: UOS v20 do not have cli11 packaged.
find_package(CLI11 2.4.1 QUIET)
if(NOT CLI11_FOUND)
list(APPEND linglong_EXTERNALS "CLI11 CLI11::CLI11")
endif()

function(get_real_target_name output target)
get_target_property("${output}" "${target}" ALIASED_TARGET)
if("${output}" STREQUAL "")
set("${output}" "${target}")
endif()
set("${output}"
${${output}}
PARENT_SCOPE)
endfunction()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# NOTE(black_desk): Qt keywords conflict with glib.
add_definitions("-DQT_NO_KEYWORDS")

# NOTE(black_desk): Enable Qt logging with context.
add_definitions("-DQT_MESSAGELOGCONTEXT")

# We need to support both Qt5 and Qt6, and according to the Qt documentation, we
# should be using versioned targets and functions. These varible must be set
# before find_package()
# https://doc.qt.io/qt-6/cmake-qt5-and-qt6-compatibility.html#recommended-practices
set(QT_DEFAULT_MAJOR_VERSION ${QT_VERSION_MAJOR})
set(QT_NO_CREATE_VERSIONLESS_FUNCTIONS ON)
set(QT_NO_CREATE_VERSIONLESS_TARGETS ON)

find_package(
Qt${QT_VERSION_MAJOR}
COMPONENTS Core DBus
REQUIRED)

find_package(PkgConfig REQUIRED)

pkg_search_module(glib2 REQUIRED IMPORTED_TARGET glib-2.0)
pkg_search_module(ostree1 REQUIRED IMPORTED_TARGET ostree-1)
pkg_search_module(systemd REQUIRED IMPORTED_TARGET libsystemd)
pkg_search_module(ELF REQUIRED IMPORTED_TARGET libelf)

set(ytj_ENABLE_TESTING NO)
set(ytj_ENABLE_INSTALL NO)

pfl_init(AUTO)

add_subdirectory(external/http)
add_subdirectory(tools/qdbusxml2cpp)

include(GNUInstallDirs)

pfl_add_libraries(
LIBS
api
dbus-api
utils
ocppi
linglong
APPS
generators/00-id-mapping
generators/05-initialize
generators/20-devices
generators/25-host-env
generators/30-user-home
generators/40-host-ipc
generators/90-legacy
ll-box
ll-builder
ll-cli
ll-package-manager
llpkg
uab
ll-session-helper)

add_subdirectory(misc)
add_subdirectory(po)
Loading

0 comments on commit 61cd8cf

Please sign in to comment.