Skip to content

Commit

Permalink
Merge pull request #1 from ElementAstro/AstroAir/add-build-script
Browse files Browse the repository at this point in the history
Add build script
  • Loading branch information
AstroAir authored Jan 25, 2025
2 parents 9ec42e8 + e8293ab commit 2aec0e6
Show file tree
Hide file tree
Showing 167 changed files with 721 additions and 493 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
compiler: [gcc, clang]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up build environment
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ cmake libcfitsio-dev zlib1g-dev libssl-dev libzip-dev libnova-dev libfmt-dev gettext
- name: Install GCC 13 and G++ 13
if: matrix.compiler == 'gcc'
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install -y gcc-13 g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 60
- name: Install Clang 18
if: matrix.compiler == 'clang'
run: |
sudo apt-get install -y clang-18
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 60
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 60
- name: Build project
run: |
mkdir build
cd build
cmake -DCMAKE_CXX_COMPILER=${{ matrix.compiler }}++ ..
make
- name: Run tests
run: |
cd build
ctest
- name: Package project
run: |
cd build
make package
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@

.cache/
build/
test/
test/
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ find_package(Curses REQUIRED)

add_executable(lithium-next ${lithium_src_dir}/app.cpp)

target_link_libraries(lithium-next PRIVATE
target_link_libraries(lithium-next PRIVATE
pybind11::module
pybind11::lto
lithium_components
Expand Down Expand Up @@ -71,4 +71,4 @@ add_subdirectory(example)
add_subdirectory(tests)

# Enable folder grouping in IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,89 @@
# lithium-next
Next Generation of Lithium

## Project Description

Lithium-Next is an open-source astrophotography terminal designed to provide a comprehensive solution for managing and automating astrophotography tasks. The project aims to offer a user-friendly interface, robust features, and seamless integration with various astrophotography equipment and software.

### Features

- Automated build process using GitHub Actions
- Support for multiple compilers (GCC and Clang)
- Detailed project configuration using CMake
- Pre-commit hooks for code quality checks
- Integration with CodeQL for code analysis
- Comprehensive logging and debugging support
- Modular architecture for easy extension and customization

## GitHub Actions Workflows

### Build Workflow

The `build.yml` workflow automates the build process for the project. It includes steps for checking out the repository, setting up the build environment, building the project, running tests, and packaging the project.

#### Triggering the Workflow

The `build.yml` workflow is triggered on push and pull request events to the `master` branch. This ensures that the project is built, tested, and packaged automatically on every push and pull request to the `master` branch.

## Development Environment Setup

To set up the development environment for Lithium-Next, follow these steps:

1. Clone the repository:
```bash
git clone https://github.com/ElementAstro/lithium-next.git
cd lithium-next
```

2. Install the required dependencies:
```bash
sudo apt-get update
sudo apt-get install -y gcc g++ cmake libcfitsio-dev zlib1g-dev libssl-dev libzip-dev libnova-dev libfmt-dev gettext
```

3. Set up the pre-commit hooks:
```bash
pre-commit install
```

4. Build the project:
```bash
mkdir build
cd build
cmake ..
make
```

5. Run the tests:
```bash
ctest
```

6. Package the project:
```bash
make package
```

7. To build with Clang, ensure Clang 18 or higher is installed and set the compiler:
```bash
sudo apt-get install -y clang-18
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 60
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 60
mkdir build-clang
cd build-clang
cmake -DCMAKE_CXX_COMPILER=clang++ ..
make
```

8. To build with GCC 13, ensure GCC 13 is installed and set the compiler:
```bash
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install -y gcc-13 g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 60
mkdir build-gcc
cd build-gcc
cmake -DCMAKE_CXX_COMPILER=g++ ..
make
```
2 changes: 1 addition & 1 deletion cmake/compiler_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ if(CMAKE_BUILD_TYPE MATCHES "Release")
target_compile_options(${PROJECT_NAME} PRIVATE /GL)
target_link_options(${PROJECT_NAME} PRIVATE /LTCG)
endif()
endif()
endif()
2 changes: 1 addition & 1 deletion cmake/policies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ if(POLICY CMP0043)
endif()
if(POLICY CMP0148)
cmake_policy(SET CMP0148 NEW)
endif()
endif()
2 changes: 1 addition & 1 deletion config/package_managers.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@
"searchCommand": "winget search {name}"
}
]
}
}
2 changes: 1 addition & 1 deletion example/components/example1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class LoggerComponent : public Component {

ATOM_MODULE(logger, [](auto& component) {
component.def("logMessage", &LoggerComponent::logMessage, "Log message");
})
})
2 changes: 1 addition & 1 deletion example/components/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ int main() {
}

