Skip to content

Port to meson #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ColumnLimit: '0'
CompactNamespaces: 'false'
Language: Cpp
PointerAlignment: Left
SortIncludes: 'false'
SortIncludes: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeInheritanceColon: 'false'
SpaceBeforeParens: ControlStatements
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: Build

on: [push, pull_request]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
BUILD_TYPE: release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

steps:
Expand All @@ -25,16 +19,14 @@ jobs:
- name: "Install dependencies"
run: |
sudo apt -y update
sudo apt -y install libgtk-3-dev libalpm-dev libarchive-dev libcurl4-openssl-dev libgpgme-dev
sudo apt -y install meson libgtk-3-dev libalpm-dev libarchive-dev libcurl4-openssl-dev libgpgme-dev

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Configure
run: meson setup build -Dtracy_enable=false -Dbuildtype=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
run: meson compile -C build

- name: Set Build number
shell: bash
Expand All @@ -49,8 +41,10 @@ jobs:
run: |
mkdir artifacts
cp build/pepv artifacts/
cp pepv.ui artifacts/
cp pepv.png artifacts/
cp data/pepv.ui artifacts/
cp data/pepv.desktop artifacts/
cp data/icons/pepv.png artifacts/
cp data/icons/sizes/* artifacts/


- name: Upload artifacts
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.vscode
.idea

subprojects/*/
subprojects/*/**
compile_commands.json
build/
.cache
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

49 changes: 0 additions & 49 deletions CMakeLists.txt

This file was deleted.

37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,39 @@
* No installing packages
* No updating packages
* Only support for `core`, `extra` and `multilib` repositories
* Also supports viewing AUR/locally built packages

## Why?
* Because i want this program only to work as a viewer, everything regarding actually messing with your system should be in your own hands with you knowing what you are doing instead of me deciding what packages stay and go blindly

# Installing
* AUR: https://aur.archlinux.org/packages/pepv-git


# Building
## Requirements
* Meson (1.1 or higher)
* git
## Instructions
* git clone this repository
* Open a terminal in the directory of the repo and run the next commands
* `mkdir build && cd build`
* `cmake ..`
* `cmake --build . --config Release`
* pepv needs the files `pepv.ui` and `pepv.png` to be somewhere it can find them together, list of paths is in order
* `../pepv.ui` Only in debug build for debug purposes
* `pepv.ui`
* Open a terminal in the directory of the repo and run the next commands for a release build
* `meson setup build -Dtracy_enable=false -Dbuildtype=release`
* `meson compile -C build`
* `meson install -C build` To install locally using built binary, this also includes:
* Desktop entry
* Icons
* README.md in doc
* UI file
* pepv will also look for `pepv.ui` in other paths, list of paths is in order
* `../data/pepv.ui` Only in debug build for debug purposes
* `PREFIX "/" DATADIR "/pepv/pepv.ui"` (PREFIX and DATADIR may be set by meson options for packaging purposes)
* `/usr/share/pepv/pepv.ui`
* `/usr/local/share/pepv/pepv.ui`
* `/app/share/pepv/pepv.ui`
* `/app/share/runtime/share/pepv/pepv.ui`
* `/run/host/user-share/pepv/pepv.ui`
* `/run/host/share/pepv/pepv.ui`

* If you want you can also resize the logo to multiple resolutions and put the images in `usr/share/icons/hicolor/SIZExSIZE/apps/pepv.png` so GTK chooses the correct resolution automatically

# I dont know how to code but i want to use this program.
# I dont know how to code but i want to use this program in a distro that doesnt have AUR.
* Follow the instructions above, you dont need to understand them
* If you are scared of basic computer usage then you can wait for someone to package this program in your arch-based distro and i may add it in this readme

# Installing
* AUR: https://aur.archlinux.org/packages/pepv-git
* If you are scared of basic computer usage then you can wait for someone to package this program in your distro and i may add it in this README or you can just open a new issue to ask for help
File renamed without changes
Binary file added data/icons/sizes/pepv-1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-36.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/sizes/pepv-96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions data/pepv.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Version=1.0
Categories=System;
Name=pepv
Icon=pepv
Exec=pepv
Terminal=false
File renamed without changes.
1 change: 0 additions & 1 deletion external/tracy
Submodule tracy deleted from c55683
61 changes: 61 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
project(
'pepv',
'c',
'cpp',
default_options: ['c_std=c18', 'cpp_std=c++20'],
meson_version: '>=1.1',
)

# TODO: Add versioning

if get_option('buildtype') == 'debug'
add_project_arguments('-DDEBUG', language: 'cpp')
endif

threads = dependency('threads')
gtk = dependency('gtk+-3.0')
libalpm = dependency('libalpm')
tracy = dependency('tracy')

message('prefix: ' + get_option('prefix'))
message('datadir: ' + get_option('datadir'))
message('buildtype: ' + get_option('buildtype'))

if get_option('tracy_enable') and get_option('buildtype') != 'debugoptimized'
warning('Profiling builds should set -- buildtype = debugoptimized')
endif

install_data('data/pepv.ui')

install_data(
'data/pepv.desktop',
install_dir: get_option('prefix') / get_option('datadir') / 'applications',
)

install_data(
'README.md',
install_dir: get_option('prefix') / get_option('datadir') / 'doc' / meson.project_name(),
)

# TODO: better install dir for this to make desktop and gtk icons work on debug builds/uninstalled tests
foreach size : [16, 22, 24, 32, 36, 48, 64, 72, 96, 128, 256, 512, 1024]
install_data(
'data/icons/sizes/pepv-@[email protected]'.format(size),
install_dir: get_option('prefix') / get_option('datadir') / 'icons/hicolor/@0@x@0@/apps/'.format(size),
rename: 'pepv.png',
install_mode: 'rw-r--r--',
)
endforeach

executable(
'pepv',
['src/events.cpp', 'src/main.cpp', 'src/pkgs.cpp', 'src/utils.cpp'],
dependencies: [threads, gtk, libalpm, tracy],
export_dynamic: true, # GTK needs this
cpp_args: [
'-DPREFIX="' + get_option('prefix') + '"',
'-DDATADIR="' + get_option('datadir') + '"',
'-Werror',
],
install: true,
)
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('tracy_enable', type: 'boolean', value: true, description: 'Enable profiling')
35 changes: 23 additions & 12 deletions src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
#include "pkgs.hpp"
#include "utils.hpp"

#include <cassert>
#include <iostream>
#include <thread>

#include <tracy/Tracy.hpp>

std::string selected;

void updatePkgInfo() {
ZoneScopedN("updatePkgInfo");
ZoneNamedN(___tracy_updatePkgInfo, "updatePkgInfo", true);
#ifdef TRACY_ENABLE
const std::string tracyArgs = "Package: " + selected;
___tracy_scoped_zone.Text(tracyArgs.c_str(), tracyArgs.size());
___tracy_updatePkgInfo.Text(tracyArgs.c_str(), tracyArgs.size());
#endif
static auto gPkgInfo = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "pkgInfo"));
static auto infoBuffer = gtk_text_view_get_buffer(gPkgInfo);

Expand Down Expand Up @@ -41,8 +45,8 @@ void updatePkgInfo() {
infoss << "Build date: " << bdss.c_str() << std::endl;
}
if (pkg.installDate.has_value()) {
auto idss = formattedTimestamp(pkg.installDate.value());
infoss << "Install date: " << idss.c_str() << std::endl;
auto installDatess = formattedTimestamp(pkg.installDate.value());
infoss << "Install date: " << installDatess.c_str() << std::endl;
}
if (pkg.packager.has_value())
infoss << "Packager: " << pkg.packager.value() << std::endl;
Expand Down Expand Up @@ -101,9 +105,11 @@ void updatePkgInfo() {
}

void updatePkgFiles() {
ZoneScopedN("updatePkgFiles");
ZoneNamedN(___tracy_updatePkgFiles, "updatePkgFiles", true);
#ifdef TRACY_ENABLE
const std::string tracyArgs = "Package: " + selected;
___tracy_scoped_zone.Text(tracyArgs.c_str(), tracyArgs.size());
___tracy_updatePkgFiles.Text(tracyArgs.c_str(), tracyArgs.size());
#endif
static auto gPkgFiles = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "pkgFiles"));
static auto filesBuffer = gtk_text_view_get_buffer(gPkgFiles);

Expand All @@ -114,9 +120,11 @@ void updatePkgFiles() {
}

void updatePkgBackupFiles() {
ZoneScopedN("updatePkgBackupFiles");
ZoneNamedN(___tracy_updatePkgBackupFiles, "updatePkgBackupFiles", true);
#ifdef TRACY_ENABLE
const std::string tracyArgs = "Package: " + selected;
___tracy_scoped_zone.Text(tracyArgs.c_str(), tracyArgs.size());
___tracy_updatePkgBackupFiles.Text(tracyArgs.c_str(), tracyArgs.size());
#endif
static auto gPkgBackup = GTK_TREE_STORE(gtk_builder_get_object(builder, "backupFilesStore"));

gtk_tree_store_clear(gPkgBackup);
Expand All @@ -132,7 +140,7 @@ void updatePkgBackupFiles() {

bool populationIsHappening = false;
void populatePkgList() {
ZoneScopedN("populatePkgList");
ZoneNamedN(___tracy_populatePkgList, "populatePkgList", true);
static const auto selection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "select"));
static const auto treeStore = GTK_TREE_STORE(gtk_builder_get_object(builder, "treeStore"));

Expand Down Expand Up @@ -169,6 +177,7 @@ void populatePkgList() {

GtkTreeIter iter;

assert(populationIsHappening == false); // This triggering means population ran twice, so performance is lost
populationIsHappening = true;
gtk_tree_selection_unselect_all(selection);

Expand All @@ -184,8 +193,10 @@ void populatePkgList() {

for (auto& e : names) {
ZoneNamedN(_tracy_zone_populate_package, "populate package", true);
#ifdef TRACY_ENABLE
const std::string tracyArgs = "Package: " + e;
_tracy_zone_populate_package.Text(tracyArgs.c_str(), tracyArgs.size());
#endif
const auto pkgDescRes = p->getDescriptionForPackage(e);
if (!pkgDescRes.first) {
std::cout << "Couldnt get description for pkg: " << e << std::endl;
Expand Down Expand Up @@ -266,7 +277,7 @@ void populatePkgList() {

extern "C" {
void on_reload_button_clicked(GtkButton* b) {
ZoneScopedN("on_reload_button_clicked");
ZoneNamedN(___tracy_on_reload_button_clicked, "on_reload_button_clicked", true);

p->uninit();
p->init();
Expand All @@ -275,7 +286,7 @@ void on_reload_button_clicked(GtkButton* b) {
}

void on_select_changed(GtkWidget* c) {
ZoneScopedN("on_select_changed");
ZoneNamedN(___tracy_on_select_changed, "on_select_changed", true);
if (populationIsHappening) return; // Even when there is nothing selected this function will still be called, dont want that
gchar* value;
GtkTreeIter iter;
Expand All @@ -298,7 +309,7 @@ void on_select_changed(GtkWidget* c) {
}

void on_applyFilters_clicked(GtkButton* c) {
ZoneScopedN("on_applyFilters_clicked");
ZoneNamedN(___tracy_on_applyFilters_clicked, "on_applyFilters_clicked", true);
populatePkgList();
}
}
1 change: 1 addition & 0 deletions src/events.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "pkgs.hpp"

#include <gtk/gtk.h>

extern GtkBuilder* builder;
Expand Down
Loading