cmake可见性和AppArmor示例

This commit is contained in:
NoDistanceY 2026-09-03 10:39:21 +08:00
commit 4b4b933e3d
19 changed files with 661 additions and 0 deletions

View file

@ -0,0 +1,9 @@
#pragma once
#include <string>
#include <color/color.h> // 公开头引用了 color → color 必须是 PUBLIC 依赖
// 注意:这里没有 timeutil.h也没有 PRINTER_TIME_FORMAT
class Printer {
public:
void print(const std::string& msg, Color c);
};

View file

@ -0,0 +1,12 @@
#include "printer/printer.h"
#include "timeutil.h" // 只在实现里用 → timeutil 是 PRIVATE 依赖
#include <iostream>
#ifndef PRINTER_TIME_FORMAT // 只在本 .cpp 里用的宏 → PRIVATE
#define PRINTER_TIME_FORMAT "%H:%M:%S" // 没从 CMake 传进来时的兜底
#endif
void Printer::print(const std::string& msg, Color c) {
std::cout << timestamp(PRINTER_TIME_FORMAT) << " "
<< colorCode(c) << msg << "\033[0m" << std::endl;
}