Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile main file of project, no matter the buffer #15

Open
DivineDominion opened this issue Apr 8, 2019 · 6 comments
Open

Compile main file of project, no matter the buffer #15

DivineDominion opened this issue Apr 8, 2019 · 6 comments

Comments

@DivineDominion
Copy link

https://github.com/textmate/blitzmax.tmbundle

The TextMate bundle uses environment settings to compile projects, not just buffers. Thanks to .tm_properties files, these can be set per directory/project, which is nice. I think with the power of .dir-locals.el to auto-load when opening a buffer, one can do the same for Emacs.

My elisp isn't that good, that's why I didn't work on a PR right away and want to coordinate efforts first. What do you think?

@DivineDominion DivineDominion changed the title compile project Compile main file of project, no matter the buffer Apr 8, 2019
@Sodaware
Copy link
Owner

Sodaware commented Apr 8, 2019

I use Projectile and usually have something like this in my .dir-locals.el file:

((nil . ((projectile-project-compilation-cmd . "bmk makeapp -r -h -o my_app src/my_app.bmx")))
 (blitzmax-mode . ((indent-tabs-mode . t)
                   (tab-width . 4)
                   (fill-column . 80))))

I then run projectile-compile-project (C-c p c) to recompile the project.

However, I would like to make it easier to compile the current buffer using Emacs' compile command. I'd also like to have something like MaxIDE's "compile and run" functionality.

I'm happy to accept a pull request if this is something you'd like to try implementing, or I can come up with a fix for it.

@DivineDominion
Copy link
Author

Oh that's a neat combo already!

What would be the obstacles to implementing "build & run"? I have yet to try, but I thought one can get away with executing open path/to/the.app in the shell on Mac, for example.

@Sodaware
Copy link
Owner

I came up with this for compile and run, but I'm not really happy with it:

(defun blitzmax-mode-compile-and-run ()
  "Compile and run contents of the current file."
  (interactive)
  (compile (format "bmk makeapp -r -h %s && %s"
                   buffer-file-name
                   (file-name-sans-extension buffer-file-name))))

Running M-x blitzmax-mode-compile-and-run will then compile the file in the current buffer and run the executable. I'd like to add support for enabling and disabling debug mode before adding it to blitzmax-mode.

I think a better solution for projects is to customize Projectile's projectile-project-compilation-cmd to include running - something like this:

((nil . ((projectile-project-compilation-cmd . "bmk makeapp -r -h -o my_app src/my_app.bmx && ./my_app")))
 (blitzmax-mode . ((indent-tabs-mode . t)
                   (tab-width . 4)
                   (fill-column . 80))))

@DivineDominion
Copy link
Author

Totally forgot about the bmk tool!

My temporary TextMate 2 setup compiles and runs the app, but the debug output and print statements appear nowhere.

The MaxIDE launches processes and pipes the output into the output window; and using stdin, if I interpret this correctly, you can debug-step through the program. That's beyond my elisp.

But the compile settings sound simple enough. I guess you don't want to switch between DEBUG/RELEASE depending on user settings, but implement a Build & Run for debug and release mode, right?

@Sodaware
Copy link
Owner

Sodaware commented Jun 2, 2019

I've added quickrun support, which makes it possible to compile and run the current buffer without having to drop to the command line. Projectile is still the better choice for compiling projects, but quickrun is useful for testing out small pieces of BlitzMax code.

@DivineDominion
Copy link
Author

That's a cool addition for quick tests! I always had MaxIDE running for the purpose of auto-saving to its tmp/untitled.bmx and executing the compiled result.

Doesn't this warrant linking to bmax as a supported language for the quickrun repo? https://github.com/syohex/emacs-quickrun/#support-programming-languages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants