HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.2k stars 657 forks source link

compilation with `-lib somelib` uses hxml build file from that lib's folder #7683

Open T1mL3arn opened 5 years ago

T1mL3arn commented 5 years ago

How to reproduce

class Main { static function main(){
trace('git library');
} }

```hx
# build-test.hxml

-main Main
--interp

class Main { static function main() { trace("actual project"); } }

```hx
# build.hxml

-lib dragonbones
-main Main
--interp

Expected result

actual project

Actual result

git library

If -lib dragonbones is commented in build.hxml then actual result is equal to expected.

Haxe 4.0.0-preview.5+7eb789f54

RealyUniqueName commented 5 years ago

Actually build-test.hxml is not executed. What happens is dragonbones/git/Main.hx shadows Main.hx of your project. I suspect if you move -main Main above -lib dragonbones you will get the expected result.

T1mL3arn commented 5 years ago

if you move -main Main above -lib dragonbones you will get the expected result.

Didn't work.

RealyUniqueName commented 5 years ago

Oh. Perhaps it's because of the compiler "plugs in" current directory before the directory of a library. Try moving Main.hx to a directory and add that dir via -cp compiler flag before/after -lib dragonbones

T1mL3arn commented 5 years ago

This helped

# build.hxml

-lib dragonbones
-cp src
-main Main
--interp

So, this is not a bug and I should close the issue? In that case would be nice to have some info like "always include your project's source and main directive right after library directives to avoid the problem when library's directory's hxml files affect current project compilation" on this manual page.

Simn commented 5 years ago

This is working as intended with the latest argument taking priority. Should be mentioned on https://haxe.org/manual/compiler-usage.html.