Menu

Fix the use of CD under Windows when wpkg is using CMake

wpkg
2015-03-13
2015-03-13
  • Mathieu SCHROETER

    Hello,

    This patch fixes the way how to change of directory under Windows.

    The goal is to fix this issue:

    wpkg --verbose --output-repository-dir S:\devel\bootstrap-windev\sysroot\toolchain\var\wpkg\ --cmake-generator MinGW Makefiles --make-tool mingw32-make --build
    ...
    -- Configuring done
    -- Generating done
    -- Build files have been written to: S:/devel/bootstrap-windev/sysroot/toolchain/var/tmp/wpkg/source/epsitec+lydia
    

    CMake must be run from the tmp directory, like:

    -- Build files have been written to: C:/Users/DevBox2/AppData/Local/Temp/wpkg-6420/build
    

    The patch:

    --- a/wpkg/libdebpackages/wpkgar_build.cpp  Fri Mar 13 15:21:55 2015
    +++ b/wpkg/libdebpackages/wpkgar_build.cpp  Fri Mar 13 15:44:02 2015
    @@ -1851,7 +1851,11 @@
      */
     void wpkgar_build::prepare_cmd(std::string& cmd, const wpkg_filename::uri_filename& dir)
     {
    +#if defined(MO_WINDOWS)
    +    cmd = "cd /d ";
    +#else
         cmd = "cd ";
    +#endif
         cmd += wpkg_util::make_safe_console_string(dir.full_path());
     #if defined(MO_WINDOWS)
         cmd += " && set PATH=";
    
    @@ -2445,7 +2445,12 @@
             created_packages[sub_name] = true;
    
             // run cmake
    -        std::string cmake_cmd("cd " + build_tmpdir.full_path() + " && cmake");
    +#if defined(MO_WINDOWS)
    +        std::string cmake_cmd("cd /d ");
    +#else
    +        std::string cmake_cmd("cd ");
    +#endif
    +        cmake_cmd += build_tmpdir.full_path() + " && cmake";
             wpkg_filename::uri_filename install_dir(install_tmpdir.append_child(sub_name).append_safe_child(f_install_prefix));
             cmake_cmd += " -DCMAKE_INSTALL_PREFIX=" + install_dir.full_path();
             cmake_cmd += " -DCMAKE_INSTALL_COMPONENT=" + sub_name;
    

    Why cd /d ?

    Because I've my development files under s:, but my user temporary directory is under c:

    See cmd documentation:

    Use the /D switch to change current drive in addition to changing current
    directory for a drive.
    

    Thank you,
    Regards

     
  • Mathieu SCHROETER

    Patch

     
  • Alexis Wilke

    Alexis Wilke - 2015-03-13

    Ah... that has been one restriction: use wpkg only on one drive. This will help in using it across multiple drives, although there may be other problems linked to that limitation.

     
  • Alexis Wilke

    Alexis Wilke - 2015-03-13

    Okay, I pushed this patch.

     

Log in to post a comment.