pawn-lang / compiler

Pawn compiler for SA-MP with bug fixes and new features - runs on Windows, Linux, macOS
Other
306 stars 72 forks source link

.amx files created at unexpected places #313

Closed YashasSamaga closed 6 years ago

YashasSamaga commented 6 years ago

Is this a BUG REPORT, FEATURE REQUEST or QUESTION?:

What happened:

Sometimes .amx files are found at the wrong place. They are usually (if not always) found at the root of the drive the original script/compiler was in.

If the script/compiler is in X:/dir1/dir2, the mysterious .amx file appears at X:/ with the same name as that of the script which was compiled.

What you expected to happen: The .amx files shouldn't be there.

How to reproduce it (as minimally and precisely as possible): A mystery.

Anything else we need to know?:

Environment:

AmyrAhmady commented 6 years ago

I have this issue since I started writing scripts in Pawn for samp (this doesn’t happen for AMXMODX scripts). So as @YashasSamaga already mentioned, this happens when I compile the file in X:/dir1/dir1/... and then 2 files will be created. one in the same folder near script_name.pwn and the other one in X root directory. Also both have the same name. I started using Zeex Compiler about a year ago and I still have this issue sometimes (not always!)

I am using windows 10, and I used to compile pawn files in winXP and win7 too. all of them with same results.

Southclaws commented 6 years ago

To add to the mystery: I've been using 3.10.4 ever since it came out, it's the default compiler for sampctl, and my C:\ root contains no .amx files at all. I've only recently started to use 3.10.7 so I'll check in a few days to see if this is happening.

Below is an example invocation of the compiler by sampctl with all the default settings and flags for a real package build, I'm thinking that I never see this because sampctl always passes absolute paths to the compiler whereas I think most users simply let pawncc determine the output directory which may be where the issues lie.

C:\Users\Southclaw\.samp\pawn\3.10.4\pawncc.exe
F:\Projects\ScavengeSurviveOrg\weapons\test.pwn
-DF:\Projects\ScavengeSurviveOrg\weapons
-oF:\Projects\ScavengeSurviveOrg\weapons\test.amx
-d3
-;+
-(+
-\+
-Z+
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\samp-stdlib
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\pawn-stdlib
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\samp-logger
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\item
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\YSI-Includes
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\amx_assembly
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\button
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\action-text
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\mathutil
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\tick-difference
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\test-boilerplate
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\personal-space
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\pawn-uuid
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\health
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\progress2
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\ut_mock_players
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\energy
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\language
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\pawn-map\include
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\pawn-memory\include
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\pawn-fsutil
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\item-array-data
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\test-boilerplate-items
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\test-boilerplate-npcs
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\FCNPC\sampsvr_files
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\zcmd
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\extracted-asset-resources\samp-plugin-crashdetect-ff05b555b1add80199cf701da91ae9fc
-iF:\Projects\ScavengeSurviveOrg\weapons\dependencies\extracted-asset-resources\samp-streamer-plugin-7c00b9d8ef1afd58a2abba656afbde24
Y-Less commented 6 years ago

I've had that, but never really thought anything of it. Normally I don't notice the extra files for weeks, so I just figured they came from an old compilation with the wrong flags given.

Zeex commented 6 years ago

Could it be because of the wrong working directory? I only saw something like this when I forgot to cd to the right place.

AmyrAhmady commented 6 years ago

So, I was cleaning my folders and I saw some .amx files in my D directory, I looked at the last modified dates and I realized in those days I probably used Pawno , so I went for some tests, I tried both old and updated compiler with VS Code, Sublime Text 3, and Pawno, well, the result was kinda weird, this bug ( or whatever you call it) only happens when you use Pawno (at least for me after about 5 tests with both compilers and 3 editors) so in my opinion it can be about Pawno.

Southclaws commented 6 years ago

I think it's safe to say that Pawno, despite its obvious greatness, seems to be randomly copying output files to the root. I vote close on this issue.

YashasSamaga commented 6 years ago

It could also be that Pawno executes the compiler with a relative path and other editors (where this mysterious behavior is not observed) execute the compiler with absolute path.

Update: the above turns out to be false. Pawno passes an absolute path of the script but does not specify any output path.

Southclaws commented 6 years ago

I was messing with Pawno for some reason and realised what this was. Pawno has two build modes: "Build" and "Build+Run" (on F5 and F6). "Build+Run" is meant to build your code and then execute some external command, such as samp-server.exe for opening up the server and testing the gamemode immediately.

image

However, the default command for this is actually just pawncc with -r -w 203:

image

Which does:

  1. copy the output to \ (root)
  2. generate a call graph .xml file which doesn't appear to happen

I think the intended usage is that you'd copy your script to gamemodes and run samp-server.exe or something. Maybe it was a left-over from when Pawn was used for other things so maybe the call graph would have been important and copying the script elsewhere was too.

So the result of this is that there's nothing "random" about this, people have just been hitting F6 instead of F5 by accident every now and then which results in this file appearing in the root.

Anyway, mystery solved!