From 0cf0507ce320c34b95f512445cacb6d3ca764f01 Mon Sep 17 00:00:00 2001 From: chfl4gs Date: Tue, 9 Jun 2020 11:57:30 +0800 Subject: [PATCH 1/2] Travis-CI build & nmake batch file updates --- .travis.yml | 39 +++++++++++++++++++++++++++++++++++++++ nmake-dll-x86.bat | 7 ------- nmake-dll.bat | 36 +++++++++++++++++++++++++++++++++++- nmake-lib.bat | 36 +++++++++++++++++++++++++++++++++++- 4 files changed, 109 insertions(+), 9 deletions(-) delete mode 100644 nmake-dll-x86.bat diff --git a/.travis.yml b/.travis.yml index 9e1325b7..0125a3eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,12 +17,51 @@ os: - osx matrix: + fast_finish: true include: - if: branch = master os: osx + osx_image: xcode10.1 compiler: clang + before_cache: + - brew cleanup + - find /usr/local/Homebrew \! -regex ".+\.git.+" -delete; + cache: + directories: + - $HOME/Library/Caches/Homebrew + - /usr/local/Homebrew + before_install: + - cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git stash && git clean -d -f script: brew update && brew install --HEAD keystone + - if: branch = master os: osx + osx_image: xcode10.1 compiler: gcc + before_cache: + - brew cleanup + - find /usr/local/Homebrew \! -regex ".+\.git.+" -delete; + cache: + directories: + - $HOME/Library/Caches/Homebrew + - /usr/local/Homebrew + before_install: + - cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git stash && git clean -d -f script: brew update && brew install --HEAD keystone + + - name: "Windows nmake 32bit" + os: windows + language: shell + script: + - mkdir build + - cd build + - cmd.exe //C 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat' x86 '&' cmd.exe //C '..\nmake-dll.bat' X86 '&' cmd.exe //c '..\nmake-lib.bat' X86 + + - name: "Windows nmake 64bit" + os: windows + language: shell + script: + - mkdir build + - cd build + - cmd.exe //C 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat' amd64 '&' cmd.exe //C '..\nmake-dll.bat' '&' cmd.exe //c '..\nmake-lib.bat' + diff --git a/nmake-dll-x86.bat b/nmake-dll-x86.bat deleted file mode 100644 index 480c7dd8..00000000 --- a/nmake-dll-x86.bat +++ /dev/null @@ -1,7 +0,0 @@ -:: Keystone assembler engine (www.keystone-engine.org) -:: Build Keystone DLL (keystone.dll) for X86, on Windows with CMake & Nmake -:: By Nguyen Anh Quynh, 2017 - -cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD="X86" -G "NMake Makefiles" .. -nmake - diff --git a/nmake-dll.bat b/nmake-dll.bat index a616ff92..7d77f6b7 100644 --- a/nmake-dll.bat +++ b/nmake-dll.bat @@ -3,7 +3,41 @@ :: By Nguyen Anh Quynh, 2016 :: This generates .\llvm\bin\keystone.dll +:: Usage: nmake-dll.bat [x86 arm aarch64 m68k mips sparc], default build all. + +@echo off + +set flags="-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON" + +set allparams= + +:loop +set str=%1 +if "%str%"=="" ( + goto end +) +set allparams=%allparams% %str% +shift /0 +goto loop + +:end +if "%allparams%"=="" ( + goto eof +) +:: remove left, right blank +:intercept_left +if "%allparams:~0,1%"==" " set "allparams=%allparams:~1%" & goto intercept_left + +:intercept_right +if "%allparams:~-1%"==" " set "allparams=%allparams:~0,-1%" & goto intercept_right + +:eof + +if "%allparams%"=="" ( +cmake "%flags%" -DLLVM_TARGETS_TO_BUILD="all" -G "NMake Makefiles" .. +) else ( +cmake "%flags%" "-DLLVM_TARGETS_TO_BUILD=%allparams%" -G "NMake Makefiles" .. +) -cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD="all" -G "NMake Makefiles" .. nmake diff --git a/nmake-lib.bat b/nmake-lib.bat index ddacf7fd..2174db31 100644 --- a/nmake-lib.bat +++ b/nmake-lib.bat @@ -3,7 +3,41 @@ :: By Nguyen Anh Quynh, 2016 :: This generates .\llvm\lib\keystone.lib +:: Usage: nmake-dll.bat [x86 arm aarch64 m68k mips sparc], default build all. + +@echo off + +set flags="-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF" + +set allparams= + +:loop +set str=%1 +if "%str%"=="" ( + goto end +) +set allparams=%allparams% %str% +shift /0 +goto loop + +:end +if "%allparams%"=="" ( + goto eof +) +:: remove left, right blank +:intercept_left +if "%allparams:~0,1%"==" " set "allparams=%allparams:~1%" & goto intercept_left + +:intercept_right +if "%allparams:~-1%"==" " set "allparams=%allparams:~0,-1%" & goto intercept_right + +:eof + +if "%allparams%"=="" ( +cmake "%flags%" -DLLVM_TARGETS_TO_BUILD="all" -G "NMake Makefiles" .. +) else ( +cmake "%flags%" "-DLLVM_TARGETS_TO_BUILD=%allparams%" -G "NMake Makefiles" .. +) -cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DLLVM_TARGETS_TO_BUILD="all" -G "NMake Makefiles" .. nmake From df3182f9f779df2387e2128c8b62c8f8f25bfa3f Mon Sep 17 00:00:00 2001 From: chfl4gs Date: Sat, 13 Jun 2020 22:44:52 +0800 Subject: [PATCH 2/2] pypi fix --- .github/workflows/python-publish.yml | 11 ++++++++++- bindings/python/build_wheel.sh | 29 ++++++++++------------------ bindings/python/setup.cfg | 2 ++ 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index d767ba49..6f5e8554 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -58,13 +58,22 @@ jobs: publish: needs: [build] runs-on: ubuntu-latest - if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags') + if: startsWith(github.ref, 'refs/tags') steps: - uses: actions/download-artifact@v2 with: name: artifact path: dist + + - name: Publish distribution 📦 to test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.testpypi_pass }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish distribution 📦 to PyPI + if: ${{ success() }} uses: pypa/gh-action-pypi-publish@master with: user: __token__ diff --git a/bindings/python/build_wheel.sh b/bindings/python/build_wheel.sh index d842a7ba..39ffcb37 100755 --- a/bindings/python/build_wheel.sh +++ b/bindings/python/build_wheel.sh @@ -1,24 +1,15 @@ #!/bin/bash set -e -x -cd /work/bindings/python - -sudo rm /usr/bin/python && sudo ln -s /opt/python/cp36-cp36m/bin/python /usr/bin/python; python -V - -function repair_wheel { - wheel="$1" - if ! auditwheel show "$wheel"; then - echo "Skipping non-platform wheel $wheel" - else - auditwheel repair "$wheel" -w /work/bindings/python/dist/ - fi -} - +cd bindings/python +sudo rm /usr/bin/python && sudo ln -s /opt/python/cp27-cp27m/bin/python /usr/bin/python; python -V # Compile wheels -/opt/python/cp36-cp36m/bin/python setup.py bdist_wheel -d wheelhouse - -# Bundle external shared libraries into the wheels -for whl in wheelhouse/*.whl; do - repair_wheel "$whl" -done +if [ -f /opt/python/cp36-cp36m/bin/python ];then + /opt/python/cp36-cp36m/bin/python setup.py bdist_wheel +else + python3 setup.py bdist_wheel +fi +cd dist +auditwheel repair *.whl +mv -f wheelhouse/*.whl . diff --git a/bindings/python/setup.cfg b/bindings/python/setup.cfg index 5e722cbb..3fdd7b20 100644 --- a/bindings/python/setup.cfg +++ b/bindings/python/setup.cfg @@ -1,2 +1,4 @@ [metadata] description-file = README.pypi-src +[bdist_wheel] +universal = 1