Skip to content

Commit

Permalink
chore: CI build both 32 bit and 64 bit binary for windows.
Browse files Browse the repository at this point in the history
chore: update CMakeLists.txt, build windows binary statically, no DLLs again.
chore: update README.md
chore: update rppi_config.yaml, default no proxy and no mirror set
chore: build_ninja.bat and build_msvc.bat for easy building jobs in windows.
chore: update .gitignore
  • Loading branch information
fxliang committed Jan 5, 2024
1 parent 92d47cc commit d1bb7a3
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 29 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
echo "build-output-dir-win32=${{ github.workspace }}/build32" >> "$GITHUB_OUTPUT"
- 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.
Expand All @@ -72,23 +73,38 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Configure CMake for Win32 build
# 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
if: ${{ matrix.os == 'windows-latest' }}
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir-win32 }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }} -A Win32
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
- name: Build Win32
if: ${{ matrix.os == 'windows-latest' }}
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir-win32 }} --config ${{ matrix.build_type }}

#- name: Test
#working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
#run: ctest --build-config ${{ matrix.build_type }}

- name: Prepare dist folder for artifacts(Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
mkdir rppi_get
copy build/deps/yaml-cpp/Release/yaml-cpp.dll rppi_get/
copy build/deps/libgit2/Release/git2.dll rppi_get/
copy build/Release/rppi_get.exe rppi_get/
copy ${{ steps.strings.outputs.build-output-dir }}/Release/rppi_get.exe rppi_get/rppi_get_x64.exe
copy ${{ steps.strings.outputs.build-output-dir-win32 }}/Release/rppi_get.exe rppi_get/rppi_get.exe
copy rppi_config.yaml rppi_get/
copy LICENSE rppi_get/
copy README.md rppi_get/
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build/
build*/
ninja/
.cache
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ set(CMAKE_CXX_EXTENSIONS OFF)
include(GNUInstallDirs)

# options
option(USE_BUNDLED_CXXOPTS "Use built-in version of cxxopts" ${MSVC})
option(USE_BUNDLED_JSON "Use built-in version of nlohmann/json" ${MSVC})
option(USE_BUNDLED_LIBGIT2 "Use built-in version of libgit2" ${MSVC})
option(USE_BUNDLED_YAMLCPP "Use built-in version of yaml-cpp" ${MSVC})
option(USE_BUNDLED_CXXOPTS "Use built-in version of cxxopts" ${WIN32})
option(USE_BUNDLED_JSON "Use built-in version of nlohmann/json" ${WIN32})
option(USE_BUNDLED_LIBGIT2 "Use built-in version of libgit2" ${WIN32})
option(USE_BUNDLED_YAMLCPP "Use built-in version of yaml-cpp" ${WIN32})

# dependencies
if (USE_BUNDLED_CXXOPTS)
Expand All @@ -30,8 +30,8 @@ endif()
if (USE_BUNDLED_LIBGIT2)
set(BUILD_TESTS OFF CACHE INTERNAL "")
set(BUILD_CLI OFF CACHE INTERNAL "")
if (MSVC)
set(BUILD_SHARED_LIBS ON CACHE INTERNAL "")
if (WIN32)
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
endif()
add_subdirectory(deps/libgit2)
set(LIBGIT2_LIBRARIES libgit2package)
Expand All @@ -45,6 +45,9 @@ if (USE_BUNDLED_YAMLCPP)
set(YAML_CPP_BUILD_TOOLS OFF CACHE INTERNAL "")
set(YAML_CPP_BUILD_TESTS OFF CACHE INTERNAL "")
set(YAML_CPP_INSTALL OFF CACHE INTERNAL "")
if (WIN32)
set(YAML_BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
endif()
add_subdirectory(deps/yaml-cpp)
else()
find_package(yaml-cpp REQUIRED)
Expand Down
51 changes: 36 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A toy to play with [rppi](https://github.com/rime/rppi)
### linux (Ubuntu for example)
```bash
sudo apt update
sudo apt install libgit2-dev -y
sudo apt -y install libgit2-dev libcxxopts-dev nlohmann-json3-dev libyaml-cpp-dev
git clone -v --depth=1 https://github.com/fxliang/rppi_get.git --recursive
cd rppi_get
cmake -B build .
Expand All @@ -15,28 +15,31 @@ output in `build/rppi_get`, copy and play with it. I am not a good linux user, s

### windows

install cmake, visual studio and git, and cmake --build it.
you can download the latest artifact of main branch, in [Actions](https://github.com/fxliang/actions)

Or you can download the latest artifact of main branch, in [Actions](https://github.com/fxliang/actions)
or install cmake, git, and Visual Studio or ninja+Mingw, follow steps bellow

maybe mingw-w64 also works, but I haven't tried it out.
- Build with MSVC

with developer command prompt
```cmd
git clone -v --depth=1 https://github.com/fxliang/rppi_get.git --recursive
cd rppi_get
.\build_msvc.bat
```

- Build with Ninja and Mingw

make sure you have ninja and Mingw in your path
```cmd
git clone -v --depth=1 https://github.com/fxliang/rppi_get.git --recursive
cd rppi_get
cmake -B build .
cmake --build build --config Release
mkdir rppi_get
copy build\Release\rppi_get.exe .\rppi_get\
copy build\deps\libgit2\Release\git2.dll .\rppi_get\
copy build\deps\yaml-cpp\Release\yaml-cpp.dll .\rppi_get\
copy rppi_config.yaml .\rppi_get\
.\build_ninja.bat
```

## Usage

configurations in rppi_config.yaml in the app directory, or `~/rppi_config.yaml` , `#` to disable, however don't comment `user_dir` and `cache_dir`
configurations in rppi_config.yaml in the app directory, or `~/.rppi_config.yaml` , `#` to disable, however don't comment `user_dir` and `cache_dir`

```yaml
# your proxy setting for libgit2
Expand All @@ -56,8 +59,12 @@ Usage:
rppi_get [OPTION...]

-h, --help print help
-I, --installed list recipes installed
-u, --update update rppi
-i, --install arg install recipe
-i, --install arg install or update a recipe
-d, --delete arg delete a recipe
-P, --purge arg purge a recipe (with dependencies and
reverseDependencies)
-g, --git arg install recipe by git repo
-s, --search arg search recipe with keyword
-c, --clean clean caches
Expand All @@ -84,13 +91,17 @@ rppi_get.exe -m https://hub.yzuu.cf/ -u
rppi_get.exe -u
```


- to list all recipes in rppi
```cmd
rppi_get.exe -l
```

- to search recipes in rppi
- to list all recipes installed
```cmd
rppi_get.exe -I
```

- to search recipes in rppi, case insensitive
```cmd
rppi_get.exe -s wubi
```
Expand Down Expand Up @@ -128,3 +139,13 @@ rppi_get.exe -g iDvel/rime-ice
```cmd
rppi_get.exe -g iDvel/rime-ice:others/recipes/full
```

- to delete a recipe(neither dependencies nor reverseDependencies will be deleted)
```cmd
rppi_get.exe -d iDvel/rime-ice
```

- to purge a recipe(dependencies and reverseDependencies **will be deleted**)
```cmd
rppi_get.exe -P iDvel/rime-ice
```
10 changes: 10 additions & 0 deletions build_msvc.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake -B build .
cmake --build build --config Release
cmake -B build32 . -A Win32
cmake --build build32 --config Release
mkdir rppi_get
copy build\Release\rppi_get.exe .\rppi_get\rppi_get_x64.exe
copy build32\Release\rppi_get.exe .\rppi_get\
copy rppi_config.yaml .\rppi_get\
copy LICENSE .\rppi_get\
copy README.md .\rppi_get\
7 changes: 7 additions & 0 deletions build_ninja.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake -B ninja . -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build ninja --config Release
mkdir rppi_get
copy ninja\rppi_get.exe .\rppi_get\
copy rppi_config.yaml .\rppi_get\
copy LICENSE .\rppi_get\
copy README.md .\rppi_get\
4 changes: 2 additions & 2 deletions rppi_config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# your proxy setting for libgit2
proxy: http://localhost:8118
# proxy: http://localhost:8118
# your github mirror setting, if your network not so good
mirror: https://hub.yzuu.cf/
# mirror: https://hub.yzuu.cf/
# target user directory
user_dir: ~/usr_dir
# cache directory
Expand Down

0 comments on commit d1bb7a3

Please sign in to comment.