├── .gitignore ├── .gitmodules ├── README.md ├── addons └── sourcemod │ ├── extensions │ ├── fakeserver.autoload │ └── fakeserver.ext.2.csgo.so │ └── gamedata │ └── fakeslots.games.txt ├── fakenameserver.txt ├── fakeserver.txt └── source └── Rustam ├── AMBuildScript ├── AMBuilder ├── CDetour ├── detourhelpers.h ├── detours.cpp └── detours.h ├── LICENSE ├── PackageScript ├── README.md ├── Release ├── CDetour │ └── detours.o ├── asm │ └── asm.o ├── chicken_panic.ext.so ├── extension.o └── sdk │ └── smsdk_ext.o ├── ambuild ├── LICENSE ├── README.md ├── __init__.py ├── cache.py ├── command.py ├── cpp.py ├── job.py ├── osutil.py ├── runner.py ├── setup.py └── worker.py ├── ambuild2 ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── builder.cpython-38.pyc │ ├── context.cpython-38.pyc │ ├── damage.cpython-38.pyc │ ├── database.cpython-38.pyc │ ├── graph.cpython-38.pyc │ ├── make_parser.cpython-38.pyc │ ├── nodetypes.cpython-38.pyc │ ├── process_manager.cpython-38.pyc │ ├── run.cpython-38.pyc │ ├── task.cpython-38.pyc │ └── util.cpython-38.pyc ├── builder.py ├── context.py ├── damage.py ├── database.py ├── frontend │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── amb2_gen.cpython-38.pyc │ │ ├── base_generator.cpython-38.pyc │ │ ├── context_manager.cpython-38.pyc │ │ ├── paths.cpython-38.pyc │ │ └── version.cpython-38.pyc │ ├── amb2_gen.py │ ├── base_generator.py │ ├── cloneable.py │ ├── cloneable_test.py │ ├── context_manager.py │ ├── cpp │ │ ├── __init__.py │ │ ├── cpp_rules.py │ │ ├── cpp_rules_test.py │ │ ├── cpp_utils.py │ │ ├── msvc_utils.py │ │ └── verify.py │ ├── paths.py │ ├── paths_test.py │ ├── proxy.py │ ├── proxy_test.py │ ├── system.py │ ├── v2_0 │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── amb2_gen.cpython-38.pyc │ │ │ ├── context.cpython-38.pyc │ │ │ ├── context_manager.cpython-38.pyc │ │ │ └── prep.cpython-38.pyc │ │ ├── amb2_gen.py │ │ ├── context.py │ │ ├── context_manager.py │ │ ├── cpp │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── builders.cpython-38.pyc │ │ │ │ ├── compilers.cpython-38.pyc │ │ │ │ ├── detect.cpython-38.pyc │ │ │ │ └── vendors.cpython-38.pyc │ │ │ ├── builders.py │ │ │ ├── compilers.py │ │ │ ├── detect.py │ │ │ └── vendors.py │ │ ├── prep.py │ │ └── vs │ │ │ ├── __init__.py │ │ │ ├── cxx.py │ │ │ ├── export_vcxproj.py │ │ │ └── gen.py │ ├── v2_1 │ │ ├── __init__.py │ │ ├── amb2_gen.py │ │ ├── context.py │ │ ├── context_manager.py │ │ ├── cpp │ │ │ ├── __init__.py │ │ │ ├── builders.py │ │ │ ├── compiler.py │ │ │ ├── detect.py │ │ │ ├── gcc.py │ │ │ ├── msvc.py │ │ │ ├── sunpro.py │ │ │ └── vendor.py │ │ ├── prep.py │ │ ├── tools │ │ │ ├── __init__.py │ │ │ └── fxc.py │ │ └── vs │ │ │ ├── __init__.py │ │ │ ├── cxx.py │ │ │ ├── export_vcxproj.py │ │ │ ├── gen.py │ │ │ └── nodes.py │ ├── v2_2 │ │ ├── __init__.py │ │ ├── amb2_gen.py │ │ ├── context.py │ │ ├── context_manager.py │ │ ├── cpp │ │ │ ├── __init__.py │ │ │ ├── builders.py │ │ │ ├── compiler.py │ │ │ ├── deptypes.py │ │ │ ├── detect.py │ │ │ ├── gcc.py │ │ │ ├── msvc.py │ │ │ └── vendor.py │ │ ├── prep.py │ │ ├── tools │ │ │ ├── __init__.py │ │ │ └── fxc.py │ │ └── vs │ │ │ ├── __init__.py │ │ │ ├── cxx.py │ │ │ ├── export_vcxproj.py │ │ │ ├── gen.py │ │ │ └── nodes.py │ ├── version.py │ └── vs │ │ ├── __init__.py │ │ ├── gen.py │ │ ├── nodes.py │ │ └── xmlbuilder.py ├── graph.py ├── make_parser.py ├── nodetypes.py ├── process_manager.py ├── run.py ├── task.py └── util.py ├── asm ├── asm.c └── asm.h ├── configure.py ├── extension.cpp ├── extension.h ├── func.cpp ├── libudis86 ├── decode.c ├── decode.h ├── extern.h ├── itab.c ├── itab.h ├── syn-att.c ├── syn-intel.c ├── syn.c ├── syn.h ├── types.h ├── udint.h ├── udis86.c └── udis86.h ├── scripts ├── ambuild_dsymutil_wrapper.sh └── ambuild_objcopy_wrapper.sh ├── sdk ├── smsdk_config.h ├── smsdk_ext.cpp └── smsdk_ext.h ├── setup.py └── tests ├── always_dirty ├── AMBuildScript ├── configure.py └── generate.py ├── api2_2 ├── AMBuildScript ├── configure.py └── core │ ├── AMBuild │ └── main.cc ├── autoinclude ├── AMBuildScript ├── activate.txt ├── configure.py ├── generate_header.py └── main.cpp ├── cx_paths ├── AMBuildScript ├── configure.py ├── helper │ └── helper.ambuild ├── main.cpp └── program.ambuild ├── dsymutil ├── AMBuildScript ├── configure.py └── main.cpp ├── invalid_symlink ├── AMBuildScript ├── configure.py └── main.cpp ├── modules ├── AMBuildScript ├── configure.py └── core │ ├── AMBuild │ ├── m2 │ ├── AMBuild │ └── m2.cc │ ├── main.cc │ └── main2.cc ├── multiarch ├── AMBuildScript ├── configure.py └── core │ ├── AMBuild │ └── main.cpp ├── originalcwd ├── AMBuildScript └── configure.py ├── precompiled-headers ├── AMBuildScript ├── configure.py └── main.cpp ├── resource_dll ├── AMBuildScript ├── configure.py └── project_resource.rc ├── shaders ├── AMBuildScript ├── code │ ├── common.hlsl │ ├── image_common.hlsl │ ├── image_ps.hlsl │ ├── image_vs.hlsl │ ├── include-shaders.cc │ └── vs_common.hlsl └── configure.py ├── shared_outputs ├── basic │ ├── AMBuildScript │ ├── configure.py │ └── generate_header.py ├── duplicates │ ├── AMBuildScript │ ├── configure.py │ └── generate_header.py ├── mixup │ ├── AMBuildScript │ ├── configure.py │ └── generate_header.py └── multiples │ ├── AMBuildScript │ ├── configure.py │ └── generate_header.py ├── staticlib ├── AMBuildScript ├── configure.py └── main.cpp └── vcfiles ├── AMBuildScript ├── configure.py └── main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | <<<<<<< HEAD 2 | source/Rustam/build/** 3 | ======= 4 | source/Rustam/build/** 5 | >>>>>>> 75cdad49d79818f19cb51d5c08ec60432e1dc02a 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "source/mmsource-1.10"] 2 | path = source/mmsource-1.10 3 | url = https://github.com/alliedmodders/metamod-source 4 | branch = 1.10-dev 5 | [submodule "source/sourcemod"] 6 | path = source/sourcemod 7 | url = https://github.com/alliedmodders/sourcemod 8 | [submodule "source/hl2sdk-csgo"] 9 | path = source/hl2sdk-csgo 10 | url = https://github.com/alliedmodders/hl2sdk -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | https://github.com/perilouswithadollarsign/cstrike15_src/blob/master/engine/baseserver.cpp 2 | 3 | Info: 4 | 5 | I made a discord server for a support n help https://discord.gg/8VQNx5wM7f 6 | 7 | If anyone is interested to fix it, I released the source code (I dont take credit for it) of CS:GO fake server redirect extensions for everyone. To stop "business opportunity" to make money from server owners who are willing to pay to get their server spoofed as well duo spammed server browser because it has went out of control. It needs gamedata update for sure its from 2021 + some fixes to properly show fake players on the internet tab. 8 | 9 | Please submit PR I will update repo btw would be nice if someone added windows support as well :) 10 | 11 | ## Note By Gamemann 12 | ### April 12th, 2023 13 | I was able to update all signatures and some of the code with help from [Nblock](https://github.com/nblockbuster). However, this extension still doesn't work properly because the `NET_SendPacket` detour hook doesn't appear to support `A2S_*` query responses. With that said, servers on the "Internet" tab within the CS:GO server browser does **not** use the `A2S_INFO` and `A2S_PLAYERS` query responses to determine the player counts. Instead, Valve validates each client on the server through Steam and calculates the player count afterwards. Therefore, you can't technically manipulate the player count. This is not the same behavior as the "Favorites" tab on the server browser which strangely uses the `A2S_INFO` query to determine the player count which makes it easy to manipulate. 14 | 15 | This forked repository's goal is to fix outdated gamedata that requires reverse engineering knowledge to update. I am not an expert in reverse engineering, but it is an area I've been very interested in and I do have experience with. Therefore, I'm hoping to use this project as a way to dig deeper into it. 16 | 17 | With that said, sadly, CS:GO/CS2's community server browser is in a bad state and filled with many thousands of spoofed redirect servers. Valve, unfortunately, hasn't done anything to combat these issues for years (the last [meaningful server browser update in CS:GO](https://blog.counter-strike.net/index.php/2014/12/11079/) that I remember was from 2014). I plan to address these issues to Valve due to the Source 2 launch and create my own open-source server browser (Best Servers) that combats against spoofing of any kind (including A2S_INFO caching). 18 | 19 | In the meantime, I'd rather exploits/spoofing software/tools be made public so that there aren't only a handful of communities/companies utilizing them and Valve can see exactly how they're doing it. 20 | 21 | ### Signatures Updated 22 | * `CBaseServer::UpdateMasterServer` - **NT** 23 | * `Update CBaseServer::ProcessConnectionlessPacket` - **NT** 24 | * `NET_SendPacket` - **NT** 25 | * `CheckConnectionLessRateLimits` - **NT** 26 | * `CNetChan::ProcessPacket` - **NT** 27 | * `CNetChan::ProcessPacketHeader` - **NT** 28 | * `CNetChan::ProcessMessages` - **NT** 29 | * `CSteam3Server::SendUpdatedServerDetails` - **NT** 30 | * `CBaseServer::RejectConnection` - **NT** 31 | * `CBaseServer::GetNumFakeClients` - **NT** 32 | * `CBaseServer::GetMasterServerPlayerCounts` - **NT** 33 | * `CBaseServer::ForwardPacketsFromMasterServerUpdater` - **NT** 34 | * `CBaseServer::GetNumPlayers` - **NT** 35 | * `CBaseServer::GetNumProxies` - **NT** 36 | * `CBaseServer::FillServerInfo` - **NT** 37 | * `NET_ReceiveDatagram` - **NT** 38 | * `NET_ProcessSocket` - **NT** 39 | * `CBaseServer::GetNumHumanPlayers` - **NT** 40 | * `CBaseServer::GetNumClients` - **NT** 41 | * `NET_GetLoopPacket` - **NT** 42 | * `NET_LagPacket` - **NT** 43 | * `NET_DiscardStaleSplitpackets` - **NT** 44 | 45 | **T** - Tested 46 | **NT** - Not Tested 47 | 48 | ### Signatures Needing Updated 49 | * `GetIP` 50 | * `GetPort` 51 | 52 | ### Unchanged Signatures 53 | * `GetIPHostByteOrder` -------------------------------------------------------------------------------- /addons/sourcemod/extensions/fakeserver.autoload: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/addons/sourcemod/extensions/fakeserver.autoload -------------------------------------------------------------------------------- /addons/sourcemod/extensions/fakeserver.ext.2.csgo.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/addons/sourcemod/extensions/fakeserver.ext.2.csgo.so -------------------------------------------------------------------------------- /addons/sourcemod/gamedata/fakeslots.games.txt: -------------------------------------------------------------------------------- 1 | "Games" 2 | { 3 | "csgo" 4 | { 5 | "Signatures" 6 | { 7 | "CBaseServer::GetNumFakeClients" 8 | { 9 | "library" "engine" 10 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x1C\x8B\x75\x08\x8B\x86\x80\x02\x00\x00\x85\xC0\x0F\x8E\x2A\x2A\x2A\x2A\x31\xDB\x31\xD2\xEB\x2A\x83\xC3\x01\x3B\x9E\x80\x02\x00\x00\x7D\x2A\x8B\x86\x74\x02\x00\x00\x8D\x3C\x9D\x00\x00\x00\x00\x8B\x04\x98\x8B\x08\x8B\x49\x70\x81\xF9\x2A\x2A\x2A\x2A\x75\x2A\x83\xB8\x10\x02\x00\x00\x01\x0F\x9F\xC0\x84\xC0\x74\x2A\x8B\x86\x74\x02\x00\x00\x8B\x04\x38\x8B\x08\x8B\x89\x80\x00\x00\x00" 11 | } 12 | "CBaseServer::GetNumHumanPlayers" 13 | { 14 | "library" "engine" 15 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x0C\x8B\x7D\x08\x8B\x87\x80\x02\x00\x00\x85\xC0\x7E\x2A" 16 | } 17 | "CBaseServer::GetMasterServerPlayerCounts" 18 | { 19 | "library" "engine" 20 | "linux" "\x55\x89\xE5\x57\x56\x31\xF6\x53\x83\xEC\x0C\x8B\x7D\x08\x8B\x8F\x80\x02\x00\x00" 21 | } 22 | "CBaseServer::GetNumClients" 23 | { 24 | "library" "engine" 25 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x0C\x8B\x75\x08\x8B\x86\x80\x02\x00\x00" 26 | } 27 | "NET_SendPacket" 28 | { 29 | "library" "engine" 30 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x58\x35\x00\x00" 31 | } 32 | "CBaseServer::ProcessConnectionlessPacket" 33 | { 34 | "library" "engine" 35 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\xE8\x0A\x00\x00" 36 | } 37 | "CBaseServer::ForwardPacketsFromMasterServerUpdater" 38 | { 39 | "library" "engine" 40 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x5C\x40\x00\x00\x8B\x45\x08" 41 | } 42 | "CBaseServer::GetNumPlayers" 43 | { 44 | "library" "engine" 45 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x1C\x8B\x75\x08\x8B\x86\x0C\x02\x00\x00" 46 | } 47 | "CBaseServer::GetNumProxies" 48 | { 49 | "library" "engine" 50 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x1C\x8B\x75\x08\x8B\x86\x80\x02\x00\x00\x85\xC0\x0F\x8E\x2A\x2A\x2A\x2A\x31\xDB\x31\xD2\xEB\x2A\x83\xC3\x01\x3B\x9E\x80\x02\x00\x00\x7D\x2A\x8B\x86\x74\x02\x00\x00\x8D\x3C\x9D\x00\x00\x00\x00\x8B\x04\x98\x8B\x08\x8B\x49\x70\x81\xF9\x2A\x2A\x2A\x2A\x75\x2A\x83\xB8\x10\x02\x00\x00\x01\x0F\x9F\xC0\x84\xC0\x74\x2A\x8B\x86\x74\x02\x00\x00\x8B\x04\x38\x8B\x08\x8B\x89\x80\x00\x00\x00" 51 | } 52 | "CBaseServer::UpdateMasterServer" 53 | { 54 | "library" "engine" 55 | "linux" "\x55\x89\xE5\x56\x53\x83\xEC\x1C\x8B\x5D\x08\x8B\x03\x53\xFF\x90\x18\x01\x00\x00" 56 | } 57 | "CBaseServer::FillServerInfo" 58 | { 59 | "library" "engine" 60 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\xE8\x0A\x00\x00" 61 | } 62 | "GetIP" 63 | { 64 | "library" "engine" 65 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x4C\x02\x00\x00\xA1\x2A\x2A\x2A\x2A\x8B\x75\x08" 66 | } 67 | "GetPort" 68 | { 69 | "library" "engine" 70 | "linux" "\x55\x89\xE5\x8B\x45\x08\x5D\x0F\xB7\x40\x08" 71 | } 72 | "GetIPHostByteOrder" 73 | { 74 | "library" "engine" 75 | "linux" "\x55\x89\xE5\x8B\x45\x08\x5D\x8B\x40\x04\x0F\xC8" 76 | } 77 | "NET_ProcessSocket" 78 | { 79 | "library" "engine" 80 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x94\x00\x00\x00" 81 | } 82 | "NET_DiscardStaleSplitpackets" 83 | { 84 | "library" "engine" 85 | "linux" "\x55\x8D\x14\x80" 86 | } 87 | "NET_GetLoopPacket" 88 | { 89 | "library" "engine" 90 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x4C\x8B\x45\x08\x8B\x40\x20" 91 | } 92 | "NET_ReceiveDatagram" 93 | { 94 | "library" "engine" 95 | "linux" "\x55\x89\xE5\x56\x53\x83\xEC\x10\x8B\x75\x08\x8B\x5D\x0C\xEB\x2A" 96 | } 97 | "NET_LagPacket" 98 | { 99 | "library" "engine" 100 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x1C\x8B\x5D\x0C\x8B\x75\x08\x83\x7B\x20\x03" 101 | } 102 | "CheckConnectionLessRateLimits" 103 | { 104 | "library" "engine" 105 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x5C\x8B\x5D\x08\x65\xA1\x14\x00\x00\x00" 106 | } 107 | "CNetChan::ProcessPacket" 108 | { 109 | "library" "engine" 110 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\xBC\x00\x00\x00\x8B\x45\x10\x8B\x5D\x08" 111 | } 112 | "CNetChan::ProcessPacketHeader" 113 | { 114 | "library" "engine" 115 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x3C\x8B\x7D\x0C\x8B\x47\x44" 116 | } 117 | "CNetChan::ProcessMessages" 118 | { 119 | "library" "engine" 120 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x18\x8B\x1D\x2A\x2A\x2A\x2A" 121 | } 122 | "CSteam3Server::SendUpdatedServerDetails" 123 | { 124 | "library" "engine" 125 | "linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x2C\x8B\x5D\x08\x65\xA1\x14\x00\x00\x00\x89\x45\xE4\x31\xC0\x8B\x43\x04" 126 | } 127 | "CBaseServer::RejectConnection" 128 | { 129 | "library" "engine" 130 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x6C\x04\x00\x00" 131 | } 132 | } 133 | } 134 | } -------------------------------------------------------------------------------- /fakenameserver.txt: -------------------------------------------------------------------------------- 1 | "FakeNameServer" 2 | { 3 | "fakenameplayer" "rcon420" 4 | "fakenameplayer" "Dave" 5 | } -------------------------------------------------------------------------------- /fakeserver.txt: -------------------------------------------------------------------------------- 1 | "FakeServer" 2 | { 3 | "0" 4 | { 5 | "hostname" "VALVE PLS FIX :D - SourceMod Community" 6 | "online" "20" //Отображаемый онлайн на сервере. / Displayed online on the server. 7 | "realonline" "-1" //После скольки человек показывать реальных игроков (-1 - показывать всегда фейковых) / After how many people show real players (-1 - always show fake ones) 8 | "clientscale" "2" //На сколько умножаем онлайн, (-1 - показывать просто реальный онлайн) / How much do we multiply online, (-1 - just show real online) 9 | "slots" "64" //Количество слотов на сервере / Number of slots on the server 10 | "game" "JailBreak" 11 | "bot" "0" //Количество отображаемых ботов на сервере / The number of displayed bots on the server 12 | "vac" "0" //Отображать ли VAC защиту, к примеру защита включена, но для всех мы можем ее скрыть и сделать вид что выключена / Whether to display VAC protection, for example, protection is on, but for everyone we can hide it and pretend that it is off 13 | "tags" "LastRequest, achievement, ba, bhop, jail, jailbreak, jb" 14 | "redirect" "1" //Включить ли переадресацию игроков на ваш оригинальный сервер. / Whether to enable redirecting players to your original server. 15 | "redirect_ip" "11.11.1.111" //Сюда указываем IP настоящего сервера, пример / Here we indicate the IP of the real server, for example 11.11.1.111:27015 16 | } 17 | } -------------------------------------------------------------------------------- /source/Rustam/AMBuilder: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | projectName = 'fakeserver' 5 | 6 | # smsdk_ext.cpp will be automatically added later 7 | sourceFiles = [ 8 | 'extension.cpp', 9 | 'CDetour/detours.cpp', 10 | 'asm/asm.c', 11 | 'libudis86/decode.c', 12 | 'libudis86/itab.c', 13 | 'libudis86/syn-att.c', 14 | 'libudis86/syn-intel.c' , 15 | 'libudis86/syn.c' , 16 | 'libudis86/udis86.c', 17 | 'func.cpp', 18 | ] 19 | 20 | ############### 21 | # Make sure to edit PackageScript, which copies your files to their appropriate locations 22 | # Simple extensions do not need to modify past this point. 23 | 24 | project = Extension.HL2Project(builder, projectName + '.ext') 25 | 26 | if os.path.isfile(os.path.join(builder.currentSourcePath, 'sdk', 'smsdk_ext.cpp')): 27 | # Use the copy included in the project 28 | project.sources += [os.path.join('sdk', 'smsdk_ext.cpp')] 29 | else: 30 | # Use the copy included with SM 1.6 and newer 31 | project.sources += [os.path.join(Extension.sm_root, 'public', 'smsdk_ext.cpp')] 32 | 33 | project.sources += sourceFiles 34 | 35 | for sdk_name in Extension.sdks: 36 | sdk = Extension.sdks[sdk_name] 37 | 38 | binary = Extension.HL2Config(project, projectName + '.ext.' + sdk.ext, sdk) 39 | 40 | Extension.extensions = builder.Add(project) 41 | -------------------------------------------------------------------------------- /source/Rustam/CDetour/detourhelpers.h: -------------------------------------------------------------------------------- 1 | /** 2 | * vim: set ts=4 : 3 | * ============================================================================= 4 | * SourceMod 5 | * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved. 6 | * ============================================================================= 7 | * 8 | * This program is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU General Public License, version 3.0, as published by the 10 | * Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 | * details. 16 | * 17 | * You should have received a copy of the GNU General Public License along with 18 | * this program. If not, see . 19 | * 20 | * As a special exception, AlliedModders LLC gives you permission to link the 21 | * code of this program (as well as its derivative works) to "Half-Life 2," the 22 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software 23 | * by the Valve Corporation. You must obey the GNU General Public License in 24 | * all respects for all other code used. Additionally, AlliedModders LLC grants 25 | * this exception to all derivative works. AlliedModders LLC defines further 26 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), 27 | * or . 28 | * 29 | * Version: $Id: detourhelpers.h 248 2008-08-27 00:56:22Z pred $ 30 | */ 31 | 32 | #ifndef _INCLUDE_SOURCEMOD_DETOURHELPERS_H_ 33 | #define _INCLUDE_SOURCEMOD_DETOURHELPERS_H_ 34 | 35 | #if defined PLATFORM_POSIX 36 | #include 37 | #define PAGE_EXECUTE_READWRITE PROT_READ|PROT_WRITE|PROT_EXEC 38 | #endif 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | struct patch_t 46 | { 47 | patch_t() 48 | { 49 | patch[0] = 0; 50 | bytes = 0; 51 | } 52 | unsigned char patch[20]; 53 | size_t bytes; 54 | }; 55 | 56 | inline void ProtectMemory(void *addr, int length, int prot) 57 | { 58 | char error[256]; 59 | #if defined PLATFORM_POSIX 60 | long pageSize = sysconf(_SC_PAGESIZE); 61 | void *startPage = ke::AlignedBase(addr, pageSize); 62 | void *endPage = ke::AlignedBase((void *)((intptr_t)addr + length), pageSize); 63 | if (mprotect(startPage, ((intptr_t)endPage - (intptr_t)startPage) + pageSize, prot) == -1) { 64 | ke::FormatSystemError(error, sizeof(error)); 65 | fprintf(stderr, "mprotect: %s\n", error); 66 | } 67 | #elif defined PLATFORM_WINDOWS 68 | DWORD old_prot; 69 | if (!VirtualProtect(addr, length, prot, &old_prot)) { 70 | ke::FormatSystemError(error, sizeof(error)); 71 | fprintf(stderr, "VirtualProtect: %s\n", error); 72 | } 73 | #endif 74 | } 75 | 76 | inline void SetMemPatchable(void *address, size_t size) 77 | { 78 | ProtectMemory(address, (int)size, PAGE_EXECUTE_READWRITE); 79 | } 80 | 81 | inline void PatchRelJump32(unsigned char *target, void *callback) 82 | { 83 | SetMemPatchable(target, 5); 84 | 85 | // jmp <32-bit displacement> 86 | target[0] = IA32_JMP_IMM32; 87 | *(int32_t *)(&target[1]) = int32_t((unsigned char *)callback - (target + 5)); 88 | } 89 | 90 | inline void PatchAbsJump64(unsigned char *target, void *callback) 91 | { 92 | int i = 0; 93 | SetMemPatchable(target, 14); 94 | 95 | // push ; allocates 64-bit stack space on x64 96 | // mov [rsp+4], ; unnecessary if upper bits are 0 97 | // ret ; jump to address on stack 98 | target[i++] = IA32_PUSH_IMM32; 99 | *(int32_t *)(&target[i]) = int32_t(int64_t(callback)); 100 | i += 4; 101 | if ((int64_t(callback) >> 32) != 0) 102 | { 103 | target[i++] = IA32_MOV_RM_IMM32; 104 | target[i++] = ia32_modrm(MOD_DISP8, 0, kREG_SIB); 105 | target[i++] = ia32_sib(NOSCALE, kREG_NOIDX, kREG_ESP); 106 | target[i++] = 0x04; 107 | *(int32_t *)(&target[i]) = (int64_t(callback) >> 32); 108 | i += 4; 109 | } 110 | target[i] = IA32_RET; 111 | } 112 | 113 | inline void DoGatePatch(unsigned char *target, void *callback) 114 | { 115 | #if defined(_WIN64) || defined(__x86_64__) 116 | int64_t diff = int64_t(callback) - (int64_t(target) + 5); 117 | int32_t upperBits = (diff >> 32); 118 | if (upperBits == 0 || upperBits == -1) 119 | PatchRelJump32(target, callback); 120 | else 121 | PatchAbsJump64(target, callback); 122 | #else 123 | PatchRelJump32(target, callback); 124 | #endif 125 | } 126 | 127 | inline void ApplyPatch(void *address, int offset, const patch_t *patch, patch_t *restore) 128 | { 129 | unsigned char *addr = (unsigned char *)address + offset; 130 | SetMemPatchable(addr, patch->bytes); 131 | 132 | if (restore) 133 | { 134 | for (size_t i=0; ibytes; i++) 135 | { 136 | restore->patch[i] = addr[i]; 137 | } 138 | restore->bytes = patch->bytes; 139 | } 140 | 141 | for (size_t i=0; ibytes; i++) 142 | { 143 | addr[i] = patch->patch[i]; 144 | } 145 | } 146 | 147 | #endif //_INCLUDE_SOURCEMOD_DETOURHELPERS_H_ 148 | -------------------------------------------------------------------------------- /source/Rustam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 AlliedModders LLC 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation and/or 11 | other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without 15 | specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /source/Rustam/PackageScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et ft=python: 2 | import os 3 | 4 | # This is where the files will be output to 5 | # package is the default 6 | builder.SetBuildFolder('package') 7 | 8 | # Add any folders you need to this list 9 | folder_list = [ 10 | 'addons/sourcemod/extensions', 11 | #'addons/sourcemod/scripting/include', 12 | #'addons/sourcemod/gamedata', 13 | #'addons/sourcemod/configs', 14 | ] 15 | 16 | # Create the distribution folder hierarchy. 17 | folder_map = {} 18 | for folder in folder_list: 19 | norm_folder = os.path.normpath(folder) 20 | folder_map[folder] = builder.AddFolder(norm_folder) 21 | 22 | # Do all straight-up file copies from the source tree. 23 | def CopyFiles(src, dest, files): 24 | if not dest: 25 | dest = src 26 | dest_entry = folder_map[dest] 27 | for source_file in files: 28 | source_path = os.path.join(builder.sourcePath, src, source_file) 29 | builder.AddCopy(source_path, dest_entry) 30 | 31 | # Include files 32 | #CopyFiles('include', 'addons/sourcemod/scripting/include', 33 | # [ 'sample.inc', ] 34 | #) 35 | 36 | # GameData files 37 | #CopyFiles('gamedata', 'addons/sourcemod/gamedata', 38 | # [ 'myfile.txt', 39 | # 'file2.txt' 40 | # ] 41 | #) 42 | 43 | # Config Files 44 | #CopyFiles('configs', 'addons/sourcemod/configs', 45 | # [ 'configfile.cfg', 46 | # 'otherconfig.cfg, 47 | # ] 48 | #) 49 | 50 | # Copy binaries. 51 | for cxx_task in Extension.extensions: 52 | builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions']) 53 | -------------------------------------------------------------------------------- /source/Rustam/README.md: -------------------------------------------------------------------------------- 1 | AMBuild is a lightweight build system designed for performance and accuracy. It is geared toward C/C++ projects which require programmatic flexibility in their builds and precise control over C/C++ compiler flags. 2 | 3 | AMBuild requires either Python 3 or Python 2.7. 4 | 5 | For more information, see: https://wiki.alliedmods.net/AMBuild 6 | 7 | # Installation 8 | 9 | ``` 10 | git clone https://github.com/alliedmodders/ambuild 11 | pip install ./ambuild 12 | ``` 13 | 14 | # AMBuild 2 15 | 16 | AMBuild 2 is a highly efficient build system designed to replace ["Alpha"-generation tools][1], such as SCons or Make. It is not a replacement for IDE project files, nor is it a front-end tool for generating other build system files, such as CMake. AMBuild is designed with three features in mind: 17 | 18 | * Accuracy. AMBuild guarantees that you never need to "clean" a build. Incremental builds should always produce the same exact result as a clean build; anything less is asking for trouble, and rebuilds are a waste of developer time. 19 | * Speed. Many build systems need to traverse the entire dependency graph. AMBuild only needs to find which files have changed. In addition, AMBuild will parallelize any independent tasks. 20 | * Programmability. Build scripts are written in Python, affording a great deal of flexibility for describing the build process. 21 | 22 | Build scripts for AMBuild are parsed once upon configuration, and are responsible for defining tasks. If build scripts change, the build is automatically reconfigured. Out of box, build scripts support the following actions: 23 | * C/C++ compilation, linking, .rc compilation, and producing symbol files for symstore/breakpad. 24 | * File copying or symlinking for packaging. 25 | * Arbitrary shell commands. 26 | 27 | # AMBuild 1 28 | 29 | AMBuild 1 was intended as a replacement for build systems such as SCons or Make. Its syntax is easier than Make and handles C/C++ dependencies automatically. Like most build systems, it performs a full recursive search for outdated files, which can make it slower for dependency graphs with many edges. It has no multiprocess support. Also unlike AMBuild 2, the dependency graph is not saved in between builds, which greatly reduces its incremental build accuracy and speed. 30 | C 31 | AMBuild 1 is installed alongside AMBuild 2 for backward compatibility, however it resides in an older namespace and has a completely separate API. 32 | 33 | # Contributing 34 | 35 | AMBuild is written in Python. All changes must be Python 2.7 compatible, since it is used on some very old machines. 36 | 37 | Code is formatted using YAPF. If GitHub tells you there are style issues, you can use "yapf -r -i ." to fix them. You can get YAPF with pip ("pip install yapf"). 38 | 39 | Bugfixes are welcome, including to older API versions. New features are only added to the newest API. 40 | 41 | AlliedModders developers can often be found in IRC (irc.gamesurge.net, #smdevs) if you have questions. 42 | 43 | # References 44 | 45 | [1]: "Build System Rules and Algorithms by Mike Shal" 46 | -------------------------------------------------------------------------------- /source/Rustam/Release/CDetour/detours.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/Release/CDetour/detours.o -------------------------------------------------------------------------------- /source/Rustam/Release/asm/asm.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/Release/asm/asm.o -------------------------------------------------------------------------------- /source/Rustam/Release/chicken_panic.ext.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/Release/chicken_panic.ext.so -------------------------------------------------------------------------------- /source/Rustam/Release/extension.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/Release/extension.o -------------------------------------------------------------------------------- /source/Rustam/Release/sdk/smsdk_ext.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/Release/sdk/smsdk_ext.o -------------------------------------------------------------------------------- /source/Rustam/ambuild/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 AlliedModders LLC 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation and/or 11 | other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without 15 | specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /source/Rustam/ambuild/README.md: -------------------------------------------------------------------------------- 1 | AMBuild is a lightweight build system designed for performance and accuracy. It is geared toward C/C++ projects which require programmatic flexibility in their builds and precise control over C/C++ compiler flags. 2 | 3 | AMBuild requires either Python 3 or Python 2.7. 4 | 5 | For more information, see: https://wiki.alliedmods.net/AMBuild 6 | 7 | # Installation 8 | 9 | ``` 10 | git clone https://github.com/alliedmodders/ambuild 11 | pip install ./ambuild 12 | ``` 13 | 14 | # AMBuild 2 15 | 16 | AMBuild 2 is a highly efficient build system designed to replace ["Alpha"-generation tools][1], such as SCons or Make. It is not a replacement for IDE project files, nor is it a front-end tool for generating other build system files, such as CMake. AMBuild is designed with three features in mind: 17 | 18 | * Accuracy. AMBuild guarantees that you never need to "clean" a build. Incremental builds should always produce the same exact result as a clean build; anything less is asking for trouble, and rebuilds are a waste of developer time. 19 | * Speed. Many build systems need to traverse the entire dependency graph. AMBuild only needs to find which files have changed. In addition, AMBuild will parallelize any independent tasks. 20 | * Programmability. Build scripts are written in Python, affording a great deal of flexibility for describing the build process. 21 | 22 | Build scripts for AMBuild are parsed once upon configuration, and are responsible for defining tasks. If build scripts change, the build is automatically reconfigured. Out of box, build scripts support the following actions: 23 | * C/C++ compilation, linking, .rc compilation, and producing symbol files for symstore/breakpad. 24 | * File copying or symlinking for packaging. 25 | * Arbitrary shell commands. 26 | 27 | # AMBuild 1 28 | 29 | AMBuild 1 was intended as a replacement for build systems such as SCons or Make. Its syntax is easier than Make and handles C/C++ dependencies automatically. Like most build systems, it performs a full recursive search for outdated files, which can make it slower for dependency graphs with many edges. It has no multiprocess support. Also unlike AMBuild 2, the dependency graph is not saved in between builds, which greatly reduces its incremental build accuracy and speed. 30 | C 31 | AMBuild 1 is installed alongside AMBuild 2 for backward compatibility, however it resides in an older namespace and has a completely separate API. 32 | 33 | # Contributing 34 | 35 | AMBuild is written in Python. All changes must be Python 2.7 compatible, since it is used on some very old machines. 36 | 37 | Code is formatted using YAPF. If GitHub tells you there are style issues, you can use "yapf -r -i ." to fix them. You can get YAPF with pip ("pip install yapf"). 38 | 39 | Bugfixes are welcome, including to older API versions. New features are only added to the newest API. 40 | 41 | AlliedModders developers can often be found in IRC (irc.gamesurge.net, #smdevs) if you have questions. 42 | 43 | # References 44 | 45 | [1]: "Build System Rules and Algorithms by Mike Shal" 46 | -------------------------------------------------------------------------------- /source/Rustam/ambuild/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild/cache.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 noet: 2 | import os 3 | import pickle 4 | 5 | class Cache: 6 | def __init__(self, path): 7 | self.vars = { } 8 | self.path = path 9 | 10 | def CacheVariable(self, name, value): 11 | self.vars[name] = value 12 | 13 | def WriteCache(self): 14 | f = open(self.path, 'wb') 15 | try: 16 | pickle.dump(self.vars, f) 17 | except Exception as e: 18 | raise e 19 | finally: 20 | f.close() 21 | 22 | def LoadCache(self): 23 | f = open(self.path, 'rb') 24 | try: 25 | self.vars = pickle.load(f) 26 | except Exception as e: 27 | f.close() 28 | raise e 29 | f.close() 30 | 31 | def HasVariable(self, key): 32 | return key in self.vars 33 | 34 | def __getitem__(self, key): 35 | return self.vars[key] 36 | 37 | -------------------------------------------------------------------------------- /source/Rustam/ambuild/command.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 noet: 2 | import os 3 | import sys 4 | import shutil 5 | import subprocess 6 | import ambuild.osutil as osutil 7 | 8 | class Command: 9 | def __init__(self): 10 | self.stderr = None 11 | self.stdout = None 12 | self.failureIsFatal = True 13 | def run(self, master, job): 14 | pass 15 | def spew(self, runner): 16 | if self.stdout != None and len(self.stdout) > 0: 17 | runner.PrintOut(self.stdout) 18 | if self.stderr != None and len(self.stderr) > 0: 19 | runner.PrintOut(self.stderr) 20 | 21 | class SymlinkCommand(Command): 22 | def __init__(self, link, target): 23 | Command.__init__(self) 24 | self.link = link 25 | self.target = target 26 | def run(self, master, job): 27 | master.PrintOut('symlinking {0} as {1}'.format(self.target, self.link)) 28 | try: 29 | os.symlink(self.target, self.link) 30 | except: 31 | master.PrintOut('symlinking failed; copying instead, {0} as {1}'.format(self.target, self.link)) 32 | shutil.copyfile(self.target, self.link) 33 | 34 | class ShellCommand(Command): 35 | def __init__(self, cmdstring, failureIsFatal = True): 36 | Command.__init__(self) 37 | self.cmdstring = cmdstring 38 | self.failureIsFatal = failureIsFatal 39 | def run(self, master, job): 40 | master.PrintOut(self.cmdstring) 41 | args = { 'args': self.cmdstring, 42 | 'stdout': subprocess.PIPE, 43 | 'stderr': subprocess.PIPE, 44 | 'shell': True } 45 | p = subprocess.Popen(**args) 46 | stdout, stderr = p.communicate() 47 | self.stdout = osutil.DecodeConsoleText(sys.stdout, stdout) 48 | self.stderr = osutil.DecodeConsoleText(sys.stderr, stderr) 49 | if p.returncode != 0: 50 | raise Exception('terminated with non-zero exitcode {0}'.format(p.returncode)) 51 | 52 | class DirectCommand(Command): 53 | def __init__(self, argv, exe = None, failureIsFatal = True, env = None): 54 | Command.__init__(self) 55 | self.exe = exe 56 | self.argv = argv 57 | self.failureIsFatal = failureIsFatal 58 | self.env = env 59 | def run(self, runner, job): 60 | runner.PrintOut(' '.join(['"' + i + '"' for i in self.argv])) 61 | args = { 'args': self.argv, 62 | 'stdout': subprocess.PIPE, 63 | 'stderr': subprocess.PIPE, 64 | 'shell': False } 65 | if self.env != None: 66 | args['env'] = self.env 67 | if self.exe != None: 68 | args['executable'] = self.exe 69 | p = subprocess.Popen(**args) 70 | stdout, stderr = p.communicate() 71 | self.stdout = osutil.DecodeConsoleText(sys.stdout, stdout) 72 | self.stderr = osutil.DecodeConsoleText(sys.stderr, stderr) 73 | if p.returncode != 0: 74 | raise Exception('failure: program terminated with non-zero exitcode {0}'.format(p.returncode)) 75 | 76 | def RunDirectCommand(runner, argv, exe = None): 77 | runner.PrintOut(' '.join([i for i in argv])) 78 | args = {'args': argv, 79 | 'stdout': subprocess.PIPE, 80 | 'stderr': subprocess.PIPE, 81 | 'shell': False} 82 | if exe != None: 83 | argv['executable'] = exe 84 | p = subprocess.Popen(**args) 85 | stdout, stderr = p.communicate() 86 | p.stdoutText = osutil.DecodeConsoleText(sys.stdout, stdout) 87 | p.stderrText = osutil.DecodeConsoleText(sys.stderr, stderr) 88 | p.realout = stdout 89 | p.realerr = stderr 90 | return p 91 | 92 | -------------------------------------------------------------------------------- /source/Rustam/ambuild/job.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 noet: 2 | import os 3 | import traceback 4 | import ambuild.worker as worker 5 | from ambuild.cache import Cache 6 | from ambuild.command import Command 7 | 8 | class TaskGroup: 9 | def __init__(self, cmds, mustBeSerial = True): 10 | self.cmds = cmds 11 | self.mustBeSerial = mustBeSerial 12 | 13 | class AsyncRun: 14 | def __init__(self, master, job, task): 15 | self.master = master 16 | self.task = task 17 | self.job = job 18 | def run(self): 19 | spewed = False 20 | try: 21 | self.task.run(self.master, self.job) 22 | spewed = True 23 | self.task.spew(self.master) 24 | except Exception as e: 25 | try: 26 | if not spewed: 27 | self.task.spew(self.master) 28 | except: 29 | pass 30 | raise Exception(str(e) + '\n' + traceback.format_exc()) 31 | 32 | class Job: 33 | def __init__(self, runner, name, workFolder = None): 34 | self.tasks = [] 35 | self.name = name 36 | self.runner = runner 37 | if workFolder == None: 38 | self.workFolder = name 39 | else: 40 | self.workFolder = workFolder 41 | self.cache = Cache(os.path.join(runner.outputFolder, '.ambuild', name + '.cache')) 42 | #ignore if cache file doesnt exist yet 43 | try: 44 | self.cache.LoadCache() 45 | except: 46 | pass 47 | 48 | def CacheVariable(self, key, value): 49 | self.cache.CacheVariable(key, value) 50 | 51 | def HasVariable(self, key): 52 | return self.cache.HasVariable(key) 53 | 54 | def GetVariable(self, key): 55 | return self.cache[key] 56 | 57 | def AddCommand(self, cmd): 58 | if not isinstance(cmd, Command): 59 | raise Exception('task is not a Command') 60 | self.tasks.append(TaskGroup([cmd])) 61 | 62 | def AddCommandGroup(self, cmds, mustBeSerial = True): 63 | if not isinstance(cmds, list): 64 | raise Exception('tasks are not in a list') 65 | self.tasks.append(TaskGroup(cmds, mustBeSerial)) 66 | 67 | def run(self, master): 68 | for group in self.tasks: 69 | if 1: #group.mustBeSerial: 70 | for task in group.cmds: 71 | r = AsyncRun(master, self, task) 72 | try: 73 | r.run() 74 | except Exception as e: 75 | self.cache.WriteCache() 76 | raise e 77 | self.cache.WriteCache() 78 | else: 79 | pool = worker.WorkerPool(master.numCPUs * 4) 80 | tasks = [AsyncRun(master, self, task) for task in group.cmds] 81 | failed = pool.RunJobs(tasks) 82 | self.cache.WriteCache() 83 | if len(failed) > 0: 84 | raise failed[0]['e'] 85 | 86 | -------------------------------------------------------------------------------- /source/Rustam/ambuild/osutil.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 noet: 2 | import os 3 | import sys 4 | import locale 5 | import subprocess 6 | import multiprocessing 7 | 8 | def IsWindows(): 9 | return sys.platform == 'win32' or sys.platform == 'cygwin' 10 | 11 | def IsMac(): 12 | return sys.platform == 'darwin' 13 | 14 | def IsUnixy(): 15 | return sys.platform[0:5] == 'linux' or IsMac() 16 | 17 | def ExecutableSuffix(): 18 | if IsWindows(): 19 | return '.exe' 20 | else: 21 | return '' 22 | 23 | def SharedLibSuffix(): 24 | if IsWindows(): 25 | return '.dll' 26 | elif sys.platform == 'darwin': 27 | return '.dylib' 28 | else: 29 | return '.so' 30 | 31 | def StaticLibSuffix(): 32 | if IsUnixy(): 33 | return '.a' 34 | return '.lib' 35 | 36 | def StaticLibPrefix(): 37 | if IsWindows(): 38 | return '' 39 | else: 40 | return 'lib' 41 | 42 | def DecodeConsoleText(origin, text): 43 | try: 44 | if origin.encoding: 45 | return text.decode(origin.encoding, 'replace') 46 | except: 47 | pass 48 | try: 49 | return text.decode(locale.getpreferredencoding(), 'replace') 50 | except: 51 | pass 52 | return text.decode('utf8', 'replace') 53 | 54 | def WaitForProcess(process): 55 | out, err = process.communicate() 56 | process.stdoutText = DecodeConsoleText(sys.stdout, out) 57 | process.stderrText = DecodeConsoleText(sys.stderr, err) 58 | return process.returncode 59 | 60 | def CreateProcess(argv, executable = None): 61 | pargs = { 'args': argv } 62 | pargs['stdout'] = subprocess.PIPE 63 | pargs['stderr'] = subprocess.PIPE 64 | if executable != None: 65 | pargs['executable'] = executable 66 | try: 67 | process = subprocess.Popen(**pargs) 68 | except: 69 | return None 70 | return process 71 | 72 | def MakePath(*list): 73 | path = os.path.join(*list) 74 | if IsWindows(): 75 | path = path.replace('\\\\', '\\') 76 | return path 77 | 78 | def RemoveFolderAndContents(path): 79 | for file in os.listdir(path): 80 | subpath = os.path.join(path, file) 81 | try: 82 | if os.path.isfile(subpath) or os.path.islink(subpath): 83 | os.unlink(subpath) 84 | elif os.path.isdir(subpath): 85 | RemoveFolderAndContents(subpath) 86 | except: 87 | pass 88 | os.rmdir(path) 89 | 90 | Folders = [] 91 | def PushFolder(path): 92 | Folders.append(os.path.abspath(os.getcwd())) 93 | os.chdir(path) 94 | 95 | def PopFolder(): 96 | os.chdir(Folders.pop()) 97 | 98 | def NumberOfCPUs(): 99 | return multiprocessing.cpu_count() 100 | 101 | def FileExists(file): 102 | if os.path.isfile(file): 103 | GetFileTime(file) 104 | return True 105 | return False 106 | 107 | def GetFileTime(file): 108 | time = os.path.getmtime(file) 109 | return time 110 | 111 | def IsFileNewer(this, that): 112 | this = GetFileTime(this) 113 | if type(that) == str: 114 | that = GetFileTime(that) 115 | return this > that 116 | 117 | -------------------------------------------------------------------------------- /source/Rustam/ambuild/runner.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 noet: 2 | from __future__ import print_function 3 | import sys 4 | import os 5 | import ambuild.osutil as osutil 6 | from ambuild.job import Job 7 | import ambuild.cache as cache 8 | import ambuild.cpp as cpp 9 | from optparse import OptionParser 10 | 11 | def _execfile(file, globals): 12 | exec(compile(open(file).read(), file, 'exec'), globals) 13 | 14 | class Runner: 15 | def __init__(self): 16 | self.jobs = [] 17 | self.options = OptionParser() 18 | self.target = { } 19 | self.numCPUs = osutil.NumberOfCPUs() 20 | self.quietAdd = False 21 | if osutil.IsWindows(): 22 | self.target['platform'] = 'windows' 23 | elif sys.platform.startswith('linux'): 24 | self.target['platform'] = 'linux' 25 | elif sys.platform.startswith('darwin'): 26 | self.target['platform'] = 'darwin' 27 | 28 | def PrintOut(self, text): 29 | print(text) 30 | 31 | def AddJob(self, name, workFolder = None): 32 | if not self.quietAdd: 33 | print('Adding job {0}.'.format(name)) 34 | job = Job(self, name, workFolder) 35 | self.jobs.append(job) 36 | return job 37 | 38 | def ListJobs(self): 39 | print("Listing {0} jobs...".format(len(self.jobs))) 40 | for job in self.jobs: 41 | print(job.name) 42 | 43 | def RunJobs(self, jobs): 44 | for job in jobs: 45 | print('Running job: {0}...'.format(job.name)) 46 | if job.workFolder != None: 47 | workFolder = os.path.join(self.outputFolder, job.workFolder) 48 | if not os.path.isdir(workFolder): 49 | os.makedirs(workFolder) 50 | osutil.PushFolder(workFolder) 51 | try: 52 | job.run(self) 53 | except Exception as e: 54 | print('Job failed: {0}'.format(str(e))) 55 | sys.exit(1) 56 | if job.workFolder != None: 57 | osutil.PopFolder() 58 | print('Completed job: {0}.'.format(job.name)) 59 | 60 | def CallerScript(self, num = 1): 61 | return sys._getframe(num).f_code.co_filename 62 | 63 | def Build(self): 64 | self.mode = 'build' 65 | (options, args) = self.options.parse_args() 66 | argn = len(args) 67 | self.quietAdd = options.list == True or argn > 0 68 | self.outputFolder = os.path.abspath(os.getcwd()) 69 | cacheFolder = os.path.join(self.outputFolder, '.ambuild') 70 | if not os.path.isdir(cacheFolder): 71 | raise Exception('could not find .ambuild folder') 72 | cacheFile = os.path.join(cacheFolder, 'cache') 73 | if not os.path.isfile(cacheFile): 74 | raise Exception('could not find .ambuild cache file') 75 | self.cache = cache.Cache(cacheFile) 76 | self.cache.LoadCache() 77 | self.sourceFolder = self.cache['sourceFolder'] 78 | self.LoadFile(os.path.join(self.sourceFolder, 'AMBuildScript')) 79 | if options.list: 80 | self.ListJobs() 81 | return 82 | jobs = [] 83 | if argn > 0: 84 | # Run jobs in order specified on command line 85 | for j in args: 86 | validJob = False 87 | for job in self.jobs: 88 | if job.name == j: 89 | jobs.append(job) 90 | validJob = True 91 | break 92 | if not validJob: 93 | raise Exception('{0} is not a valid job name'.format(j)) 94 | else: 95 | jobs = self.jobs 96 | self.RunJobs(jobs) 97 | 98 | def Configure(self, folder): 99 | self.mode = 'config' 100 | (options, args) = self.options.parse_args() 101 | self.options = options 102 | self.args = args 103 | self.sourceFolder = os.path.abspath(folder) 104 | self.outputFolder = os.path.abspath(os.getcwd()) 105 | cacheFolder = os.path.join(self.outputFolder, '.ambuild') 106 | if os.path.isdir(cacheFolder): 107 | osutil.RemoveFolderAndContents(cacheFolder) 108 | os.mkdir(cacheFolder) 109 | if not os.path.isdir(cacheFolder): 110 | raise Exception('could not create .ambuild folder') 111 | self.cache = cache.Cache(os.path.join(cacheFolder, 'cache')) 112 | self.cache.CacheVariable('sourceFolder', self.sourceFolder) 113 | self.LoadFile(os.path.join(self.sourceFolder, 'AMBuildScript')) 114 | self.cache.WriteCache() 115 | f = open(os.path.join(self.outputFolder, 'build.py'), 'w') 116 | f.write(""" 117 | # vim: set ts=2 sw=2 tw=99 noet: 118 | import sys 119 | import ambuild.runner as runner 120 | 121 | run = runner.Runner() 122 | run.options.usage = '%prog [options] [job list]' 123 | run.options.add_option('-l', '--list-jobs', action='store_true', dest='list', help='print list of jobs') 124 | run.Build() 125 | """) 126 | 127 | def Include(self, path, xtras = None): 128 | self.LoadFile(os.path.join(self.sourceFolder, path), xtras) 129 | 130 | def LoadFile(self, path, xtras = None): 131 | globals = { 132 | 'AMBuild': self, 133 | 'Cpp': cpp 134 | } 135 | if xtras != None: 136 | globals.update(xtras) 137 | _execfile(path, globals) 138 | 139 | -------------------------------------------------------------------------------- /source/Rustam/ambuild/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # vim: set ts=2 sw=2 tw=99 et: 3 | 4 | import sys 5 | 6 | def detect_distutils(): 7 | sys.path.pop(0) 8 | try: 9 | import ambuild2.util 10 | try: 11 | val = getattr(ambuild2.util, 'INSTALLED_BY_PIP_OR_SETUPTOOLS') 12 | except AttributeError: 13 | sys.exit(1) 14 | except ImportError: 15 | pass 16 | 17 | sys.exit(0) 18 | 19 | # This if statement is supposedly required by multiprocessing. 20 | if __name__ == '__main__': 21 | import os 22 | import multiprocessing as mp 23 | 24 | mp.freeze_support() 25 | proc = mp.Process(target = detect_distutils) 26 | proc.start() 27 | proc.join() 28 | 29 | if proc.exitcode != 0: 30 | sys.stderr.write("You have an older installation of AMBuild. AMBuild must\n") 31 | sys.stderr.write("now be installed using pip (see README.md). To prevent\n") 32 | sys.stderr.write("conflicts, please remove the old distutils version. You can\n") 33 | sys.stderr.write("do this by inspecting the following paths and removing\n") 34 | sys.stderr.write("any ambuild folders:\n") 35 | 36 | for path in sys.path[1:]: 37 | for subdir in ['ambuild', 'ambuild2']: 38 | subpath = os.path.join(path, subdir) 39 | if os.path.exists(subpath): 40 | sys.stderr.write('\t{}\n'.format(subpath)) 41 | 42 | sys.stderr.write('Aborting installation.\n') 43 | sys.stderr.flush() 44 | sys.exit(1) 45 | 46 | from setuptools import setup, find_packages 47 | try: 48 | import sqlite3 49 | except: 50 | raise SystemError('py-sqlite3 must be installed') 51 | 52 | amb_scripts = [] 53 | if sys.platform != 'win32': 54 | if sys.platform == 'darwin': 55 | amb_scripts.append('scripts/ambuild_dsymutil_wrapper.sh') 56 | else: 57 | amb_scripts.append('scripts/ambuild_objcopy_wrapper.sh') 58 | 59 | setup(name = 'AMBuild', 60 | version = '2.0', 61 | description = 'AlliedModders Build System', 62 | author = 'David Anderson', 63 | author_email = 'dvander@alliedmods.net', 64 | url = 'http://www.alliedmods.net/ambuild', 65 | packages = find_packages(), 66 | python_requires = '>=2.6', 67 | entry_points = {'console_scripts': ['ambuild = ambuild2.run:cli_run']}, 68 | scripts = amb_scripts, 69 | zip_safe = False) 70 | -------------------------------------------------------------------------------- /source/Rustam/ambuild/worker.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 noet: 2 | import threading 3 | 4 | class Worker: 5 | def __call__(self): 6 | while len(self.jobs): 7 | try: 8 | job = self.jobs.pop() 9 | job.run() 10 | except KeyboardInterrupt as ki: 11 | return 12 | except Exception as e: 13 | self.e = e 14 | self.failedJob = job 15 | 16 | class WorkerPool: 17 | def __init__(self, numWorkers): 18 | self.numWorkers = numWorkers 19 | self.workers = [] 20 | for i in range(0, self.numWorkers): 21 | self.workers.append(Worker()) 22 | 23 | def RunJobs(self, jobs): 24 | for w in self.workers: 25 | w.failedJob = None 26 | w.e = None 27 | w.jobs = [] 28 | w.thread = threading.Thread(target = w) 29 | 30 | #Divvy up jobs 31 | num = 0 32 | for i in jobs: 33 | self.workers[num].jobs.append(i) 34 | num = num + 1 35 | if num == self.numWorkers: 36 | num = 0 37 | 38 | #Start up each thread 39 | for w in self.workers: 40 | w.thread.start() 41 | 42 | #Wait for threads to finish 43 | failed = [] 44 | for w in self.workers: 45 | w.thread.join() 46 | if w.failedJob != None or w.e != None: 47 | failed.append({'job': w.failedJob, 'e': w.e}) 48 | 49 | return failed 50 | 51 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/builder.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/context.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/context.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/damage.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/damage.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/database.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/database.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/graph.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/graph.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/make_parser.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/make_parser.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/nodetypes.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/nodetypes.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/process_manager.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/process_manager.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/run.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/run.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/task.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/task.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/__pycache__/util.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/__pycache__/util.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/damage.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import os 18 | import sys 19 | from ambuild2 import nodetypes 20 | from ambuild2.graph import Graph 21 | 22 | def ComputeSourceDirty(node): 23 | if not os.path.exists(node.path): 24 | return True 25 | 26 | return os.path.getmtime(node.path) != node.stamp 27 | 28 | def ComputeOutputDirty(node): 29 | if not os.path.exists(node.path): 30 | return True 31 | 32 | # If the timestamp on the object file has changed, then one of two things 33 | # happened: 34 | # (1) The build command completed, but the build process crashed, and we 35 | # never got a chance to update the timestamp. 36 | # (2) The file was modified behind our back. 37 | # 38 | # In the first case, our preceding command node will not have been undirtied, 39 | # so we should be able to find our incoming command in the graph. However, 40 | # case #2 breaks that guarantee. To be safe, if the timestamp has changed, 41 | # we mark the node as dirty. 42 | stamp = os.path.getmtime(node.path) 43 | return stamp != node.stamp 44 | 45 | def ComputeDirty(node): 46 | if node.type == nodetypes.Source: 47 | dirty = ComputeSourceDirty(node) 48 | elif node.type == nodetypes.Output: 49 | dirty = ComputeOutputDirty(node) 50 | else: 51 | raise Exception('cannot compute dirty bit for node type: ' + node.type) 52 | return dirty 53 | 54 | def ComputeDamageGraph(database, only_changed = False): 55 | graph = Graph(database) 56 | 57 | def maybe_mkdir(node): 58 | if not os.path.exists(node.path): 59 | graph.create.append(node) 60 | 61 | database.query_mkdir(maybe_mkdir) 62 | 63 | dirty = [] 64 | 65 | def maybe_add_dirty(node): 66 | if ComputeDirty(node): 67 | database.mark_dirty(node) 68 | dirty.append(node) 69 | 70 | database.query_known_dirty(lambda node: dirty.append(node)) 71 | database.query_maybe_dirty(maybe_add_dirty) 72 | 73 | if only_changed: 74 | return dirty 75 | 76 | for entry in dirty: 77 | if entry.type == nodetypes.Output: 78 | # Ensure that our command has been marked as dirty. 79 | incoming = database.query_strong_inputs(entry) 80 | incoming |= database.query_dynamic_inputs(entry) 81 | 82 | # There should really only be one command to generate an output. 83 | if len(incoming) != 1: 84 | sys.stderr.write('Error in dependency graph: an output has multiple inputs.') 85 | sys.stderr.write('Output: {0}'.format(entry.format())) 86 | return None 87 | 88 | for cmd in incoming: 89 | graph.addEntry(cmd) 90 | else: 91 | graph.addEntry(entry) 92 | 93 | graph.finish() 94 | 95 | # Find all leaf commands in the graph and mark them as dirty. This ensures 96 | # that we'll include them in the next damage graph. In theory, all leaf 97 | # commands should *already* be dirty, so this is just in case. 98 | def finish_mark_dirty(entry): 99 | if entry.dirty == nodetypes.NOT_DIRTY: 100 | # Mark this node as dirty in the DB so we don't have to check the 101 | # filesystem next time. 102 | database.mark_dirty(entry) 103 | 104 | graph.for_each_leaf_command(finish_mark_dirty) 105 | 106 | return graph 107 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/__pycache__/amb2_gen.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/__pycache__/amb2_gen.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/__pycache__/base_generator.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/__pycache__/base_generator.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/__pycache__/context_manager.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/__pycache__/context_manager.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/__pycache__/paths.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/__pycache__/paths.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/__pycache__/version.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/__pycache__/version.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/base_generator.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | class BaseGenerator(object): 18 | def __init__(self, cm): 19 | self.cm = cm 20 | 21 | @property 22 | def backend(self): 23 | raise Exception('Must be implemented!') 24 | 25 | def addSymlink(self, context, source, output_path): 26 | raise Exception('Must be implemented!') 27 | 28 | def addFolder(self, context, folder): 29 | raise Exception('Must be implemented!') 30 | 31 | def addCopy(self, context, source, output_path): 32 | raise Exception('Must be implemented!') 33 | 34 | def addShellCommand(self, 35 | context, 36 | inputs, 37 | argv, 38 | outputs, 39 | folder = -1, 40 | dep_type = None, 41 | weak_inputs = [], 42 | shared_outputs = [], 43 | env_data = None): 44 | raise Exception('Must be implemented!') 45 | 46 | def addConfigureFile(self, context, path): 47 | raise Exception('Must be implemented!') 48 | 49 | # The following methods are only needed to implement v2.2 generators. 50 | def newProgramProject(self, context, name): 51 | raise NotImplementedError() 52 | 53 | def newLibraryProject(self, context, name): 54 | raise NotImplementedError() 55 | 56 | def newStaticLibraryProject(self, context, name): 57 | raise NotImplementedError() 58 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/cloneable.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import collections 18 | import copy 19 | 20 | # An object inheriting from Cloneable will be automatically shallow-copied 21 | # when constructing child build contexts. Use copy.deepcopy to clone. 22 | class Cloneable(object): 23 | def __init__(self): 24 | pass 25 | 26 | class CloneableDict(collections.OrderedDict, Cloneable): 27 | def __init__(self, *args, **kwargs): 28 | super(CloneableDict, self).__init__(*args, **kwargs) 29 | 30 | class CloneableList(list, Cloneable): 31 | def __init__(self, *args, **kwargs): 32 | super(CloneableList, self).__init__(*args, **kwargs) 33 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/cloneable_test.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=4 ts=8 sw=4 tw=99 et: 2 | import collections 3 | import copy 4 | import unittest 5 | from ambuild2.frontend.cloneable import Cloneable 6 | from ambuild2.frontend.cloneable import CloneableDict 7 | 8 | class CloneableDictTests(unittest.TestCase): 9 | def runTest(self): 10 | obj = CloneableDict() 11 | self.assertTrue(isinstance(obj, Cloneable)) 12 | self.assertTrue(isinstance(obj, collections.OrderedDict)) 13 | 14 | obj['blah'] = [1, 2, 3, 4, 5] 15 | 16 | clone = copy.deepcopy(obj) 17 | self.assertTrue(isinstance(clone, Cloneable)) 18 | self.assertTrue(isinstance(clone, collections.OrderedDict)) 19 | self.assertIsNot(obj, clone) 20 | self.assertIn('blah', clone) 21 | self.assertIsNot(obj['blah'], clone['blah']) 22 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/context_manager.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import copy 18 | import os 19 | import sys 20 | from ambuild2 import util 21 | 22 | class ContextManager(object): 23 | def __init__(self, sourcePath, buildPath, originalCwd, options, args): 24 | super(ContextManager, self).__init__() 25 | self.sourcePath = sourcePath 26 | self.buildPath = os.path.normpath(buildPath) 27 | self.originalCwd = originalCwd 28 | self.options = options 29 | self.args = args 30 | self.configure_failed = False 31 | self.contextStack_ = [] 32 | self.generator = None 33 | self.db = None 34 | self.refactoring = False 35 | 36 | # Nonce. 37 | ALWAYS_DIRTY = object() 38 | 39 | @property 40 | def apiVersion(self): 41 | raise Exception('Implement me!') 42 | 43 | def setBackend(self, backend): 44 | self.backend_ = backend 45 | 46 | def pushContext(self, cx): 47 | self.contextStack_.append(cx) 48 | 49 | def popContext(self): 50 | self.contextStack_.pop() 51 | 52 | def compileScript(self, path): 53 | with open(path) as fp: 54 | chars = fp.read() 55 | 56 | # Python 2.6 can't compile() with Windows line endings?!?!!? 57 | chars = chars.replace('\r\n', '\n') 58 | chars = chars.replace('\r', '\n') 59 | 60 | return compile(chars, path, 'exec') 61 | 62 | def Context(self, name): 63 | return AutoContext(self, self.contextStack_[-1], name) 64 | 65 | def generateBuildFiles(self): 66 | build_py = os.path.join(self.buildPath, 'build.py') 67 | with open(build_py, 'w') as fp: 68 | fp.write(""" 69 | #!{exe} 70 | # vim set: ts=8 sts=2 sw=2 tw=99 et: 71 | import sys 72 | from ambuild2 import run 73 | 74 | if not run.CompatBuild(r"{build}"): 75 | sys.exit(1) 76 | """.format(exe = sys.executable, build = self.buildPath)) 77 | 78 | with open(os.path.join(self.buildPath, 'Makefile'), 'w') as fp: 79 | fp.write(""" 80 | all: 81 | "{exe}" "{py}" 82 | """.format(exe = sys.executable, py = build_py)) 83 | 84 | def createGenerator(self, name): 85 | sys.stderr.write('Unrecognized build generator: {}\n'.format(name)) 86 | sys.exit(1) 87 | 88 | # name is None when a generator is already set. 89 | def generate(self, name = None): 90 | if self.generator is None: 91 | self.createGenerator(name) 92 | self.generator.preGenerate() 93 | self.parseBuildScripts() 94 | self.generator.postGenerate() 95 | if self.options.make_scripts: 96 | self.generateBuildFiles() 97 | return True 98 | 99 | @property 100 | def backend(self): 101 | return self.backend_.backend() 102 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/cpp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/cpp/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/cpp/cpp_rules.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import copy 18 | 19 | DEFAULT_RULES = { 20 | 'family==gcc': { 21 | 'arch==x86': { 22 | 'CFLAGS': ['-m32'], 23 | 'platform==mac': { 24 | 'CFLAGS': ['-arch', 'i386'], 25 | }, 26 | }, 27 | 'arch==x86_64': { 28 | 'CFLAGS': ['-m64'], 29 | 'platform==mac': { 30 | 'CFLAGS': ['-arch', 'x86_64'], 31 | }, 32 | }, 33 | }, 34 | } 35 | 36 | class RulesParser(object): 37 | def __init__(self): 38 | self.rules = copy.deepcopy(DEFAULT_RULES) 39 | self.inputs_ = None 40 | self.props_ = None 41 | 42 | def parse(self, inputs): 43 | self.inputs_ = inputs 44 | self.props_ = {} 45 | for key, value in self.rules.items(): 46 | self.parse_property(key, value) 47 | return self.props_ 48 | 49 | def parse_property(self, key, value): 50 | if isinstance(value, dict): 51 | self.parse_section(key, value) 52 | else: 53 | self.add_prop(key, value) 54 | 55 | def add_prop(self, key, value): 56 | if key not in self.props_: 57 | self.props_[key] = value 58 | return 59 | if isinstance(value, list): 60 | self.props_[key].extend(value) 61 | else: 62 | self.props_[key] = value 63 | 64 | def parse_section(self, key, value): 65 | if '==' in key: 66 | op = lambda x, y: x == y 67 | parts = key.split('==') 68 | elif '!=' in key: 69 | op = lambda x, y: x != y 70 | parts = key.split('!=') 71 | else: 72 | raise Exception('Subsections must have an == or != operator') 73 | 74 | parts = [part.strip() for part in parts] 75 | if len(parts) != 2 or not len(parts[0]) or not len(parts[1]): 76 | raise Exception('Invalid operator or multiple operators, expected two components') 77 | 78 | if parts[0] not in self.inputs_: 79 | raise Exception('Unknown rule variable "{}"'.format(parts[0])) 80 | if not op(self.inputs_[parts[0]], parts[1]): 81 | return 82 | 83 | for sub_key, sub_value in sorted(value.items()): 84 | self.parse_property(sub_key, sub_value) 85 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/cpp/cpp_rules_test.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import unittest 18 | from ambuild2.frontend.cpp.cpp_rules import RulesParser 19 | 20 | TestRules = { 21 | 'family==gcc': { 22 | 'arch==x86': { 23 | 'CFLAGS': ['-m32'], 24 | 'platform==mac': { 25 | 'CFLAGS': ['-arch', 'i386'], 26 | }, 27 | }, 28 | 'arch==x86_64': { 29 | 'CFLAGS': ['-m64'], 30 | }, 31 | } 32 | } 33 | 34 | class IsSubPathTests(unittest.TestCase): 35 | def runTest(self): 36 | rp = RulesParser() 37 | rp.rules = TestRules 38 | props = rp.parse({ 39 | 'family': 'gcc', 40 | 'arch': 'x86_64', 41 | }) 42 | self.assertIn('CFLAGS', props) 43 | self.assertEquals(props['CFLAGS'], ['-m64']) 44 | 45 | props = rp.parse({ 46 | 'family': 'msvc', 47 | 'arch': 'x86_64', 48 | }) 49 | self.assertEquals(props, {}) 50 | 51 | props = rp.parse({ 52 | 'family': 'gcc', 53 | 'arch': 'x86', 54 | 'platform': 'mac', 55 | }) 56 | self.assertIn('CFLAGS', props) 57 | self.assertEquals(props['CFLAGS'], ['-m32', '-arch', 'i386']) 58 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/cpp/cpp_utils.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import uuid 18 | 19 | def CreateUnifiedHeader(header_guard, sources): 20 | text = "" 21 | text += "/* AUTO-GENERATED: DO NOT EDIT */\n" 22 | text += "#ifndef {}\n".format(header_guard) 23 | text += "#define {}\n".format(header_guard) 24 | for source in sources: 25 | text += "# include <{}>\n".format(source) 26 | text += "#endif /* {} */\n".format(header_guard) 27 | return text 28 | 29 | def CreateSingleIncludeSource(header_name): 30 | text = "" 31 | text += "/* AUTO-GENERATED: DO NOT EDIT */\n" 32 | text += "#include \"{}\"\n".format(header_name) 33 | return text -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/paths.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import os 18 | from ambuild2 import util 19 | 20 | # Given an optional contextual folder and a folder path, compute the full 21 | # relative path, erroring if it's outside the build folder. 22 | # 23 | # The parent folder and resolved folder are returned as a tuple. 24 | def ResolveFolder(parent, folder): 25 | parent_path = '' 26 | if parent: 27 | parent_path = parent.path 28 | path = os.path.normpath(os.path.join(parent_path, folder)) 29 | 30 | if path.startswith('..'): 31 | util.con_err(util.ConsoleRed, 'Output path ', util.ConsoleBlue, path, util.ConsoleRed, 32 | ' is outside the build folder!', util.ConsoleNormal) 33 | raise Exception('Cannot generate folders outside the build folder') 34 | 35 | return parent_path, path 36 | 37 | def Join(*nodes): 38 | paths = [] 39 | for node in nodes: 40 | if node is None: 41 | continue 42 | if util.IsString(node): 43 | paths.append(node) 44 | else: 45 | paths.append(node.path) 46 | return os.path.join(*paths) 47 | 48 | def IsSubPath(other, folder, path_module = os.path): 49 | other = path_module.abspath(other) 50 | folder = path_module.abspath(folder) 51 | 52 | drive1, _ = path_module.splitdrive(other) 53 | drive2, _ = path_module.splitdrive(folder) 54 | if drive1 != drive2: 55 | return False 56 | 57 | relative = path_module.relpath(other, folder) 58 | if relative.startswith( 59 | os.pardir 60 | ): # Short-circuit on '..' -OR- '../', this is always pointing outside of "folder". 61 | return False 62 | elif relative.startswith( 63 | os.curdir): # Short-circuit on '.' -OR- './', this is always pointing to a child item. 64 | return True 65 | 66 | return other.startswith(folder) # In most cases, we shouldn't ever arrive to this point. 67 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/paths_test.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=4 ts=8 sw=4 tw=99 et: 2 | import ntpath 3 | import unittest 4 | from ambuild2.frontend import paths 5 | 6 | class IsSubPathTests(unittest.TestCase): 7 | def runTest(self): 8 | self.assertEqual(paths.IsSubPath("/a/b/c", "/a"), True) 9 | self.assertEqual(paths.IsSubPath("/t/b/c", "/a"), False) 10 | self.assertEqual(paths.IsSubPath("t", "./"), True) 11 | self.assertEqual(paths.IsSubPath(r"C:\blah", "C:\\", ntpath), True) 12 | self.assertEqual(paths.IsSubPath(r"C:\blah", "D:\\", ntpath), False) 13 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/proxy.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | 18 | # AttributeProxy objects will appear to have all the attributes of an inner 19 | # object, as well as their own attributes. Locally set attributes will 20 | # override wrapped ones. This is basically how JavaScript prototype-based 21 | # inheritance works. 22 | class AttributeProxy(object): 23 | def __init__(self, wrapped_obj): 24 | self._wrapped_obj = wrapped_obj 25 | self._own_attrs = set() 26 | 27 | def __getattr__(self, name): 28 | return getattr(self._wrapped_obj, name) 29 | 30 | def __setattr__(self, name, value): 31 | if name in ['_own_attrs_', '_wrapped_obj']: 32 | return object.__setattr__(self, name, value) 33 | 34 | own_attrs = getattr(self, '_own_attrs', None) 35 | if own_attrs is not None: 36 | own_attrs.add(name) 37 | return object.__setattr__(self, name, value) 38 | 39 | def __dir__(self): 40 | me = set(dir(super(AttributeProxy, self))) | set(self.__dict__.keys()) 41 | wrapped = set(dir(self._wrapped_obj)) 42 | return sorted(list(me | wrapped)) 43 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/proxy_test.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=4 ts=8 sw=4 tw=99 et: 2 | import unittest 3 | from ambuild2.frontend.proxy import AttributeProxy 4 | 5 | class InnerObject(object): 6 | def __init__(self): 7 | self.x = 10 8 | self.y = 20 9 | 10 | class AttributeProxyTests(unittest.TestCase): 11 | def runTest(self): 12 | inner = InnerObject() 13 | outer = AttributeProxy(inner) 14 | 15 | self.assertEqual(outer.x, 10) 16 | self.assertEqual(outer.y, 20) 17 | 18 | inner.z = 30 19 | self.assertEqual(outer.z, 30) 20 | 21 | outer.a = 10 22 | self.assertFalse(hasattr(inner, 'a')) 23 | 24 | self.assertTrue(hasattr(outer, 'a')) 25 | self.assertTrue(hasattr(outer, 'x')) 26 | self.assertTrue(hasattr(outer, 'y')) 27 | self.assertTrue(hasattr(outer, 'z')) 28 | 29 | self.assertIn('a', dir(outer)) 30 | self.assertIn('x', dir(outer)) 31 | self.assertIn('y', dir(outer)) 32 | self.assertIn('z', dir(outer)) 33 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/system.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | from ambuild2 import util 18 | 19 | class System(object): 20 | def __init__(self, platform, arch, subarch = '', abi = ''): 21 | super(System, self).__init__() 22 | self.platform_ = platform 23 | self.arch_ = arch 24 | self.subarch_ = subarch 25 | self.abi_ = abi 26 | 27 | @property 28 | def platform(self): 29 | return self.platform_ 30 | 31 | @property 32 | def arch(self): 33 | return self.arch_ 34 | 35 | @property 36 | def subarch(self): 37 | return self.subarch_ 38 | 39 | @property 40 | def abi(self): 41 | return self.abi_ 42 | 43 | @property 44 | def triple(self): 45 | suffix = '' 46 | if self.abi: 47 | suffix += '-' + self.abi 48 | return '{}-{}{}{}'.format(self.platform, self.arch, self.subarch, suffix) 49 | 50 | System.Host = System(util.Platform(), util.Architecture, util.SubArch, util.DetectHostAbi()) 51 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/__pycache__/amb2_gen.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/__pycache__/amb2_gen.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/__pycache__/context.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/__pycache__/context.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/__pycache__/context_manager.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/__pycache__/context_manager.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/__pycache__/prep.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/__pycache__/prep.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/amb2_gen.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import os 18 | from ambuild2 import nodetypes 19 | from ambuild2 import util 20 | from ambuild2.frontend import amb2_gen 21 | from ambuild2.frontend.v2_0.cpp import detect 22 | 23 | class Generator(amb2_gen.Generator): 24 | def __init__(self, cm): 25 | super(Generator, self).__init__(cm) 26 | self.compiler = None 27 | 28 | def copyBuildVars(self, vars): 29 | if not self.compiler: 30 | return 31 | 32 | # Save any environment variables that are relevant to the build. 33 | compilers = [ 34 | ('cc', self.compiler.cc), 35 | ('cxx', self.compiler.cxx), 36 | ] 37 | for prefix, comp in compilers: 38 | for prop_name in comp.extra_props: 39 | key = '{0}_{1}'.format(prefix, prop_name) 40 | vars[key] = comp.extra_props[prop_name] 41 | 42 | def detectCompilers(self): 43 | if not self.compiler: 44 | with util.FolderChanger(self.cacheFolder): 45 | self.base_compiler = detect.DetectCxx(os.environ, self.cm.options) 46 | self.compiler = self.base_compiler.clone() 47 | 48 | return self.compiler 49 | 50 | def addCxxObjTask(self, cx, shared_outputs, folder, obj): 51 | cxxData = {'argv': obj.argv, 'type': obj.behavior} 52 | _, (cxxNode,) = self.addCommand(context = cx, 53 | weak_inputs = obj.sourcedeps, 54 | inputs = [obj.inputObj], 55 | outputs = [obj.outputFile], 56 | node_type = nodetypes.Cxx, 57 | folder = folder, 58 | data = cxxData, 59 | shared_outputs = shared_outputs, 60 | env_data = obj.env_data) 61 | return cxxNode 62 | 63 | def addCxxRcTask(self, cx, folder, obj): 64 | rcData = { 65 | 'cl_argv': obj.cl_argv, 66 | 'rc_argv': obj.rc_argv, 67 | } 68 | _, (_, rcNode) = self.addCommand(context = cx, 69 | weak_inputs = obj.sourcedeps, 70 | inputs = [obj.inputObj], 71 | outputs = [obj.preprocFile, obj.outputFile], 72 | node_type = nodetypes.Rc, 73 | folder = folder, 74 | data = rcData, 75 | env_data = obj.env_data) 76 | return rcNode 77 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/context_manager.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import os 18 | import sys, copy 19 | from ambuild2 import util 20 | from ambuild2.frontend import context_manager 21 | from ambuild2.frontend.v2_0.context import AutoContext 22 | from ambuild2.frontend.v2_0.context import Context 23 | from ambuild2.frontend.version import Version 24 | 25 | class ContextManager(context_manager.ContextManager): 26 | def __init__(self, sourcePath, buildPath, originalCwd, options, args): 27 | super(ContextManager, self).__init__(sourcePath, buildPath, originalCwd, options, args) 28 | self.contextStack_.append(None) 29 | 30 | # This is a hack... if we ever do cross-compiling or something, we'll have 31 | # to change this. 32 | self.host_platform = util.Platform() 33 | self.target_platform = util.Platform() 34 | 35 | @property 36 | def apiVersion(self): 37 | return Version('2.0') 38 | 39 | def parseBuildScripts(self): 40 | root = os.path.join(self.sourcePath, 'AMBuildScript') 41 | self.evalScript(root) 42 | 43 | def importScript(self, context, file, vars = None): 44 | path = os.path.normpath(os.path.join(context.sourcePath, file)) 45 | self.addConfigureFile(context, path) 46 | 47 | new_vars = copy.copy(vars or {}) 48 | new_vars['builder'] = context 49 | 50 | code = self.compileScript(path) 51 | exec(code, new_vars) 52 | 53 | obj = util.Expando() 54 | for key in new_vars: 55 | setattr(obj, key, new_vars[key]) 56 | return obj 57 | 58 | def Context(self, name): 59 | return AutoContext(self, self.contextStack_[-1], name) 60 | 61 | def evalScript(self, file, vars = None): 62 | file = os.path.normpath(file) 63 | 64 | cx = Context(self, self.contextStack_[-1], file) 65 | self.pushContext(cx) 66 | 67 | full_path = os.path.join(self.sourcePath, cx.buildScript) 68 | 69 | self.generator.addConfigureFile(cx, full_path) 70 | 71 | new_vars = copy.copy(vars or {}) 72 | new_vars['builder'] = cx 73 | 74 | # Run it. 75 | rvalue = None 76 | code = self.compileScript(full_path) 77 | 78 | exec(code, new_vars) 79 | 80 | if 'rvalue' in new_vars: 81 | rvalue = new_vars['rvalue'] 82 | del new_vars['rvalue'] 83 | 84 | self.popContext() 85 | return rvalue 86 | 87 | def getLocalFolder(self, context): 88 | return context.localFolder_ 89 | 90 | def createGenerator(self, name): 91 | if name == 'vs': 92 | from ambuild2.frontend.v2_0.vs.gen import Generator 93 | self.generator = Generator(self) 94 | elif name == 'ambuild2': 95 | from ambuild2.frontend.v2_0.amb2_gen import Generator 96 | self.generator = Generator(self) 97 | else: 98 | return super(ContextManager, self).createGenerator(name) 99 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/cpp/__init__.py: -------------------------------------------------------------------------------- 1 | from ambuild2.frontend.v2_0.cpp.compilers import Compiler 2 | from ambuild2.frontend.v2_0.cpp.builders import CppNodes 3 | from ambuild2.frontend.v2_0.cpp.builders import Dep 4 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/cpp/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/cpp/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/cpp/__pycache__/builders.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/cpp/__pycache__/builders.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/cpp/__pycache__/compilers.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/cpp/__pycache__/compilers.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/cpp/__pycache__/detect.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/cpp/__pycache__/detect.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/cpp/__pycache__/vendors.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/cpp/__pycache__/vendors.cpython-38.pyc -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/cpp/vendors.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | 18 | import os 19 | from ambuild2 import util 20 | from ambuild2.frontend.version import Version 21 | 22 | class Vendor(object): 23 | def __init__(self, name, version, behavior, command, objSuffix): 24 | self.name = name 25 | self.version = version 26 | self.behavior = behavior 27 | self.command = command 28 | self.objSuffix = objSuffix 29 | self.debuginfo_argv = [] 30 | self.extra_props = {} 31 | self.versionObject = Version('{0}-{1}'.format(name, self.version)) 32 | 33 | def nameForExecutable(self, name): 34 | return name + util.ExecutableSuffix 35 | 36 | def nameForSharedLibrary(self, name): 37 | return name + util.SharedLibSuffix 38 | 39 | def nameForStaticLibrary(self, name): 40 | return util.StaticLibPrefix + name + util.StaticLibSuffix 41 | 42 | class MSVC(Vendor): 43 | def __init__(self, command, version): 44 | super(MSVC, self).__init__('msvc', version, 'msvc', command, '.obj') 45 | self.definePrefix = '/D' 46 | self.debuginfo_argv = ['/Zi'] 47 | if int(self.version) >= 1800: 48 | self.debuginfo_argv += ['/FS'] 49 | 50 | def like(self, name): 51 | return name == 'msvc' 52 | 53 | def parse_debuginfo(self, debuginfo): 54 | if debuginfo == 'bundled': 55 | return 'separate' 56 | return debuginfo 57 | 58 | @staticmethod 59 | def IncludePath(outputPath, includePath): 60 | # Hack - try and get a relative path because CL, with either 61 | # /Zi or /ZI, combined with subprocess, apparently tries and 62 | # looks for paths like c:\bleh\"c:\bleh" <-- wtf 63 | # .. this according to Process Monitor 64 | outputPath = os.path.normcase(outputPath) 65 | includePath = os.path.normcase(includePath) 66 | outputDrive = os.path.splitdrive(outputPath)[0] 67 | includeDrive = os.path.splitdrive(includePath)[0] 68 | if outputDrive == includeDrive: 69 | return os.path.relpath(includePath, outputPath) 70 | return includePath 71 | 72 | def formatInclude(self, outputPath, includePath): 73 | return ['/I', self.IncludePath(outputPath, includePath)] 74 | 75 | def preprocessArgs(self, sourceFile, outFile): 76 | return ['/showIncludes', '/nologo', '/P', '/c', sourceFile, '/Fi' + outFile] 77 | 78 | def objectArgs(self, sourceFile, objFile): 79 | return ['/showIncludes', '/nologo', '/c', sourceFile, '/Fo' + objFile] 80 | 81 | class CompatGCC(Vendor): 82 | def __init__(self, name, command, version): 83 | super(CompatGCC, self).__init__(name, version, 'gcc', command, '.o') 84 | parts = version.split('.') 85 | self.majorVersion = int(parts[0]) 86 | self.minorVersion = int(parts[1]) 87 | self.definePrefix = '-D' 88 | 89 | def formatInclude(self, outputPath, includePath): 90 | return ['-I', os.path.normpath(includePath)] 91 | 92 | def objectArgs(self, sourceFile, objFile): 93 | return ['-H', '-c', sourceFile, '-o', objFile] 94 | 95 | def parse_debuginfo(self, debuginfo): 96 | return debuginfo 97 | 98 | class GCC(CompatGCC): 99 | def __init__(self, command, version): 100 | super(GCC, self).__init__('gcc', command, version) 101 | self.debuginfo_argv = ['-g3', '-ggdb3'] 102 | 103 | def like(self, name): 104 | return name == 'gcc' 105 | 106 | class Clang(CompatGCC): 107 | def __init__(self, vendor_name, command, version): 108 | super(Clang, self).__init__(vendor_name, command, version) 109 | self.name = 'clang' # Rewrite name to just 'clang' to make things easier. 110 | self.vendor_name = vendor_name 111 | self.debuginfo_argv = ['-g3'] 112 | 113 | def like(self, name): 114 | return name == 'gcc' or name == 'clang' or name == self.vendor_name 115 | 116 | class Emscripten(Clang): 117 | def __init__(self, command, version): 118 | super(Emscripten, self).__init__('emscripten', command, version) 119 | self.name = 'emscripten' 120 | 121 | def like(self, name): 122 | if name == 'emscripten': 123 | return True 124 | return super(Emscripten, self).like(name) 125 | 126 | def nameForExecutable(self, name): 127 | return name + '.js' 128 | 129 | class SunPro(Vendor): 130 | def __init__(self, command, version): 131 | super(SunPro, self).__init__('sun', version, 'sun', command, '.o') 132 | self.definePrefix = '-D' 133 | self.debuginfo_argv = ['-g3'] 134 | 135 | def formatInclude(self, outputPath, includePath): 136 | return ['-I', os.path.normpath(includePath)] 137 | 138 | def objectArgs(self, sourceFile, objFile): 139 | return ['-H', '-c', sourceFile, '-o', objFile] 140 | 141 | def like(self, name): 142 | return name == 'sun' 143 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/vs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_0/vs/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_0/vs/gen.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | 18 | from ambuild2.frontend.vs import gen as vs_gen 19 | from ambuild2.frontend.v2_0.vs import cxx 20 | 21 | class Generator(vs_gen.Generator): 22 | def __init__(self, cm): 23 | super(Generator, self).__init__(cm) 24 | 25 | def detectCompilers(self): 26 | if not self.compiler: 27 | self.base_compiler = cxx.Compiler(cxx.Compiler.GetVersionFromVS(self.vs_version)) 28 | self.compiler = self.base_compiler.clone() 29 | return self.compiler 30 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/__init__.py: -------------------------------------------------------------------------------- 1 | from ambuild2.frontend.v2_1.prep import Preparer 2 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/amb2_gen.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import os 18 | from ambuild2 import nodetypes 19 | from ambuild2 import util 20 | from ambuild2.frontend import amb2_gen 21 | from ambuild2.frontend.v2_1.cpp import detect 22 | 23 | class Generator(amb2_gen.Generator): 24 | def __init__(self, cm): 25 | super(Generator, self).__init__(cm) 26 | self.compiler = None 27 | 28 | def detectCompilers(self, options): 29 | if options is None: 30 | options = {} 31 | if not self.compiler: 32 | with util.FolderChanger(self.cacheFolder): 33 | self.base_compiler = detect.AutoDetectCxx(self.cm.target, self.cm.options, options) 34 | if self.base_compiler is None: 35 | raise Exception('Could not detect a suitable C/C++ compiler') 36 | self.compiler = self.base_compiler.clone() 37 | 38 | return self.compiler 39 | 40 | def copyBuildVars(self, vars): 41 | if not self.compiler: 42 | return 43 | for prop_name in self.compiler.vendor.extra_props: 44 | key = '{0}_{1}'.format(self.compiler.vendor.name, prop_name) 45 | vars[key] = self.compiler.vendor.extra_props[prop_name] 46 | 47 | def addCxxObjTask(self, cx, shared_outputs, folder, obj): 48 | cxxData = {'argv': obj.argv, 'type': obj.behavior} 49 | _, (cxxNode,) = self.addCommand(context = cx, 50 | weak_inputs = obj.sourcedeps, 51 | inputs = [obj.inputObj], 52 | outputs = [obj.outputFile], 53 | node_type = nodetypes.Cxx, 54 | folder = folder, 55 | data = cxxData, 56 | shared_outputs = shared_outputs, 57 | env_data = obj.env_data) 58 | return cxxNode 59 | 60 | def addCxxRcTask(self, cx, folder, obj): 61 | rcData = { 62 | 'cl_argv': obj.cl_argv, 63 | 'rc_argv': obj.rc_argv, 64 | } 65 | _, (_, rcNode) = self.addCommand(context = cx, 66 | weak_inputs = obj.sourcedeps, 67 | inputs = [obj.inputObj], 68 | outputs = [obj.preprocFile, obj.outputFile], 69 | node_type = nodetypes.Rc, 70 | folder = folder, 71 | data = rcData, 72 | env_data = obj.env_data) 73 | return rcNode 74 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/cpp/__init__.py: -------------------------------------------------------------------------------- 1 | from ambuild2.frontend.v2_1.cpp.compiler import Compiler 2 | from ambuild2.frontend.v2_1.cpp.builders import CppNodes 3 | from ambuild2.frontend.v2_1.cpp.builders import Dep 4 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/cpp/gcc.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import os 18 | from ambuild2 import util 19 | from ambuild2.frontend.v2_1.cpp.vendor import Vendor 20 | 21 | class GCCLookalike(Vendor): 22 | def __init__(self, version): 23 | super(GCCLookalike, self).__init__(version) 24 | 25 | @property 26 | def behavior(self): 27 | return 'gcc' 28 | 29 | @property 30 | def definePrefix(self): 31 | return '-D' 32 | 33 | @property 34 | def objSuffix(self): 35 | return '.o' 36 | 37 | @property 38 | def debugInfoArgv(self): 39 | return [] 40 | 41 | def parseDebugInfoType(self, debuginfo): 42 | return debuginfo 43 | 44 | def formatInclude(self, outputPath, includePath): 45 | return ['-I', os.path.normpath(includePath)] 46 | 47 | def objectArgs(self, sourceFile, objFile): 48 | return ['-H', '-c', sourceFile, '-o', objFile] 49 | 50 | def staticLinkArgv(self, files, outputFile): 51 | return ['ar', 'rcs', outputFile] + files 52 | 53 | def programLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 54 | return cmd_argv + files + linkFlags + ['-o', outputFile] 55 | 56 | def libLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 57 | argv = cmd_argv + files + linkFlags 58 | if util.IsMac(): 59 | argv += ['-dynamiclib'] 60 | else: 61 | argv += ['-shared'] 62 | argv += ['-o', outputFile] 63 | return argv 64 | 65 | def preprocessArgv(self, sourceFile, outFile): 66 | return ['-H', '-E', sourceFile, '-o', outFile] 67 | 68 | @staticmethod 69 | def IncludePath(outputPath, includePath): 70 | return includePath 71 | 72 | class GCC(GCCLookalike): 73 | def __init__(self, version): 74 | super(GCC, self).__init__(version) 75 | 76 | @property 77 | def name(self): 78 | return 'gcc' 79 | 80 | @property 81 | def family(self): 82 | return 'gcc' 83 | 84 | def like(self, name): 85 | return name == 'gcc' 86 | 87 | class Clang(GCCLookalike): 88 | def __init__(self, version, vendor_prefix = None): 89 | # Set this first, since the constructor will need it. 90 | self.vendor_name = 'clang' 91 | if vendor_prefix is not None: 92 | self.vendor_name = '{0}-clang'.format(vendor_prefix) 93 | super(Clang, self).__init__(version) 94 | 95 | @property 96 | def name(self): 97 | return self.vendor_name 98 | 99 | @property 100 | def family(self): 101 | return 'clang' 102 | 103 | def like(self, name): 104 | return name == 'gcc' or name == 'clang' or name == self.name 105 | 106 | @property 107 | def debugInfoArgv(self): 108 | return ['-g3'] 109 | 110 | class Emscripten(Clang): 111 | def __init__(self, version): 112 | # Set this first, since the constructor will need it. 113 | super(Emscripten, self).__init__(version, 'emscripten') 114 | 115 | def nameForExecutable(self, name): 116 | return name + '.js' 117 | 118 | def nameForSharedLibrary(self, name): 119 | return name + '.bc' 120 | 121 | def nameForStaticLibrary(self, name): 122 | return util.StaticLibPrefix + name + '.a' 123 | 124 | @property 125 | def name(self): 126 | return 'emscripten' 127 | 128 | @property 129 | def family(self): 130 | return 'emscripten' 131 | 132 | def like(self, name): 133 | return name == 'gcc' or name == 'clang' or name == 'emscripten-clang' or name == 'emscripten' 134 | 135 | @property 136 | def debugInfoArgv(self): 137 | return [] 138 | 139 | def staticLinkArgv(self, files, outputFile): 140 | return ['emar', 'rcs', outputFile] + files 141 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/cpp/msvc.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import os 18 | import re 19 | from ambuild2 import util 20 | from ambuild2.frontend.v2_1.cpp.vendor import Vendor 21 | 22 | # Microsoft Visual C++ 23 | class MSVC(Vendor): 24 | def __init__(self, version): 25 | super(MSVC, self).__init__(version) 26 | 27 | @property 28 | def name(self): 29 | return 'msvc' 30 | 31 | @property 32 | def behavior(self): 33 | return 'msvc' 34 | 35 | @property 36 | def family(self): 37 | return 'msvc' 38 | 39 | def like(self, name): 40 | return name == 'msvc' 41 | 42 | @property 43 | def definePrefix(self): 44 | return '/D' 45 | 46 | @property 47 | def objSuffix(self): 48 | return '.obj' 49 | 50 | @property 51 | def debugInfoArgv(self): 52 | if int(self.version_string) >= 1800: 53 | return ['/Zi', '/FS'] 54 | return ['/Zi'] 55 | 56 | def parseDebugInfoType(self, debuginfo): 57 | if debuginfo == 'bundled': 58 | return 'separate' 59 | return debuginfo 60 | 61 | def objectArgs(self, sourceFile, objFile): 62 | return ['/showIncludes', '/nologo', '/c', sourceFile, '/Fo' + objFile] 63 | 64 | def staticLinkArgv(self, files, outputFile): 65 | return ['lib', '/OUT:' + outputFile] + files 66 | 67 | def programLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 68 | argv = cmd_argv + files 69 | argv += ['/link'] 70 | argv += linkFlags 71 | argv += [ 72 | '/OUT:' + outputFile, 73 | '/nologo', 74 | ] 75 | if symbolFile: 76 | argv += ['/DEBUG', '/PDB:"' + symbolFile + '.pdb"'] 77 | return argv 78 | 79 | def libLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 80 | argv = cmd_argv + files 81 | argv += ['/link'] 82 | argv += linkFlags 83 | argv += [ 84 | '/OUT:' + outputFile, 85 | '/nologo', 86 | '/DLL', 87 | ] 88 | if symbolFile: 89 | argv += ['/DEBUG', '/PDB:"' + symbolFile + '.pdb"'] 90 | return argv 91 | 92 | def preprocessArgv(self, sourceFile, outFile): 93 | return ['/showIncludes', '/nologo', '/P', '/c', sourceFile, '/Fi' + outFile] 94 | 95 | @staticmethod 96 | def IncludePath(outputPath, includePath): 97 | # Hack - try and get a relative path because CL, with either 98 | # /Zi or /ZI, combined with subprocess, apparently tries and 99 | # looks for paths like c:\bleh\"c:\bleh" <-- wtf 100 | # .. this according to Process Monitor 101 | outputPath = os.path.normcase(outputPath) 102 | includePath = os.path.normcase(includePath) 103 | outputDrive = os.path.splitdrive(outputPath)[0] 104 | includeDrive = os.path.splitdrive(includePath)[0] 105 | if outputDrive == includeDrive: 106 | return os.path.relpath(includePath, outputPath) 107 | return includePath 108 | 109 | def formatInclude(self, outputPath, includePath): 110 | return ['/I', MSVC.IncludePath(outputPath, includePath)] 111 | 112 | ## 113 | # MSVC-specific properties. 114 | ## 115 | @property 116 | def shared_pdb_name(self): 117 | cl_version = int(self.version_string) 118 | 119 | # Truncate down to the major version then correct the offset 120 | # There is some evidence that the first digit of the minor version can be used for the PDB, but I can't reproduce it 121 | cl_version = int(cl_version / 100) - 6 122 | 123 | # Microsoft introduced a discontinuity with vs2015 124 | if cl_version >= 13: 125 | cl_version += 1 126 | 127 | # Pad it back out again 128 | cl_version *= 10 129 | 130 | return 'vc{0}.pdb'.format(cl_version) 131 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/cpp/sunpro.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import os 18 | from ambuild2 import util 19 | from ambuild2.frontend.v2_1.cpp.vendor import Vendor 20 | 21 | class SunPro(Vendor): 22 | def __init__(self, version): 23 | super(SunPro, self).__init__(version) 24 | 25 | @property 26 | def name(self): 27 | return 'sun' 28 | 29 | @property 30 | def behavior(self): 31 | return 'sun' 32 | 33 | @property 34 | def family(self): 35 | return 'sun' 36 | 37 | def like(self, name): 38 | return name == 'sun' 39 | 40 | @property 41 | def definePrefix(self): 42 | return '/D' 43 | 44 | @property 45 | def objSuffix(self): 46 | return '.o' 47 | 48 | @property 49 | def debugInfoArgv(self): 50 | return ['-g3'] 51 | 52 | def parseDebugInfoType(self, debuginfo): 53 | return debuginfo 54 | 55 | def objectArgs(self, sourceFile, objFile): 56 | return ['-H', '-c', sourceFile, '-o', objFile] 57 | 58 | def formatInclude(self, outputPath, includePath): 59 | return ['-I', os.path.normpath(includePath)] 60 | 61 | def staticLinkArgv(self, files, outputFile): 62 | return ['ar', 'rcs', outputFile] + files 63 | 64 | def programLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 65 | return cmd_argv + files + linkFlags + ['-o', outputFile] 66 | 67 | def libLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 68 | return cmd_argv + files + linkFlags + ['-o', outputFile] 69 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/cpp/vendor.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | 18 | import os 19 | from ambuild2 import util 20 | from ambuild2.frontend.version import Version 21 | 22 | class Vendor(object): 23 | def __init__(self, version): 24 | super(Vendor, self).__init__() 25 | self.version_string = version 26 | self.version = Version('{0}-{1}'.format(self.name, version)) 27 | self.extra_props = {} 28 | 29 | def nameForExecutable(self, name): 30 | return name + util.ExecutableSuffix 31 | 32 | def nameForSharedLibrary(self, name): 33 | return name + util.SharedLibSuffix 34 | 35 | def nameForStaticLibrary(self, name): 36 | return util.StaticLibPrefix + name + util.StaticLibSuffix 37 | 38 | def equals(self, other): 39 | return self.name == other.name and \ 40 | self.version == other.version and \ 41 | self.extra_props == other.extra_props 42 | 43 | def __str__(self): 44 | return '{0}-{1}'.format(self.name, self.version_string) 45 | 46 | @property 47 | def behavior(self): 48 | raise Exception("Must be implemented") 49 | 50 | @property 51 | def name(self): 52 | raise Exception("Must be implemented") 53 | 54 | @property 55 | def family(self): 56 | raise Exception("Must be implemented") 57 | 58 | def like(self, name): 59 | raise Exception("Must be implemented") 60 | 61 | @property 62 | def definePrefix(self): 63 | raise Exception("Must be implemented") 64 | 65 | @property 66 | def objSuffix(self): 67 | raise Exception("Must be implemented") 68 | 69 | @property 70 | def debugInfoArgv(self): 71 | raise Exception("Must be implemented") 72 | 73 | def parseDebugInfoType(self, debuginfo): 74 | raise Exception("Must be implemented") 75 | 76 | def formatInclude(self, outputPath, includePath): 77 | raise Exception("Must be implemented") 78 | 79 | def objectArgs(self, sourceFile, objFile): 80 | raise Exception("Must be implemented") 81 | 82 | # Note: this should return a complete initial argv, not partial. 83 | # AMBuild does not detect AR/LIB separately yet. 84 | def staticLinkArgv(self, files, outputFile): 85 | raise Exception("Must be implemented") 86 | 87 | # For this and libLinkArgv(), the symbolFile should not have an extension. 88 | # The vendor chooses the extension if it supports symbol files at all. 89 | def programLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 90 | raise Exception("Must be implemented") 91 | 92 | def libLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 93 | raise Exception("Must be implemented") 94 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/tools/__init__.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 et: 2 | 3 | from ambuild2.frontend.v2_1.tools.fxc import FxcJob as FXC 4 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/vs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_1/vs/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/vs/gen.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import ambuild2.frontend.vs.gen as vs_gen 18 | from ambuild2.frontend.v2_1.vs import cxx 19 | 20 | class Generator(vs_gen.Generator): 21 | def __init__(self, cm): 22 | super(Generator, self).__init__(cm) 23 | 24 | # Overridden. 25 | def detectCompilers(self, options): 26 | if not self.compiler: 27 | version = cxx.Compiler.GetVersionFromVS(self.vs_version) 28 | vendor = cxx.VisualStudio(version) 29 | self.base_compiler = cxx.Compiler(vendor) 30 | self.compiler = self.base_compiler.clone() 31 | return self.compiler 32 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_1/vs/nodes.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | 18 | class Node(object): 19 | def __init__(self, context, path): 20 | super(Node, self).__init__() 21 | self.context = context 22 | self.path = path 23 | self.children = set() 24 | self.parents = set() 25 | 26 | def addParent(self, parent): 27 | self.parents.add(parent) 28 | parent.children.add(self) 29 | 30 | class FolderNode(Node): 31 | def __init__(self, path): 32 | super(FolderNode, self).__init__(None, path) 33 | 34 | @property 35 | def kind(self): 36 | return 'folder' 37 | 38 | class ContainerNode(Node): 39 | def __init__(self, cx): 40 | super(ContainerNode, self).__init__(cx, None) 41 | 42 | @property 43 | def kind(self): 44 | return 'container' 45 | 46 | class OutputNode(Node): 47 | def __init__(self, context, path, parent): 48 | super(OutputNode, self).__init__(context, path) 49 | self.addParent(parent) 50 | 51 | @property 52 | def kind(self): 53 | return 'output' 54 | 55 | class ProjectNode(Node): 56 | def __init__(self, context, path, project): 57 | super(ProjectNode, self).__init__(context, path) 58 | self.project = project 59 | self.uuid = None 60 | 61 | @property 62 | def kind(self): 63 | return 'project' 64 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_2/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_2/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_2/amb2_gen.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import os 18 | from ambuild2 import util 19 | from ambuild2.frontend import amb2_gen 20 | from ambuild2.frontend.v2_2.cpp import builders 21 | from ambuild2.frontend.v2_2.cpp import detect 22 | 23 | class Generator(amb2_gen.Generator): 24 | def __init__(self, cm): 25 | super(Generator, self).__init__(cm) 26 | 27 | def detectCompilers(self, **kwargs): 28 | with util.FolderChanger(self.cacheFolder): 29 | return detect.AutoDetectCxx(self.cm.host, self.cm.options, **kwargs) 30 | 31 | def newProgramProject(self, context, name): 32 | return builders.Project(builders.Program, name) 33 | 34 | def newLibraryProject(self, context, name): 35 | return builders.Project(builders.Library, name) 36 | 37 | def newStaticLibraryProject(self, context, name): 38 | return builders.Project(builders.StaticLibrary, name) -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_2/cpp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_2/cpp/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_2/cpp/deptypes.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | 18 | class CppNodes(object): 19 | def __init__(self, output, debug_outputs, type, target): 20 | self.binary = output 21 | self.debug = debug_outputs 22 | self.type = type 23 | self.target = target 24 | 25 | class PchNodes(object): 26 | def __init__(self, folder, header_file, pch_file, object_file, source_type): 27 | self.folder = folder 28 | self.header_file = header_file 29 | self.pch_file = pch_file 30 | self.object_file = object_file 31 | self.source_type = source_type 32 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_2/cpp/gcc.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import os 18 | from ambuild2 import util 19 | from ambuild2.frontend.v2_2.cpp.deptypes import PchNodes 20 | from ambuild2.frontend.v2_2.cpp.vendor import Vendor 21 | 22 | class GCCLookalike(Vendor): 23 | def __init__(self, version): 24 | super(GCCLookalike, self).__init__(version) 25 | 26 | @property 27 | def behavior(self): 28 | return 'gcc' 29 | 30 | @property 31 | def definePrefix(self): 32 | return '-D' 33 | 34 | @property 35 | def objSuffix(self): 36 | return '.o' 37 | 38 | @property 39 | def debugInfoArgv(self): 40 | return [] 41 | 42 | def parseDebugInfoType(self, debuginfo): 43 | return debuginfo 44 | 45 | @property 46 | def pch_needs_source_file(self): 47 | return False 48 | 49 | def formatInclude(self, build_root, output_path, include): 50 | return ['-I', os.path.normpath(include)] 51 | 52 | # We could use -MF -, but trying to parse something as idiosyncratic as Make 53 | # is probably best done when absolutely nothing else might be interspersed. 54 | def emits_dependency_file(self): 55 | return True 56 | 57 | def dependencyArgv(self, out_file): 58 | return ['-MD', '-MF', out_file] 59 | 60 | def objectArgs(self, sourceFile, objFile): 61 | return ['-c', sourceFile, '-o', objFile] 62 | 63 | def makePchArgv(self, source_file, obj_file, source_type): 64 | return ['-c', '-x', source_type + '-header', source_file, '-o', obj_file] 65 | 66 | def staticLinkArgv(self, files, outputFile): 67 | return ['ar', 'rcs', outputFile] + files 68 | 69 | def programLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 70 | return cmd_argv + files + linkFlags + ['-o', outputFile] 71 | 72 | def libLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 73 | argv = cmd_argv + files + linkFlags 74 | if util.IsMac(): 75 | argv += ['-dynamiclib'] 76 | else: 77 | argv += ['-shared'] 78 | argv += ['-o', outputFile] 79 | return argv 80 | 81 | def preprocessArgv(self, sourceFile, outFile): 82 | return ['-H', '-E', sourceFile, '-o', outFile] 83 | 84 | @staticmethod 85 | def IncludePath(outputPath, includePath): 86 | return includePath 87 | 88 | class GCC(GCCLookalike): 89 | def __init__(self, version): 90 | super(GCC, self).__init__(version) 91 | 92 | @property 93 | def name(self): 94 | return 'gcc' 95 | 96 | @property 97 | def family(self): 98 | return 'gcc' 99 | 100 | def like(self, name): 101 | return name == 'gcc' 102 | 103 | @property 104 | def pch_needs_strong_deps(self): 105 | return False 106 | 107 | def nameForPch(self, source_file): 108 | return source_file + '.gch' 109 | 110 | def formatPchInclude(self, build_root, output_path, pch): 111 | local_path = os.path.relpath(pch.header_file.path, output_path) 112 | return ['-include', local_path, '-I', os.path.split(local_path)[0]] 113 | 114 | class Clang(GCCLookalike): 115 | def __init__(self, version, vendor_prefix = None): 116 | # Set this first, since the constructor will need it. 117 | self.vendor_name = 'clang' 118 | if vendor_prefix is not None: 119 | self.vendor_name = '{0}-clang'.format(vendor_prefix) 120 | super(Clang, self).__init__(version) 121 | 122 | @property 123 | def name(self): 124 | return self.vendor_name 125 | 126 | @property 127 | def family(self): 128 | return 'clang' 129 | 130 | def like(self, name): 131 | return name == 'gcc' or name == 'clang' or name == self.name 132 | 133 | @property 134 | def debugInfoArgv(self): 135 | return ['-g3'] 136 | 137 | def nameForPch(self, source_file): 138 | return source_file + '.pch' 139 | 140 | def formatPchInclude(self, build_root, output_path, pch): 141 | pch_path = os.path.relpath(pch.pch_file.path, output_path) 142 | return ['-include-pch', pch_path, '-I', os.path.split(pch_path)[0]] 143 | 144 | @property 145 | def pch_needs_strong_deps(self): 146 | return True 147 | 148 | class Emscripten(Clang): 149 | def __init__(self, version): 150 | # Set this first, since the constructor will need it. 151 | super(Emscripten, self).__init__(version, 'emscripten') 152 | 153 | def nameForExecutable(self, name): 154 | return name + '.js' 155 | 156 | def nameForSharedLibrary(self, name): 157 | return name + '.bc' 158 | 159 | def nameForStaticLibrary(self, name): 160 | return util.StaticLibPrefix + name + '.a' 161 | 162 | @property 163 | def name(self): 164 | return 'emscripten' 165 | 166 | @property 167 | def family(self): 168 | return 'emscripten' 169 | 170 | def like(self, name): 171 | return name == 'gcc' or name == 'clang' or name == 'emscripten-clang' or name == 'emscripten' 172 | 173 | @property 174 | def debugInfoArgv(self): 175 | return [] 176 | 177 | def staticLinkArgv(self, files, outputFile): 178 | return ['emar', 'rcs', outputFile] + files 179 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_2/cpp/vendor.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=4 sw=4 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | 18 | import os 19 | from ambuild2 import util 20 | from ambuild2.frontend.version import Version 21 | 22 | class Vendor(object): 23 | def __init__(self, version): 24 | super(Vendor, self).__init__() 25 | self.version_string = version 26 | self.version = Version('{0}-{1}'.format(self.name, version)) 27 | self.extra_props = {} 28 | 29 | def nameForExecutable(self, name): 30 | return name + util.ExecutableSuffix 31 | 32 | def nameForSharedLibrary(self, name): 33 | return name + util.SharedLibSuffix 34 | 35 | def nameForStaticLibrary(self, name): 36 | return util.StaticLibPrefix + name + util.StaticLibSuffix 37 | 38 | def equals(self, other): 39 | return self.name == other.name and \ 40 | self.version == other.version and \ 41 | self.extra_props == other.extra_props 42 | 43 | def __str__(self): 44 | return '{0}-{1}'.format(self.name, self.version_string) 45 | 46 | @property 47 | def behavior(self): 48 | raise Exception("Must be implemented") 49 | 50 | @property 51 | def name(self): 52 | raise Exception("Must be implemented") 53 | 54 | @property 55 | def family(self): 56 | raise Exception("Must be implemented") 57 | 58 | def like(self, name): 59 | raise Exception("Must be implemented") 60 | 61 | @property 62 | def definePrefix(self): 63 | raise Exception("Must be implemented") 64 | 65 | @property 66 | def objSuffix(self): 67 | raise Exception("Must be implemented") 68 | 69 | @property 70 | def debug_info_argv(self): 71 | raise Exception("Must be implemented") 72 | 73 | def parseDebugInfoType(self, debuginfo): 74 | raise Exception("Must be implemented") 75 | 76 | def formatInclude(self, outputPath, includePath): 77 | raise Exception("Must be implemented") 78 | 79 | def formatPchInclude(self, output_path, pch): 80 | raise Exception("Must be implemented") 81 | 82 | def objectArgs(self, sourceFile, objFile): 83 | raise Exception("Must be implemented") 84 | 85 | # Note: this should return a complete initial argv, not partial. 86 | # AMBuild does not detect AR/LIB separately yet. 87 | def staticLinkArgv(self, files, outputFile): 88 | raise Exception("Must be implemented") 89 | 90 | # For this and libLinkArgv(), the symbolFile should not have an extension. 91 | # The vendor chooses the extension if it supports symbol files at all. 92 | def programLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 93 | raise Exception("Must be implemented") 94 | 95 | def libLinkArgv(self, cmd_argv, files, linkFlags, symbolFile, outputFile): 96 | raise Exception("Must be implemented") 97 | 98 | def nameForPrecompiledHeader(self, name): 99 | raise Exception("Must be implemented") 100 | 101 | @property 102 | def pch_needs_source_file(self): 103 | raise Exception("Must be implemented") 104 | 105 | @property 106 | def shared_pdb_flags(self): 107 | return set() 108 | 109 | def nameForPch(self, source_file): 110 | raise Exception("Must be implemented") 111 | 112 | @property 113 | def emits_dependency_file(self): 114 | raise Exception("Must be implemented") 115 | 116 | # If emits_dependency_file is True, this must be implemented. 117 | def dependencyArgv(self, out_file): 118 | raise Exception("Must be implemented") 119 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_2/tools/__init__.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 et: 2 | 3 | from ambuild2.frontend.v2_2.tools.fxc import FxcJob as FXC 4 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_2/vs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/v2_2/vs/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_2/vs/gen.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | import ambuild2.frontend.vs.gen as vs_gen 18 | from ambuild2.frontend.v2_2.vs import cxx 19 | 20 | class Generator(vs_gen.Generator): 21 | def __init__(self, cm): 22 | super(Generator, self).__init__(cm) 23 | self.vs_version_number = cxx.Compiler.GetVersionFromVS(self.vs_version) 24 | self.vs_vendor = cxx.VisualStudio(self.vs_version_number) 25 | 26 | # Overridden. 27 | def detectCompilers(self, **kwargs): 28 | return cxx.Compiler(self.vs_vendor, kwargs.pop('target_arch', None)) 29 | 30 | def newProgramProject(self, context, name): 31 | return cxx.Project(cxx.Program, name) 32 | 33 | def newLibraryProject(self, context, name): 34 | return cxx.Project(cxx.Library, name) 35 | 36 | def newStaticLibraryProject(self, context, name): 37 | return cxx.Project(cxx.StaticLibrary, name) 38 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/v2_2/vs/nodes.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | 18 | class Node(object): 19 | def __init__(self, context, path): 20 | super(Node, self).__init__() 21 | self.context = context 22 | self.path = path 23 | self.children = set() 24 | self.parents = set() 25 | 26 | def addParent(self, parent): 27 | self.parents.add(parent) 28 | parent.children.add(self) 29 | 30 | class FolderNode(Node): 31 | def __init__(self, path): 32 | super(FolderNode, self).__init__(None, path) 33 | 34 | @property 35 | def kind(self): 36 | return 'folder' 37 | 38 | class ContainerNode(Node): 39 | def __init__(self, cx): 40 | super(ContainerNode, self).__init__(cx, None) 41 | 42 | @property 43 | def kind(self): 44 | return 'container' 45 | 46 | class OutputNode(Node): 47 | def __init__(self, context, path, parent): 48 | super(OutputNode, self).__init__(context, path) 49 | self.addParent(parent) 50 | 51 | @property 52 | def kind(self): 53 | return 'output' 54 | 55 | class ProjectNode(Node): 56 | def __init__(self, context, path, project): 57 | super(ProjectNode, self).__init__(context, path) 58 | self.project = project 59 | self.uuid = None 60 | 61 | @property 62 | def kind(self): 63 | return 'project' 64 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/version.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | from ambuild2 import util 18 | 19 | class Version(object): 20 | def __init__(self, string): 21 | super(Version, self).__init__() 22 | if type(string) is int: 23 | self.string = str(string) 24 | self.vendor_name = None 25 | self.components = [string] 26 | else: 27 | self.string = string 28 | self.vendor_name, self.components = Version.split(string) 29 | 30 | def __str__(self): 31 | return self.string 32 | 33 | @staticmethod 34 | def split(string): 35 | vendor_pos = string.rfind('-') 36 | if vendor_pos != -1: 37 | vendor_name = string[:vendor_pos] 38 | version = string[vendor_pos + 1:] 39 | else: 40 | vendor_name = None 41 | version = string 42 | return vendor_name, [int(part) for part in version.split('.')] 43 | 44 | def __eq__(self, other): 45 | result = self.cmp_base(other) 46 | return result is not None and result == 0 47 | 48 | def __ne__(self, other): 49 | result = self.cmp_base(other) 50 | return result is None or result != 0 51 | 52 | def __le__(self, other): 53 | result = self.cmp_base(other) 54 | return result is not None and result <= 0 55 | 56 | def __lt__(self, other): 57 | result = self.cmp_base(other) 58 | return result is not None and result < 0 59 | 60 | def __gt__(self, other): 61 | result = self.cmp_base(other) 62 | return result is not None and result > 0 63 | 64 | def __ge__(self, other): 65 | result = self.cmp_base(other) 66 | return result is not None and result >= 0 67 | 68 | @staticmethod 69 | def parse(other): 70 | if hasattr(other, 'components'): 71 | components = other.components 72 | return getattr(other, 'vendor', None), other.components 73 | if type(other) is int: 74 | components = [other] 75 | return None, components 76 | return Version.split(str(other)) 77 | 78 | def cmp_base(self, other): 79 | vendor_name, components = Version.parse(other) 80 | 81 | # If this version or the other version doesn't care about the vendor name, 82 | # then return an ok comparison for compatibility. Otherwise, the vendor 83 | # names must match. 84 | if vendor_name is not None and self.vendor_name is not None: 85 | if vendor_name != self.vendor_name: 86 | return None 87 | return util.compare(self.components, components) 88 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/vs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamemann/fake-player-redirect/2629a2b7dff5375bf86736f38f680ed3c328015b/source/Rustam/ambuild2/frontend/vs/__init__.py -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/vs/nodes.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | 18 | class Node(object): 19 | def __init__(self, context, path): 20 | super(Node, self).__init__() 21 | self.context = context 22 | self.path = path 23 | self.children = set() 24 | self.parents = set() 25 | 26 | def addParent(self, parent): 27 | self.parents.add(parent) 28 | parent.children.add(self) 29 | 30 | class FolderNode(Node): 31 | def __init__(self, path): 32 | super(FolderNode, self).__init__(None, path) 33 | 34 | @property 35 | def kind(self): 36 | return 'folder' 37 | 38 | class ContainerNode(Node): 39 | def __init__(self, cx): 40 | super(ContainerNode, self).__init__(cx, None) 41 | 42 | @property 43 | def kind(self): 44 | return 'container' 45 | 46 | class OutputNode(Node): 47 | def __init__(self, context, path, parent): 48 | super(OutputNode, self).__init__(context, path) 49 | self.addParent(parent) 50 | 51 | @property 52 | def kind(self): 53 | return 'output' 54 | 55 | class ProjectNode(Node): 56 | def __init__(self, context, path, project): 57 | super(ProjectNode, self).__init__(context, path) 58 | self.project = project 59 | self.uuid = None 60 | 61 | @property 62 | def kind(self): 63 | return 'project' 64 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/frontend/vs/xmlbuilder.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | 18 | class XmlScope(object): 19 | def __init__(self, builder, tag, **kwargs): 20 | self.builder_ = builder 21 | self.tag_ = tag 22 | self.kwargs_ = kwargs 23 | 24 | def __enter__(self): 25 | self.builder_.enter(self.tag_, **self.kwargs_) 26 | 27 | def __exit__(self, type, value, traceback): 28 | self.builder_.leave(self.tag_) 29 | 30 | class XmlBuilder(object): 31 | def __init__(self, fp, version = "1.0", encoding = "utf-8"): 32 | super(XmlBuilder, self).__init__() 33 | self.fp_ = fp 34 | self.indent_ = 0 35 | self.write(''.format(version, encoding)) 36 | 37 | def block(self, tag, **kwargs): 38 | return XmlScope(self, tag, **kwargs) 39 | 40 | def tag(self, tag, contents = None, **kwargs): 41 | open = self.build_element(tag, **kwargs) 42 | if contents is None: 43 | self.write('<{0} />'.format(open)) 44 | else: 45 | self.write('<{0}>{1}'.format(open, contents, tag)) 46 | 47 | # Internal. 48 | def enter(self, tag, **kwargs): 49 | elt = self.build_element(tag, **kwargs) 50 | self.write('<{0}>'.format(elt)) 51 | self.indent_ += 1 52 | 53 | def leave(self, tag): 54 | self.indent_ -= 1 55 | self.write(''.format(tag)) 56 | 57 | def build_element(self, tag, **kwargs): 58 | if len(kwargs) == 0: 59 | return '{0}'.format(tag) 60 | 61 | props = [] 62 | for key in kwargs: 63 | props.append('{0}="{1}"'.format(key, kwargs[key])) 64 | attrs = ' '.join(props) 65 | return '{0} {1}'.format(tag, attrs) 66 | 67 | def write(self, line): 68 | self.fp_.write(' ' * self.indent_) 69 | self.fp_.write(line) 70 | self.fp_.write('\n') 71 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/graph.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 sw=2 tw=99 et: 2 | # 3 | # This file is part of AMBuild. 4 | # 5 | # AMBuild is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # AMBuild is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with AMBuild. If not, see . 17 | from ambuild2 import nodetypes 18 | 19 | class GraphNode(object): 20 | def __init__(self, entry): 21 | self.entry = entry 22 | self.incoming = set() 23 | self.outgoing = set() 24 | self.outputs = set() 25 | self.is_command = entry.isCommand() 26 | 27 | @property 28 | def type(self): 29 | return self.entry.type 30 | 31 | def isCommand(self): 32 | return self.is_command 33 | 34 | class Graph(object): 35 | def __init__(self, database): 36 | self.db = database 37 | self.node_map = {} 38 | self.node_list = [] 39 | self.worklist = [] 40 | self.create = [] 41 | 42 | def importEntry(self, entry): 43 | assert entry not in self.node_map 44 | 45 | graph_node = GraphNode(entry) 46 | self.node_map[entry] = graph_node 47 | self.node_list.append(graph_node) 48 | self.worklist.append(graph_node) 49 | return graph_node 50 | 51 | def addEntry(self, entry): 52 | if entry in self.node_map: 53 | return self.node_map[entry] 54 | 55 | return self.importEntry(entry) 56 | 57 | def addEdge(self, from_node, to_node): 58 | from_node.outgoing.add(to_node) 59 | to_node.incoming.add(from_node) 60 | 61 | def addEdgeToEntry(self, from_node, to_entry): 62 | if to_entry not in self.node_map: 63 | to_node = self.importEntry(to_entry) 64 | else: 65 | to_node = self.node_map[to_entry] 66 | self.addEdge(from_node, to_node) 67 | 68 | def integrate(self): 69 | while len(self.worklist): 70 | node = self.worklist.pop() 71 | 72 | for child_entry in self.db.query_outgoing(node.entry): 73 | self.addEdgeToEntry(node, child_entry) 74 | 75 | def complete_ordering(self): 76 | for node in self.node_list: 77 | if not node.isCommand(): 78 | continue 79 | 80 | for weak_input in self.db.query_weak_inputs(node.entry): 81 | if weak_input not in self.node_map: 82 | continue 83 | dep = self.node_map[weak_input] 84 | dep.outgoing.add(node) 85 | node.incoming.add(dep) 86 | 87 | # We should try to get rid of this algorithm; it's very expensive and not 88 | # really needed if we just include non-command nodes in the compressed 89 | # version of the graph. 90 | def filter_commands(self): 91 | worklist = [node for node in self.node_list if not node.isCommand()] 92 | for node in worklist: 93 | for output in node.outgoing: 94 | output.incoming.remove(node) 95 | output_delta = node.incoming - output.incoming 96 | output.incoming |= output_delta 97 | for x in output_delta: 98 | x.outgoing.add(output) 99 | 100 | for input in node.incoming: 101 | input.outgoing.remove(node) 102 | input_delta = node.outgoing - input.outgoing 103 | input.outgoing |= input_delta 104 | for x in input_delta: 105 | x.incoming.add(input) 106 | 107 | self.node_list = [node for node in self.node_list if node.isCommand()] 108 | 109 | def finish(self): 110 | self.integrate() 111 | self.complete_ordering() 112 | self.node_map = None 113 | 114 | @property 115 | def leafs(self): 116 | return [node for node in self.node_list if not len(node.incoming)] 117 | 118 | def for_each_child_of(self, node, callback): 119 | for outgoing in node.outgoing: 120 | if outgoing.isCommand(): 121 | callback(outgoing.entry) 122 | else: 123 | self.for_each_child_of(outgoing, callback) 124 | 125 | def for_each_leaf_command(self, callback): 126 | for node in self.leafs: 127 | if node.isCommand(): 128 | callback(node.entry) 129 | else: 130 | self.for_each_child_of(node, callback) 131 | 132 | def printGraph(self): 133 | for entry in self.create: 134 | print(' : ' + entry.format()) 135 | 136 | def printNode(node, indent): 137 | print((' ' * indent) + ' - ' + node.entry.format()) 138 | for incoming in node.incoming: 139 | printNode(incoming, indent + 1) 140 | 141 | for node in [node for node in self.node_list if not len(node.incoming)]: 142 | printNode(node, 0) 143 | -------------------------------------------------------------------------------- /source/Rustam/ambuild2/make_parser.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=4 ts=8 sw=4 tw=99 et: 2 | 3 | def LineHasContinuation(line): 4 | num_escapes = 0 5 | 6 | pos = len(line) - 1 7 | while pos >= 0: 8 | if line[pos] != '\\': 9 | break 10 | num_escapes += 1 11 | pos -= 1 12 | 13 | return num_escapes % 2 == 1 14 | 15 | def Preprocess(lines): 16 | chars = '' 17 | 18 | ignoring = False 19 | for line in lines: 20 | if line.endswith('\n'): 21 | line = line[:len(line) - 1] 22 | has_continuation = LineHasContinuation(line) 23 | if has_continuation: 24 | if ignoring: 25 | continue 26 | if line.startswith('#'): 27 | ignoring = True 28 | continue 29 | chars += line[:len(line) - 1] 30 | else: 31 | ignoring = False 32 | if line.startswith('#'): 33 | continue 34 | chars += line 35 | return chars 36 | 37 | class Parser(object): 38 | def __init__(self, fp): 39 | self.chars_ = Preprocess(fp.readlines()) 40 | self.pos_ = 0 41 | 42 | def parse(self): 43 | tok = self.lex(':') 44 | if tok is None or self.peek() != ':': 45 | raise Exception('No Makefile dependency rules found') 46 | self.pos_ += 1 47 | 48 | items = [] 49 | while True: 50 | tok = self.lex() 51 | if tok == '\n' or tok == '\r' or tok is None: 52 | break 53 | if tok.isspace(): 54 | continue 55 | items.append(tok) 56 | return items 57 | 58 | def lex(self, stop_token = None): 59 | token = self.peek() 60 | if token is None: 61 | return None 62 | self.pos_ += 1 63 | 64 | if token.isspace(): 65 | return token 66 | 67 | while True: 68 | c = self.peek() 69 | if c is None or c == stop_token or c.isspace(): 70 | break 71 | self.pos_ += 1 72 | if c == '\\': 73 | next_char = self.peek() 74 | if next_char is None: 75 | token += '\\' 76 | continue 77 | token += next_char 78 | self.pos_ += 1 79 | else: 80 | token += c 81 | 82 | return token 83 | 84 | def skip_newline(self, c): 85 | if c == '\r': 86 | self.pos_ += 1 87 | if self.peek() == '\n': 88 | self.pos_ += 1 89 | return True 90 | if self.peek() == '\n': 91 | self.pos_ += 1 92 | return True 93 | return False 94 | 95 | def peek(self): 96 | if self.pos_ >= len(self.chars_): 97 | return None 98 | return self.chars_[self.pos_] 99 | 100 | def ParseDependencyFile(filename, fp): 101 | p = Parser(fp) 102 | return p.parse() 103 | -------------------------------------------------------------------------------- /source/Rustam/asm/asm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define OP_JMP 0xE9 4 | #define OP_JMP_SIZE 5 5 | #define X64_ABS_SIZE 14 6 | 7 | #define OP_NOP 0x90 8 | #define OP_NOP_SIZE 1 9 | 10 | #define OP_PREFIX 0xFF 11 | #define OP_JMP_SEG 0x25 12 | 13 | #define OP_JMP_BYTE 0xEB 14 | #define OP_JMP_BYTE_SIZE 2 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | void check_thunks(unsigned char *dest, unsigned char *pc); 21 | 22 | //if dest is NULL, returns minimum number of bytes needed to be copied 23 | //if dest is not NULL, it will copy the bytes to dest as well as fix CALLs and JMPs 24 | //http://www.devmaster.net/forums/showthread.php?t=2311 25 | int copy_bytes(unsigned char *func, unsigned char* dest, unsigned int required_len); 26 | 27 | //insert a specific JMP instruction at the given location 28 | void inject_jmp(void* src, void* dest); 29 | 30 | //fill a given block with NOPs 31 | void fill_nop(void* src, unsigned int len); 32 | 33 | //evaluate a JMP at the target 34 | void* eval_jump(void* src); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /source/Rustam/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | # Simple extensions do not need to modify this file. 6 | 7 | builder = run.PrepareBuild(sourcePath = sys.path[0]) 8 | 9 | builder.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None, 10 | help='Root search folder for HL2SDKs') 11 | builder.options.add_option('--mms-path', type=str, dest='mms_path', default=None, 12 | help='Path to Metamod:Source') 13 | builder.options.add_option('--sm-path', type=str, dest='sm_path', default=None, 14 | help='Path to SourceMod') 15 | builder.options.add_option('--enable-debug', action='store_const', const='1', dest='debug', 16 | help='Enable debugging symbols') 17 | builder.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt', 18 | help='Enable optimization') 19 | builder.options.add_option('-s', '--sdks', default='all', dest='sdks', 20 | help='Build against specified SDKs; valid args are "all", "present", or ' 21 | 'comma-delimited list of engine names (default: %default)') 22 | 23 | builder.Configure() 24 | -------------------------------------------------------------------------------- /source/Rustam/extension.h: -------------------------------------------------------------------------------- 1 | /** 2 | * vim: set ts=4 : 3 | * ============================================================================= 4 | * SourceMod Sample Extension 5 | * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. 6 | * ============================================================================= 7 | * 8 | * This program is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU General Public License, version 3.0, as published by the 10 | * Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 | * details. 16 | * 17 | * You should have received a copy of the GNU General Public License along with 18 | * this program. If not, see . 19 | * 20 | * As a special exception, AlliedModders LLC gives you permission to link the 21 | * code of this program (as well as its derivative works) to "Half-Life 2," the 22 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software 23 | * by the Valve Corporation. You must obey the GNU General Public License in 24 | * all respects for all other code used. Additionally, AlliedModders LLC grants 25 | * this exception to all derivative works. AlliedModders LLC defines further 26 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), 27 | * or . 28 | * 29 | * Version: $Id$ 30 | */ 31 | 32 | #ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ 33 | #define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ 34 | 35 | /** 36 | * @file extension.h 37 | * @brief Sample extension code header. 38 | */ 39 | 40 | #include "sdk/smsdk_ext.h" 41 | #include "CDetour/detours.h" 42 | 43 | /** 44 | * @brief Sample implementation of the SDK Extension. 45 | * Note: Uncomment one of the pre-defined virtual functions in order to use it. 46 | */ 47 | 48 | class Sample : public SDKExtension 49 | { 50 | public: 51 | /** 52 | * @brief This is called after the initial loading sequence has been processed. 53 | * 54 | * @param error Error message buffer. 55 | * @param maxlen Size of error message buffer. 56 | * @param late Whether or not the module was loaded after map load. 57 | * @return True to succeed loading, false to fail. 58 | */ 59 | virtual bool SDK_OnLoad(char *error, size_t maxlen, bool late); 60 | 61 | //void OnMapStart(); 62 | /** 63 | * @brief This is called right before the extension is unloaded. 64 | */ 65 | virtual void SDK_OnUnload(); 66 | 67 | /** 68 | * @brief This is called once all known extensions have been loaded. 69 | * Note: It is is a good idea to add natives here, if any are provided. 70 | */ 71 | virtual void SDK_OnAllLoaded(); 72 | 73 | /** 74 | * @brief Called when the pause state is changed. 75 | */ 76 | //virtual void SDK_OnPauseChange(bool paused); 77 | 78 | /** 79 | * @brief this is called when Core wants to know if your extension is working. 80 | * 81 | * @param error Error message buffer. 82 | * @param maxlen Size of error message buffer. 83 | * @return True if working, false otherwise. 84 | */ 85 | //virtual bool QueryRunning(char *error, size_t maxlen); 86 | public: 87 | #if defined SMEXT_CONF_METAMOD 88 | /** 89 | * @brief Called when Metamod is attached, before the extension version is called. 90 | * 91 | * @param error Error buffer. 92 | * @param maxlen Maximum size of error buffer. 93 | * @param late Whether or not Metamod considers this a late load. 94 | * @return True to succeed, false to fail. 95 | */ 96 | virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late); 97 | 98 | /** 99 | * @brief Called when Metamod is detaching, after the extension version is called. 100 | * NOTE: By default this is blocked unless sent from SourceMod. 101 | * 102 | * @param error Error buffer. 103 | * @param maxlen Maximum size of error buffer. 104 | * @return True to succeed, false to fail. 105 | */ 106 | //virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen); 107 | 108 | /** 109 | * @brief Called when Metamod's pause state is changing. 110 | * NOTE: By default this is blocked unless sent from SourceMod. 111 | * 112 | * @param paused Pause state being set. 113 | * @param error Error buffer. 114 | * @param maxlen Maximum size of error buffer. 115 | * @return True to succeed, false to fail. 116 | */ 117 | //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen); 118 | #endif 119 | }; 120 | 121 | #endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ 122 | -------------------------------------------------------------------------------- /source/Rustam/libudis86/decode.h: -------------------------------------------------------------------------------- 1 | /* udis86 - libudis86/decode.h 2 | * 3 | * Copyright (c) 2002-2009 Vivek Thampi 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef UD_DECODE_H 27 | #define UD_DECODE_H 28 | 29 | #include "types.h" 30 | #include "itab.h" 31 | 32 | #define MAX_INSN_LENGTH 15 33 | 34 | /* itab prefix bits */ 35 | #define P_none ( 0 ) 36 | #define P_cast ( 1 << 0 ) 37 | #define P_CAST(n) ( ( n >> 0 ) & 1 ) 38 | #define P_rexb ( 1 << 1 ) 39 | #define P_REXB(n) ( ( n >> 1 ) & 1 ) 40 | #define P_inv64 ( 1 << 4 ) 41 | #define P_INV64(n) ( ( n >> 4 ) & 1 ) 42 | #define P_rexw ( 1 << 5 ) 43 | #define P_REXW(n) ( ( n >> 5 ) & 1 ) 44 | #define P_def64 ( 1 << 7 ) 45 | #define P_DEF64(n) ( ( n >> 7 ) & 1 ) 46 | #define P_rexr ( 1 << 8 ) 47 | #define P_REXR(n) ( ( n >> 8 ) & 1 ) 48 | #define P_oso ( 1 << 9 ) 49 | #define P_OSO(n) ( ( n >> 9 ) & 1 ) 50 | #define P_aso ( 1 << 10 ) 51 | #define P_ASO(n) ( ( n >> 10 ) & 1 ) 52 | #define P_rexx ( 1 << 11 ) 53 | #define P_REXX(n) ( ( n >> 11 ) & 1 ) 54 | #define P_ImpAddr ( 1 << 12 ) 55 | #define P_IMPADDR(n) ( ( n >> 12 ) & 1 ) 56 | #define P_seg ( 1 << 13 ) 57 | #define P_SEG(n) ( ( n >> 13 ) & 1 ) 58 | #define P_str ( 1 << 14 ) 59 | #define P_STR(n) ( ( n >> 14 ) & 1 ) 60 | #define P_strz ( 1 << 15 ) 61 | #define P_STR_ZF(n) ( ( n >> 15 ) & 1 ) 62 | 63 | /* operand type constants -- order is important! */ 64 | 65 | enum ud_operand_code { 66 | OP_NONE, 67 | 68 | OP_A, OP_E, OP_M, OP_G, 69 | OP_I, OP_F, 70 | 71 | OP_R0, OP_R1, OP_R2, OP_R3, 72 | OP_R4, OP_R5, OP_R6, OP_R7, 73 | 74 | OP_AL, OP_CL, OP_DL, 75 | OP_AX, OP_CX, OP_DX, 76 | OP_eAX, OP_eCX, OP_eDX, 77 | OP_rAX, OP_rCX, OP_rDX, 78 | 79 | OP_ES, OP_CS, OP_SS, OP_DS, 80 | OP_FS, OP_GS, 81 | 82 | OP_ST0, OP_ST1, OP_ST2, OP_ST3, 83 | OP_ST4, OP_ST5, OP_ST6, OP_ST7, 84 | 85 | OP_J, OP_S, OP_O, 86 | OP_I1, OP_I3, OP_sI, 87 | 88 | OP_V, OP_W, OP_Q, OP_P, 89 | OP_U, OP_N, OP_MU, 90 | 91 | OP_R, OP_C, OP_D, 92 | 93 | OP_MR 94 | } UD_ATTR_PACKED; 95 | 96 | 97 | /* operand size constants */ 98 | 99 | enum ud_operand_size { 100 | SZ_NA = 0, 101 | SZ_Z = 1, 102 | SZ_V = 2, 103 | SZ_RDQ = 7, 104 | 105 | /* the following values are used as is, 106 | * and thus hard-coded. changing them 107 | * will break internals 108 | */ 109 | SZ_B = 8, 110 | SZ_W = 16, 111 | SZ_D = 32, 112 | SZ_Q = 64, 113 | SZ_T = 80, 114 | SZ_O = 128, 115 | 116 | SZ_Y = 17, 117 | 118 | /* 119 | * complex size types, that encode sizes for operands 120 | * of type MR (memory or register), for internal use 121 | * only. Id space 256 and above. 122 | */ 123 | SZ_BD = (SZ_B << 8) | SZ_D, 124 | SZ_BV = (SZ_B << 8) | SZ_V, 125 | SZ_WD = (SZ_W << 8) | SZ_D, 126 | SZ_WV = (SZ_W << 8) | SZ_V, 127 | SZ_WY = (SZ_W << 8) | SZ_Y, 128 | SZ_DY = (SZ_D << 8) | SZ_Y, 129 | SZ_WO = (SZ_W << 8) | SZ_O, 130 | SZ_DO = (SZ_D << 8) | SZ_O, 131 | SZ_QO = (SZ_Q << 8) | SZ_O, 132 | 133 | } UD_ATTR_PACKED; 134 | 135 | 136 | /* resolve complex size type. 137 | */ 138 | static inline enum ud_operand_size 139 | Mx_mem_size(enum ud_operand_size size) 140 | { 141 | return (size >> 8) & 0xff; 142 | } 143 | 144 | static inline enum ud_operand_size 145 | Mx_reg_size(enum ud_operand_size size) 146 | { 147 | return size & 0xff; 148 | } 149 | 150 | /* A single operand of an entry in the instruction table. 151 | * (internal use only) 152 | */ 153 | struct ud_itab_entry_operand 154 | { 155 | enum ud_operand_code type; 156 | enum ud_operand_size size; 157 | }; 158 | 159 | 160 | /* A single entry in an instruction table. 161 | *(internal use only) 162 | */ 163 | struct ud_itab_entry 164 | { 165 | enum ud_mnemonic_code mnemonic; 166 | struct ud_itab_entry_operand operand1; 167 | struct ud_itab_entry_operand operand2; 168 | struct ud_itab_entry_operand operand3; 169 | uint32_t prefix; 170 | }; 171 | 172 | struct ud_lookup_table_list_entry { 173 | const uint16_t *table; 174 | enum ud_table_type type; 175 | const char *meta; 176 | }; 177 | 178 | 179 | 180 | static inline int 181 | ud_opcode_field_sext(uint8_t primary_opcode) 182 | { 183 | return (primary_opcode & 0x02) != 0; 184 | } 185 | 186 | extern struct ud_itab_entry ud_itab[]; 187 | extern struct ud_lookup_table_list_entry ud_lookup_table_list[]; 188 | 189 | #endif /* UD_DECODE_H */ 190 | 191 | /* vim:cindent 192 | * vim:expandtab 193 | * vim:ts=4 194 | * vim:sw=4 195 | */ 196 | -------------------------------------------------------------------------------- /source/Rustam/libudis86/extern.h: -------------------------------------------------------------------------------- 1 | /* udis86 - libudis86/extern.h 2 | * 3 | * Copyright (c) 2002-2009, 2013 Vivek Thampi 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef UD_EXTERN_H 27 | #define UD_EXTERN_H 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | #include "types.h" 34 | 35 | /* ============================= PUBLIC API ================================= */ 36 | 37 | extern void ud_init(struct ud*); 38 | 39 | extern void ud_set_mode(struct ud*, uint8_t); 40 | 41 | extern void ud_set_pc(struct ud*, uint64_t); 42 | 43 | extern void ud_set_input_hook(struct ud*, int (*)(struct ud*)); 44 | 45 | extern void ud_set_input_buffer(struct ud*, const uint8_t*, size_t); 46 | 47 | #ifndef __UD_STANDALONE__ 48 | extern void ud_set_input_file(struct ud*, FILE*); 49 | #endif /* __UD_STANDALONE__ */ 50 | 51 | extern void ud_set_vendor(struct ud*, unsigned); 52 | 53 | extern void ud_set_syntax(struct ud*, void (*)(struct ud*)); 54 | 55 | extern void ud_input_skip(struct ud*, size_t); 56 | 57 | extern int ud_input_end(const struct ud*); 58 | 59 | extern unsigned int ud_decode(struct ud*); 60 | 61 | extern unsigned int ud_disassemble(struct ud*); 62 | 63 | extern void ud_translate_intel(struct ud*); 64 | 65 | extern void ud_translate_att(struct ud*); 66 | 67 | extern const char* ud_insn_asm(const struct ud* u); 68 | 69 | extern const uint8_t* ud_insn_ptr(const struct ud* u); 70 | 71 | extern uint64_t ud_insn_off(const struct ud*); 72 | 73 | extern const char* ud_insn_hex(struct ud*); 74 | 75 | extern unsigned int ud_insn_len(const struct ud* u); 76 | 77 | extern const struct ud_operand* ud_insn_opr(const struct ud *u, unsigned int n); 78 | 79 | extern int ud_opr_is_sreg(const struct ud_operand *opr); 80 | 81 | extern int ud_opr_is_gpr(const struct ud_operand *opr); 82 | 83 | extern enum ud_mnemonic_code ud_insn_mnemonic(const struct ud *u); 84 | 85 | extern const char* ud_lookup_mnemonic(enum ud_mnemonic_code c); 86 | 87 | extern void ud_set_user_opaque_data(struct ud*, void*); 88 | 89 | extern void* ud_get_user_opaque_data(const struct ud*); 90 | 91 | extern uint64_t ud_insn_sext_imm(const struct ud*, const struct ud_operand*); 92 | 93 | extern void ud_set_asm_buffer(struct ud *u, char *buf, size_t size); 94 | 95 | extern void ud_set_sym_resolver(struct ud *u, 96 | const char* (*resolver)(struct ud*, 97 | uint64_t addr, 98 | int64_t *offset)); 99 | 100 | /* ========================================================================== */ 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | #endif /* UD_EXTERN_H */ 106 | -------------------------------------------------------------------------------- /source/Rustam/libudis86/syn.h: -------------------------------------------------------------------------------- 1 | /* udis86 - libudis86/syn.h 2 | * 3 | * Copyright (c) 2002-2009 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef UD_SYN_H 27 | #define UD_SYN_H 28 | 29 | #include "types.h" 30 | #ifndef __UD_STANDALONE__ 31 | # include 32 | #endif /* __UD_STANDALONE__ */ 33 | 34 | extern const char* ud_reg_tab[]; 35 | 36 | uint64_t ud_syn_rel_target(struct ud*, struct ud_operand*); 37 | 38 | #ifdef __GNUC__ 39 | int ud_asmprintf(struct ud *u, const char *fmt, ...) 40 | __attribute__ ((format (printf, 2, 3))); 41 | #else 42 | int ud_asmprintf(struct ud *u, const char *fmt, ...); 43 | #endif 44 | 45 | void ud_syn_print_addr(struct ud *u, uint64_t addr); 46 | void ud_syn_print_imm(struct ud* u, const struct ud_operand *op); 47 | void ud_syn_print_mem_disp(struct ud* u, const struct ud_operand *, int sign); 48 | 49 | #endif /* UD_SYN_H */ 50 | 51 | /* 52 | vim: set ts=2 sw=2 expandtab 53 | */ 54 | -------------------------------------------------------------------------------- /source/Rustam/libudis86/udint.h: -------------------------------------------------------------------------------- 1 | /* udis86 - libudis86/udint.h -- definitions for internal use only 2 | * 3 | * Copyright (c) 2002-2009 Vivek Thampi 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef _UDINT_H_ 27 | #define _UDINT_H_ 28 | 29 | #ifdef HAVE_CONFIG_H 30 | # include 31 | #endif /* HAVE_CONFIG_H */ 32 | 33 | #if defined(UD_DEBUG) && HAVE_ASSERT_H 34 | # include 35 | # define UD_ASSERT(_x) assert(_x) 36 | #else 37 | # define UD_ASSERT(_x) 38 | #endif /* !HAVE_ASSERT_H */ 39 | 40 | #if defined(UD_DEBUG) 41 | #define UDERR(u, msg) \ 42 | do { \ 43 | (u)->error = 1; \ 44 | fprintf(stderr, "decode-error: %s:%d: %s", \ 45 | __FILE__, __LINE__, (msg)); \ 46 | } while (0) 47 | #else 48 | #define UDERR(u, m) \ 49 | do { \ 50 | (u)->error = 1; \ 51 | } while (0) 52 | #endif /* !LOGERR */ 53 | 54 | #define UD_RETURN_ON_ERROR(u) \ 55 | do { \ 56 | if ((u)->error != 0) { \ 57 | return (u)->error; \ 58 | } \ 59 | } while (0) 60 | 61 | #define UD_RETURN_WITH_ERROR(u, m) \ 62 | do { \ 63 | UDERR(u, m); \ 64 | return (u)->error; \ 65 | } while (0) 66 | 67 | #ifndef __UD_STANDALONE__ 68 | # define UD_NON_STANDALONE(x) x 69 | #else 70 | # define UD_NON_STANDALONE(x) 71 | #endif 72 | 73 | /* printf formatting int64 specifier */ 74 | #ifdef FMT64 75 | # undef FMT64 76 | #endif 77 | #if defined(_MSC_VER) || defined(__BORLANDC__) 78 | # define FMT64 "I64" 79 | #else 80 | # if defined(__APPLE__) 81 | # define FMT64 "ll" 82 | # elif defined(__amd64__) || defined(__x86_64__) 83 | # define FMT64 "l" 84 | # else 85 | # define FMT64 "ll" 86 | # endif /* !x64 */ 87 | #endif 88 | 89 | #endif /* _UDINT_H_ */ 90 | -------------------------------------------------------------------------------- /source/Rustam/libudis86/udis86.h: -------------------------------------------------------------------------------- 1 | /* udis86 - udis86.h 2 | * 3 | * Copyright (c) 2002-2009 Vivek Thampi 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, 7 | * are permitted provided that the following conditions are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef UDIS86_H 27 | #define UDIS86_H 28 | 29 | #include "libudis86/types.h" 30 | #include "libudis86/extern.h" 31 | #include "libudis86/itab.h" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /source/Rustam/scripts/ambuild_dsymutil_wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -lt 3 ]; then 4 | echo "Usage: <...linker args>"; 5 | exit 1; 6 | fi 7 | 8 | LD_FILE=$1 9 | LD_EXEC=$2 10 | 11 | shift; 12 | shift; 13 | 14 | $LD_EXEC $@ 15 | if [ $? -ne 0 ]; then 16 | exit $? 17 | fi 18 | dsymutil $LD_FILE 19 | if [ $? -ne 0 ]; then 20 | exit $? 21 | fi 22 | strip -S $LD_FILE 23 | if [ $? -ne 0 ]; then 24 | exit $? 25 | fi 26 | 27 | -------------------------------------------------------------------------------- /source/Rustam/scripts/ambuild_objcopy_wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -lt 3 ]; then 4 | echo "Usage: <...linker args>"; 5 | exit 1; 6 | fi 7 | 8 | LD_FILE=$1 9 | LD_EXEC=$2 10 | 11 | shift; 12 | shift; 13 | 14 | $LD_EXEC $@ 15 | if [ $? -ne 0 ]; then 16 | exit $? 17 | fi 18 | objcopy --only-keep-debug $LD_FILE $LD_FILE.dbg 19 | if [ $? -ne 0 ]; then 20 | exit $? 21 | fi 22 | objcopy --strip-debug $LD_FILE 23 | if [ $? -ne 0 ]; then 24 | exit $? 25 | fi 26 | objcopy --add-gnu-debuglink=$LD_FILE.dbg $LD_FILE 27 | if [ $? -ne 0 ]; then 28 | exit $? 29 | fi 30 | -------------------------------------------------------------------------------- /source/Rustam/sdk/smsdk_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * vim: set ts=4 : 3 | * ============================================================================= 4 | * SourceMod Sample Extension 5 | * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. 6 | * ============================================================================= 7 | * 8 | * This program is free software; you can redistribute it and/or modify it under 9 | * the terms of the GNU General Public License, version 3.0, as published by the 10 | * Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 | * details. 16 | * 17 | * You should have received a copy of the GNU General Public License along with 18 | * this program. If not, see . 19 | * 20 | * As a special exception, AlliedModders LLC gives you permission to link the 21 | * code of this program (as well as its derivative works) to "Half-Life 2," the 22 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software 23 | * by the Valve Corporation. You must obey the GNU General Public License in 24 | * all respects for all other code used. Additionally, AlliedModders LLC grants 25 | * this exception to all derivative works. AlliedModders LLC defines further 26 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), 27 | * or . 28 | * 29 | * Version: $Id$ 30 | */ 31 | 32 | #ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ 33 | #define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ 34 | 35 | /** 36 | * @file smsdk_config.h 37 | * @brief Contains macros for configuring basic extension information. 38 | */ 39 | 40 | /* Basic information exposed publicly */ 41 | #define SMEXT_CONF_NAME "FakeServer" 42 | #define SMEXT_CONF_DESCRIPTION "Fake MasterServer" 43 | #define SMEXT_CONF_VERSION "1.0" 44 | #define SMEXT_CONF_AUTHOR "Dave" 45 | #define SMEXT_CONF_URL "EasyGaming.ru" 46 | #define SMEXT_CONF_LOGTAG "FakeSlots" 47 | #define SMEXT_CONF_LICENSE "GPL" 48 | #define SMEXT_CONF_DATESTRING __DATE__ 49 | 50 | /** 51 | * @brief Exposes plugin's main interface. 52 | */ 53 | #define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name; 54 | 55 | /** 56 | * @brief Sets whether or not this plugin required Metamod. 57 | * NOTE: Uncomment to enable, comment to disable. 58 | */ 59 | #define SMEXT_CONF_METAMOD 60 | 61 | /** Enable interfaces you want to use here by uncommenting lines */ 62 | //#define SMEXT_ENABLE_FORWARDSYS 63 | //#define SMEXT_ENABLE_HANDLESYS 64 | #define SMEXT_ENABLE_PLAYERHELPERS 65 | //#define SMEXT_ENABLE_DBMANAGER 66 | #define SMEXT_ENABLE_GAMECONF 67 | //#define SMEXT_ENABLE_MEMUTILS 68 | #define SMEXT_ENABLE_GAMEHELPERS 69 | //#define SMEXT_ENABLE_TIMERSYS 70 | //#define SMEXT_ENABLE_THREADER 71 | //#define SMEXT_ENABLE_LIBSYS 72 | //#define SMEXT_ENABLE_MENUS 73 | //#define SMEXT_ENABLE_ADTFACTORY 74 | //#define SMEXT_ENABLE_PLUGINSYS 75 | //#define SMEXT_ENABLE_ADMINSYS 76 | //#define SMEXT_ENABLE_TEXTPARSERS 77 | //#define SMEXT_ENABLE_USERMSGS 78 | //#define SMEXT_ENABLE_TRANSLATOR 79 | //#define SMEXT_ENABLE_ROOTCONSOLEMENU 80 | 81 | #endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ 82 | -------------------------------------------------------------------------------- /source/Rustam/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # vim: set ts=2 sw=2 tw=99 et: 3 | 4 | import sys 5 | 6 | def detect_distutils(): 7 | sys.path.pop(0) 8 | try: 9 | import ambuild2.util 10 | try: 11 | val = getattr(ambuild2.util, 'INSTALLED_BY_PIP_OR_SETUPTOOLS') 12 | except AttributeError: 13 | sys.exit(1) 14 | except ImportError: 15 | pass 16 | 17 | sys.exit(0) 18 | 19 | # This if statement is supposedly required by multiprocessing. 20 | if __name__ == '__main__': 21 | import os 22 | import multiprocessing as mp 23 | 24 | mp.freeze_support() 25 | proc = mp.Process(target = detect_distutils) 26 | proc.start() 27 | proc.join() 28 | 29 | if proc.exitcode != 0: 30 | sys.stderr.write("You have an older installation of AMBuild. AMBuild must\n") 31 | sys.stderr.write("now be installed using pip (see README.md). To prevent\n") 32 | sys.stderr.write("conflicts, please remove the old distutils version. You can\n") 33 | sys.stderr.write("do this by inspecting the following paths and removing\n") 34 | sys.stderr.write("any ambuild folders:\n") 35 | 36 | for path in sys.path[1:]: 37 | for subdir in ['ambuild', 'ambuild2']: 38 | subpath = os.path.join(path, subdir) 39 | if os.path.exists(subpath): 40 | sys.stderr.write('\t{}\n'.format(subpath)) 41 | 42 | sys.stderr.write('Aborting installation.\n') 43 | sys.stderr.flush() 44 | sys.exit(1) 45 | 46 | from setuptools import setup, find_packages 47 | try: 48 | import sqlite3 49 | except: 50 | raise SystemError('py-sqlite3 must be installed') 51 | 52 | amb_scripts = [] 53 | if sys.platform != 'win32': 54 | if sys.platform == 'darwin': 55 | amb_scripts.append('scripts/ambuild_dsymutil_wrapper.sh') 56 | else: 57 | amb_scripts.append('scripts/ambuild_objcopy_wrapper.sh') 58 | 59 | setup(name = 'AMBuild', 60 | version = '2.0', 61 | description = 'AlliedModders Build System', 62 | author = 'David Anderson', 63 | author_email = 'dvander@alliedmods.net', 64 | url = 'http://www.alliedmods.net/ambuild', 65 | packages = find_packages(), 66 | python_requires = '>=2.6', 67 | entry_points = {'console_scripts': ['ambuild = ambuild2.run:cli_run']}, 68 | scripts = amb_scripts, 69 | zip_safe = False) 70 | -------------------------------------------------------------------------------- /source/Rustam/tests/always_dirty/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | import os 3 | 4 | _, outputs = builder.AddCommand( 5 | inputs = builder.ALWAYS_DIRTY, 6 | outputs = ['sample.h'], 7 | argv = ['python', os.path.join(builder.sourcePath, 'generate.py')] 8 | ) 9 | -------------------------------------------------------------------------------- /source/Rustam/tests/always_dirty/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | API_VERSION = '2.1' 3 | 4 | import sys 5 | try: 6 | from ambuild2 import run 7 | if not run.HasAPI(API_VERSION): 8 | raise Exception() 9 | except: 10 | sys.stderr.write('AMBuild {0} must be installed to build this project.\n'.format(API_VERSION)) 11 | sys.stderr.write('http://www.alliedmods.net/ambuild\n') 12 | sys.exit(1) 13 | 14 | builder = run.BuildParser(sourcePath = sys.path[0], api = API_VERSION) 15 | builder.Configure() 16 | -------------------------------------------------------------------------------- /source/Rustam/tests/always_dirty/generate.py: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 tw=99 et: 2 | import datetime 3 | 4 | def main(): 5 | with open('sample.h', 'w') as fp: 6 | fp.write("const char* DATE = {0};\n".format(datetime.datetime.now())) 7 | 8 | if __name__ == '__main__': 9 | main() 10 | -------------------------------------------------------------------------------- /source/Rustam/tests/api2_2/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | builder.cxx = builder.DetectCxx() 3 | builder.Build('core/AMBuild') 4 | if '-Wall' in builder.cxx.cflags: 5 | raise Exception('Child build script did not inherit properly') 6 | -------------------------------------------------------------------------------- /source/Rustam/tests/api2_2/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | API_VERSION = '2.2' 3 | 4 | import sys 5 | try: 6 | from ambuild2 import run 7 | if not run.HasAPI(API_VERSION): 8 | raise Exception() 9 | except: 10 | sys.stderr.write('AMBuild {0} must be installed to build this project.\n'.format(API_VERSION)) 11 | sys.stderr.write('http://www.alliedmods.net/ambuild\n') 12 | sys.exit(1) 13 | 14 | builder = run.BuildParser(sourcePath = sys.path[0], api = API_VERSION) 15 | builder.Configure() 16 | -------------------------------------------------------------------------------- /source/Rustam/tests/api2_2/core/AMBuild: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | 3 | # This should only change the cxx for this builder. 4 | if builder.cxx.like('gcc'): 5 | builder.cxx.cflags += ['-Wall', '-Werror'] 6 | else: 7 | builder.cxx.cflags += ['/WX'] 8 | 9 | program = builder.cxx.Program('sample') 10 | program.sources += [ 11 | 'main.cc', 12 | ] 13 | 14 | builder.Add(program) 15 | -------------------------------------------------------------------------------- /source/Rustam/tests/api2_2/core/main.cc: -------------------------------------------------------------------------------- 1 | 2 | int main() 3 | { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /source/Rustam/tests/autoinclude/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | builder.DetectCompilers() 5 | 6 | argv = [ 7 | sys.executable, 8 | os.path.join(builder.sourcePath, 'generate_header.py'), 9 | os.path.join(builder.buildPath, 'output.h') 10 | ] 11 | 12 | outputs = [ 13 | os.path.join(builder.buildFolder, 'output.h') 14 | ] 15 | 16 | sources = [ 17 | os.path.join(builder.sourcePath, 'activate.txt'), 18 | argv[1] 19 | ] 20 | cmd_node, (output_header,) = builder.AddCommand( 21 | inputs = sources, 22 | argv = argv, 23 | outputs = outputs 24 | ) 25 | 26 | program = builder.compiler.Library("hello") 27 | program.compiler.includes += [builder.buildPath] 28 | program.compiler.sourcedeps += [output_header] 29 | program.sources = [ 30 | 'main.cpp' 31 | ] 32 | builder.Add(program) 33 | -------------------------------------------------------------------------------- /source/Rustam/tests/autoinclude/activate.txt: -------------------------------------------------------------------------------- 1 | I don't do anything. 2 | -------------------------------------------------------------------------------- /source/Rustam/tests/autoinclude/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.BuildParser(sourcePath = sys.path[0], api = '2.1') 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/autoinclude/generate_header.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | 4 | with open(sys.argv[1], 'w') as fp: 5 | fp.write(""" 6 | #ifndef HELLO_STRING 7 | # define HELLO_STRING "HELLO!" 8 | #endif 9 | """) 10 | -------------------------------------------------------------------------------- /source/Rustam/tests/autoinclude/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | printf("%s\n", HELLO_STRING); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /source/Rustam/tests/cx_paths/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | builder.DetectCompilers() 3 | if builder.compiler.family == 'gcc': 4 | builder.compiler.cflags += [ 5 | '-Wall', 6 | '-Werror' 7 | ] 8 | 9 | builder.RunBuildScript('helper/helper.ambuild') 10 | -------------------------------------------------------------------------------- /source/Rustam/tests/cx_paths/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.BuildParser(sourcePath = sys.path[0], api = "2.1") 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/cx_paths/helper/helper.ambuild: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | 3 | builder.RunBuildScript('/program.ambuild') 4 | -------------------------------------------------------------------------------- /source/Rustam/tests/cx_paths/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char** argv) 4 | { 5 | printf("hello!\n"); 6 | } 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/cx_paths/program.ambuild: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | program = builder.compiler.Program('sample') 3 | program.sources += [ 4 | 'main.cpp', 5 | ] 6 | builder.Add(program) 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/dsymutil/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | builder.DetectCompilers() 5 | 6 | program = builder.compiler.Program("hello") 7 | program.sources = [ 8 | 'main.cpp' 9 | ] 10 | builder.Add(program) 11 | -------------------------------------------------------------------------------- /source/Rustam/tests/dsymutil/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.PrepareBuild(sourcePath = sys.path[0]) 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/dsymutil/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | return printf("hello!\n"); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /source/Rustam/tests/invalid_symlink/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | builder.DetectCompilers() 5 | 6 | program = builder.compiler.Program("hello") 7 | program.sources = [ 8 | 'main.cpp' 9 | ] 10 | out = builder.Add(program) 11 | builder.AddSymlink(out.binary, 'hello.bin') 12 | -------------------------------------------------------------------------------- /source/Rustam/tests/invalid_symlink/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.PrepareBuild(sourcePath = sys.path[0]) 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/invalid_symlink/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | return printf("hello!\n"); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /source/Rustam/tests/modules/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | builder.DetectCxx() 3 | 4 | builder.Build('core/AMBuild') 5 | -------------------------------------------------------------------------------- /source/Rustam/tests/modules/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.BuildParser(sourcePath = sys.path[0], api = "2.1") 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/modules/core/AMBuild: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | 3 | program = builder.cxx.Program('sample') 4 | program.sources += [ 5 | 'main.cc', 6 | ] 7 | 8 | m1 = program.Module(builder, 'm1') 9 | m1.sources += [ 10 | 'main2.cc', 11 | ] 12 | 13 | builder.Build('m2/AMBuild', { 'program': program }) 14 | 15 | builder.Add(program) 16 | -------------------------------------------------------------------------------- /source/Rustam/tests/modules/core/m2/AMBuild: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | 3 | m2 = program.Module(builder, 'm2') 4 | m2.compiler.cflags = [] 5 | m2.sources += [ 6 | 'm2.cc', 7 | ] 8 | -------------------------------------------------------------------------------- /source/Rustam/tests/modules/core/m2/m2.cc: -------------------------------------------------------------------------------- 1 | int m2() 2 | { 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /source/Rustam/tests/modules/core/main.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | extern int m1(); 5 | 6 | int main() 7 | { 8 | return m1(); 9 | } 10 | -------------------------------------------------------------------------------- /source/Rustam/tests/modules/core/main2.cc: -------------------------------------------------------------------------------- 1 | 2 | int m1() 3 | { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /source/Rustam/tests/multiarch/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | import platform 3 | from ambuild2.frontend.version import Version 4 | 5 | def has_x86(): 6 | if builder.host.platform == 'mac': 7 | version = Version(platform.mac_ver()[0]) 8 | return version < '10.13' 9 | return True 10 | 11 | if has_x86(): 12 | builder.x86 = builder.DetectCxx(target_arch = 'x86') 13 | else: 14 | builder.x86 = None 15 | builder.x64 = builder.DetectCxx(target_arch = 'x86_64') 16 | 17 | for cxx in [builder.x86, builder.x64]: 18 | if cxx and cxx.like('msvc'): 19 | cxx.cxxflags += ['/EHsc'] 20 | 21 | builder.Build('core/AMBuild') 22 | -------------------------------------------------------------------------------- /source/Rustam/tests/multiarch/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | API_VERSION = '2.2' 3 | 4 | import sys 5 | try: 6 | from ambuild2 import run 7 | if not run.HasAPI(API_VERSION): 8 | raise Exception() 9 | except: 10 | sys.stderr.write('AMBuild {0} must be installed to build this project.\n'.format(API_VERSION)) 11 | sys.stderr.write('http://www.alliedmods.net/ambuild\n') 12 | sys.exit(1) 13 | 14 | builder = run.BuildParser(sourcePath = sys.path[0], api = API_VERSION) 15 | builder.Configure() 16 | -------------------------------------------------------------------------------- /source/Rustam/tests/multiarch/core/AMBuild: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | 3 | project = builder.ProgramProject('sample') 4 | project.sources += [ 5 | 'main.cpp', 6 | ] 7 | 8 | for cxx in [builder.x86, builder.x64]: 9 | if cxx is None: 10 | continue 11 | 12 | if cxx.like('gcc'): 13 | cxx.cflags += [ 14 | '-Wall', 15 | '-Werror' 16 | ] 17 | elif cxx.like('msvc'): 18 | cxx.cflags += ['/WX'] 19 | 20 | project.Configure(cxx, 'sample', cxx.target.arch) 21 | 22 | builder.Add(project) 23 | -------------------------------------------------------------------------------- /source/Rustam/tests/multiarch/core/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | std::cout << sizeof(void*) << std::endl; 5 | } 6 | -------------------------------------------------------------------------------- /source/Rustam/tests/originalcwd/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | # This should print the same thing as when configure.py'd, no matter where 5 | # we build from, when AMBuildScript changes. 6 | print(builder.originalCwd) 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/originalcwd/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.PrepareBuild(sourcePath = sys.path[0]) 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/precompiled-headers/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | builder.cxx = builder.DetectCxx() 3 | 4 | headers = builder.cxx.PrecompiledHeaders('all-headers', 'c++') 5 | headers.sources += [ 6 | 'vector', 7 | 'string', 8 | 'map', 9 | 'unordered_map', 10 | 'unordered_set', 11 | 'list', 12 | 'utility', 13 | 'functional', 14 | ] 15 | pch = builder.Add(headers) 16 | 17 | program = builder.cxx.Program('sample') 18 | program.compiler.includes += [pch] 19 | program.sources += [ 20 | 'main.cpp', 21 | ] 22 | builder.Add(program) 23 | -------------------------------------------------------------------------------- /source/Rustam/tests/precompiled-headers/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | API_VERSION = '2.2' 3 | 4 | import sys 5 | try: 6 | from ambuild2 import run 7 | if not run.HasAPI(API_VERSION): 8 | raise Exception() 9 | except: 10 | sys.stderr.write('AMBuild {0} must be installed to build this project.\n'.format(API_VERSION)) 11 | sys.stderr.write('http://www.alliedmods.net/ambuild\n') 12 | sys.exit(1) 13 | 14 | builder = run.BuildParser(sourcePath = sys.path[0], api = API_VERSION) 15 | builder.Configure() 16 | -------------------------------------------------------------------------------- /source/Rustam/tests/precompiled-headers/main.cpp: -------------------------------------------------------------------------------- 1 | #include "all-headers.h" 2 | 3 | int main() 4 | { 5 | std::vector stuff; 6 | return (int)stuff.size(); 7 | } 8 | -------------------------------------------------------------------------------- /source/Rustam/tests/resource_dll/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | import os 3 | cxx = builder.DetectCxx() 4 | binary = cxx.Library('project_name') 5 | compiler = binary.compiler 6 | compiler.linkflags += [ 7 | '/NOENTRY', 8 | ] 9 | compiler.includes += [ 10 | os.path.join(builder.currentSourcePath), 11 | ] 12 | 13 | binary.sources += [ 14 | 'project_resource.rc', 15 | ] 16 | 17 | builder.Add(binary) 18 | -------------------------------------------------------------------------------- /source/Rustam/tests/resource_dll/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | API_VERSION = '2.1.1' 3 | 4 | import sys 5 | try: 6 | from ambuild2 import run 7 | if not run.HasAPI(API_VERSION): 8 | raise Exception() 9 | except: 10 | sys.stderr.write('AMBuild {0} must be installed to build this project.\n'.format(API_VERSION)) 11 | sys.stderr.write('http://www.alliedmods.net/ambuild\n') 12 | sys.exit(1) 13 | 14 | builder = run.BuildParser(sourcePath = sys.path[0], api = API_VERSION) 15 | builder.Configure() 16 | -------------------------------------------------------------------------------- /source/Rustam/tests/resource_dll/project_resource.rc: -------------------------------------------------------------------------------- 1 | #define ID_FILE_EXIT 4001 2 | -------------------------------------------------------------------------------- /source/Rustam/tests/shaders/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 2 | import os 3 | builder.DetectCxx() 4 | 5 | shaders = builder.tools.FXC('shaders', 'my::stuff') 6 | shaders.listDefineName = 'SHADER_MAP' 7 | shaders.shaders += [ 8 | { 9 | 'source': 'code/image_vs.hlsl', 10 | 'variable': 'sImageVS', 11 | 'profile': 'vs_4_0', 12 | }, 13 | { 14 | 'source': 'code/image_ps.hlsl', 15 | 'variable': 'sImagePS', 16 | 'profile': 'ps_4_0', 17 | }, 18 | ] 19 | 20 | program = builder.cxx.Program('sample') 21 | program.sources += [ 22 | 'code/include-shaders.cc', 23 | ] 24 | program.custom += [shaders] 25 | builder.Add(program) 26 | -------------------------------------------------------------------------------- /source/Rustam/tests/shaders/code/common.hlsl: -------------------------------------------------------------------------------- 1 | // (C) 2015 AlliedModders LLC 2 | // All rights reserved. 3 | // 4 | -------------------------------------------------------------------------------- /source/Rustam/tests/shaders/code/image_common.hlsl: -------------------------------------------------------------------------------- 1 | 2 | struct IMAGE_VS_OUTPUT { 3 | float4 pos : SV_Position; 4 | float2 source_uv : TEXCOORD0; 5 | float4 image_rect : TEXCOORD1; 6 | }; 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/shaders/code/image_ps.hlsl: -------------------------------------------------------------------------------- 1 | #include "common.hlsl" 2 | #include "image_common.hlsl" 3 | 4 | Texture2D tImage : register(ps, t0); 5 | sampler sSampler : register(ps, s0); 6 | 7 | float4 main(const IMAGE_VS_OUTPUT v) : SV_Target 8 | { 9 | float2 image_offset = v.image_rect.xy; 10 | float2 image_size = v.image_rect.zw; 11 | float2 uv = image_offset + image_size * frac(v.source_uv); 12 | return tImage.Sample(sSampler, uv); 13 | } 14 | -------------------------------------------------------------------------------- /source/Rustam/tests/shaders/code/image_vs.hlsl: -------------------------------------------------------------------------------- 1 | #include "common.hlsl" 2 | #include "vs_common.hlsl" 3 | #include "image_common.hlsl" 4 | 5 | struct Image { 6 | float4 source_uv; 7 | float4 dest; 8 | uint tile_index; 9 | uint3 padding; 10 | }; 11 | 12 | cbuffer imageBuffer : register(b4) { 13 | Image images[1365]; 14 | }; 15 | 16 | IMAGE_VS_OUTPUT main(const VS_INPUT input) 17 | { 18 | Image image = images[input.id]; 19 | 20 | QuadVertexInfo vi = ComputeQuadVertex( 21 | image.tile_index, 22 | image.dest, 23 | input.pos); 24 | 25 | float2 uv = (vi.clipped_pos - vi.dest_rect.xy) / vi.dest_rect.zw; 26 | 27 | IMAGE_VS_OUTPUT v; 28 | v.pos = vi.out_vertex; 29 | v.source_uv = uv; //TexturizeQuadVertex(image.source_uv, input.pos); 30 | v.image_rect = image.source_uv; 31 | return v; 32 | } 33 | -------------------------------------------------------------------------------- /source/Rustam/tests/shaders/code/include-shaders.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "shaders-include.h" 4 | 5 | int main() 6 | { 7 | #define _(name) \ 8 | printf("%p %d\n", my::stuff::name##_Bytes, int(my::stuff::name##_Length)); 9 | SHADER_MAP(_) 10 | #undef _ 11 | } 12 | -------------------------------------------------------------------------------- /source/Rustam/tests/shaders/code/vs_common.hlsl: -------------------------------------------------------------------------------- 1 | 2 | // Group #1: Updates on Window size changes. 3 | cbuffer worldBuffer : register(b0) { 4 | float4x4 kProjection; 5 | }; 6 | 7 | struct Tile { 8 | float4 screenRect; 9 | }; 10 | 11 | // Group #2: Updated on tile buffer changes. 12 | cbuffer tileBuffer : register(b1) { 13 | Tile tiles[4096]; 14 | }; 15 | 16 | struct VS_INPUT { 17 | float2 pos : POSITION; 18 | uint id : SV_InstanceID; 19 | }; 20 | 21 | struct QuadVertexInfo { 22 | // The vertex to pass to the pixel shader. 23 | float4 out_vertex; 24 | // Destination rect, in screen space. 25 | float4 dest_rect; 26 | // Destination vertex, clipped to tile bounds. 27 | float2 clipped_pos; 28 | }; 29 | 30 | QuadVertexInfo ComputeQuadVertex(uint tile_index, float4 dest_rect, float2 vertex) 31 | { 32 | float4 tile_screen_rect = tiles[tile_index].screenRect; 33 | 34 | // Convert the vertex to screen space. 35 | #if 0 36 | float2 screen_vertex = lerp( 37 | dest_rect.xy, // Top-left vertex. 38 | dest_rect.zw, // Bottom-right vertex. 39 | vertex); 40 | #else 41 | float2 screen_vertex = float2( 42 | dest_rect.x + vertex.x * dest_rect.z, 43 | dest_rect.y + vertex.y * dest_rect.w); 44 | #endif 45 | 46 | // Clamp the vertex to inside the tile. 47 | #if 1 48 | screen_vertex = clamp( 49 | screen_vertex, 50 | tile_screen_rect.xy, 51 | tile_screen_rect.xy + tile_screen_rect.zw); 52 | #endif 53 | 54 | QuadVertexInfo info; 55 | info.out_vertex = mul(kProjection, float4(screen_vertex, 0, 1)); 56 | info.dest_rect = dest_rect; 57 | info.clipped_pos = screen_vertex; 58 | 59 | return info; 60 | } 61 | 62 | float2 TexturizeQuadVertex(float4 uv_rect, float2 pos) 63 | { 64 | return float2( 65 | uv_rect.x + pos.x * uv_rect.z, 66 | uv_rect.y + pos.y * uv_rect.w); 67 | } 68 | -------------------------------------------------------------------------------- /source/Rustam/tests/shaders/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | API_VERSION = '2.1' 3 | 4 | import sys 5 | try: 6 | from ambuild2 import run 7 | if not run.HasAPI(API_VERSION): 8 | raise Exception() 9 | except: 10 | sys.stderr.write('AMBuild {0} must be installed to build this project.\n'.format(API_VERSION)) 11 | sys.stderr.write('http://www.alliedmods.net/ambuild\n') 12 | sys.exit(1) 13 | 14 | builder = run.BuildParser(sourcePath = sys.path[0], api = API_VERSION) 15 | builder.Configure() 16 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/basic/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | argv = [ 5 | sys.executable, 6 | os.path.join(builder.sourcePath, 'generate_header.py'), 7 | 'output.h' 8 | ] 9 | 10 | shared_outputs = [ 11 | # Comment for reconfigure test #1. 12 | os.path.join(builder.buildFolder, 'output.h') 13 | ] 14 | 15 | # Comment all below for reconfigure test #2. 16 | work_folder = builder.AddFolder('work') 17 | 18 | builder.AddCommand( 19 | inputs = [], 20 | argv = argv, 21 | outputs = [], 22 | folder = work_folder, 23 | shared_outputs = shared_outputs 24 | ) 25 | 26 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/basic/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.PrepareBuild(sourcePath = sys.path[0]) 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/basic/generate_header.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | 4 | with open(sys.argv[1], 'w') as fp: 5 | fp.write(""" 6 | #ifndef HELLO_STRING 7 | # define HELLO_STRING "HELLO!" 8 | #endif 9 | """) 10 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/duplicates/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | argv = [ 5 | sys.executable, 6 | os.path.join(builder.sourcePath, 'generate_header.py'), 7 | 'output.h' 8 | ] 9 | 10 | shared_outputs = [ 11 | os.path.join(builder.buildFolder, 'output.h') 12 | ] 13 | 14 | def FailTest1(): 15 | builder.AddCommand( 16 | inputs = [], 17 | argv = argv, 18 | outputs = [], 19 | shared_outputs = shared_outputs + shared_outputs 20 | ) 21 | 22 | def FailTest2(): 23 | builder.AddCommand( 24 | inputs = [], 25 | argv = argv, 26 | outputs = shared_outputs + shared_outputs 27 | ) 28 | 29 | def FailTest3(): 30 | builder.AddCommand( 31 | inputs = [], 32 | argv = argv, 33 | outputs = shared_outputs, 34 | shared_outputs = shared_outputs 35 | ) 36 | 37 | # All of these should fail. 38 | FailTest1() 39 | #FailTest2() 40 | #FailTest3() 41 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/duplicates/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.PrepareBuild(sourcePath = sys.path[0]) 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/duplicates/generate_header.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | 4 | with open(sys.argv[1], 'w') as fp: 5 | fp.write(""" 6 | #ifndef HELLO_STRING 7 | # define HELLO_STRING "HELLO!" 8 | #endif 9 | """) 10 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/mixup/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | argv = [ 5 | sys.executable, 6 | os.path.join(builder.sourcePath, 'generate_header.py'), 7 | 'output.h' 8 | ] 9 | 10 | shared_outputs = [ 11 | os.path.join(builder.buildFolder, 'output.h') 12 | ] 13 | 14 | def Test1(): 15 | builder.AddCommand( 16 | inputs = [], 17 | argv = argv, 18 | outputs = [], 19 | shared_outputs = shared_outputs 20 | ) 21 | 22 | def Test2(): 23 | # Change the output to a normal output. 24 | builder.AddCommand( 25 | inputs = [], 26 | argv = argv, 27 | outputs = shared_outputs 28 | ) 29 | 30 | def Test3(): 31 | # Change back to a shared output. 32 | Test1() 33 | 34 | def Test4(): 35 | # Change to a folder. 36 | builder.AddFolder('output.h') 37 | 38 | def Test5(): 39 | # Change back to a shared output. 40 | Test1() 41 | 42 | def TestFail1(): 43 | Test2() 44 | Test1() 45 | 46 | def TestFail2(): 47 | Test1() 48 | Test2() 49 | 50 | def TestFail3(): 51 | Test1() 52 | Test4() 53 | 54 | def TestFail4(): 55 | Test4() 56 | Test1() 57 | 58 | # Uncomment 1, run, recomment, uncomment 2 to test. Repeat. Each time using 59 | # refactoring mode should fail. 60 | Test1() 61 | #Test2() 62 | #Test3() 63 | #Test4() 64 | #Test5() 65 | 66 | # These tests should all fail. 67 | #TestFail1() 68 | #TestFail2() 69 | #TestFail3() 70 | #TestFail4() 71 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/mixup/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.PrepareBuild(sourcePath = sys.path[0]) 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/mixup/generate_header.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | 4 | with open(sys.argv[1], 'w') as fp: 5 | fp.write(""" 6 | #ifndef HELLO_STRING 7 | # define HELLO_STRING "HELLO!" 8 | #endif 9 | """) 10 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/multiples/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | argv = [ 5 | sys.executable, 6 | os.path.join(builder.sourcePath, 'generate_header.py'), 7 | 'output.h' 8 | ] 9 | 10 | shared_outputs = [ 11 | os.path.join(builder.buildFolder, 'output.h') 12 | ] 13 | 14 | # Comment anything below to test reconfiguring. 15 | builder.AddCommand( 16 | inputs = [], 17 | argv = argv, 18 | outputs = [], 19 | shared_outputs = shared_outputs 20 | ) 21 | 22 | builder.AddCommand( 23 | inputs = [], 24 | argv = argv, 25 | outputs = [], 26 | shared_outputs = shared_outputs 27 | ) 28 | 29 | builder.AddCommand( 30 | inputs = [], 31 | argv = argv, 32 | outputs = [], 33 | shared_outputs = shared_outputs 34 | ) 35 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/multiples/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.PrepareBuild(sourcePath = sys.path[0]) 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/shared_outputs/multiples/generate_header.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | 4 | with open(sys.argv[1], 'w') as fp: 5 | fp.write(""" 6 | #ifndef HELLO_STRING 7 | # define HELLO_STRING "HELLO!" 8 | #endif 9 | """) 10 | -------------------------------------------------------------------------------- /source/Rustam/tests/staticlib/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | builder.DetectCompilers() 5 | 6 | program = builder.compiler.StaticLibrary("hello") 7 | program.sources = [ 8 | 'main.cpp' 9 | ] 10 | builder.Add(program) 11 | -------------------------------------------------------------------------------- /source/Rustam/tests/staticlib/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.BuildParser(sourcePath = sys.path[0], api = '2.0') 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/staticlib/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" int egg() 4 | { 5 | return printf("hello!\n"); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /source/Rustam/tests/vcfiles/AMBuildScript: -------------------------------------------------------------------------------- 1 | # vim: set ts=8 sts=2 tw=99 et ft=python: 2 | import os, sys 3 | 4 | builder.DetectCompilers() 5 | 6 | program = builder.compiler.Library("hello") 7 | program.sources = [ 8 | 'main.cpp' 9 | ] 10 | 11 | # Comment below to test successful folder removal. 12 | builder.Add(program) 13 | -------------------------------------------------------------------------------- /source/Rustam/tests/vcfiles/configure.py: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 ts=8 sw=2 tw=99 et: 2 | import sys 3 | from ambuild2 import run 4 | 5 | builder = run.PrepareBuild(sourcePath = sys.path[0]) 6 | builder.Configure() 7 | -------------------------------------------------------------------------------- /source/Rustam/tests/vcfiles/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" int egg() 4 | { 5 | return printf("hello!\n"); 6 | } 7 | 8 | --------------------------------------------------------------------------------