This project is read-only.

Note: this feature is unavailable in the Preview Release. It is only available if you are building the IDE from the latest sources. Also remember this feature is still in its works.

Introduction

Remember this is an advanced feature that gives the user more control on how they choose to build there projects. So only use this feature if you know what you are doing. Remember that basic Powershell and Batch scripting knowledge is a prerequisite.

How it works

Under Build choose the menu item that says Build Using Custom Script. Then a dialog should come like this one shown below:

scripting

Now the editor script should be blank at first so select the script type PowerShell. Why not batch file because it is deprecated and it is not implemented at this moment and Powershell has Power in its name. Any way the editor should be filled with a script template. The script template is shown below:

#Copyright � 2012  Daniel Lopez
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

#Note: Script can be modified but do not modify function declaration or command line arguments.


function Compile([string[]]$i, [string[]]$o)
{
    $count = $i.length
    $count2 = $o.length
    if ($count.Equals($count2))
    {
        for($index = 0; $index -lt $count; $index++)
        {
            (nasm -fwin32 -o $o[$index] $i[$index] )  2>&1  | foreach-object {$_.ToString()} | tee -variable err
            echo $err
        }
        
    }
}

function Link([string[]]$objs, [string]$o)
{
    $objects = ""
    foreach($obj in $objs)
    {
        $objects += ($obj + " ")
    }
    (gcc $objects -o $o) 2>&1  | foreach-object {$_.ToString()} | tee -variable err
    echo $err
}

if ($args.Count.Equals(3))
{
    if ($args[0].Count.Equals($args[1].Count))
    {
        
        Compile $args[0] $args[1]
        Link $args[1] $args[2]
    }
    else
    {
        echo "Argument 1 and Argument 2 Must Have The Same Array Size!"
    }
}
else
{
    echo "Invalid amount of arguments"
}


 


This template itself is already created so that no modifications are necessary if you want to build without adding any fancy linker or assembler arguments. Remember they are certain parts of the script that shouldn't be modified because they are reserved for the IDE to function properly. If you do the entire monitor would explode and jeopardize the entire city. Well except the part of the monitor exploding. But it won't build if you modify those parts.

Parts that cannot be modified:

  • Function declarations
  • Anything having to do with $args.
  • The commented license.

What this feature isn't

It isn't way to load external scripts. Why because I do not want to introduce bugs, or someone trying to make the IDE load a malicious scripts.

Conclusion

All that really has to be done is to fill the stubs inside the function and basically do not touch anything reserved by the IDE. The template is safe to use without any code modification.

FAQS

Q: Why is Batch file deprecated but it is going to be part of this feature?

A: Well because some users of the IDE might not have Powershell installed. Although Powershell is shipped with most OEM versions of Windows. So my recommendation use Batch if Powershell is unavailable or is unsupported. Read more about Powershell
here. As of Beta Batch File is now obsolete and in favor of Powershell.

Q: What is the advantage of this feature instead of building the other way?

A: Although the results might be the same usually. The built in scripting features might give the user more power and control on how they want to build the entire project.

Q: Why is their no build output regardless whether it build successfully or not?

A: This is a bug that hasn't been fixed yet. Everything works at this moment except for build output. That means if the build had compiler errors, or linker errors, or even warning the build output will be blank. But this will be fixed in a later release.

As of Beta, PowerShell displaying no output has been fixed.

Last edited Nov 18, 2012 at 6:49 PM by stack_and_heap, version 9

Comments

No comments yet.