• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Possible to require from subdirectories?

Participant ,
Dec 18, 2017 Dec 18, 2017

Copy link to clipboard

Copied

Not the highest priority but I'd like to better organize my source files. Is it possible to require Lua files from subdirectories? I've tried "require foo/bar" and "require foo.bar" but get an error. I also tried looking at Lua's package.path but Lr seems to hide that (?).

I assume I can do this with the require() in John Ellis's debugging toolkit but I'm not looking to require something from a common, peer directory and I wonder if there's something built-in that's lighter weight?

db

TOPICS
SDK

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 18, 2017 Dec 18, 2017

The built-in "require" doesn't do search paths or subdirectories, unfortunately.  That's why I ended up writing Require.lua in the toolkit.

I don't know why the "package" module isn't included in the LR SDK environment, but it may be because LR has its own method of managing loaded modules and plugins.  "package" is available internally inside LR, which you can see by doing the following:

import "LrHiddenLua".package

(you'll need the debugging toolkit installed). I've never tried it from inside a p

...

Votes

Translate

Translate
LEGEND ,
Dec 18, 2017 Dec 18, 2017

Copy link to clipboard

Copied

The built-in "require" doesn't do search paths or subdirectories, unfortunately.  That's why I ended up writing Require.lua in the toolkit.

I don't know why the "package" module isn't included in the LR SDK environment, but it may be because LR has its own method of managing loaded modules and plugins.  "package" is available internally inside LR, which you can see by doing the following:

import "LrHiddenLua".package

(you'll need the debugging toolkit installed). I've never tried it from inside a plugin.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 24, 2018 Feb 24, 2018

Copy link to clipboard

Copied

Out of curiosity, John, do you have any methods for dealing with required modules in other directories to the main plugin when compiling?

thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 24, 2018 Feb 24, 2018

Copy link to clipboard

Copied

FWIW, I include '.' in the require.path pathlist then compile everything into a release .lrplugin folder using a bash script. This seems to work and it's simple. Toying with using make but I'm honestly not sure it warrants it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 24, 2018 Feb 24, 2018

Copy link to clipboard

Copied

I include '.' in the require.path pathlist then compile everything into a release .lrplugin folder using a bash script. This seems to work and it's simple. Toying with using make but I'm honestly not sure it warrants it.

This is exactly what I do.  The script compiles the Lua modules into a temp folder, copies any other necessary resources (images, settings files, etc), then zips up the temp folder.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 24, 2018 Feb 24, 2018

Copy link to clipboard

Copied

kimaldis​, for what it's worth, I started a recent project with a gnu make file and, although I'm comfortable with make, it was overkill. I remembered that Make isn't really for automation, it's for managing dependencies in big projects - traditionally to cut down on compile times. None of that applies to most LR plugin projects. So, I just backed off to a simple bash script and it was the right choice. You are welcome to take mine and run with it if suits you:

LrSlide/build.sh at master · DaveBurns/LrSlide · GitHub

db

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 26, 2018 Feb 26, 2018

Copy link to clipboard

Copied

I haven't tried it just yet but a better solution might be Growl. It can be configured to watch for changes in source files & recompile automatically.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 26, 2018 Feb 26, 2018

Copy link to clipboard

Copied

Beg pardon; Gulp

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 26, 2018 Feb 26, 2018

Copy link to clipboard

Copied

Well, true but then again, how many source files do you have? My IDE sees a .lua file change and runs the bash script in a split second. The complexity is low and bash comes preinstalled (at least on Macs).

db

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 26, 2018 Feb 26, 2018

Copy link to clipboard

Copied

LATEST

a gulpfille is really no harder than a shell script.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines