Post reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.
Name:
Email:
Subject:
Message icon:

Verification:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?:

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

Posted by: Sam.
« on: July 05, 2015, 01:19:30 PM »

In windows, you can also use the registry to detect the processor architecture (independently of the process architecture that is calling the environmental variable):

Code: [Select]
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE
Posted by: Argent77
« on: July 05, 2015, 11:49:54 AM »

To complement K4thos' code snippets I have put together a WeiDU function that may help modders when working with external tools for multiple systems and architectures. I'll post it here for demonstration purposes. I'm also planning to add it along with more functions into future releases of my tileconv and tile2ee tools.

GET_SYSTEM_ARCH: Attempts to detect the system architecture Weidu is currently running on (in contrast to WEIDU_ARCH, which only detects the architecture of the WeiDU binary). Returns either "amd64" for 64-bit environments or "x86" for true 32-bit environments. Falls back to %WEIDU_ARCH% in case of problems.
Code: [Select]
DEFINE_ACTION_FUNCTION GET_SYSTEM_ARCH
  RET
    SYSTEM_ARCH
BEGIN
  ACTION_MATCH "%WEIDU_OS%" WITH
    win32
    BEGIN
<<<<<<<< .../a7#inlined/a7arch.bat
@echo off
if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto AMD64
if /i "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto AMD64
SET a7arch=x86
goto OUT
:AMD64
SET a7arch=amd64
:OUT
echo %a7arch%>override/a7arch.txt
>>>>>>>>
      COPY ~.../a7#inlined/a7arch.bat~ ~override/a7arch.bat~
      AT_NOW ~call override\a7arch.bat~
      DELETE + ~override/a7arch.bat~
      COPY - ~override/a7arch.txt~ ~override~
        REPLACE_EVALUATE CASE_INSENSITIVE ~amd64~ BEGIN
          SPRINT SYSTEM_ARCH ~amd64~
        END ~~
      DELETE + ~override/a7arch.txt~
    END

    osx unix
    BEGIN
      OUTER_SPRINT SYSTEM_ARCH ~x86~
      AT_NOW ~echo $(uname -m) >override/a7arch.txt~
      COPY - ~override/a7arch.txt~ ~override~
        REPLACE_EVALUATE CASE_INSENSITIVE ~x86_64~ BEGIN
          SPRINT SYSTEM_ARCH ~amd64~
        END ~~
      DELETE + ~override/a7arch.txt~
    END

    DEFAULT
  END

  ACTION_IF (~%SYSTEM_ARCH%~ STRING_EQUAL ~~) BEGIN
    OUTER_SPRINT SYSTEM_ARCH ~%WEIDU_ARCH%~
  END
END


// Patch version of GET_SYSTEM_ARCH.
DEFINE_PATCH_FUNCTION GET_SYSTEM_ARCH
  RET
    SYSTEM_ARCH
BEGIN
  INNER_PATCH ~foo~ BEGIN
    LPF GET_SYSTEM_ARCH RET SYSTEM_ARCH END
  END
END
Posted by: K4thos
« on: July 02, 2015, 10:09:35 AM »

I'm trying to assign different versions of tools based on operating system, either 32 or 64bits. Things that normally works within windows like:
Code: [Select]
::32/64Bit Switch
ECHO %PROCESSOR_ARCHITECTURE%|FINDSTR AMD64>NUL && SET arch_var=AMD64 || SET arch_var=x86
ECHO %arch_var%>arch_var.txt
or simply
Code: [Select]
ECHO arch_var=%PROCESSOR_ARCHITECTURE% >EET\arch_var.txtseems to return x86 instead of AMD64 when used in weidu with AT_NOW command. I could look for "Program Files (x86)" directory but it's not good enough evidence of anything as bad software can easily create this directory on a 32-bit machine.

Thanks in advance.

edit: I think this code is reliable and works within 32-bit weidu. %PROCESSOR_ARCHITEW6432% variable works correctly. Only %PROCESSOR_ARCHITECTURE% can't be used within 32-bit environment. Leaving the code here in case someone needs it too:
Code: [Select]
OUTER_SPRINT arch_var ~~
ACTION_IF ~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~ BEGIN
OUTER_SPRINT os_slash ~\~
OUTER_SPRINT exe ~.exe~
<<<<<<<< .../arch_var.bat
::32/64Bit Switch
ECHO %PROCESSOR_ARCHITEW6432%|FINDSTR AMD64>NUL && SET arch_var=AMD64 || SET arch_var=x86
ECHO %arch_var%>EET\arch_var.txt
>>>>>>>>
COPY ~.../arch_var.bat~ ~EET/arch_var.bat~
AT_NOW ~CALL EET\arch_var.bat~
COPY - ~EET/arch_var.txt~ ~EET~
REPLACE_EVALUATE CASE_INSENSITIVE ~AMD64~ BEGIN
SPRINT arch_var ~x86_64\~
PATCH_PRINT ~arch_var = %arch_var%~
END ~~
END ELSE BEGIN //osx and linux
OUTER_SPRINT os_slash ~/~
OUTER_SPRINT exe ~~
END

ACTION_FOR_EACH tool IN tile2ee tileconv BEGIN
OUTER_SPRINT EVAL ~%tool%~ ~EET%os_slash%bin%os_slash%%WEIDU_OS%%os_slash%%arch_var%%tool%%exe%~
PRINT ~%tool% path assigned to EET%os_slash%bin%os_slash%%WEIDU_OS%%os_slash%%arch_var%%tool%%exe%~
END