snicklin Posted December 17, 2015 Share Posted December 17, 2015 Is it possible in MADS to include everything in a directory? I want to do something like this: icl 'lib/macros/*.mac' I could write some build script to sort it all out, but if there is any built-in way to do this, I'd rather use this. If it isn't technically possible, TeBe, could this be added in a future version? Quote Link to comment Share on other sites More sharing options...
MaPa Posted December 17, 2015 Share Posted December 17, 2015 I think that if it is not technically possible, Tebe can't add it in future version 1 Quote Link to comment Share on other sites More sharing options...
snicklin Posted December 17, 2015 Author Share Posted December 17, 2015 I think that if it is not technically possible, Tebe can't add it in future version Ooh you cheeky monkey! OK, I'll rephrase that - "If it isn't technically possible in the current version of MADS, TeBe, could this be added in a future version?". It'd be a useful feature. Every time that I add a new macro to a directory, I don't really want to have to update another file to say to include it. Quote Link to comment Share on other sites More sharing options...
mono Posted December 17, 2015 Share Posted December 17, 2015 It's quite simple using gnu make tool. When you place your macros in ./macros/ subdirectory and sources in ./ directory you can create ./Makefile file: MACRODIR=macros OBJS=test1.xex test2.xex all: macros.asm $(OBJS) %.xex: %.asm mads -m:macros.asm -o:$@ $< macros.asm: $(MACRODIR)/* cat $^ >$@ clean: rm -f macros.asm $(OBJS) .PHONY: all clean This buildfile makes ./macros.asm file as concatenation of all ./macros/* files and finally calls mads assembler for each OBJS with -m:macros.asm. OBJS contains space separated names of executables for your sources (test1.xex for test1.asm, test2.xex for test2.asm etc.). No macro file in ./macros/ subdir can't ends with 'end' directive. Now doing make will build your project, but make clean will clean generated files (macros.asm and all .xex files). Concatenation all macro files into one is required by mads because only one -m parameter is allowed. If multiple -m would be allowed (maybe in the future) then Makefile could be: MACRODIR=macros OBJS=test1.xex test2.xex all: $(OBJS) %.xex: %.asm for m in $(MACRODIR)/*; do echo "-m:$$m"; done | xargs mads -o:$@ $< clean: rm -f $(OBJS) .PHONY: all clean and temporary macros.asm woudln't be created. I recommend make tool for automatic management of project and do many jobs without waiting for new mads feature requests will be implemented. 1 Quote Link to comment Share on other sites More sharing options...
snicklin Posted December 18, 2015 Author Share Posted December 18, 2015 It's quite simple using gnu make tool. Thank you for your input into this. The only issue that I have here is that it will require me to rewrite the whole build system which I've created (and it is pretty elaborate). I've used 'make' before, but it's too much of an upheaval to do this. I've added all my macros into an include file and this brings them all in. I think even that if MADS was to support *.mac then it would also need to be able to recursively go downwards into subdirectories. I may just write a short Perl script to list all the .mac files underneath a directory and then write them to a file in a format that I can include that output file into the project. This won't be a big deal but isn't as neat as if the functionality was there. Thank you though, I'm grateful for your input here. Quote Link to comment Share on other sites More sharing options...
mono Posted December 18, 2015 Share Posted December 18, 2015 I understand. To recursivelly find all *.mac files in subdirectories and concatenate all files into one you can just use: find ./macros -name "*.mac" | xargs cat >macros.mac Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted December 18, 2015 Share Posted December 18, 2015 copy everything into the folder? or did I misse something? Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted December 18, 2015 Share Posted December 18, 2015 There are surely two different objectives being discussed here. One is to scan a single folder for all matching files, and the other (which I'd have thought unnecessary in this case) is to recursively scan the tree. Quote Link to comment Share on other sites More sharing options...
snicklin Posted December 18, 2015 Author Share Posted December 18, 2015 Although I am running Linux Mint, I've got a Windows VM booted up for my development environment, so the 'find' command can't be used in this case. I cannot revert this because other tools in the build chain rely on Windows. When I first started this thread, I had all my macros in one directory. Since then I've split them up into different directories underneath a 'macro' directory. @Heaven/TQA, not to copy the files, just to list them all out so that they can be included in MADS. Currently I have code like below and I have to add a new line to it every time that I add a new macro. If I could just do - icl -R 'lib/macros' '*.mac' then this could pick up all of the macros below this directory. icl 'lib/macros/stack/@call.mac' icl 'lib/macros/stack/@pull.mac' icl 'lib/macros/stack/@exit.mac' icl 'lib/macros/stack/pushAll.mac' icl 'lib/macros/stack/pullAll.mac' icl 'lib/macros/mSetGameStage.mac' etc etc No worries anyway, I'll write a little Perl script, won't take long. Quote Link to comment Share on other sites More sharing options...
snicklin Posted December 19, 2015 Author Share Posted December 19, 2015 (edited) Just in-case anyone else is interested (and uses Perl on Windows), I've got a quick hack solution to this. It's not that neat in that it calls 'dir' in Windows, but it does the job. use Cwd; sub writeAllFilesOfTypeRecursive { my $direc=shift; my $qualifier=shift; my $output=shift; if("$direc" eq "" || "$qualifier" eq "") { die("Error: writeAllFilesOfType ($dir) ($qualifier) called without 'directory' or 'qualifier'\n"); } $ori_wd=cwd(); chdir "$direc"; @files=`dir /N /s /B $qualifier`; chdir "$ori_wd"; $prwd=cwd(); print "File list: $prwd\n"; print @files; open(FILE,">$output"); foreach $entry (@files) { chomp($entry); print FILE " icl \'$entry\'\n"; } close(FILE); } writeAllFilesOfTypeRecursive("lib/macros","*.mac","macroList.asm"); Then you just need to include 'macroList.asm' into your build. Edited December 19, 2015 by snicklin 1 Quote Link to comment Share on other sites More sharing options...
pirx Posted December 20, 2015 Share Posted December 20, 2015 you can have busybox for windows and use find, cat, etc. I have cygwin, but it is overkill for this task. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.