๋กœ์ผ“๐Ÿพ
article thumbnail

 

 

๊ฐœ๋ฐœ์„ ํ•˜๋‹ค๋ณด๋ฉด ํ•œ๊ฐ€์ง€ ๋ฒ„์ „๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋‹ค์–‘ํ•œ ๋ฒ„์ „์„ ์ง€์›ํ•ด์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ํŒŒ์ด์ฌ์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด 3.8, 3.9, 3.10 ๋ฒ„์ „ ๋ชจ๋‘ ์ง€์›ํ•ด์ฃผ์–ด์•ผ ํ•˜์ฃ .

 

๋ฒ„์ „๋ฟ๋งŒ OS ๋„ Linux x86, arm, Window, MacOS ๋“ฑ ๋‹ค์–‘ํ•˜๊ฒŒ ์ง€์›ํ•ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

C/C++ ๋กœ ๋งŒ๋“ค์–ด์ง„ ํ”„๋กœ์ ํŠธ๋ฅผ swig ๋ฅผ ํ†ตํ•ด ํŒŒ์ด์ฌ, ์ž๋ฐ”, Go ๋“ฑ ๋‹ค์–‘ํ•œ ์–ธ์–ด๊ณผ ๋‹ค์–‘ํ•œ ๋ฒ„์ „์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํŒจํ‚ค์ง€๋ฅผ ๋งŒ๋“ค์–ด์•ผ ํ–ˆ๋˜ ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋‹ค์–‘ํ•œ os, ๋‹ค์–‘ํ•œ ์–ธ์–ด, ๋‹ค์–‘ํ•œ ๋ฒ„์ „์„ ์ง€์›

 

C/C++ ํ”„๋กœ์ ํŠธ์— ์‚ฌ์šฉ๋˜๋Š” CMakeLists.txt(cmake) ์™€ Github Action ์˜ matrix ๋ฅผ ์ด์šฉํ•˜๋ฉด ์–ด๋ ต์ง€ ์•Š๊ฒŒ ๋‹ค์–‘ํ•œ ๋ฒ„์ „์˜ ํŒจํ‚ค์ง€๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

์ด๋ฒˆ ๊ธ€์—์„œ๋Š” ํŒŒ์ด์ฌ๊ณผ Linux x86 ๋งŒ ๋‹ค๋ฃจ๋ฉฐ, 3.8, 3.9, 3.10 ๋ฒ„์ „์˜ ํŒŒ์ด์ฌ์„ ์ง€์›ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

(swig ๋ฅผ ์ง์ ‘์ ์œผ๋กœ ์ด์šฉํ•˜๋Š” ๊ฒƒ์€ ์„ค๋ช…ํ•˜์ง€ ์•Š์œผ๋ฉฐ, ํŒจํ‚ค์ง€๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ ๋˜ํ•œ ๋ณด์—ฌ๋“œ๋ฆฌ์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค)

์‹ค์Šตํ•  os, ์–ธ์–ด, ๋ฒ„์ „

 

๊ทธ๋Ÿผ ๋ ›์ธ ๋‘๋”์ฝ”๋“œ~

 

 

์šฐ์„  github action ๋ถ€ํ„ฐ ์‚ดํŽด๋ด…์‹œ๋‹ค.

 

github action ์—๋Š” matrix ๋ผ๋Š” ๊ฐœ๋…์ด ์กด์žฌํ•˜์—ฌ ๋‹ค์–‘ํ•œ ๋ฒ„์ „์ด๋‚˜ OS ๋ฅผ ๋ณ‘๋ ฌ์ ์œผ๋กœ ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

 

์ด๋Ÿฐ์‹์œผ๋กœ ์ž‘์„ฑํ•˜๋ฉด job ์€ ์ง๋ ฌ์ด ์•„๋‹Œ ๋ณ‘๋ ฌ๋กœ ์ฒ˜๋ฆฌ๋˜๋ฉฐ, echo ๊ฐ€ ๊ฐ๊ฐ ๋Ÿฌ๋„ˆ๋งˆ๋‹ค 1,2,3 ์”ฉ ์ฐํžˆ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

์ด๊ฑธ ํ™œ์šฉํ•˜๋ฉด ๋‹ค์–‘ํ•œ ๋ฒ„์ „์˜ ํŒŒ์ด์ฌ์„ ์†์‰ฝ๊ฒŒ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ๊ฒ ๋„ค์š”.

name: Matrix
run-name: Matrix 

on:
  push:
    branches: main

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        count: [1, 2, 3]
    steps:
      - name: runner test
        env:
          COUNT: ${{ matrix.count }}
        run: |
          echo "count: $COUNT"
          sleep 10m

 

์ด๋ ‡๊ฒŒํ•˜๋ฉด ์ด 3๊ฐœ์˜ ๋Ÿฌ๋„ˆ๊ฐ€ ์‹คํ–‰๋˜๋ฉฐ, ๊ฐ๊ฐ ๋Ÿฌ๋„ˆ๋Š” ํ‘œ์‹œ๋œ ํŒŒ์ด์ฌ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

name: Matrix
run-name: Matrix 

on:
  push:
    branches: main

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-versions: [ '3.8', '3.9', '3.10' ]
    steps:
	  
      ...

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-versions }}
          cache: 'pip'
          update-environment: true

 

์ด๋ ‡๊ฒŒ ๋‹ค์šด๋ฐ›์€ ํŒŒ์ด์ฌ์€ /opt/hostedtoolcache/Python/3.9.18/x64 ์™€ ๊ฐ™์€ ๊ฒฝ๋กœ๋ฅผ ๊ฐ€์ง€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

