Skip to content

Commit

Permalink
enable symlink for win
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-sevostianov-sc committed Jan 9, 2023
1 parent f0e72c6 commit 4bf6f12
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 52 deletions.
10 changes: 10 additions & 0 deletions launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,16 @@ int run(int argc, char **argv, int is_gui) {

/* compute script name from our .exe name*/
GetModuleFileNameA(NULL, script, sizeof(script));
/* resolve final path in case script name is symlink */
HANDLE hFile = CreateFile(script,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
GetFinalPathNameByHandle(hFile, script, 256, VOLUME_NAME_DOS);

end = script + strlen(script);
while( end>script && *end != '.')
*end-- = '\0';
Expand Down
5 changes: 5 additions & 0 deletions launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required (VERSION 3.17.0)
set (CMAKE_SYSTEM_VERSION 6.1 CACHE TYPE INTERNAL FORCE)
project (launcher C)
add_definitions(-DGUI -DWIN32_LEAN_AND_MEAN)
add_executable(launcher ../launcher.c)
Binary file modified setuptools/cli-32.exe
Binary file not shown.
Binary file modified setuptools/cli-64.exe
Binary file not shown.
Binary file modified setuptools/cli-arm64.exe
Binary file not shown.
Binary file modified setuptools/cli.exe
Binary file not shown.
Binary file modified setuptools/gui-32.exe
Binary file not shown.
Binary file modified setuptools/gui-64.exe
Binary file not shown.
Binary file modified setuptools/gui-arm64.exe
Binary file not shown.
Binary file modified setuptools/gui.exe
Binary file not shown.
31 changes: 12 additions & 19 deletions tools/msvc-build-launcher-arm64.cmd
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
@echo off

REM Build with jaraco/windows Docker image

set PATH_OLD=%PATH%
set PATH=C:\BuildTools\VC\Auxiliary\Build;%PATH_OLD%

REM now for arm 64-bit
REM Cross compile for arm64
call VCVARSx86_arm64
if "%ERRORLEVEL%"=="0" (
cl /D "GUI=0" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:arm64 /SUBSYSTEM:CONSOLE /out:setuptools/cli-arm64.exe
cl /D "GUI=1" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:arm64 /SUBSYSTEM:WINDOWS /out:setuptools/gui-arm64.exe
) else (
echo Visual Studio 2019 with arm64 toolchain not installed
)

set PATH=%PATH_OLD%

del -R build
mkdir build
cd build
call "cmake"
if ERRORLEVEL 1 (echo Cannot locate CMake on PATH & exit /b 2)
mkdir arm64
cd arm64
cmake -G "Visual Studio 17 2022" -A "arm64" ../../launcher
MSBuild launcher.vcxproj /t:Build /property:Configuration=Release /property:Platform=arm64 /p:OutDir="../../setuptools" /p:TargetName="cli-arm64" /p:GUI=0
MSBuild launcher.vcxproj /t:Build /property:Configuration=Release /property:Platform=arm64 /p:OutDir="../../setuptools" /p:TargetName="gui-arm64" /p:GUI=1

cd ..\..
54 changes: 21 additions & 33 deletions tools/msvc-build-launcher.cmd
Original file line number Diff line number Diff line change
@@ -1,39 +1,27 @@
@echo off

REM Use old Windows SDK 6.1 so created .exe will be compatible with
REM old Windows versions.
REM Windows SDK 6.1 may be downloaded at:
REM http://www.microsoft.com/en-us/download/details.aspx?id=11310
set PATH_OLD=%PATH%

REM The SDK creates a false install of Visual Studio at one of these locations
set PATH=C:\Program Files\Microsoft Visual Studio 9.0\VC\bin;%PATH%
set PATH=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin;%PATH%

REM set up the environment to compile to x86
call VCVARS32
if "%ERRORLEVEL%"=="0" (
cl /D "GUI=0" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:x86 /SUBSYSTEM:CONSOLE /out:setuptools/cli-32.exe
cl /D "GUI=1" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:x86 /SUBSYSTEM:WINDOWS /out:setuptools/gui-32.exe
) else (
echo Windows SDK 6.1 not found to build Windows 32-bit version
)
del -R build
mkdir build
cd build
call "cmake"
if ERRORLEVEL 1 (echo Cannot locate CMake on PATH & exit /b 2)
mkdir win32
cd win32
cmake -G "Visual Studio 17 2022" -A "Win32" ../../launcher
MSBuild launcher.vcxproj /t:Build /property:Configuration=Release /property:Platform=Win32 /p:OutDir="../../setuptools" /p:TargetName="cli-32" /p:GUI=0
MSBuild launcher.vcxproj /t:Build /property:Configuration=Release /property:Platform=Win32 /p:OutDir="../../setuptools" /p:TargetName="gui-32" /p:GUI=1

cd ..
cd ..
REM buildout (and possibly other implementations) currently depend on
REM the 32-bit launcher scripts without the -32 in the filename, so copy them
REM there for now.
copy setuptools/cli-32.exe setuptools/cli.exe
copy setuptools/gui-32.exe setuptools/gui.exe

REM now for 64-bit
REM Use the x86_amd64 profile, which is the 32-bit cross compiler for amd64
call VCVARSx86_amd64
if "%ERRORLEVEL%"=="0" (
cl /D "GUI=0" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:x64 /SUBSYSTEM:CONSOLE /out:setuptools/cli-64.exe
cl /D "GUI=1" /D "WIN32_LEAN_AND_MEAN" launcher.c /O2 /link /MACHINE:x64 /SUBSYSTEM:WINDOWS /out:setuptools/gui-64.exe
) else (
echo Windows SDK 6.1 not found to build Windows 64-bit version
)
copy setuptools\cli-32.exe setuptools\cli.exe
copy setuptools\gui-32.exe setuptools\gui.exe

set PATH=%PATH_OLD%
cd build
mkdir 64
cd 64
cmake -G "Visual Studio 17 2022" -A "x64" ../../launcher
MSBuild launcher.vcxproj /t:Build /property:Configuration=Release /property:Platform=x64 /p:OutDir="../../setuptools" /p:TargetName="cli-64" /p:GUI=0
MSBuild launcher.vcxproj /t:Build /property:Configuration=Release /property:Platform=x64 /p:OutDir="../../setuptools" /p:TargetName="gui-64" /p:GUI=1

cd ..\..

0 comments on commit 4bf6f12

Please sign in to comment.