Сборка Windows exe с помощью Travis CI - PullRequest
1 голос
/ 18 июня 2020

Я работаю над MacOS Catalina, но хочу создать файл .exe для запуска на Windows из очень простого репозитория Github (https://github.com/hect1995/TimerShutDown), который я создал.

Чтобы выполнить sh, что мне рекомендовано использовать Travis CI, и я использовал https://frame.42yeah.me/2020/02/27/travis-ci.html в качестве ресурса.

Следуя инструкциям, которые я создал в моем репозитории CMakeList.txt, run_command_and_apply_environment_differences.sh и vcvars64_vs2017.bat, как указано в ссылке, которую я включил.

Мой .travis.yml выглядит так:

language: cpp
compiler: cl
os: windows
script:
- source ./run_command_and_apply_environment_differences.sh "call vcvars64_vs2017.bat"
- mkdir build
- cd build
- cmake -G "NMake Makefiles" ..
- nmake all
- 7z a meli.zip timer.exe
- ls
deploy:
  provider: releases
  api_key:
    secure: ..........
  file: meli
  on:
    repo: hect1995/TimerShutDown
  skip_cleanup: 'true'

И мой CMakeList.txt как:

cmake_minimum_required(VERSION 3.5)
project(TimerShutDown LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_CXX_FLAGS  "-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic")
set(CMAKE_CXX_STANDARD 17)
add_executable(timer TimerShutDown.cpp)

После фиксации и проверки веб-интерфейса travis-ci я получаю:

travis_fold:start:worker_info
[0K[33;1mWorker information[0m
hostname: 0a9b350c-fad0-45cb-9460-07436dfaa8c5@1.worker-com-78f4bfd8fc-999g5.gce-production-3
version: v6.2.17 https://github.com/travis-ci/worker/tree/bc420764f334fe0d096a417c80426f672f1b7d18
instance: travis-job-22a790f3-b69e-4c16-95ff-7a5c39d100e9 travis-ci-windows-1809-containers-1591408217-f1e3a578 (via amqp)
startup: 6.220642644s
travis_fold:end:worker_info
[0KSecret environment variables are not obfuscated on Windows, please refer to our documentation: https://docs.travis-ci.com/user/best-practices-security[0m
travis_time:start:08c2f9c3
[0Ktravis_time:end:08c2f9c3:start=1592513335826403700,finish=1592513335867923800,duration=41520100,event=check_unsupported
[0Ktravis_time:start:0a2e492a
[0Ktravis_time:end:0a2e492a:start=1592513335919029900,finish=1592513335964019600,duration=44989700,event=apt_get_update
[0Ktravis_time:start:0e5b6a63
[0K[33;1mDisabling Windows Defender[0m
$ powershell -Command Set-MpPreference -DisableArchiveScanning \$true
$ powershell -Command Set-MpPreference -DisableRealtimeMonitoring \$true
$ powershell -Command Set-MpPreference -DisableBehaviorMonitoring \$true
travis_time:end:0e5b6a63:start=1592513336019322100,finish=1592513339154518800,duration=3135196700,event=disable_windows_defender
[0Ktravis_time:start:1c7b39bb
[0Ktravis_time:start:0b71264a
[0Ktravis_time:end:0b71264a:start=1592513339242016100,finish=1592513339421355800,duration=179339700,event=checkout
[0K
travis_fold:start:git.checkout
[0Ktravis_time:start:1ce7f0fb
[0K$ git clone --depth=50 --branch=v0.0.4 https://github.com/hect1995/TimerShutDown.git hect1995/TimerShutDown
Cloning into 'hect1995/TimerShutDown'...
travis_time:end:1ce7f0fb:start=1592513339465777600,finish=1592513340475370500,duration=1009592900,event=checkout
[0K$ cd hect1995/TimerShutDown
$ git checkout -qf v0.0.4
travis_fold:end:git.checkout
[0K
travis_time:end:1ce7f0fb:start=1592513339465777600,finish=1592513340558803300,duration=1093025700,event=checkout
[0Ktravis_time:start:12ce5e00
[0Ktravis_time:end:12ce5e00:start=1592513340603049300,finish=1592513340697202800,duration=94153500,event=env
[0K$ export TRAVIS_COMPILER=cl
$ export CXX=${CXX:-g++}
$ export CXX_FOR_BUILD=${CXX_FOR_BUILD:-g++}
$ export CC=${CC:-gcc}
$ export CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
$ cl --version
travis_time:start:019a62ca
[0K$ source ./run_command_and_apply_environment_differences.sh "call vcvars64_vs2017.bat"
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
Note: switching to '1f96e37cfa4189eb2d530b3eb6e46b9564db98e4'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

/c/Users/travis/.travis/functions: line 109: cl: command not found
[vcvarsall.bat] Environment initialized for: 'x64'
travis_time:end:019a62ca:start=1592513340757640300,finish=1592513343086851000,duration=2329210700,event=script
[0K[32;1mThe command "source ./run_command_and_apply_environment_differences.sh "call vcvars64_vs2017.bat"" exited with 0.[0m
travis_time:start:222e0a23
[0K$ mkdir build
travis_time:end:222e0a23:start=1592513343136725800,finish=1592513343204528000,duration=67802200,event=script
[0K[32;1mThe command "mkdir build" exited with 0.[0m
travis_time:start:192a9422
[0K$ cd build
travis_time:end:192a9422:start=1592513343252251400,finish=1592513343290164500,duration=37913100,event=script
[0K[32;1mThe command "cd build" exited with 0.[0m
travis_time:start:2a620736
[0K$ cmake -G "NMake Makefiles" ..
-- The CXX compiler identification is GNU 8.1.0
-- Check for working CXX compiler: C:/ProgramData/chocolatey/bin/g++.exe
-- Check for working CXX compiler: C:/ProgramData/chocolatey/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/travis/build/hect1995/TimerShutDown/build
travis_time:end:2a620736:start=1592513343338398100,finish=1592513348864636400,duration=5526238300,event=script
[0K[32;1mThe command "cmake -G "NMake Makefiles" .." exited with 0.[0m
travis_time:start:01d1e05c
[0K$ nmake all
[35m[1mScanning dependencies of target timer[0m
[ 50%] [32mBuilding CXX object CMakeFiles/timer.dir/timerShutDown.cpp.obj[0m

Microsoft (R) Program Maintenance Utility Version 14.16.27040.0
Copyright (C) Microsoft Corporation.  All rights reserved.

[100%] [32m[1mLinking CXX executable timer.exe[0m
[100%] Built target timer
travis_time:end:01d1e05c:start=1592513348905598500,finish=1592513350870157200,duration=1964558700,event=script
[0K[32;1mThe command "nmake all" exited with 0.[0m
travis_time:start:06594c54
[0K$ 7z a meli.zip timer.exe

7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21

Scanning the drive:
1 file, 2498445 bytes (2440 KiB)

Creating archive: meli.zip

Add new data to archive: 1 file, 2498445 bytes (2440 KiB)


Files read from disk: 1
Archive size: 503613 bytes (492 KiB)
Everything is Ok
travis_time:end:06594c54:start=1592513350920836900,finish=1592513351519863900,duration=599027000,event=script
[0K[32;1mThe command "7z a meli.zip timer.exe" exited with 0.[0m
travis_time:start:13e54c19
[0K$ ls
CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
meli.zip
timer.exe
travis_time:end:13e54c19:start=1592513351570897100,finish=1592513351641789200,duration=70892100,event=script
[0K[32;1mThe command "ls" exited with 0.[0m

travis_fold:start:dpl_0
[0Ktravis_time:start:134a70da
[0K$ ruby -S gem install dpl
Successfully installed dpl-1.10.15
Parsing documentation for dpl-1.10.15
Installing ri documentation for dpl-1.10.15
Done installing documentation for dpl after 0 seconds
1 gem installed
travis_time:end:134a70da:start=1592513352196029100,finish=1592513354677945800,duration=2481916700,event=after_success
[0Ktravis_fold:end:dpl_0
[0Ktravis_time:start:18a15679
[0KSuccessfully installed multipart-post-2.1.1
Successfully installed faraday-0.15.4
Successfully installed public_suffix-3.0.3
Successfully installed addressable-2.7.0
Successfully installed sawyer-0.8.2
Successfully installed octokit-4.6.2
Successfully installed mime-types-data-3.2020.0512
Successfully installed mime-types-3.3.1
Successfully installed dpl-releases-1.10.15
Parsing documentation for multipart-post-2.1.1
Installing ri documentation for multipart-post-2.1.1
Parsing documentation for faraday-0.15.4
Installing ri documentation for faraday-0.15.4
Parsing documentation for public_suffix-3.0.3
Installing ri documentation for public_suffix-3.0.3
Parsing documentation for addressable-2.7.0
Installing ri documentation for addressable-2.7.0
Parsing documentation for sawyer-0.8.2
Installing ri documentation for sawyer-0.8.2
Parsing documentation for octokit-4.6.2
Installing ri documentation for octokit-4.6.2
Parsing documentation for mime-types-data-3.2020.0512
Installing ri documentation for mime-types-data-3.2020.0512
Parsing documentation for mime-types-3.3.1
Installing ri documentation for mime-types-3.3.1
Parsing documentation for dpl-releases-1.10.15
Installing ri documentation for dpl-releases-1.10.15
Done installing documentation for multipart-post, faraday, public_suffix, addressable, sawyer, octokit, mime-types-data, mime-types, dpl-releases after 4 seconds
9 gems installed
travis_fold:start:dpl.1
[33mInstalling deploy dependencies[0m
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/options.rb:166: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:55: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
The system cannot find the path specified.
The system cannot find the path specified.
Logged in as Hector Esteban
Deploying to repo: hect1995/TimerShutDown
Current tag is: v0.0.4

travis_fold:end:dpl.1
travis_fold:start:dpl.2
[33mPreparing deploy[0m

travis_fold:end:dpl.2
travis_fold:start:dpl.3
[33mDeploying application[0m

travis_fold:end:dpl.3
travis_time:end:18a15679:start=1592513354767121800,finish=1592513366965795700,duration=12198673900,event=after_success
[0K
Done. Your build exited with 0.
Setting target_commitish to 1f96e37cfa4189eb2d530b3eb6e46b9564db98e4

Проблема:

Если я запускаю Windows timer.exe Я получаю:

The code execution cannot proceed because `libwinpthread-1.dll` not found. Reinstalling the program may fix this problem

Я следил как сделать stati c линковку libwinpthread-1.dll в mingw? и сделал:

SET(CMAKE_CXX_FLAGS  "-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic")

Но все равно выдает ошибку в Windows.

Что я делаю не так?

...