Skip to content
Permalink
Browse files

Final touches on CMake builds on Linux.

Improved build.sh and README, better install directories.
Updated .gitignore.
  • Loading branch information...
chuma committed May 17, 2018
1 parent b497f0c commit 96d97ecc698d2bdeba0f4e83b79a145e6ba4cad7
Showing with 368 additions and 21 deletions.
  1. +4 −2 .gitignore
  2. +10 −9 CMakeLists.txt
  3. +2 −2 K/CMakeLists.txt
  4. +186 −0 K/Misc/UPStrings.cp
  5. +101 −0 K/Misc/UPStrings.h
  6. +16 −0 Monitor/CMakeLists.txt
  7. +29 −7 README.cmake.md
  8. +20 −1 _Build_/CMake/build.sh
@@ -1,5 +1,7 @@
*.swp
build/
bin/
lib/
DerivedData/
*.mode1v3
*.mode2v3
@@ -8,5 +10,5 @@ DerivedData/
*.xcuserdatad
.DS_Store
_Build_/Jam/build.LINUX/
_Build_/CMake/cmake*
_Build_/CMake/CMake*
_Build_/CMake/
!_Build/CMake/build.sh
@@ -14,7 +14,6 @@ option(armlejit "Use ARMLE JIT" OFF)
option(appX11 "X11+CLI application" ON)
option(appFLTK "FLTK application" OFF)

set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR})

# Release / Debug compile flags.
@@ -63,13 +62,13 @@ add_subdirectory(K)
## 1) Gather all common sources

file(GLOB elib_common_sources "Emulator/*.cp")
file(GLOB elib_Monitor_sources "Monitor/*.cp")
# file(GLOB elib_Monitor_sources "Monitor/*.cp")

set_source_files_properties(${elib_common_sources} PROPERTIES LANGUAGE CXX)
set_source_files_properties(${elib_Monitor_sources} PROPERTIES LANGUAGE CXX)
# set_source_files_properties(${elib_Monitor_sources} PROPERTIES LANGUAGE CXX)

# Add "einsteinlib" as a library target
add_library(einsteinlib STATIC ${elib_common_sources} ${elib_Monitor_sources})
add_library(einsteinlib STATIC ${elib_common_sources})

# add include directories ... do I need this?
target_include_directories(einsteinlib PUBLIC
@@ -97,7 +96,8 @@ if(${WIN32})
elseif(${UNIX})

if (${APPLE})
set(EINSTEIN_TARGET "MACOSX")
# FIXME OS X is called OPENSTEP ...
set(EINSTEIN_TARGET "OPENSTEP")
# FIXME add OS X sources here.
set(EINSTEIN_SCREEN_MANAGER "Cocoa")
else()
@@ -126,18 +126,19 @@ endif()

# Add the Emulator/ sub-dir, which has CMakeLists all the way down
add_subdirectory(Emulator)
add_subdirectory(Monitor)

string(TOUPPER ${CMAKE_HOST_SYSTEM_NAME} _LOCAL_LIB_DIR_SUFFIX)
install(TARGETS einsteinlib DESTINATION lib.${_LOCAL_LIB_DIR_SUFFIX})
install(TARGETS einsteinlib DESTINATION lib/${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_BUILD_TYPE})

target_link_libraries(einsteinlib files host jit log nativecalls network pcmcia platform rom screen serial sound ${LINKLIBS} k)
target_link_libraries(einsteinlib monitor files host jit log nativecalls network pcmcia platform rom screen serial sound ${LINKLIBS} k)


############################
# EINSTEIN EMULATOR
add_executable(einstein app/einstein.cp app/TCLIApp.cp)

install(TARGETS einstein DESTINATION einstein-${CMAKE_BUILD_TYPE})
install(TARGETS einstein
DESTINATION bin/${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_BUILD_TYPE})

set_source_files_properties(app/einstein.cp app/TCLIApp.cp PROPERTIES LANGUAGE CXX)
target_link_libraries(einstein k einsteinlib)
@@ -43,7 +43,7 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
add_definitions (-DTARGET_OS_LINUX -DHAS_C99_LONGLONG -Wno-multichar)
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
add_definitions (-DTARGET_OS_OPENSTEP)
set(SOURCES ${SOURCES} Misc/UpStrings.cp)
set(SOURCES ${SOURCES} Misc/UPStrings.cp)
endif()

set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE CXX)
@@ -56,4 +56,4 @@ target_link_libraries(k ${M_LIB} ${PTHREAD_LIB})