return 0;
}
}
2 changes: 1 addition & 1 deletion example/config/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ int main() {
}

return 0;
}
}
2 changes: 1 addition & 1 deletion example/task/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ int main() {
}

return 0;
}
}
8 changes: 4 additions & 4 deletions modules/image/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.20)
project(lithium_image
project(lithium_image
VERSION 1.0.0
LANGUAGES C CXX
)
Expand All @@ -20,8 +20,8 @@ include_directories(src)

# 创建共享库
add_library(${PROJECT_NAME} SHARED ${SOURCES})
target_include_directories(${PROJECT_NAME}
PUBLIC
target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${OpenCV_INCLUDE_DIRS}
Expand All @@ -41,4 +41,4 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
)

add_subdirectory(examples)
add_subdirectory(examples)
1 change: 0 additions & 1 deletion modules/image/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ foreach(CPP_FILE ${CPP_FILES})
add_executable(${EXE_NAME} ${CPP_FILE})
target_link_libraries(${EXE_NAME} ${LIBRARIES_TO_LINK})
endforeach()

2 changes: 1 addition & 1 deletion modules/image/examples/thumbhash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ int main() {
std::cerr << "Error occurred: " << e.what() << std::endl;
return -1;
}
}
}
2 changes: 1 addition & 1 deletion modules/image/src/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ auto base64Decode(std::string const& encoded_string) -> std::string {
}

return result;
}
}
2 changes: 1 addition & 1 deletion modules/image/src/base64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ auto base64Encode(unsigned char const* bytes_to_encode,
*/
auto base64Decode(std::string const& encoded_string) -> std::string;

#endif // LITHIUM_IMAGE_BASE64_HPP
#endif // LITHIUM_IMAGE_BASE64_HPP
2 changes: 1 addition & 1 deletion modules/image/src/binning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,4 @@ template void process_mono_bin<uint16_t>(std::span<const uint8_t> srcData,
uint32_t camxbin, uint32_t camybin);
template void process_mono_bin<uint32_t>(std::span<const uint8_t> srcData,
cv::Mat& result, uint32_t srcStride,
uint32_t camxbin, uint32_t camybin);
uint32_t camxbin, uint32_t camybin);
2 changes: 1 addition & 1 deletion modules/image/src/binning.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ cv::Mat processWithBinning(std::span<const uint8_t> srcData, uint32_t width,
uint32_t newWidth, uint32_t newHeight,
uint32_t camxbin, uint32_t camybin, bool isColor);

#endif // LITHIUM_MODULE_IMAGE_BINNING_HPP
#endif // LITHIUM_MODULE_IMAGE_BINNING_HPP
2 changes: 1 addition & 1 deletion modules/image/src/hist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,4 @@ auto drawHistogram(const cv::Mat& hist, int histSize, int width,
LOG_F(INFO, "Histogram visualization completed in {}ms", duration.count());

return histImage;
}
}
2 changes: 1 addition & 1 deletion modules/image/src/hist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ auto drawHistogram(const cv::Mat& hist, int histSize = DEFAULT_HIST_SIZE,
int width = DEFAULT_WIDTH,
int height = DEFAULT_HEIGHT) -> cv::Mat;

