flat assembler
Message board for the users of flat assembler.
Index
> Linux > linux fasmg include path |
Author |
|
donn 03 Aug 2020, 21:28
Super simple:
Does anyone have any make.sh examples on Linux? Tried dozens of variations of getting include in the path, including putting it in the PATH outside the script. Coming from a Windows project, trying to extend to Linux finally https://board.flatassembler.net/topic.php?t=21361. Code: #!/bin/sh #export include=include #set include=include #export include=/mnt/c/Users/donn/datap/external/fasmg/include #export PATH=/mnt/c/Users/donn/datap/external/fasmg/include:$PATH ../fasmg.x64 ../../../src/main/asm/linux/datap.asm ../../../src/main/asm/datap.obj Tried re-arranging the folders with relative paths as a temporary workaround, but farthest I got was this: Code: Error: symbol 'SCNHDR' is undefined or out of scope. |
|||
03 Aug 2020, 21:28 |
|
Furs 04 Aug 2020, 15:41
Tomasz Grysztar wrote: This is what works for me: donn, any particular reason your lines are commented out? The # sign in front means the line is a comment. BTW don't forget to use quotes around variables to be safe, like $PATH. Just quote the entire thing. |
|||
04 Aug 2020, 15:41 |
|
donn 04 Aug 2020, 17:35
Hmm, tried a few more things, put the make_linux.sh and .asm file in the fasmg folder (/mnt/c/Users/donn/datap/external/fasmg2) so relative paths wouldn't be needed too:
Code: #!/bin/bash echo "Making" INCLUDE=/mnt/c/Users/donn/datap/external/fasmg2/examples/x86/include echo $INCLUDE ./fasmg.x64 datap.asm Tried updating fasmg to version g.izxz, echoing from within the script echoes as expected, and tried the quotes around the path. I also tried cd'ing to the dir that was echoed to make sure I typed it right; I could cd there and back. In the asm file, I have: Code: include 'format/format.inc'
Yeah, the # lines are commented out, just wanted to show some variations on what I tried. I think exports are available outside the running script, they are otherwise available only within the script. Tried export again too though. It's been a while since I regularly used Linux so I could be missing something. Maybe it's a WSL thing on this computer. I can try some other variations later.
|
||||||||||
04 Aug 2020, 17:35 |
|
revolution 04 Aug 2020, 23:05
Code: export INCLUDE=/path/to/folder |
|||
04 Aug 2020, 23:05 |
|
Furs 05 Aug 2020, 19:54
donn wrote: I think exports are available outside the running script, they are otherwise available only within the script. Tried export again too though. It's been a while since I regularly used Linux so I could be missing something. export makes the variable visible to all spawned processes after that point. It won't make them visible "outside" the script, as in, affect currently running processes! That makes no sense since the environment is set at process launch. And it's not persistent, as soon as the shell is over it's gone. Of course, apps launched with the exported variables will still have them, since they're fixed at launch. Code: a=1 b=2 c=3 export a some_app & export b some_app2 & unset a b=0 some_app3 & wait some_app2 will have both 'a' and 'b' variables. some_app3 will have only 'b', but the value of 'b' will be 0. some_app2 will still be running (it's ran in the background due to &) and its 'b' will be 2 still. Last edited by Furs on 06 Aug 2020, 14:39; edited 1 time in total |
|||
05 Aug 2020, 19:54 |
|
bitRAKE 06 Aug 2020, 05:01
Furs wrote: some_app will still be running (it's ran in the background due to &) and its 'b' will be 2 still. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
06 Aug 2020, 05:01 |
|
Tomasz Grysztar 06 Aug 2020, 07:50
Furs wrote: Don't you need to export INCLUDE? |
|||
06 Aug 2020, 07:50 |
|
Furs 06 Aug 2020, 14:34
bitRAKE wrote: when does some_app get a "b"? Think of it like this, in high-level terms, what the shell does when you launch an app from it: Code: LaunchAppFromShell() { CreateNewApp Iterate through all environment and exported variables: Copy them to the new App's environment Start the app } Since there was no 'b' when we launched some_app, it won't have one in its environment, and this applies for its entire lifespan. If you launch another some_app later, after you exported b, of course it's a completely new and separate process, which will have b set to whatever value it has when you launch it. Of course, if you execute a child shell/process, it will also get a copy of environment and exported variables. That's why if you export variables in your user's profile (~/.profile shell script), they'll be available for your user session: the profile script is the parent of all of your user apps and is executed at the beginning of user login. |
|||
06 Aug 2020, 14:34 |
|
donn 07 Aug 2020, 19:29
It works now! Was these pesky carriage return characters:
Code: #!/bin/bash^M echo "Making"^M #export include=include^M export INCLUDE="/mnt/c/Users/donn/datap/external/fasmg2/examples/x86/include"^M echo $INCLUDE^M #export include=/mnt/c/Users/donn/datap/external/fasmg/include^M #export PATH=/mnt/c/Users/donn/datap/external/fasmg/include:$PATH^M ./fasmg.x64 datap.asm Edited in vi and now up to this: Code: donn@DESKTOP-14N7AAI:/mnt/c/users/donn/datap/solution/linux$ ../../src/main/asm/make_linux2.sh Making2 /mnt/c/Users/donn/datap/external/fasmg2/examples/x86/include flat assembler version g.iveex ../../src/main/asm/linux/datap.asm [11] ../../src/main/asm/linux/../datap.inc [3] ../../src/main/asm/linux/../Includes.inc [1] ../../src/main/asm/linux/../Include/Allocate.inc [1] ../../src/main/asm/linux/../Include/../Allocate/Allocate.inc [3]: section '.data' data readable writeable align 16 macro section [33] Custom error: invalid argument. Final make script looks like this: Code: #!/bin/bash echo "Making2" export INCLUDE="/mnt/c/Users/donn/datap/external/fasmg2/examples/x86/include" echo $INCLUDE ./fasmg.x64 datap.asm I agree with everything you said regarding env vars also, my terminology and conceptual knowledge is a bit behind with this. So I guess there are three levels of variable scope here. [shell session ---[bash script ------VAR=VALUE ------export VAR2=VALUE2 ------[called process ------------VAR2=VALUE ------] ---] ] None of the vars will be available in the shell session itself unless if you use one of these methods. That point about env vars not being available to already running processes is totally legitimate too. I included echoes within the script to test these things, and adjusted my understanding of the scope from this. |
|||
07 Aug 2020, 19:29 |
|
4next 06 Nov 2024, 18:45
Hello everyone,
for those still struggling with Fasmg INCLUDE environment variable, here's a Makefile way to go: Code: .PHONY: all ASM_SRC = $(wildcard *.asm) AS = fasmg SHELL=bash SHFLAGS=-c INCLUDE=$(shell pwd)/include all: .exp .exp: @echo "Exported INCLUDE" export INCLUDE=$(INCLUDE); \ $(SHELL) $(SHFLAGS) '$(MAKE) .asm' .asm: $(ASM_SRC) @echo @echo "Building ..." @echo "Include is $(INCLUDE)" $(AS) $< $(basename $(notdir $<)) chmod +x $(basename $(notdir $<)) clean: $(ASM_SRC) rm -f $(basename $(notdir $<)) Cheers |
|||
06 Nov 2024, 18:45 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.