string(TOUPPER ${CMAKE_HOST_SYSTEM_NAME} _LOCAL_LIB_DIR_SUFFIX)

install(TARGETS k DESTINATION lib.${_LOCAL_LIB_DIR_SUFFIX})
install(TARGETS k DESTINATION lib/${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_BUILD_TYPE})
@@ -0,0 +1,186 @@
// ==============================
// Fichier: UPStrings.cp
// Projet: K
//
// Cr�� le: 22/1/2001
// Tabulation: 4 espaces
//
// ***** BEGIN LICENSE BLOCK *****
// Version: MPL 1.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is UPStrings.cp.
//
// The Initial Developer of the Original Code is Paul Guyot.
// Portions created by the Initial Developer are Copyright (C) 2001-2004,2003
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Paul Guyot <pguyot@kallisys.net> (original author)
//
// ***** END LICENSE BLOCK *****
// ===========

#include <K/Defines/KDefinitions.h>
#include <K/Misc/UPStrings.h>

// Routines de conversion de cha�nes Pascal <-> C

#ifdef __MWERKS__
#pragma warn_resultnotused off
#pragma warn_implicitconv off
#pragma warn_extracomma off
#endif

#if TARGET_OS_MACOS
#include <Types.h>
#include <Memory.h>
#elif TARGET_OS_OPENSTEP
#include <CoreServices/CoreServices.h>
#endif

#ifdef __MWERKS__
#pragma warn_resultnotused on
#pragma warn_implicitconv reset
#pragma warn_extracomma reset
#endif

// -------------------------------------------------------------------------- //
// * P2CStrCopy( char*, ConstStr255Param, long )
// -------------------------------------------------------------------------- //
void
UPStrings::P2CStrCopy(
char* outDestString,
ConstStr255Param inSourceString,
long inMaxLength )
{
// Taille de la cha�ne
register long theLength = inSourceString[0];

// On tronque si n�cessaire.
if (theLength > inMaxLength)
{
theLength = inMaxLength;
}

// Copie des caract�res.
::BlockMove( &inSourceString[1], outDestString, theLength );

// Ajout du terminateur.
outDestString[theLength] = '\0';
}

// -------------------------------------------------------------------------- //
// * C2PStrCopy( Str255, const char*, long )
// -------------------------------------------------------------------------- //
void
UPStrings::C2PStrCopy(
Str255 outDestString,
const char* inSourceString,
long inMaxLength )
{
// On mesure la taille en m�me temps qu'on copie.

// Taille de la cha�ne
register long theLength = 0;

// Curseur sur la cha�ne.
register const char* theSourceString = inSourceString;
do {
register char theChar = *theSourceString;
if (theChar == '\0')
{
break;
}

theSourceString++;
theLength++;
outDestString[theLength] = (unsigned char) theChar;
} while (theLength <= inMaxLength);

// D�passement?
if (theLength > inMaxLength )
{
theLength = inMaxLength;
}

// On �crit la taille.
outDestString[0] = (unsigned char) theLength;
}

// -------------------------------------------------------------------------- //
// * P2CStr( Str255 )
// -------------------------------------------------------------------------- //
char*
UPStrings::P2CStr( Str255 ioString )
{
// Taille de la cha�ne
register long theLength = ioString[0];

// D�placement des caract�res.
// BlockMove sait g�rer les zones de m�moire qui se recouvrent.
::BlockMove( &ioString[1], ioString, theLength );

// Ajout du terminateur.
ioString[theLength] = '\0';

return (char*) ioString;
}

