Skip to content

Legacy Includes

Southclaws edited this page May 25, 2018 · 1 revision

"Legacy Includes" refers to include files that do not have a GitHub page or can not be installed for some reason. This is simple to resolve, albeit awkward compared to the standard sampctl workflow.

Solution

What you can do is create a temporary folder to store incompatible include files in then add that folder to your Package build configuration(s) as an additional include directory. This will then allow you to #include <> these files as normal.

Create a Legacy Includes Folder

First, create a folder named legacy in your package directory. If your package is a gamemode, this will be in the same folder as gamemodes and filterscripts etc.

Then move all the incompatible .inc files in there.

Add legacy To Build Configuation(s)

You now have a folder named legacy which contains all the old include files but sampctl has no knowledge of it.

To solve that, all you need to do is add the following block to your Package Definition File:

  "builds": [
    {
      "name": "main",
      "includes": ["includes"]
    }
  ]

I know not everyone is familiar with manipulating JSON, so assuming your pawn.json looks like this:

{
  "user": "Southclaws",
  "repo": "myserver",
  "entry": "gamemodes/gamemode.pwn",
  "output": "gamemodes/gamemode.amx",
  "dependencies": ["sampctl/samp-stdlib"]
}

After, it should look like this:

{
  "user": "Southclaws",
  "repo": "myserver",
  "entry": "gamemodes/gamemode.pwn",
  "output": "gamemodes/gamemode.amx",
  "dependencies": ["sampctl/samp-stdlib"],
  "builds": [
    {
      "name": "main",
      "includes": ["legacy"]
    }
  ]
}

Note the extra comma after the dependencies block. Commas in JSON have the same rules as commas in arrays in Pawn: the last element doesn't have a comma after it.

Explanation

So what that does is it adds a build config to the package. A build config is a way of changing how the compiler is run. A package can have multiple builds, but you probably don't need to worry about that just yet.

The fact that we added a single build means it'll be used automatically when you run sampctl package build because this command always picks the first build config in the list and merges its settings with some defaults. By adding the includes field, we initialise the list of include paths with the name of the folder we created. During the build process, this list grows in size as all the directories in dependencies are added. You can read more about how this works here.

Clone this wiki locally