+ Reply to Thread
Results 1 to 1 of 1

Thread: [Tutorial] Coding Sourcemod the Eclipse way

  1. #1
    HULK SMASH RAAAAH! MacNetron's Avatar
    Join Date
    Dec 2008
    Posts
    2,768
    Thanks
    635
    Thanked 781 Times in 473 Posts
    Blog Entries
    1

    [Tutorial] Coding Sourcemod the Eclipse way

    Although Sourcemod code is fairly simple and you really can code it with just your favourite editor in c/c++ mode for syntax highlighting and compile it commandline, it is far more geeky to do it in Eclipse.

    Main advantages for me are:
    - I know Eclipse very well (Java ftw!)
    - I can run external commands easy and capture the output
    - code repository integration

    Download the latest Eclipse IDE for C/C++ Developers.

    Extract it and start it by just running eclipse.exe. I do advise creating a shortcut with the version number and the flavor of eclipse (ie. "Eclipse 3.5 CPP"). Believe it or not, I've got 4 different Eclipses

    For workspace, similar advice. In my case: "D:\workspace-3.5-cpp". You really don't want to have different Eclipses share the same workspace as your layout and plugins are saved in your workspace. Different versions may break your workspace!

    Get rid of the welcome screen and create a new project in the left part (Project Explorer):


    A wizard will show up. Choose General - Project:


    And give the project a nice name. Eclipse will automatically create the project in your workspace:


    Now, I add my current EmptyServerMapChange source code. Just drag 'n drop the file, or copy/paste.


    As you might be able to see, the icon on the .sp is an EditPlus one. Clicking it will open the file in EditPlus. Lets change it to Eclipse and associate it with the C/C++ editor.
    Open the Preferences by Window -> Preferences and navigate to General -> Editors -> File associations.
    Add the file type *.sp and add C/C++ as Associated editor:


    That is better!


    Now we can code in Eclipse, but still need to compile the code commandline. Of course we add the sourcepawn compiler as an external tool so we can run that tool from Eclipse and compile the code:


    Click the button to add a new launch configuration and fill in the name of the script, location of the sourcepawn compiler, working directory is our project location (is a variable) and the argument given to the commandline is our selected resource (also variable):


    On tab Refresh, make sure the refresh is enabled and on project containing the selected resource. This makes sure you don't have to hit the refresh button but the .smx will show up immediately:


    Last on tab Common, enable the display of this task:


    Now reap the fruits of our hard labor. Select the .sp and run the tool:


    Awesome! :coool:

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts