mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-03-25 04:47:02 +00:00
Make "mymake" work on OSX, and add it to Travis.
Fix a -Wformat bug exposed by compiling with Clang. To preprocess C++11 code, you need `g++ -E -std=c++11`, not just `g++ -E`. (The old code worked for GCC 6+ and Clang 6+ because they changed the default mode from C++03 to C++14. But for GCC 5, we still need `-std=c++11`. And regardless, it's a good idea.) Add a "-mac" option to mymake, and cleanly factor out `set_mac`, `set_linux`, and `set_win`. When you build mymake using `make -f Makefile.simple mymake`, you get a mymake that knows what platform it's on. This means you don't have to pass `mymake -mac` on OSX, nor `mymake -win` on Windows. The old code put `INCLUDE(___hyper-main.cpp)` into a C++ file that would be preprocessed, which doesn't work because libSDL does essentially `-Dmain=SDL_main`, which turns this into `INCLUDE(___hyper-SDL_main.cpp)`, which gives us a "file not found" error from mymake. The solution is to put filenames into quotation marks, so that the string "main" never appears as a token in the C++ file. (Alternatively, we could have renamed "hyper-main.cpp" to "hypermain.cpp".) Add several new "mymake" entries in the Travis build matrix, and add the "mymake" builds' badge to the README.
This commit is contained in:
parent
6e4b6ee93c
commit
a49c40cee7
44
.travis.yml
44
.travis.yml
@ -85,6 +85,41 @@ matrix:
|
||||
TRAVIS_OS_NAME=linux
|
||||
TRAVIS_COMPILER_NAME=emscripten
|
||||
TRAVIS_BUILD_SYSTEM=emscripten
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: >-
|
||||
TRAVIS_OS_NAME=osx
|
||||
TRAVIS_COMPILER_NAME=clang
|
||||
TRAVIS_BUILD_SYSTEM=mymake
|
||||
HYPERROGUE_USE_GLEW=1
|
||||
HYPERROGUE_USE_PNG=1
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: >-
|
||||
TRAVIS_OS_NAME=osx
|
||||
TRAVIS_COMPILER_NAME=clang
|
||||
TRAVIS_BUILD_SYSTEM=mymake
|
||||
HYPERROGUE_USE_GLEW=1
|
||||
HYPERROGUE_USE_PNG=1
|
||||
HYPERROGUE_USE_ROGUEVIZ=1
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: >-
|
||||
TRAVIS_OS_NAME=linux
|
||||
TRAVIS_COMPILER_NAME=gcc
|
||||
TRAVIS_BUILD_SYSTEM=mymake
|
||||
HYPERROGUE_USE_GLEW=1
|
||||
HYPERROGUE_USE_PNG=1
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: gcc
|
||||
env: >-
|
||||
TRAVIS_OS_NAME=linux
|
||||
TRAVIS_COMPILER_NAME=gcc
|
||||
TRAVIS_BUILD_SYSTEM=mymake
|
||||
HYPERROGUE_USE_GLEW=1
|
||||
HYPERROGUE_USE_PNG=1
|
||||
HYPERROGUE_USE_ROGUEVIZ=1
|
||||
|
||||
before_install:
|
||||
- |-
|
||||
@ -143,6 +178,13 @@ script:
|
||||
make
|
||||
elif [[ "$TRAVIS_BUILD_SYSTEM" == "Makefile" ]]; then
|
||||
make -f Makefile.simple
|
||||
elif [[ "$TRAVIS_BUILD_SYSTEM" == "mymake" ]]; then
|
||||
make -f Makefile.simple mymake
|
||||
if [[ "$HYPERROGUE_USE_ROGUEVIZ" == "1" ]]; then
|
||||
./mymake -rv
|
||||
else
|
||||
./mymake
|
||||
fi
|
||||
elif [[ "$TRAVIS_BUILD_SYSTEM" == "emscripten" ]]; then
|
||||
docker run --rm -v $(pwd):/src trzeci/emscripten make -f Makefile.simple emscripten
|
||||
else
|
||||
@ -152,6 +194,8 @@ script:
|
||||
# Test hyperrogue.
|
||||
if [[ "$TRAVIS_BUILD_SYSTEM" == "emscripten" ]]; then
|
||||
ls -lAF hyper.html hyper.js hyper.wasm
|
||||
elif [[ "$TRAVIS_BUILD_SYSTEM" == "mymake" ]]; then
|
||||
./hyper --help
|
||||
else
|
||||
./hyperrogue --help
|
||||
fi
|
||||
|
@ -150,7 +150,7 @@ langen$(EXE_EXTENSION): langen.cpp language-??.cpp language-ptbr.cpp
|
||||
$(CXX) -O0 $(CXXFLAGS) $(langen_CXXFLAGS) langen.cpp $(LDFLAGS) -o $@
|
||||
|
||||
makeh$(EXE_EXTENSION): makeh.cpp
|
||||
$(CXX) makeh.cpp -o $@
|
||||
$(CXX) -O2 makeh.cpp -o $@
|
||||
|
||||
autohdr.h: makeh$(EXE_EXTENSION) *.cpp
|
||||
./makeh classes.cpp locations.cpp hyperpoint.cpp geometry.cpp goldberg.cpp init.cpp floorshapes.cpp cell.cpp multi.cpp shmup.cpp pattern2.cpp mapeditor.cpp graph.cpp textures.cpp hprint.cpp language.cpp util.cpp complex.cpp *.cpp > autohdr.h
|
||||
@ -161,6 +161,9 @@ language-data.cpp: langen$(EXE_EXTENSION)
|
||||
savepng$(OBJ_EXTENSION): savepng.cpp
|
||||
$(CXX) -O2 $(CXXFLAGS) -c savepng.cpp -o $@
|
||||
|
||||
mymake$(EXE_EXTENSION): mymake.cpp
|
||||
$(CXX) -O2 $(CXXFLAGS) mymake.cpp -o $@
|
||||
|
||||
emscripten: hyper.html
|
||||
|
||||
%.html %.js %.wasm: %.emscripten-sources
|
||||
@ -173,5 +176,6 @@ hyper.emscripten-sources: *.cpp autohdr.h
|
||||
clean:
|
||||
rm -f langen$(EXE_EXTENSION) language-data.cpp
|
||||
rm -f makeh$(EXE_EXTENSION) autohdr.h
|
||||
rm -rf mymake$(EXE_EXTENSION) mymake_files/
|
||||
rm -f hyperrogue$(EXE_EXTENSION) hyper$(OBJ_EXTENSION) $(hyper_RES) savepng$(OBJ_EXTENSION)
|
||||
rm -f hyper.html hyper.js hyper.wasm
|
||||
|
@ -3,6 +3,7 @@
|
||||
<a href="https://travis-ci.org/zenorogue/hyperrogue/builds">
|
||||
<img align="right" src="https://badges.herokuapp.com/travis/zenorogue/hyperrogue?branch=master&env=TRAVIS_BUILD_SYSTEM=autotools&label=autotools" alt="TravisCI badge">
|
||||
<img align="right" src="https://badges.herokuapp.com/travis/zenorogue/hyperrogue?branch=master&env=TRAVIS_BUILD_SYSTEM=Makefile&label=make" alt="TravisCI badge">
|
||||
<img align="right" src="https://badges.herokuapp.com/travis/zenorogue/hyperrogue?branch=master&env=TRAVIS_BUILD_SYSTEM=mymake&label=mymake" alt="TravisCI badge">
|
||||
<img align="right" src="https://badges.herokuapp.com/travis/zenorogue/hyperrogue?branch=master&env=TRAVIS_BUILD_SYSTEM=emscripten&label=web" alt="TravisCI badge">
|
||||
</a>
|
||||
</p>
|
||||
|
73
mymake.cpp
73
mymake.cpp
@ -17,21 +17,41 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
string opts = "-DFHS -DLINUX -DWHATEVER -DMYMAKE -I/usr/include/SDL";
|
||||
string opts;
|
||||
|
||||
string default_standard = " -std=c++11";
|
||||
string standard = default_standard;
|
||||
|
||||
string preprocessor =
|
||||
"g++ -E";
|
||||
string preprocessor;
|
||||
string compiler;
|
||||
string linker;
|
||||
string libs;
|
||||
|
||||
string compiler =
|
||||
"g++ -Wall -Wextra -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-implicit-fallthrough -rdynamic -fdiagnostics-color=always -c";
|
||||
void set_linux() {
|
||||
preprocessor = "g++ -E";
|
||||
compiler = "g++ -Wall -Wextra -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-implicit-fallthrough -rdynamic -fdiagnostics-color=always -c";
|
||||
linker = "g++ -rdynamic -o hyper";
|
||||
opts = "-DFHS -DLINUX -I/usr/include/SDL";
|
||||
libs = " savepng.o -lSDL -lSDL_ttf -lSDL_mixer -lSDL_gfx -lGLEW -lGL -lpng -rdynamic -lpthread -lz";
|
||||
}
|
||||
|
||||
string linker =
|
||||
"g++ -rdynamic -o hyper";
|
||||
|
||||
string libs = " savepng.o -lSDL -lSDL_ttf -lSDL_mixer -lSDL_gfx -lGLEW -lGL -lpng -rdynamic -lpthread -lz";
|
||||
void set_mac() {
|
||||
preprocessor = "g++ -E";
|
||||
compiler = "g++ -march=native -W -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-implicit-fallthrough -c";
|
||||
linker = "g++ -o hyper";
|
||||
opts = "-DMAC -I/usr/local/include";
|
||||
libs = " savepng.o -L/usr/local/lib -framework AppKit -framework OpenGL -lSDL -lSDLMain -lSDL_gfx -lSDL_mixer -lSDL_ttf -lpng -lpthread -lz";
|
||||
}
|
||||
|
||||
void set_win() {
|
||||
preprocessor = "g++ -E";
|
||||
compiler = "runbat bwin-g.bat -c";
|
||||
linker = "runbat bwin-linker.bat";
|
||||
opts = "-DFHS -DLINUX -I/usr/include/SDL";
|
||||
libs = "";
|
||||
|
||||
standard = "";
|
||||
}
|
||||
|
||||
vector<string> modules;
|
||||
|
||||
@ -55,6 +75,13 @@ bool file_exists(string fname) {
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#if defined(MAC)
|
||||
set_mac();
|
||||
#elif defined(WINDOWS)
|
||||
set_win();
|
||||
#else
|
||||
set_linux();
|
||||
#endif
|
||||
for(string fname: {"Makefile.loc", "Makefile.simple", "Makefile"})
|
||||
if(file_exists(fname))
|
||||
system("make -f " + fname + " language-data.cpp autohdr.h savepng.o");
|
||||
@ -68,10 +95,21 @@ int main(int argc, char **argv) {
|
||||
if(c == '=' || c == '-' || c == '/') obj_dir += "_";
|
||||
else obj_dir += c;
|
||||
}
|
||||
else if(s == "-win")
|
||||
compiler = "runbat bwin-g.bat -c", obj_dir += "/win", setdir += "../", standard = "",
|
||||
linker = "runbat bwin-linker.bat", libs = "";
|
||||
|
||||
else if(s == "-win") {
|
||||
set_win();
|
||||
obj_dir += "/win";
|
||||
setdir += "../";
|
||||
}
|
||||
else if(s == "-mac") {
|
||||
set_mac();
|
||||
obj_dir += "/mac";
|
||||
setdir += "../";
|
||||
}
|
||||
else if(s == "-linux") {
|
||||
set_linux();
|
||||
obj_dir += "/linux";
|
||||
setdir += "../";
|
||||
}
|
||||
else if(s == "-O2")
|
||||
optimized = 2, compiler += " -O2", obj_dir += "/O2", setdir += "../";
|
||||
else if(s == "-O3")
|
||||
@ -109,6 +147,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
if(!optimized)
|
||||
compiler += " -g3";
|
||||
preprocessor += " " + standard;
|
||||
compiler += " " + standard;
|
||||
ifstream fs("hyper.cpp");
|
||||
|
||||
@ -125,8 +164,8 @@ int main(int argc, char **argv) {
|
||||
string iext = "";
|
||||
for(char c: s) if(c == '"') in = !in; else if(!in) ; else if(c == '.') ext = !ext; else if(!ext) t += c; else iext += c;
|
||||
if(iext == "h") { fsm << "#include \"" + setdir + "hyper.h\"\n"; continue; }
|
||||
if(iext != "cpp") printf("unknown extension: %s\n", iext);
|
||||
fsm << "INCLUDE(___" << t << ")\n";
|
||||
if(iext != "cpp") printf("unknown extension: %s\n", iext.c_str());
|
||||
fsm << "INCLUDE(\"" << t << "\")\n";
|
||||
continue;
|
||||
}
|
||||
fsm << s << "\n";
|
||||
@ -140,8 +179,8 @@ int main(int argc, char **argv) {
|
||||
ifstream fs2(obj_dir+"/hyper.E");
|
||||
while(getline(fs2, s)) {
|
||||
if(s.substr(0, 7) == "INCLUDE") {
|
||||
s = s.substr(11);
|
||||
s = s.substr(0,s.size() - 1);
|
||||
s = s.substr(9);
|
||||
s = s.substr(0,s.size() - 2);
|
||||
modules.push_back(s);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user