lifepillar / ASMake

An AppleScript build library
10 stars 3 forks source link

Execute AppleScript in makefile #3

Closed craibuc closed 9 years ago

craibuc commented 10 years ago

I was hoping to execute AppleScript from within the the build action:

script build
    property parent : Task(me)
    property description : "Build script bundle."

    echo("Building...")
    osacompile("Controller", "scptd", {"-x"})

    -- hide the extension
    my hideExtension("Controller.scptd")

end script

on hideExtension(theFile)
    tell application "Finder"
        set extension hidden of theFile to true
    end tell
end hideExtension

However, I get an error:

./makefile.applescript: execution error: «script build» doesn’t understand the “hideExtension” message. (-1708)

Is there a way to do this? Also, how do I get a reference to the current directory?

lifepillar commented 10 years ago

You should put the definition of hideExtension() inside the build script. If you want to keep it at the top level, you may change the code as follows:

property TopLevel : me

script build
  -- [...]
  TopLevel's hideExtension("Controller.scptd")
end script

on hideExtension(theFile)
  -- [...]
end hideExtension

Inside a task, you may get the POSIX path of the working directory with my PWD.