How to share custom build step between Win and Osx ?



  • Hello everybody

    I need your help please !
    I'm trying to create a Qt project that would build a dynamic library on window and a static one on osx from the same code.
    Therefore I need different custom build steps for each platform that copy some dependent files for deployment etc.

    Is there a way to manage that directly in the .pro file instead of having the custom steps in the .pro.user file?

    Many thanks in advance
    regards
    Manfred



  • If you add something like this to your project file of your library it should work:

    TEMPLATE = 			lib
    CONFIG += 			staticlib
    
    win32 { 
    CONFIG -= 			staticlib
    CONFIG +=			dll
    }
    

    When the library is compiled on OS X (or anything other than Windows for that matter) then you will end up with a static library. When compiled on Windows you will end up with a dynamic library (DLL).

    There is nothing you need to change in the project file for the application that uses the library. You likely need the INCLUDEPATH and LIBS entries regardless if this is static or dynamic but no other changes should be needed to the application that uses the library.



  • Hi Rondog,
    thanks for your reply.
    Yes this is what I already do but I need to deploy different files for each platform that are currently managed by custom build steps.

    For example, the windows DLL should ship with a DEF file that is needed by clients that use VisualStudio

    The problem is that these custom build steps are saved in the .pro.user file and are specific for each developer.
    I'd like to share these custom build steps among my team and still being able to build for different platforms.

    Any ideas?

    regards
    Manfred


  • Qt Champions 2016

    @Manfred said in How to share custom build step between Win and Osx ?:

    I'd like to share these custom build steps

    How often would they be updated?
    it is pretty easy to grab section and
    simply paste into other .user file.
    If many, it always works pretty good to simply use the code revision tool to merge it into
    an existing .user file. Its xml so pretty structured. You could even write tool do it if really many.



  • I think you use the like this steps.

    Build Steps

    qmake: qmake.exe demo.pro -r -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
    Make: mingw32-make.exe in E:\Work\App\demo\build-demo-Desktop_Qt_5_7_0_MinGW_32bit-Debug
    Custom Process Step: xcopy /Y/D .\_LIB\\Lib\Win32\Debug\*.dll ..\build-demo-Desktop_Qt_5_
    

    But the Custom Process Step is in .user.pro file. And we can not commit it to Git and share to other one.

    And How to do it ?

    From the case, we use the perl Scripting language(you can do other language).

    Share my perl code for you wish to help you.

    my $OS_type = $^O;  # maybe "MSWin32" for Win32 or "darwin" for MacOSX or "linux" for ubuntu
    
    if($OS_type =~ /MSWin32/){
    	$Des_D = '..\build-demo-Desktop_Qt_5_7_0_MinGW_32bit-Debug\debug';
    	$Des_R = '..\build-demo-Desktop_Qt_5_7_0_MinGW_32bit-Release\release';	
    	((-d $Des_D) || (-d $Des_R)) || die;	
    	$demoDllPath = '.\_LIB\libs\Lib\Win32'; (-d $demoDllPath) || die;
    		
    	# copy lib files	
    	if(-d $Des_D) {			
    		system("xcopy /Y/D $demoDllPath\\Debug\\*.dll $Des_D\\");
    	}
    	if(-d $Des_R) {			
    		system("xcopy /Y/D $demoDllPath\\Release\\*.dll $Des_R\\");
    	}	
    } 
    elsif($OS_type =~ /darwin/){ # MAC OSX
    	$Des_D = '../build-demo-Desktop_Qt_5_7_0_clang_64bit-Debug';	             
    	$Des_R = '../build-demo-Desktop_Qt_5_7_0_clang_64bit-Release';
    	((-d $Des_D) || (-d $Des_R)) || die;
    	$demoDylibPath = './_LIB/libs/Lib/OSX'; (-d $demoDylibPath) || die;
    		
    	# copy lib files : 
    	if(-d $Des_D) {			
    		system("cp -f $demoDylibPath/Debug/libDemoApp.dylib $AppPath/libDemoApp.1.dylib");		
    	}
    	if(-d $Des_R) {	
    		system("cp -f $demoDylibPath/Release/libDemoApp.dylib $AppPath/libDemoApp.1.dylib");
    	}			
    		
     
    else { die(">$OS_type<\n"); }
    
     system("pause");
    

    And then , You just add bulid step to your user.pro file. oh, Don't forget your computer must can run the perl code or some other scripting code.

    Custom Process Step: perl build_perl_script.pl
    


  • Hi and thank you both for your comments!

    I finally opted for the script solution as I find it to be the most flexible one.
    I basically launch a script from my pro file, depending on the platform

    win32{
        message( "------------BUILDING FOR WINDOWS32 -----------");
        DEFINES += LIB_WIN
        QMAKE_CXXFLAGS += -shared
        . . .
        # Post link steps 
        QMAKE_POST_LINK = $$PWD/win_post.bat $$PWD $$OUT_PWD 
    }
    iphoneos {
        message( "-------------BUILDING FOR IOS --------------");
    
        DEFINES += LIB_IOS
        QT -= gui
        Qt =+ core
        TARGET = . . .
        TEMPLATE = lib
        CONFIG -= dll
        CONFIG += staticlib
        . . . 
    
        QMAKE_POST_LINK = $$PWD/ios_post.sh $$PWD $$OUT_PWD 
    }
    
    

    I consider the subject SOLVED!

    Thanks again and have a nice day!
    best regards
    Manfred



  • @Manfred Very Good!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.