Skip to content

Commit

Permalink
Added a CMakeLists.txt that can produce valid binary using `nekotools…
Browse files Browse the repository at this point in the history
… boot -c ...`.

Re. HaxeFoundation/neko#130
  • Loading branch information
andyli committed Feb 3, 2017
1 parent 61ba6ab commit eff059a
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ test/libraries/vsc/
dump/
deploy/
repo_integration_tests/
haxelib
run.c

# run.n is in the repo
!/run.n
Expand All @@ -28,3 +30,21 @@ www/bower_components
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml

# CMake
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake

# VisualStudio
*.vcxproj
*.vcxproj.filters
*.sln
Win32
haxelib.dir
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:

matrix:
include:
# haxe development + neko master
# haxe development + neko development
- os: linux
sudo: required
dist: trusty
Expand All @@ -16,7 +16,7 @@ matrix:
before_install:
- sudo add-apt-repository ppa:haxe/snapshots -y
- sudo apt-get update
- sudo apt-get install haxe=1:3.4* neko-dev libapache2-mod-neko -y
- sudo apt-get install haxe neko-dev libapache2-mod-neko -y
- mkdir ~/haxelib && haxelib setup ~/haxelib
- sudo usermod -a -G travis www-data
# haxe 3.2.1 + neko 2.1.0
Expand Down
55 changes: 55 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 2.8.7)

include(GNUInstallDirs)
project(Haxelib C)

# put output in ${CMAKE_BINARY_DIR}

set(OUTPUT_DIR ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIR})

# avoid the extra "Debug", "Release" directories
# http://stackoverflow.com/questions/7747857/in-cmake-how-do-i-work-around-the-debug-and-release-directories-visual-studio-2
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${OUTPUT_DIR} )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${OUTPUT_DIR} )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${OUTPUT_DIR} )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )

# find Haxe and Neko

find_program(HAXE_COMPILER haxe)

find_path(NEKO_INCLUDE_DIRS neko.h)
find_library(NEKO_LIBRARIES neko)
find_program(NEKO neko)
find_program(NEKOTOOLS nekotools)

message(STATUS "HAXE_COMPILER: ${HAXE_COMPILER}")
message(STATUS "NEKO_INCLUDE_DIRS: ${NEKO_INCLUDE_DIRS}")
message(STATUS "NEKO_LIBRARIES: ${NEKO_LIBRARIES}")
message(STATUS "NEKOTOOLS: ${NEKOTOOLS}")

include_directories(${NEKO_INCLUDE_DIRS})

add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/run.n
COMMAND ${HAXE_COMPILER} client.hxml
VERBATIM
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/run.c
COMMAND ${NEKOTOOLS} boot -c run.n
VERBATIM
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS ${CMAKE_SOURCE_DIR}/run.n
)

add_executable(haxelib
${CMAKE_SOURCE_DIR}/run.c
)

target_link_libraries(haxelib ${NEKO_LIBRARIES})
11 changes: 11 additions & 0 deletions test/RunCi.hx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ class RunCi {

static function compileClient():Void {
runCommand("haxe", ["client.hxml"]);

var nekotoolsBootC = switch [Sys.getEnv("TRAVIS_HAXE_VERSION"), Sys.systemName()] {
case [null | "development", "Linux"]:
true;
case _:
false;
}
if (nekotoolsBootC) {
runCommand("cmake", ["."]);
runCommand("cmake", ["--build", "."]);
}
}

static function compileLegacyClient():Void {
Expand Down

0 comments on commit eff059a

Please sign in to comment.