// -------------------------------------------------------------------------- //
// * P2CStr( Str255 )
// -------------------------------------------------------------------------- //
unsigned char*
UPStrings::C2PStr( char* ioString )
{
// Taille de la cha�ne
register long theLength = 0;

// Caract�re pr�c�dent.
register char thePreviousChar = '\0';

// Curseur sur la cha�ne.
register char* theString = ioString;
do {
// Lecture du caract�re courant.
register char theChar = *theString;

// On �crit le caract�re pr�c�dent.
*theString = thePreviousChar;

// Si c'est la fin, on sort.
if (theChar == '\0')
{
break;
}

// Au suivant.
theString++;
theLength++;
thePreviousChar = theChar;
} while (theLength < 256);

// D�tection du d�passement.
if (theLength == 256)
{
theLength = 255;
}

// Ecriture de la taille.
ioString[0] = (char) theLength;

return (unsigned char*) ioString;
}

// ================================= //
// Disc space -- the final frontier! //
// ================================= //
@@ -0,0 +1,101 @@
// ==============================
// Fichier: UPStrings.h
// Projet: K
//
// Créé le: 22/1/2001
// Tabulation: 4 espaces
//
// ***** BEGIN LICENSE BLOCK *****
// Version: MPL 1.1
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is UPStrings.h.
//
// The Initial Developer of the Original Code is Paul Guyot.
// Portions created by the Initial Developer are Copyright (C) 2001-2004
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Paul Guyot <pguyot@kallisys.net> (original author)
//
// ***** END LICENSE BLOCK *****
// ===========

#ifndef _UPSTRINGS_H
#define _UPSTRINGS_H

#include <K/Defines/KDefinitions.h>

///
/// Classe d'utilitaires pour g�rer les cha�nes au format pascal utilis� sous MacOS.
///
/// \author Paul Guyot <pguyot@kallisys.net>
/// \version $Revision: 1.4 $
///
/// \test aucun test d�fini.
///
class UPStrings
{
public:
///
/// Conversion d'une cha�ne pascal en une cha�ne C.
///
/// \param outDestString m�moire tampon pour mettre le r�sultat
/// \param inSourceString cha�ne Pascal � convertir
/// \param inMaxLength taille maximale de la cha�ne en caract�re (taille
/// de outDestString moins 1)
///
static void P2CStrCopy(
char* outDestString,
ConstStr255Param inSourceString,
long inMaxLength = 255 );

///
/// Conversion d'une cha�ne C en une cha�ne pascal.
///
/// \param outDestString m�moire tampon pour mettre le r�sultat
/// \param inSourceString cha�ne C � convertir
/// \param inMaxLength taille maximale de la cha�ne en caract�re (taille
/// de outDestString moins 1)
///
static void C2PStrCopy(
Str255 outDestString,
const char* inSourceString,
long inMaxLength = 255 );

///
/// Conversion sur place d'une cha�ne pascal en une cha�ne C.
/// La cha�ne pass�e en entr�e est modifi�e.
///
/// \param ioString cha�ne Pascal � convertir
/// \return un pointeur sur la cha�ne, d�sormais au format C.
///
static char* P2CStr( Str255 ioString );

///
/// Conversion sur place d'une cha�ne C en une cha�ne pascal.
/// La cha�ne pass�e en entr�e est modifi�e.
///
/// \param ioString cha�ne C � convertir
/// \return un pointeur sur la cha�ne, d�sormais au format pascal.
///
static unsigned char* C2PStr( char* ioString );
};

#endif
// __UPSTRINGS__

// =========================== //
// /* Halley */ //
// //
// (Halley's comment.) //
// =========================== //
@@ -0,0 +1,16 @@
# Monitor CMakeLists

file(GLOB headers *.h)
file(GLOB sources *.cp)

set_source_files_properties(${sources} PROPERTIES LANGUAGE CXX)

add_library(monitor STATIC ${sources})

target_include_directories(monitor PUBLIC
../
../Emulator/JIT/
../Emulator/JIT/Generic/
../Emulator/)

target_link_libraries(monitor k)

0 comments on commit 96d97ec

Please sign in to comment.
You can’t perform that action at this time.