AmigaPorts / ACE

Amiga C Engine
Mozilla Public License 2.0
161 stars 26 forks source link

How to make tools? #115

Closed bryanpope closed 4 years ago

bryanpope commented 4 years ago

I have been trying to make the tools in ACE/tools directory and am currently using the Cygwin terminal. From there I cd into the tools directory, then mkdir build && cd build cmake .. -G"Unix Makefiles"

But then I get the error CMake Error at CMakeLists.txt:27 (find_package): By not providing "Findfmt.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "fmt", but CMake did not find one.

Could not find a package configuration file provided by "fmt" with any of the following names:

fmtConfig.cmake
fmt-config.cmake

Add the installation prefix of "fmt" to CMAKE_PREFIX_PATH or set "fmt_DIR" to a directory containing one of the above files. If "fmt" provides a separate development package or SDK, be sure it has been installed.

Do I need to have something else installed in cygwin? Where should this fmt*.cmake file be?

tehKaiN commented 4 years ago

Okay, so first of all, I build tools using mingw compiler like all other windows stuff. Of course you should be able to build it on Amiga or cygwin's gcc too, but either way you need fmt package.

CMake has an ability to install built packages to be automatically found later. I've done something like this using mingw compiler:

cd some/temp/dir
git clone https://github.com/fmtlib/fmt
cd fmt
mkdir build & cd build
# passing CMAKE_INSTALL_PREFIX is important - you point where package should be installed.
# It needs to be specified because cmake defaults to program files to which it doesn't have access.
# Moreover you should use separate install dir per compiler (native/amiga/etc.)
cmake .. -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=c:/prg/cmake_install
mingw32-make
mingw32-make install
# ensure that files have been created in install prefix dir

Then you specify CMAKE_PREFIX_PATH environmental variable to said install folder and the next time cygwin will see all installed packages. Okay, so to recap, for you using cygwin:

  1. either set in your system a variable CMAKE_PREFIX_PATH to folder of your choice, e.g. c:/cygwin/cmake_install or /cygdrive/c/cygwin/cmake_install (same dir, different format, dunno which will work)
  2. Be sure to start console/terminal/any related program after this change because otherwise new/changed envvar will not be seen!
  3. download libfmt
  4. build as usual in cygwin but specify CMAKE_INSTALL_PREFIX to folder above
  5. then you should be able to build tools using cygwin compiler.

I strongly advise to use cygwin/native compiler for that - the point of those tools is to incorporate them into cmakelists, so you need them as windows executables to run them on windows. See Aminer's CMakeLists - convertbitmaps, palette and other stuff all use them - you have some fns defined in ACE's CmakeLists.

Tell me if you had a success with doing so. If I missed the step or something is too complex for you, just tell me - I'll try to guide you through this. Those comments will be later transformed into guide in docs. ;)

On the bottom note, perhaps I should add fmt as a submodule and refer to that. But I'll do that a bit later, after experimenting with moving ACE towards modern C++ and reorganizing things a bit.

bryanpope commented 4 years ago

I was finally able to build fmtlib, then build tools... but, I had to add add_definitions(-D_XOPEN_SOURCE=700) to fmtlib's CMakeLists.txt as I received the error:

‘strptime’ was not declared in this scope; did you mean ‘strftime’? 84 | auto result = strptime(ctx.begin(), format.c_str(), &t); | ~~^~~~~~~ | strftime make[2]: *** [test/CMakeFiles/scan-test.dir/build.make:81: test/CMakeFiles/scan-test.dir/scan-test.cc.obj] Error 1

Then I tried to make AMIner, but it aborted with a core dump while trying to generate ../data/base0.bm from I think aminer_editing.gpl. It looks like tileset_conv generated the core dump.

I am wondering if I needed to do something else to get fmtlib to make and that what I did only hid the error but didn't really fix it?

tehKaiN commented 4 years ago

Were you using cygwin to build tools? I'll try this myself later today and report to you back.

bryanpope commented 4 years ago

Yes I was using cygwin to build the tools, after using it to build fmtlib.

tehKaiN commented 4 years ago

Okay, so that's what worked for me:

  1. Updated cygwin by downloading setup and running it again. My install was from 2007 apparently. ;)
  2. Get yourself an apt-cyg if you don't have it already (I think it's one of Bebbo compiler's steps)
  3. Run cygwin from attached cygwin.bat with no additional env vars set
  4. apt-cyg install cmake - earlier I've used native windows cmake since I use mingw for building native apps, on cygwin you need a cygwin'd cmake
  5. cd /cygdrive/c/prg/_git/fmt or whatever your path is
  6. mkdir build && cd build,
  7. if you tried to build earlier, rm CMakeCache.txt
  8. cmake .. - should show "configuring complete"
  9. make -j4
  10. make install - should install to /usr/local

Then, go to ace tools directory and:

  1. mkdir build && cd build
  2. if you tried to build earlier, rm CMakeCache.txt
  3. cmake .. - should show "configuring complete"
  4. make -j4

You will see some warnings about freetypeamalgam, but don't bother about them. After all that you should have bin directory with utils ready to use.

Let me know if that solves it for you. ;)

bryanpope commented 4 years ago

I am able to build the tools, but I still get the core dump abort from tileset_conv when it is trying to generate ../data/base0.bm at 13% while make'ing AMIner.

bryanpope commented 4 years ago

This is what is causing the error: ../deps/ace/tools/bin/tileset_conv E:/Amiga/AMIner/_res/base0 32 E:/Amiga/AMIner/data/base0.bm -i -plt E:/Amiga/AMIner/_res/palettes/aminer_editing.gpl

Which outputs this: Palette color count: 32 Read 32 colors from 'E:/Amiga/AMIner/_res/palettes/aminer_editing.gpl' 0 [main] tileset_conv 91 cygwin_exception::open_stackdumpfile: Dumping stack trace to tileset_conv.exe.stackdump

bryanpope commented 4 years ago

I think I may have figured out the problem. In bitmap.cpp, you are doing a free(pData) in tChunkyBitmap::fromPng() when it unable to load a png, but when going through that code I could not see anywhere this buffer is malloc'd when the file is not found.

After commenting that line out, tileset_conv was able to skip past all the missing files.

tehKaiN commented 4 years ago

huh, I'll do a a fresh clone of this code today and see what files are missing. Guess I've commited too little on that repo and still have some crucial files as local copy, oops!

tehKaiN commented 4 years ago

I think I may have figured out the problem. In bitmap.cpp, you are doing a free(pData) in tChunkyBitmap::fromPng() when it unable to load a png, but when going through that code I could not see anywhere this buffer is malloc'd when the file is not found.

That's fixed in latest commits on master branch. Regarding missing files, those should now be available on action_modes branch.

Sorry for quite a delay!