Scripting:Build Environment: Difference between revisions
The Watcher [PHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs) (Created page with "If you are interested in using this package as the base from which you can develop your own scripts, or just want to bugfix and recompile twscript, you will need to do rather...") |
The Watcher [PHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs) No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
== Setting up the compiler == | == Setting up the compiler == | ||
Before you can do any compiling, you need a compiler. This is actually not as straightforward as you might think: | Before you can do any compiling, you need a compiler. This is actually not as straightforward as you might think: even if you already have a compiler available, there's a good chance it may not actually work with this code, or it may produce an .osm that Thief can't actually load (or it may work fine, in which case, great! But don't blame me if you end up up to your armpits in soul-devouring, tentacled horrors from beyond time and space when trying it). Hence, you are strongly advised to follow these steps, even if you already have a working compiler setup, unless you're feeling adventurous: | ||
# Download the TDM-GCC compiler suite for Windows from the [http://tdm-gcc.tdragon.net/ project site]. You want to click on the "TDM32 bundle" button (currently 3.8.1), this will take you to a sourceforge download page to download a <code>tdm-gcc-<version>.exe</code> file. | # Download the TDM-GCC compiler suite for Windows from the [http://tdm-gcc.tdragon.net/ project site]. You want to click on the "TDM32 bundle" button (currently 3.8.1), this will take you to a sourceforge download page to download a <code>tdm-gcc-<version>.exe</code> file. | ||
Line 80: | Line 80: | ||
# Download the latest installer from http://git-scm.com/downloads | # Download the latest installer from http://git-scm.com/downloads | ||
# Run the installer, clicking "Next" through it until you come to the "Adjusting your PATH environment" page. Select the "Run Git from the Windows Command Prompt" option, and click "Next" | # Run the installer, clicking "Next" through it until you come to the "Adjusting your PATH environment" page. Select the "Run Git from the Windows Command Prompt" option, and click "Next" | ||
# | # On the "Choosing the SSH executable" step, leave the option "Use OpenSSH" enabled. '''Do not select "Use (Tortoise)Plink"''', even if you have it installed and working. Enabling that option can, and usually will, cause problems. | ||
# Keep clicking "Next" until it starts installing. | # Keep clicking "Next" until it starts installing. | ||
# Twiddle your thumbs for a while. | # Twiddle your thumbs for a while. | ||
Line 104: | Line 104: | ||
You should now have three or four directories inside your t2scripts directory: lg, scriptlib, twscript, and possibly publicscripts. Now to compile them... | You should now have three or four directories inside your t2scripts directory: lg, scriptlib, twscript, and possibly publicscripts. Now to compile them... | ||
== Compiling the libraries == | |||
Before you can actually create any scripts, you need to have compiled the support libraries your scripts will need to use in order to communicate with the Dark engine. This step should be pretty straightforward at this point. Henceforth, for simplicity, I am going to assume that all the projects you cloned in the previous section are inside the <code>C:\t2scripts</code> directory as discussed there - if you cloned them elsewhere, you must update the paths accordingly. | |||
Before you compile the libraries, I recommend a few changes to them: | |||
Open <code>C:\t2scripts\lg\Makefile</code> in your text editor, go to line 24, and change | |||
CXXFLAGS = -W -Wall -Wno-unused-parameter -masm=intel $(INCLUDEDIRS) | |||
to be | |||
CXXFLAGS = -std=gnu++0x -W -Wall -Wno-unused-parameter -masm=intel $(INCLUDEDIRS) | |||
Open <code>C:\t2scripts\scriptlib\Makefile</code> in your text editor, go to line 45, and change | |||
CXXFLAGS = -W -Wall -masm=intel | |||
to read | |||
CXXFLAGS = -std=gnu++0x -W -Wall -masm=intel | |||
Now you can start compiling: | |||
# Start Mintty from the start menu | |||
# Change into the lg directory, eg: <code>cd /c/t2scripts/lg</code> | |||
# Run <code>make</code> (mingw32-make may work as well, but I just use make) | |||
# Change into the scriptlib directory, eg: <code>cd /c/t2scripts/scriptlib</code> | |||
# Run <code>make</code> | |||
== Test compiling TWScript == | |||
At this point, all the libraries required to compile scripts should be in place | |||
and compiled, so it is time to actually give it a go. Before you start working | |||
on any scripts of your own, you should make sure your environment is sane by | |||
compiling the TWScript package: | |||
# If a Mintty window isn't current open, start one. | |||
# Change into the twscript directory: <code>cd /c/t2scripts/twscript</code> | |||
# Run <code>make</code> | |||
If all is well, this should complete with no errors. | |||
<references/> | <references/> | ||
{{Scripting:Navbox}} | {{Scripting:Navbox}} | ||
{{:Site Navigation}} | {{:Site Navigation}} |
Latest revision as of 21:04, 12 September 2014
If you are interested in using this package as the base from which you can develop your own scripts, or just want to bugfix and recompile twscript, you will need to do rather more work than a normal Dromed user. You will need to have at least the following installed:
- a working compiler setup (and editor to code in)
- git (the distributed version control system) to fetch the library code.
- the supporting libraries
- the twscript code.
what follows is a walkthrough of how to get the above set up, and how to get to the point where you can actually compile scripts.
Setting up the compiler
Before you can do any compiling, you need a compiler. This is actually not as straightforward as you might think: even if you already have a compiler available, there's a good chance it may not actually work with this code, or it may produce an .osm that Thief can't actually load (or it may work fine, in which case, great! But don't blame me if you end up up to your armpits in soul-devouring, tentacled horrors from beyond time and space when trying it). Hence, you are strongly advised to follow these steps, even if you already have a working compiler setup, unless you're feeling adventurous:
- Download the TDM-GCC compiler suite for Windows from the project site. You want to click on the "TDM32 bundle" button (currently 3.8.1), this will take you to a sourceforge download page to download a
tdm-gcc-<version>.exe
file. - Run the
tdm-gcc-<version>.exe
installer:- Click "Create"
- Select "MinGW/TDM (32-bit), click "Next"
- On the "New Installation: Installation Directory" step, unless you have some particular reason to change the install directory, just click "Next"
- Unless you have some preferred sourceforge mirror, click "Next" again.
- Review the selected components, you shouldn't need to change any, so click "Install".
- Go look at lolcats or something for a bit.
- From the Start Menu, select TDM-GCC-32 -> MinGW Command Prompt
- When the command prompt appears, type the following: `gcc -v`. If all goes well, you should see several lines of information output, ending in
gcc version X.X.X (tdm-2)
, eg:
This is enough to get you a working compiler, but the toolset included is very limited, I generally suggest installing MSYS as well.
Setting up MSYS
MSYS includes a number of additional tools to make using the compiler a little less painful, to install it:
- Download the latest version of the
mingw-get-setup.exe
installer from sourceforge - Run
mingw-get-setup.exe
as Administrator - Click 'Install'
- Change the "Installation directory" to the directory you installed TDM-GCC to (usually
C:\TDM-GCC-32
with the default settings). If you do not do this, the MSYS tools won't locate your compiler correctly without additional work. - Click 'Continue' (you should be able to leave all the options on defaults)
- Wait while stuff is downloaded
- Eventually the downloads will complete, then click 'Continue'
- The "MinGW Installation Manager" should now open
- Click on the checkbox next to "msys-base' and select "Mark for installation"
- Click on "All Packages" in the left list of the "MinGW Installation Manager"
- Locate "msys-mintty" in the list on the right. It should be about four fifths of the way down the list.[1]
- Click on the checkbox next to "msys-mintty' and select "Mark for installation"
- From the "Installation" menu, select "apply changes"
- Click "Apply"
- Wait while packages are downloaded and installed, then click "close"
- Close the package manager.
It is possible to skip steps 10 to 12, but the default command prompt for msys uses the ghastly and dreadful default Windows command line tool. mintty is far more usable and fully-featured.
For some reason best - if not only - known to the MinGW maintainers, the MinGW Installation Manager does not appear to create useful start menu shortcuts. This means that, unless you want to faff around each time you open the terminal, you need to create an appropriate shortcut:
- Using Windows Explorer, locate your msys directory. If you have followed the steps above and left the install paths as the defaults, this should be
C:\TDM-GCC-32\msys\1.0
. The directory should contain a filemsys.bat
. - Select the
msys.bat
file, right click, and select "Create shortcut" from the popup menu. - Select the shortcut and rename it to "Mintty"
- Open the shortcut properties.
- In the "Target:" field, add -mintty to the end, so it reads
C:\TDM-GCC-32\msys\1.0\msys.bat -mintty
- In the "Start in:" field, add
\bin
to the end, so it readsC:\TDM-GCC-32\msys\1.0\bin
- If you want, change the icon to use the msys icon
- Apply the changes, and okay the properties window to close it.
- Drag the shortcut into the Windows start menu
- Run the Mintty shortcut from the start menu, after a brief delay a terminal prompt should open
- run
make
the terminal should respond withmake: *** No targets specified and no makefile found. Stop.
- run
gcc -v
you should get the same output as before.
At this point, you should have a working compiler, and a decent set of tools installed.
Setting up an editor
I'm not going to tell you to use one editor or another here - editor choice has been the subject of Holy Wars for decades, and almost everyone has their favorite. If you don't have a decent programmer's editor installed, you can go far worse than to start off with Notepad++: it's fast, light, does syntax highlighting and block folding. TDM-GCC plays nice with the Code::Blocks IDE, so you might want to look at that. I tend to use Emacs, but I'm also reliably informed that I'm insane, so you may or may not want to attempt that.
Note that, if you use an IDE like Code::Blocks, do not expect to be able to use the IDE's build process to compile the scripts: you are going to need to use make, and wrangle makefiles, to get them to build unless you want to do a lot of finagling.
Setting up git
To actually get the code, you need to install git. If you already have git (or github's native tool) installed, you can skip this section.
- Download the latest installer from http://git-scm.com/downloads
- Run the installer, clicking "Next" through it until you come to the "Adjusting your PATH environment" page. Select the "Run Git from the Windows Command Prompt" option, and click "Next"
- On the "Choosing the SSH executable" step, leave the option "Use OpenSSH" enabled. Do not select "Use (Tortoise)Plink", even if you have it installed and working. Enabling that option can, and usually will, cause problems.
- Keep clicking "Next" until it starts installing.
- Twiddle your thumbs for a while.
- Once the install has finished, run Git -> Git Bash from the Start Menu.
- If all goes well, the Git Bash window should open, and you can use
git --version
to confirm that git is working.
Before continuing, you may want to become familiar with the basics of using Git. A good place to start is the online Pro Git Book.
Getting the code
Now you should be in the position where you can actually start to fetch code to work on. All the code is on github, so you need to clone copies of it with git (you may wish to fork the twscript project before doing so, if you want to push your changes back to github, but that's up to you).
- Create a directory somewhere on your system, something like
C:\t2scripts
. It doesn't matter what you call it, provided that you can remember it, and it does not contain spaces. Spaces in filenames are a Bad Thing when working with mingw/msys and friends, and they're another way to summon those soul-devouring, tentacled horrors from beyond time and space, so avoid them: CamelCase or underscore_names are your friend. - From the start menu, select Git -> Git Bash
- Change into the directory you created in the first step, using unix-like syntax, eg:
cd /c/t2scripts
- Enter the following commands to clone Telliamed's script support libraries:
git clone https://github.com/whoopdedo/lg.git git clone https://github.com/whoopdedo/scriptlib.git
- And this one to clone twscript (if you have forked it, clone your fork instead!):
git clone https://github.com/TheWatcher/twscript.git
- You'll probably also want to grab Telliamed's Public Scripts package itself, so that you can use the various script implementations it contains as a reference. You can either look at it on the web at github, or clone a local copy:
git clone https://github.com/whoopdedo/publicscripts.git
You should now have three or four directories inside your t2scripts directory: lg, scriptlib, twscript, and possibly publicscripts. Now to compile them...
Compiling the libraries
Before you can actually create any scripts, you need to have compiled the support libraries your scripts will need to use in order to communicate with the Dark engine. This step should be pretty straightforward at this point. Henceforth, for simplicity, I am going to assume that all the projects you cloned in the previous section are inside the C:\t2scripts
directory as discussed there - if you cloned them elsewhere, you must update the paths accordingly.
Before you compile the libraries, I recommend a few changes to them:
Open C:\t2scripts\lg\Makefile
in your text editor, go to line 24, and change
CXXFLAGS = -W -Wall -Wno-unused-parameter -masm=intel $(INCLUDEDIRS)
to be
CXXFLAGS = -std=gnu++0x -W -Wall -Wno-unused-parameter -masm=intel $(INCLUDEDIRS)
Open C:\t2scripts\scriptlib\Makefile
in your text editor, go to line 45, and change
CXXFLAGS = -W -Wall -masm=intel to read CXXFLAGS = -std=gnu++0x -W -Wall -masm=intel
Now you can start compiling:
- Start Mintty from the start menu
- Change into the lg directory, eg:
cd /c/t2scripts/lg
- Run
make
(mingw32-make may work as well, but I just use make) - Change into the scriptlib directory, eg:
cd /c/t2scripts/scriptlib
- Run
make
Test compiling TWScript
At this point, all the libraries required to compile scripts should be in place and compiled, so it is time to actually give it a go. Before you start working on any scripts of your own, you should make sure your environment is sane by compiling the TWScript package:
- If a Mintty window isn't current open, start one.
- Change into the twscript directory:
cd /c/t2scripts/twscript
- Run
make
If all is well, this should complete with no errors.
- ↑ Note: do not enable any other packages for installation unless you know what you're doing. Especially do not enable any of the compiler packages.
|
|