News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

using ld linker under windows

Started by Emil_halim, October 20, 2010, 09:25:55 PM

Previous topic - Next topic

Sevag.K


well, this is a doozy.
the problem is not a problem, it's a feature.  now to figure out how to disable this "feature" on specific macros.

HIDE templates are actually kMake scripts, what's happening is that when kMake creates a file, it expands the macros in the file.  this is used in the templates to replace the macro $(filename) to the name you entered for the project.  the problem is, the files are created from within a foreach loop, so all instances of $(%) are also expanded!

i'm thinking the simplest solution would be to modify kMake so that when it encounters a macro written such
$$(<macro id>) it will not expand the macro, instead, it will replace it with $(<macro id>).


Sevag.K


made a quick adjustment to kMake.
download and copy to HIDE\bin

just before creating the template, add an extra '$' just before every '$(%)' macro that you don't want replaced so that each one looks like this:

$$(%)

this way kMake will completely ignore the macro on the first pass expansion and remove the preceding '$' on the second pass expansion, so your final result in the created file will be what you want, a $(%)

hope this doesn't cause too much confusion.  i've been tinkering with kMake since i started programming and it's internals are a monstrosity.


Emil_halim

I have another idea, may be it is more better or not i do not know.

instead of double $$ macro , you can put a two keywords that enclose a section of kmake script code
, and in that section all the macro is frozen , i.g no macro replacement will take place in that part.

any way thanks for your help.

Sevag.K


the way kMake is coded internally, this would be difficult to do.

Emil_halim

ok , if i got it well, all macros of Script code have to be $$ before creating a template.

because , HIDE will remove one $ when creating a new project.

so that after choosing create template menu i have to manually change $ to $$.

wright i am ?

Sevag.K

the point is that it has to be $$ only in the final template.  you can do this before creating the template or after by modifying the generates script file.

i said you should do it before because if you modify the generated template instead, you must only change the script file section.  it's confusing so i'll illustrate.

let's say you made your script.

"thescript.kmk"

[BUILD]

%c\this and that. $(%)



now, just before creating the template in HIDE:



[BUILD]

%c\this and that. $$(%)



once you create the template, it will look something like this (yours will be different of course)


; Template generated by HIDE 1.50.01 hla 2.14/stdlib 8.0
; This is a kMake script for generating a HIDE project
; To activate, use HIDE menu Project > New Project From Template
; Or use kMake, syntax:
; kMake filename=<filename> <templatename>[.kmk]

[Template]
author= HIDE
version= 0
date= unknown

[Description]
<text>
Template generated by HIDE
<replace with your template description>
</text>

[MACROS]
folders=units,src
files="src\templatetest.hla","thescript.kmk"

[BUILD]

<< if ! filename >>
<< error: Usage: kMake filename=<project_name> <templatename>[.kmk] >>
<< endif >>

#BUILD_FOLDERS
#BUILD_HPR
#BUILD_SOURCES

[BUILD_FOLDERS]

mkdir $(filename)
cd $(filename)
<< foreach: folders >>
mkdir $(%)
<< endfor >>

[BUILD_HPR]

<< CreateFile: hpr_file, keep >>
rename hpr_file $(filename).hpr

[hpr_file]
<text>

[HPR Settings]
Project Version=10
options=00000040
tab=4
backups=3
usetemp=false
useunits=true
useback=false
mainfile=src\templatetest.hla
findscope=00000001
findflags=00000000

[HPR Jobs]
templatetest
thescript

[templatetest.files]
templatetest.hla,src,hlaprogram

[templatetest.extlinked]
kernel32.lib
user32.lib
hlalib.lib
hidelib.lib

[templatetest]
console=true
output=$(filename).exe
type=program
main=templatetest.hla

[templatetest.link]
-heap:0xF4240,0xF4240
-stack:0xF4240,0xF4240
-base:0x4000000
-entry:HLAMain
-section:.data,RW
-section:.text,ER
-machine:ix86


[HPR Folders]
units
src

[thescript]
type=target
output=$(filename)
target=thescript.kmk

[thescript.files]
thescript.kmk,,kmake



</text>

[BUILD_SOURCES]
<< foreach: files >>
<< CreateFile: $(%),keep >>
<< endfor >>

[src\templatetest.hla]
<text>
program templatetest;

#include ("stdlib.hhf")

begin templatetest;


end templatetest;

</text>

[thescript.kmk]
<text>
[BUILD]

%c\this and that. $$(%)



</text>


notice the double $$ are only in the [thescript.kmk] section, as it should be.


after creating the template, go back to the original for your current project.
you can use ctrl-z to undo all the changes quickly.


[BUILD]

%c\this and that. $(%)



from now on, when you create a new project using the template you just made, you don't have to worry anymore, it will put the correct macros unexpanded.


Emil_halim