#endif // HIST_HPP
#endif // HIST_HPP
2 changes: 1 addition & 1 deletion modules/image/src/imgio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,4 +464,4 @@ int saveFitsAsPNG(const std::string& fitsFileName, bool isColor, int cameraBin,
LOG_F(INFO, "Image processing and saving completed successfully: {}",
fileName);
return 0;
}
}
2 changes: 1 addition & 1 deletion modules/image/src/imgio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ auto saveMatTo16BitPng(
auto saveMatToFits(const cv::Mat& image, const std::string& output_path =
"/dev/shm/MatToFITS.fits") -> bool;

#endif
#endif
2 changes: 1 addition & 1 deletion modules/image/src/imgutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ auto eightSymmetryCircleCheck(const cv::Mat& rect_contour,

auto fourSymmetryCircleCheck(const cv::Mat& rect_contour,
const cv::Point& center, float radius) -> int;
#endif // LITHIUM_IMAGE_UTILS_HPP
#endif // LITHIUM_IMAGE_UTILS_HPP
10 changes: 5 additions & 5 deletions modules/image/src/test_base64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ TEST_F(Base64Test, EncodeStandardString) {
// RFC 4648 Test Vectors
TEST_F(Base64Test, EncodeRFCTestVectors) {
for (const auto& [input, expected] : testVectors) {
EXPECT_EQ(base64Encode(reinterpret_cast<const unsigned char*>(input.c_str()),
input.length()),
EXPECT_EQ(base64Encode(reinterpret_cast<const unsigned char*>(input.c_str()),
input.length()),
expected);
}
}
Expand Down Expand Up @@ -74,7 +74,7 @@ TEST_F(Base64Test, DecodeRFCTestVectors) {
}
}

// Padding Tests
// Padding Tests
TEST_F(Base64Test, HandlePadding) {
EXPECT_EQ(base64Decode("YQ=="), "a"); // 1 byte, 2 padding chars
EXPECT_EQ(base64Decode("YWI="), "ab"); // 2 bytes, 1 padding char
Expand Down Expand Up @@ -102,7 +102,7 @@ TEST_F(Base64Test, RoundtripStrings) {
TEST_F(Base64Test, RoundtripBinaryData) {
std::string encoded = base64Encode(binaryData.data(), binaryData.size());
std::string decoded = base64Decode(encoded);
EXPECT_EQ(std::vector<unsigned char>(decoded.begin(), decoded.end()),
EXPECT_EQ(std::vector<unsigned char>(decoded.begin(), decoded.end()),
binaryData);
}

Expand Down Expand Up @@ -130,4 +130,4 @@ TEST_F(Base64Test, HandleLongStrings) {

TEST_F(Base64Test, HandleWhitespace) {
EXPECT_EQ(base64Decode("SG Vs\nbG8="), "Hello");
}
}
6 changes: 3 additions & 3 deletions modules/image/src/test_binning.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BinningTest : public ::testing::Test {
smallImage = cv::Mat(100, 100, CV_8UC1, cv::Scalar(128));
largeImage = cv::Mat(3000, 3000, CV_8UC1, cv::Scalar(128));
colorImage = cv::Mat(100, 100, CV_8UC3, cv::Scalar(64, 128, 192));

// Create images with different bit depths
image8bit = cv::Mat(100, 100, CV_8UC1, cv::Scalar(128));
image16bit = cv::Mat(100, 100, CV_16UC1, cv::Scalar(32768));
Expand Down Expand Up @@ -98,7 +98,7 @@ TEST_F(BinningTest, BinningPreservesAverageIntensity) {
cv::Scalar originalMean = cv::mean(smallImage);
auto result = processMatWithBinAvg(smallImage, 2, 2, false, true);
cv::Scalar binnedMean = cv::mean(result);

EXPECT_NEAR(originalMean[0], binnedMean[0], 1.0);
}

Expand All @@ -122,4 +122,4 @@ TEST_F(BinningTest, LargeBinningFactors) {
EXPECT_GT(cv::mean(result)[0], 0);
}

} // namespace
} // namespace
2 changes: 1 addition & 1 deletion modules/image/src/test_imgio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ TEST_F(ImgIOTest, LoadMultipleImagesWithMixedValidity) {
"white.jpg"};
auto images = loadImages(testDir.string(), filenames);
ASSERT_EQ(images.size(), 2); // Only valid images should be loaded
}
}
2 changes: 1 addition & 1 deletion modules/image/src/test_imgutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ TEST_F(ImgUtilsTest, ExtremeDimensions) {

cv::Mat wideImg(10, 1000, CV_8UC3, cv::Scalar(128, 128, 128));
EXPECT_NO_THROW(autoWhiteBalance(wideImg));
}
}
Loading

0 comments on commit 2aec0e6

Please sign in to comment.