how to use jenkins to build 32 bit and 64 bit program and sealed in one package

南楼画角 提交于 2021-02-11 14:27:54

问题


it is another time to seek help from stack overflow .

I am trying to use jenkins , My aim is to build a windows install package that contains 32bit and 64bit version.

My prior manual routine is : built the 32bit and 64bit separately , and use innoSetup to build the package containing 2 versions.

if use jenkins ,the procedure will be :

  1. a linux jenkins server(master) send a build request to windowns jenkins server(agent)
  2. agent checkout code from svn
  3. built the package with 2 versions

I guess the master will need to send 2 request ( or maybe one request to trigger 2 jobs to build the 2 versions separately ,sorry ,I am new to jenkins) to the agent

but unfortunately , the 32 ,64 bit will need different CMakeLists.txt ,as they will need to link to third party library .(need to set the path of the third library in cmakeList)

but svn code is just one copy , so the CMakeList.txt will be same .(in the manual way ,I will revise the cmakeList when build a specific version)

So I don't know how to do this ?

Is there a way to turn around ?(create another svn repository?)

Thanks...


回答1:


Using seperate CMakeLists.txt files not necessary. You can distinguish the 32 and 64 bit versions by checking CMAKE_SIZEOF_VOID_P after the project() command. This allows you to keep the logic specific to 32/64 bit seperate.

Furthermore you could set cache variables when setting up cmake via -D VAR_NAME=value.

CMakeLists.txt

...

project(MyProject)

add_executable(MyProgram main.cpp wordsizeDependent.h)

# additional logic that depends on 32/64 bit
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
    target_sources(MyProgram PRIVATE x64/wordsizeDependent.cpp)
else()
    target_sources(MyProgram PRIVATE Win32/wordsizeDependent.cpp)
endif()

Since I'm not familiar with the jenkins cmake plugin I'll use the bat step assuming you use a jenkins pipeline and assume the directory repo contains the CMakeLists.txt file. Also build64 and build32 should already exist and be clean (or at least not contain cache values that cause a different behaviour than expected).

Furthermore I assume the logic runs on the correct jenkins node and cmake is installed there.

// 64 bit build
bat """cmake -G "Visual Studio 16 2019" -A x64 -S repo -B build64
cmake --build build64 --config Release"""


// 32 bit build
bat """cmake -G "Visual Studio 16 2019" -A Win32 -S repo -B build32
cmake --build build32 --config Release"""

You'll probably want to add a cpack call, use innoSetup and transfer the resulting package to the appropriate location on the appropriate machine. This would build both 32 and 64 bit using the same job. You could even run builds on linux and windows agents in the same job, if this is needed; Jobs are not restricted to a single agent and you can do more than one thing on an agent per job...



来源:https://stackoverflow.com/questions/64892333/how-to-use-jenkins-to-build-32-bit-and-64-bit-program-and-sealed-in-one-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!