Git Product home page Git Product logo

mtasa_txbuild's Introduction

Toxic Build

Tool used for MTA resources compilation based on meta.xml.

Usage

Define environment variable TXBUILD as path to directory where this repository has been cloned.

In every resource source directory create Makefile:

PROJECT_NAME := <resource name>
PROJECT_DIR  := <resource organizational directory>

include $(TXBUILD)/generic.mak

In root source directory for all resources create config.mak file (customize example for your needs):

SELF := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))

PREPROCESS     := 1
COMPILE        := 1
UTF8_BOM       := 0
JOIN           := 0
PROTECT        := 1
LOADER_PATH    := $(SELF)loader.lua
ifeq ($(windir),)
 RESOURCES_PATH := /mnt/c/Program\ Files\ (x86)/MTA\ San\ Andreas\ 1.5/server/mods/deathmatch/resources/
else
 RESOURCES_PATH := C:/Program\ Files\ (x86)/MTA\ San\ Andreas\ 1.5/server/mods/deathmatch/resources/
endif
TEMP_DIR       := build

Compile resource using Make tool. On Windows you need mingw32-make (included in txbuild). For example:

$(TXBUILD)\mingw32-make

Configuration properties

Behaviour of txbuild can be defined in config.mak files in resource directory or up to 3 levels higher in filesystem hierarchy. Configuration files on higher level has lower priority. File can define any set of following optional variables:

  • PREPROCESS - run preprocessor on every Lua file. See description of preprocessor below.
  • COMPILE - compile Lua files using luac_mta tool
  • UTF8_BOM - add UTF8 BOM to final Lua scripts
  • JOIN - join all Lua scripts into one big script - recommended to increase difficulty of reverse engineering
  • PROTECT - protect scripts by embedding them for loading by custom loader specified in LOADER_PATH
  • RESOURCES_PATH - destination path for compiled resources
  • TEMP_DIR - name of directory used for building

Preprocessor

Preprocessor runs every line starting with # and evaluates expressions $(...). See examples below.

Conditional compilation:

#if FEATURE_A
addCommandHandler('a', ...)
#end

Including other file:

#include 'a.lua'

Compile-time constants:

#define TIMEOUT 200

setTimer(function () end, $(TIMEOUT))

Protection with loader

Loader is a preprocessed Lua script used for additional protection of scripts. If PROTECT is set to 1 every Lua script is returned as embedded in custom loader defined using LOADER_PATH variable in config.mak. When preprocessing loader file preprocessor variable __LUA_CHUNK_TBL__ contains table of strings from input Lua file. Loader can use preprocessor to encrypt those lines and embedd them for future execution in runtime.

Building

Toxic Build consists of some native components that needs to be built using a C++ compiler. The project uses CMake build system. Source code is in src directory.

On Windows Visual Studio can be used for building (it has CMake support built-in). Alternatively MinGW can be used with a separate CMake GUI tool. Building can be avoided by downloading txbuild-bin-win32.zip file from Releases page and unpacking it in the root directory (preserving bin subdirectory).

On Linux GCC and CMake can be installed from distribution package manager.

To build on Ubuntu run:

sudo apt-get install build-essentials cmake
mkdir build
cmake ../src -DCMAKE_BUILD_TYPE=Release
make

Copyright

Copyright (c) 2012 Rafał Harabień

mtasa_txbuild's People

Contributors

rafalh avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.