[Tutorial] Pawn Development in OS X
#1

Since I haven't seen a guide anywhere on this forum as to how to set up a development environment for macOS, I figured out that it would be a good idea to share my newly-found knowledge with you guys. So let's get started!

Start off by downloading the following:Setting up Sublime Text 3

After obviously downloading it, place it in your Applications folder and launch it. You should see the program pop up, possibly nagging you every now and then to purchase it. All I can tell you is that if you have $70 to spare, then this is the way to go. Anyway, it would be very nice to have Pawn syntax, function autocompletes and a nice build script in Sublime Text to make our development easier and faster. PackageControl is a great package manager for Sublime, with a lot of handy-dandy tools for the program. To install it, follow the instructions here.

After installing PackageControl, it's time to use it. The package we are interested in is the Pawn syntax package, which contains Pawn syntax and many function autocompletes (even the ones for popular plugins and includes!). In Sublime, go to Tools > Command Palette... (or press Shift+CMD+P from now on), and type in the keyword 'install' in the search bar that should pop up. You should get a first search result of Package Control: Install Package. Select it, and after doing so a list of available packages will appear. Type in the keyword 'pawn', and the package Pawn syntax should be visible. Select that, and it will install right away.

Sublime Text is almost set up, we just need to set up the build script to go with our compiler. Go to Tools > Build System... > New Build System. A new file should appear, with a bare-bones build script that contains a command make. Delete that line and paste in the following:
Code:
{
	"cmd": ["./pawncc", "$file", "-iinclude", "-o$file_path/$file_base_name", "-;+", "-(+", "-d3"],
	"file_regex": "(.*?)[(]([0-9]*)[)]",
	"working_dir": "/Applications/Pawn",
	"selector": "source.pwn"
}
As you might have guessed, our compiler will go in the Applications folder. If you don't like that, you can place it elsewhere, but make sure you change the working_dir in the build script! Save the build script in the directory that initially comes up (Sublime Text 3/Packages/User), and call it Pawn.sublime-build

Setting up the compiler

Now that Sublime is out of the way, we can get to the main bit of this tutorial: the compiler itself! After downloading the Zeex's Pawn Compiler zip package (or after making it from source), you should have three files and a folder include. Place those contents in a folder called Pawn, and move it to the Applications folder (or wherever you like). The compiler itself is the pawncc executable, which is run with the parameters specified in the build script.

However, we still need to provide all the includes in order to gain access to all functions required to write gamemodes and filterscripts. We can get those from the SA-MP Windows Server package that contains PAWNO, and with it the includes. Copy all the files located in pawno/include and move them to the corresponding include folder for our macOS compiler.

And that's it, you're ready to go!
You can enable Pawn syntax by going into View > Syntax and selecting Pawn in Sublime Text 3. If Sublime doesn't automatically select our build system for .pwn files, then you can do so manually by going to Tools > Build System and selecting Pawn. By default, the shortcut to building is CMD+B.

If you have any questions regarding this tutorial, then don't hesitate to ask!
Reply
#2

My error:
Assertion failed: (*(ptr+1)=='\0'), function readline, file /UsePawn compiler 3.10 Copyright © 1997-2006, ITB CompuPhase

rs/Artur/Downloads/pawn-master/source/compiler/sc2.c, line 415.
[Finished in 0.0s with exit code -6]
[cmd: ['./pawncc', '/Users/viotquentin/Desktop/SAMP/gamemodes/roleplay.pwn', '-iinclude', '-o/Users/viotquentin/Desktop/SAMP/gamemodes/roleplay', '-;+', '-(+', '-d3']]
[dir: /Applications/Pawn]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
Reply
#3

Quote:
Originally Posted by Inuro
View Post
My error:
Assertion failed: (*(ptr+1)=='\0'), function readline, file /UsePawn compiler 3.10 Copyright © 1997-2006, ITB CompuPhase

rs/Artur/Downloads/pawn-master/source/compiler/sc2.c, line 415.
[Finished in 0.0s with exit code -6]
[cmd: ['./pawncc', '/Users/viotquentin/Desktop/SAMP/gamemodes/roleplay.pwn', '-iinclude', '-o/Users/viotquentin/Desktop/SAMP/gamemodes/roleplay', '-;+', '-(+', '-d3']]
[dir: /Applications/Pawn]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
Try downloading the compiled binaries from here (the Darwin release) and see if that helps.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)