Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

恢复交叉编译 #144

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/ubuntu_aarch64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: ubuntu-aarch64-build

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
cross: [aarch64-linux-musl]

concurrency:
group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Cross-Musl-${{ matrix.cross }}
cancel-in-progress: true

steps:
- uses: actions/checkout@v4

- name: Cache xmake aarch64 packages
id: cache-xmake-ubuntu-aarch64
uses: actions/cache@v3
env:
cache-name: cache-ubuntu-aarch64-modules
with:
path: |
~/.xmake
./${{ matrix.cross }}-cross.linux
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@master
actions-cache-folder: '.xmake-cache'

- name: Installation musl
run: |
wget https://github.com/xmake-mirror/musl.cc/releases/download/20210202/${{ matrix.cross }}-cross.linux.tgz
tar -xvf ${{ matrix.cross }}-cross.linux.tgz

- name: configure
run: |
xmake f -p cross -a aarch64 --sdk=`pwd`/${{ matrix.cross }}-cross -y

- name: build
run: |
xmake -b hikyuu
2 changes: 1 addition & 1 deletion .github/workflows/windows_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: configure
shell: cmd
run: |
xmake f -y --pyver=3.11
xmake f -y

- name: build
shell: cmd
Expand Down
2 changes: 1 addition & 1 deletion hikyuu_extern_libs/packages/m/mysql/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package("mysql")
elseif is_plat("linux", "cross") and is_arch("aarch64", "arm64.*") then
add_urls("https://github.com/fasiondog/hikyuu_extern_libs/releases/download/1.0.0/mysql-$(version)-linux-aarch64.zip",
"https://gitee.com/fasiondog/hikyuu_extern_libs/releases/download/1.0.0/mysql-$(version)-linux-aarch64.zip")
add_versions("8.0.21", "5ceb31ddc75bfaa0ec5324fa1564dae3abdb7ea9d3f0763f10d06e871d21d7d4")
add_versions("8.0.21", "385a7e280f86aa864f02ae7061c940a20f1ace358f906d330453992331b638c8")
end

