add: 两个例子 #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "make dylib" | |
on: | |
push: | |
branches: [master] | |
paths: | |
- "src/**.c" | |
- "inc/**.h" | |
- "Makefile" | |
- ".github/workflows/make-dylib.yml" | |
pull_request: | |
branches: [master] | |
paths: | |
- "src/**.c" | |
- "inc/**.h" | |
- "Makefile" | |
- ".github/workflows/make-dylib.yml" | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: "Log level" | |
required: true | |
default: "warning" | |
jobs: | |
build-dylib-linux: | |
strategy: | |
fail-fast: true | |
matrix: | |
platform: [x86, x64] | |
os: [ubuntu-latest] | |
runs-on: "${{ matrix.os }}" | |
name: "Build dylib: ${{ matrix.os }} / ${{ matrix.platform }}" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
# 设置GCC版本 | |
- name: Set up GCC | |
uses: egor-tensin/setup-gcc@v1 | |
with: | |
version: latest | |
platform: "${{ matrix.platform }}" | |
# 构建 (linux) | |
- name: Make dylib at ${{ matrix.os }} / ${{ matrix.platform }} | |
run: | | |
make dylib | |
env: | |
MTFMT_BUILD_C_DEFS: "-D_MSTR_BUILD_DYLIB=1 -D_MSTR_USE_MALLOC=1 -D_MSTR_USE_HARDWARE_DIV=1" | |
MTFMT_BUILD_USE_LTO: "1" | |
MTFMT_BUILD_TARGET_NAME: "mtfmt_${{ matrix.platform }}" | |
# 打包 | |
- name: Upload artifact | |
if: github.ref == 'refs/heads/master' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dylib-artifact | |
path: target/* | |
build-dylib-win: | |
strategy: | |
fail-fast: true | |
matrix: | |
platform: [x86, x64] | |
os: [windows-latest] | |
runs-on: "${{ matrix.os }}" | |
name: "Build dll: ${{ matrix.os }} / ${{ matrix.platform }}" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install Cygwin | |
uses: egor-tensin/setup-cygwin@v4 | |
with: | |
packages: make gcc-g++ | |
- name: Make dll at ${{ matrix.os }} / ${{ matrix.platform }} | |
run: | | |
make dylib | |
env: | |
MTFMT_BUILD_C_DEFS: "-D_MSTR_BUILD_DLL=1 -D_MSTR_USE_MALLOC=1 -D_MSTR_USE_HARDWARE_DIV=1 -D_MSTR_USE_STD_IO=1" | |
MTFMT_BUILD_USE_LTO: "1" | |
MTFMT_BUILD_INC_ADDITIONAL_OUT: "1" | |
MTFMT_BUILD_TARGET_NAME: "mtfmt_win_${{ matrix.platform }}" | |
MTFMT_BUILD_LIB_EXT: ".lib" | |
MTFMT_BUILD_DYLIB_EXT: ".dll" | |
# 打包 | |
- name: Upload artifact | |
if: github.ref == 'refs/heads/master' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dll-artifact | |
path: target/* |