๋˜ CMakeList.txt (cmake) ์—์„  ํŒŒ์ด์ฌ์„ ์‚ฌ์šฉํ•  ๋•Œ, Python3_ROOT_DIR ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ๋จผ์ € ์ฐพ์•„๋ณด๊ฒŒ ๋˜๋Š”๋ฐ,

๋‹คํ–‰ํžˆ actions/setup-python ์—์„œ ๊ธฐ๋ณธ์ ์ธ ํ™˜๊ฒฝ๋ณ€์ˆ˜ ๋“ค์€ ์ œ๊ณต์„ ํ•ด์ค๋‹ˆ๋‹ค.

 

cmake ๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๋™์ ์œผ๋กœ ํŒŒ์ด์ฌ ๋ฒ„์ „์„ ๋ฐ›์•„์•ผ ํ•˜๋Š”๋ฐ, Python3_ROOT_DIR ์„ ์‚ฌ์šฉํ•ด์„œ ์†์‰ฝ๊ฒŒ ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. 

์ด ๋ถ€๋ถ„์€ ๋’ค์—์„œ ๋” ์•Œ์•„๋ณด๋„๋ก ํ•˜์ฃ .

 

 

๊ทธ๋Ÿผ ์ด์ œ CMakeList.txt (cmake) ์—์„œ์˜ ์ž‘์—…์„ ์•Œ์•„๋ณด์ฃ .

 

์œ„์—์„œ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋กœ ๋“ฑ๋กํ•œ Python3_ROOT_DIR ์„ CMakeList.txt ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก set ์„ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

์ดํ›„ find_package ๋ฅผ ํ†ตํ•ด Python3_ROOT_DIR ๊ฐ€ ๋ฌธ์ œ์—†๋‹ค๋ฉด ์•Œ์•„์„œ ์ฐพ์•„์ค๋‹ˆ๋‹ค.

set(Python3_ROOT_DIR ${Python3_ROOT_DIR})

find_package(Python3 COMPONENTS Interpreter Development)

message("Python3_ROOT_DIR: $ENV{Python3_ROOT_DIR}")
message("Python3_INCLUDE_DIRS: ${Python3_INCLUDE_DIRS}")

include_directories( ${Python3_INCLUDE_DIRS} )

 

Python3_INCLUDE_DIRS ์€ ์–ด๋””์„œ ์˜จ ํ™˜๊ฒฝ๋ณ€์ˆ˜์ธ์ง€ ๊ถ๊ธˆํ•˜์‹คํ…๋ฐ, find_package ๋ฅผ ํ†ตํ•ด python ์„ ์ฐพ๊ฒŒ ๋œ๋‹ค๋ฉด, ์ถ”๊ฐ€์ ์œผ๋กœ ์ œ๊ณต๋˜๋Š” ํ™˜๊ฒฝ๋ณ€์ˆ˜๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค. Python3_INCLUDE_DIRS ๋˜ํ•œ ๊ทธ์— ํฌํ•จ๋˜๋ฉฐ, ํ•ด๋‹น ๋””๋ ‰ํ„ฐ๋ฆฌ์—๋Š” ํ—ค๋” ํŒŒ์ผ๋“ค์ด ์กด์žฌํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

์ด์™ธ ์ถ”๊ฐ€์ ์œผ๋กœ ์ œ๊ณต๋˜๋Š” ๋ณ€์ˆ˜๋“ค์ด ๊ถ๊ธˆํ•˜๋‹ค๋ฉด ์—ฌ๊ธฐ ์ฐธ๊ณ !

Python3_ROOT_DIR ์€ ๊ธฐ๋ณธ์ ์œผ๋กœ /opt/hostedtoolcache/Python/3.x.x/x64  ์˜ ๊ฒฝ๋กœ๋ฅผ ๊ฐ€์ง‘๋‹ˆ๋‹ค

 

๋์ž…๋‹ˆ๋‹ค.

 

์ด๋ ‡๊ฒŒ CMakeList.txt ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ์•Œ์•„์„œ ๋จธ์‹ (๋Ÿฌ๋„ˆ)์˜ ์„ค์น˜๋œ ํŒŒ์ด์ฌ ๋ฒ„์ „์„ ์ฐพ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

๊ทธ๋Ÿผ ์ด์ œ ์•ก์…˜์„ ์‹คํ–‰๋ณด๊ณ  ๊ฒฐ๊ณผ๊ฐ’์„ ํ•œ๋ฒˆ ๋ณด์ฃ .

์•ก์…˜ ๊ฒฐ๊ณผ

 

3๊ฐœ์˜ ๋Ÿฌ๋„ˆ์— ๊ฐ๊ฐ 3.10, 3.8, 3.9 ๋ฒ„์ „์ด ์„ค์น˜๋๊ณ , cmake ์—์„œ ์‚ฌ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

์ •ํ™•ํžˆ๋Š” ๊ฐ ํŒŒ์ด์ฌ ๋ฒ„์ „์€ swig ์—์„œ ์‚ฌ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

 

์˜ค๋Š˜์€ cmake ์™€ matrix ๋ฅผ ์ด์šฉํ•˜์—ฌ ๋‹ค์–‘ํ•œ ํŒŒ์ด์ฌ ๋ฒ„์ „์—์„œ ๋นŒ๋“œ ๋˜๋„๋ก ํ•ด๋ดค์Šต๋‹ˆ๋‹ค.

 

๊ทธ๋Ÿผ ์—ฌ๊ธฐ๊นŒ์ง€~

 

profile on loading

Loading...