on_install("windows", "linux", "cross", function (package)
Expand Down
26 changes: 26 additions & 0 deletions hikyuu_extern_libs/packages/p/pybind11/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package("pybind11")

set_kind("library", {headeronly = true})
set_homepage("https://github.com/pybind/pybind11")
set_description("Seamless operability between C++11 and Python.")
set_license("BSD-3-Clause")

add_urls("https://github.com/pybind/pybind11/archive/$(version).zip",
"https://github.com/pybind/pybind11.git")
add_versions("v2.11.1", "b011a730c8845bfc265f0f81ee4e5e9e1d354df390836d2a25880e123d021f89")

on_install(function (package)
os.cp("include", package:installdir())
end)

-- on_test(function (package)
-- assert(package:check_cxxsnippets({test = [[
-- #include <pybind11/pybind11.h>
-- int add(int i, int j) {
-- return i + j;
-- }
-- PYBIND11_MODULE(example, m) {
-- m.def("add", &add, "A function which adds two numbers");
-- }
-- ]]}, {configs = {languages = "c++11"}}))
-- end)
39 changes: 19 additions & 20 deletions hikyuu_pywrap/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
option("pyver")
set_default("3.9")
set_showmenu(true)
set_category("hikyuu")
set_description("Use python version xy")
option_end()

add_requires("pybind11", {system = false, alias = "pybind11"})
add_requireconfs("pybind11.python", {override = true, system = false, version = get_config("pyver")})

target("core")
set_kind("shared")
Expand Down Expand Up @@ -42,19 +35,25 @@ target("core")

add_rpathdirs("$ORIGIN", "$ORIGIN/lib", "$ORIGIN/../lib")

-- on_load(function(target)
-- import("lib.detect.find_tool")
-- import("lib.detect.find_path")
-- local python = assert(find_tool("python3", {version = true}), "python not found, please install it first! note: python version must > 3.0")
-- local exepath = path.directory(python.program)
-- if is_host("windows") then
-- includepath = find_path("Python.h", {exepath}, {suffixes = {"include"}})
-- else
-- local pyver = python.version:match("%d+.%d+")
-- includepath = find_path("Python.h", {path.directory(exepath)}, {suffixes = {"include/python" .. pyver}})
-- end
-- target:add("includedirs", includepath)
-- end)
on_load("windows", "linux", "macosx", function(target)
import("lib.detect.find_tool")
if is_plat("windows") then
-- detect installed python3
local python = assert(find_tool("python", {version = true}), "python not found, please install it first! note: python version must > 3.0")
assert(python.version > "3", python.version .. " python version must > 3.0, please use python3.0 or later!")
-- find python include and libs directory
local pydir = os.iorun("python -c \"import sys; print(sys.executable)\"")
pydir = path.directory(pydir)
target:add("includedirs", pydir .. "/include")
target:add("linkdirs", pydir .. "/libs")
return
end

-- get python include directory.
local pydir = try { function () return os.iorun("python3-config --includes"):trim() end }
assert(pydir, "python3-config not found!")
target:add("cxflags", pydir)
end)

after_build(function(target)
if is_plat("macosx") then
Expand Down
26 changes: 13 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# -*- coding:utf-8 -*-

from setuptools import setup, find_packages
import sys
Expand All @@ -10,9 +10,9 @@
import click


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# 前置检查
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
def check_xmake():
"""检查是否按照了编译工具 xmake"""
print("checking xmake ...")
Expand All @@ -25,7 +25,7 @@ def get_python_version():
py_version = platform.python_version_tuple()
min_version = int(py_version[1])
main_version = int(py_version[0])
#py_version = main_version * 10 + min_version if min_version < 10 else main_version * 100 + min_version
# py_version = main_version * 10 + min_version if min_version < 10 else main_version * 100 + min_version
py_version = f"{main_version}.{min_version}"
print(f'current python version: {py_version}')
return py_version
Expand Down Expand Up @@ -102,9 +102,9 @@ def clear_with_python_changed(mode):
shutil.rmtree(build_pywrap_dir)


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# 执行构建
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
def start_build(verbose=False, mode='release', feedback=True, worker_num=2):
""" 执行编译 """
global g_verbose
Expand All @@ -118,13 +118,13 @@ def start_build(verbose=False, mode='release', feedback=True, worker_num=2):

py_version = current_compile_info['py_version']

#如果 python版本或者编译模式发生变化,则编译依赖的 boost 库(boost.python)
# 如果 python版本或者编译模式发生变化,则编译依赖的 boost 库(boost.python)
history_compile_info = get_history_compile_info()
if py_version != history_compile_info[
'py_version'] or history_compile_info['mode'] != mode:
clear_with_python_changed(mode)
cmd = "xmake f {} -c -y -m {} --pyver={} --feedback={}".format(
"-v -D" if verbose else "", mode, py_version, feedback)
cmd = "xmake f {} -c -y -m {} --feedback={}".format(
"-v -D" if verbose else "", mode, feedback)
print(cmd)
os.system(cmd)

Expand All @@ -143,9 +143,9 @@ def start_build(verbose=False, mode='release', feedback=True, worker_num=2):
save_current_compile_info(current_compile_info)


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# 控制台命令
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------


@click.group()
Expand Down Expand Up @@ -341,9 +341,9 @@ def upload():
os.system("twine upload dist/*")


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# 添加 click 命令
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
cli.add_command(build)
cli.add_command(test)
cli.add_command(clear)
Expand Down
6 changes: 1 addition & 5 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,9 @@ add_requires("myboost " .. boost_version, {
filesystem = true,
serialization = true,
system = false,
-- python = false,
-- pyver = get_config("pyver"),
python = false,
},
})
-- if is_plat("windows") then
-- add_requireconfs("myboost.python", {override = true, system=false})
-- end

add_requires("spdlog", {system = false, configs = {header_only = true, fmt_external = true, vs_runtime = "MD"}})
add_requireconfs("spdlog.fmt", {override = true, version = fmt_version, configs = {header_only = true}})
Expand Down