On Sat, Jun 03, 2017 at 09:21:06PM +0200, Nicolas Boulenguez wrote: > libmozs-24-dev, or the more recent firefox-dev (= 52) use many C++ > features. The .h files are incompatible with C, thus with Objective-C.
Have you considered the option of compiling all files which include C++ headers as Objective-C++? In theory it should be possible, with certain limitations. The attached rough patch attempts to do this, and can serve as a basis in case you intend to update to mozjs52. (Sorry that I cannot help you with that, my C++ knowledge is insufficient for this task.) Basically, it should be evaluated which approach is easier and better for long-term maintenance -- switching to C++-based mozjs or to an entirely different JavaScript engine. I would understand completely if you and/or your upstream reject the Objective-C++ aproach entirely. Looking at the first compiler errors: ,---- | src/Core/Entities/Entity.h:67:14: error: use of enum ‘OOScanClass’ without previous declaration | typedef enum OOScanClass OOScanClass; | ^~~~~~~~~~~ | src/Core/Entities/Entity.h:70:6: error: using typedef-name ‘OOScanClass’ after ‘enum’ | enum OOScanClass | ^~~~~~~~~~~ | src/Core/Entities/Entity.h:67:26: note: ‘OOScanClass’ has a previous declaration here | typedef enum OOScanClass OOScanClass; | ^~~~~~~~~~~ `---- Forward declaration of enums not allowed? Easy to fix. ,---- | src/Core/Entities/ShipEntity.h:616:39: error: expected identifier before ‘new’ | - (void) setHyperspaceSpinTime:(float)new; | ^~~ | src/Core/Entities/ShipEntity.h:616:42: error: expected ‘:’ before ‘;’ token | - (void) setHyperspaceSpinTime:(float)new; | ^ `---- Since "new" is a reserved keyword in C++, it can't be used. You'll have to replace "new" with "oo_new" or similar and update the implementation accordingly. There are several methods like this. ,---- | src/Core/Entities/ShipEntity.h:1257:53: error: ‘jsval’ does not name a type | - (void) doScriptEvent:(jsid)message withArguments:(jsval *)argv count:(uintN)argc; | ^~~~~ | src/Core/Entities/ShipEntity.h:1257:73: error: ‘uintN’ does not name a type; did you mean ‘uint’? | - (void) doScriptEvent:(jsid)message withArguments:(jsval *)argv count:(uintN)argc; | ^~~~~ | uint `---- I assume these are due to mozjs API changes. ,---- | src/Core/Scripting/OOJavaScriptEngine.h: In function ‘JSClass* OOJSGetClass(JSContext*, JSObject*)’: | src/Core/Scripting/OOJavaScriptEngine.h:372:20: error: invalid conversion from ‘const JSClass*’ to ‘JSClass*’ [-fpermissive] | return JS_GetClass(obj); | ~~~~~~~~~~~^~~~~ `---- Likewise. ,---- | src/Core/Entities/StationEntity.h:120:88: error: expected identifier before ‘export’ | - (OOCreditsQuantity) legalStatusOfManifest:(OOCommodityMarket *)manifest export:(BOOL)export; | ^~~~~~ `---- ,---- | In file included from src/Core/Entities/DockEntity.mm:28:0: | src/Core/OOCollectionExtractors.h:80:32: error: expected identifier before ‘class’ | - (id) oo_objectOfClass:(Class)class atIndex:(NSUInteger)index defaultValue:(id)value; | ^~~~~ `---- Like above, "class" and "export" are reserved C++ keywords. Replacing "class" can be trickier as it's used for Objective-C forward declarations and there's also NSObject's "+class" method. ,---- | src/Core/Entities/DockEntity.mm: In function ‘-[DockEntity pruneAndCountShipsOnApproach]’: | src/Core/OOCocoa.h:343:42: error: expected ‘;’ before ‘in’ | #define foreach(VAR, COLLECTION) for(VAR in COLLECTION) | ^ | src/Core/Entities/DockEntity.mm:67:2: note: in expansion of macro ‘foreach’ | foreach (idObj, [shipsOnApproach allKeys]) | ^~~~~~~ `---- Fast enumeration not available in Objective-C++? If so, this is easy to fix.
diff --git a/debian/control b/debian/control index 8089ad1..6cf0c4b 100644 --- a/debian/control +++ b/debian/control @@ -7,8 +7,8 @@ Build-Depends: dpkg-dev (>= 1.16.1), debhelper (>= 10), libsdl1.2-dev, libopenal-dev, libvorbis-dev, libespeak-ng-libespeak-dev, libminizip-dev, libgnustep-base-dev, - libnspr4-dev, libmozjs185-dev, - libpng-dev, mesa-common-dev, gobjc, + libnspr4-dev, libmozjs-52-dev, + libpng-dev, mesa-common-dev, gobjc++, pkg-config Build-Depends-Indep: libreoffice-writer Homepage: http://www.oolite.org diff --git a/debian/patches/debian_version_of_libmozjs.diff b/debian/patches/debian_version_of_libmozjs.diff index 496f3bd..d6b695b 100644 --- a/debian/patches/debian_version_of_libmozjs.diff +++ b/debian/patches/debian_version_of_libmozjs.diff @@ -218,7 +218,7 @@ Forwarded: Michael Werle <mi...@michaelwerle.com> ifeq ($(OO_JAVASCRIPT_TRACE),yes) ADDITIONAL_OBJCFLAGS += -DMOZ_TRACE_JSCALLS=1 endif -+ PKG_CONFIG_LIBRARIES += glu gl x11 sdl mozjs185 nspr openal vorbisfile minizip ++ PKG_CONFIG_LIBRARIES += glu gl x11 sdl mozjs-52 nspr openal vorbisfile minizip + PKG_CONFIG_CFLAGS := `pkg-config --cflags $(PKG_CONFIG_LIBRARIES)` + PKG_CONFIG_LDLIBS := `pkg-config --libs $(PKG_CONFIG_LIBRARIES)` + ADDITIONAL_OBJC_LIBS += $(PKG_CONFIG_LDLIBS) diff --git a/debian/patches/gobjc++.patch b/debian/patches/gobjc++.patch new file mode 100644 index 0000000..08a6420 --- /dev/null +++ b/debian/patches/gobjc++.patch @@ -0,0 +1,425 @@ +Description: Compile all files which include C++ headers as Objective-C++ +Author: Yavor Doganov <ya...@gnu.org> +Bug-Debian: https://bugs.debian.org/863788 +Forwarded: no +Last-Update: 2017-10-29 +--- + +--- oolite.orig/GNUmakefile ++++ oolite/GNUmakefile +@@ -1,6 +1,7 @@ + include $(GNUSTEP_MAKEFILES)/common.make + include config.make + ++vpath %.mm src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug + vpath %.m src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug + vpath %.h src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug + vpath %.c src/SDL:src/Core:src/BSDCompat:src/Core/Debug +@@ -158,6 +159,11 @@ + ADDITIONAL_OBJCFLAGS += -DSNAPSHOT_BUILD -DOOLITE_SNAPSHOT_VERSION=\"$(VERSION_STRING)\" + endif + ++# GNUstep Make treats Objective-C++ files differently, using a ++# separate variable. The -std=gnu99 option is not recognized by the ++# compiler so filter it out as it triggers a warning. ++ADDITIONAL_OBJCCFLAGS := $(filter-out -std=gnu99,$(ADDITIONAL_OBJCFLAGS)) ++ + OBJC_PROGRAM_NAME = oolite + + oolite_C_FILES = \ +@@ -176,94 +182,105 @@ + OOTCPStreamDecoderAbstractionLayer.m + + OOLITE_ENTITY_FILES = \ +- DockEntity.m \ +- DustEntity.m \ +- Entity.m \ +- OOEntityWithDrawable.m \ +- OOParticleSystem.m \ +- PlanetEntity.m \ +- PlayerEntity.m \ +- PlayerEntityContracts.m \ +- PlayerEntityControls.m \ +- PlayerEntityLegacyScriptEngine.m \ +- PlayerEntityLoadSave.m \ +- PlayerEntityScriptMethods.m \ +- PlayerEntitySound.m \ +- PlayerEntityStickMapper.m \ +- PlayerEntityStickProfile.m \ +- ProxyPlayerEntity.m \ +- OOBreakPatternEntity.m \ +- ShipEntity.m \ +- ShipEntityAI.m \ +- ShipEntityScriptMethods.m \ +- SkyEntity.m \ +- StationEntity.m \ +- OOSunEntity.m \ +- WormholeEntity.m \ +- OOLightParticleEntity.m \ +- OOFlasherEntity.m \ +- OOExhaustPlumeEntity.m \ +- OOSparkEntity.m \ +- OOECMBlastEntity.m \ +- OOPlanetEntity.m \ +- OOPlasmaShotEntity.m \ +- OOPlasmaBurstEntity.m \ +- OOFlashEffectEntity.m \ +- OOExplosionCloudEntity.m \ +- ShipEntityLoadRestore.m \ +- OOLaserShotEntity.m \ +- OOQuiriumCascadeEntity.m \ +- OORingEffectEntity.m \ +- OOVisualEffectEntity.m \ +- OOWaypointEntity.m ++ PlanetEntity.m ++ ++# ENTITY ObjC++ files. ++oolite_OBJCC_FILES = \ ++ DustEntity.mm \ ++ DockEntity.mm \ ++ PlayerEntity.mm \ ++ Entity.mm \ ++ OOEntityWithDrawable.mm \ ++ OOParticleSystem.mm \ ++ PlayerEntityContracts.mm \ ++ PlayerEntityControls.mm \ ++ PlayerEntityLegacyScriptEngine.mm \ ++ PlayerEntityLoadSave.mm \ ++ PlayerEntityScriptMethods.mm \ ++ PlayerEntitySound.mm \ ++ PlayerEntityStickMapper.mm \ ++ PlayerEntityStickProfile.mm \ ++ ProxyPlayerEntity.mm \ ++ OOBreakPatternEntity.mm \ ++ ShipEntity.mm \ ++ ShipEntityAI.mm \ ++ ShipEntityScriptMethods.mm \ ++ SkyEntity.mm \ ++ StationEntity.mm \ ++ OOSunEntity.mm \ ++ WormholeEntity.mm \ ++ OOLightParticleEntity.mm \ ++ OOFlasherEntity.mm \ ++ OOExhaustPlumeEntity.mm \ ++ OOSparkEntity.mm \ ++ OOECMBlastEntity.mm \ ++ OOPlanetEntity.mm \ ++ OOPlasmaShotEntity.mm \ ++ OOPlasmaBurstEntity.mm \ ++ OOFlashEffectEntity.mm \ ++ OOExplosionCloudEntity.mm \ ++ ShipEntityLoadRestore.mm \ ++ OOLaserShotEntity.mm \ ++ OOQuiriumCascadeEntity.mm \ ++ OORingEffectEntity.mm \ ++ OOVisualEffectEntity.mm \ ++ OOWaypointEntity.mm + + OOLITE_GRAPHICS_DRAWABLE_FILES = \ +- OODrawable.m \ +- OOPlanetDrawable.m \ +- OOMesh.m ++ OODrawable.m ++ ++# DRAWABLE ObjC++ files. ++oolite_OBJCC_FILES += \ ++ OOPlanetDrawable.mm \ ++ OOMesh.mm + + OOLITE_GRAPHICS_MATERIAL_FILES = \ +- OOMaterialSpecifier.m \ +- OOBasicMaterial.m \ + OODefaultShaderSynthesizer.m \ + OOMaterial.m \ + OONullTexture.m \ +- OOPlanetTextureGenerator.m \ +- OOStandaloneAtmosphereGenerator.m \ + OOPNGTextureLoader.m \ +- OOShaderMaterial.m \ +- OOShaderProgram.m \ + OOShaderUniform.m \ + OOShaderUniformMethodType.m \ + OOSingleTextureMaterial.m \ +- OOTexture.m \ +- OOConcreteTexture.m \ + OOTextureGenerator.m \ +- OOTextureLoader.m \ + OOPixMap.m \ + OOTextureScaling.m \ + OOPixMapChannelOperations.m \ + OOMultiTextureMaterial.m \ +- OOMaterialConvenienceCreators.m \ + OOCombinedEmissionMapGenerator.m \ + OOPixMapTextureLoader.m + ++# GRAPHICS_MATERIAL ObjC++ files. ++oolite_OBJCC_FILES += \ ++ OOMaterialSpecifier.mm \ ++ OOBasicMaterial.mm \ ++ OOStandaloneAtmosphereGenerator.mm \ ++ OOPlanetTextureGenerator.mm \ ++ OOShaderMaterial.mm \ ++ OOShaderProgram.mm \ ++ OOTexture.mm \ ++ OOConcreteTexture.mm \ ++ OOTextureLoader.mm \ ++ OOMaterialConvenienceCreators.mm ++ + OOLITE_GRAPHICS_MISC_FILES = \ +- OOCrosshairs.m \ + OODebugGLDrawing.m \ + OOGraphicsResetManager.m \ + OOOpenGL.m \ + OOOpenGLStateManager.m \ +- OOOpenGLExtensionManager.m \ +- OOOpenGLMatrixManager.m \ + OOProbabilisticTextureManager.m \ +- OOSkyDrawable.m \ + OOTextureSprite.m \ +- OOPolygonSprite.m \ + OOConvertCubeMapToLatLong.m + ++# GRAPHICS_MISC ObjC++ files. ++oolite_OBJCC_FILES += \ ++ OOCrosshairs.mm \ ++ OOOpenGLExtensionManager.mm \ ++ OOOpenGLMatrixManager.mm \ ++ OOSkyDrawable.mm \ ++ OOPolygonSprite.mm ++ + OOLITE_MATHS_FILES = \ +- CollisionRegion.m \ + OOMeshToOctreeConverter.m \ + Octree.m \ + OOHPVector.m \ +@@ -272,6 +289,10 @@ + OOVector.m \ + OOVoxel.m + ++# MATHS ObjC++ files. ++oolite_OBJCC_FILES += \ ++ CollisionRegion.mm ++ + OOLITE_OXP_VERIFIER_FILES = \ + OOAIStateMachineVerifierStage.m \ + OOCheckDemoShipsPListVerifierStage.m \ +@@ -290,67 +311,72 @@ + OOLITE_RSRC_MGMT_FILES = \ + OldSchoolPropertyListWriting.m \ + OOCache.m \ +- OOCacheManager.m \ +- OOConvertSystemDescriptions.m \ +- OOOXZManager.m \ + OOPListParsing.m \ +- OOSystemDescriptionManager.m \ +- ResourceManager.m \ + TextureStore.m + ++# RSRC_MGMT ObjC++ files. ++oolite_OBJCC_FILES += \ ++ OOCacheManager.mm \ ++ OOConvertSystemDescriptions.mm \ ++ OOOXZManager.mm \ ++ ResourceManager.mm \ ++ OOSystemDescriptionManager.mm ++ + OOLITE_SCRIPTING_FILES = \ +- EntityOOJavaScriptExtensions.m \ +- OOJavaScriptEngine.m \ +- OOJSEngineTimeManagement.m \ + OOJSEngineDebuggerHelpers.m \ +- OOConstToJSString.m \ +- OOJSCall.m \ +- OOJSClock.m \ +- OOJSDock.m \ +- OOJSEntity.m \ +- OOJSEquipmentInfo.m \ +- OOJSExhaustPlume.m \ +- OOJSFlasher.m \ +- OOJSFunction.m \ +- OOJSGlobal.m \ +- OOJSInterfaceDefinition.m \ +- OOJSManifest.m \ +- OOJSMission.m \ +- OOJSMissionVariables.m \ +- OOJSOolite.m \ +- OOJSPlanet.m \ +- OOJSPlayer.m \ ++ OOJSCall.m ++ ++# SCRIPTING ObjC++ files. ++oolite_OBJCC_FILES += \ ++ EntityOOJavaScriptExtensions.mm \ ++ OOJavaScriptEngine.mm \ ++ OOJSEngineTimeManagement.mm \ ++ OOConstToJSString.mm \ ++ OOJSClock.mm \ ++ OOJSDock.mm \ ++ OOJSEntity.mm \ ++ OOJSEquipmentInfo.mm \ ++ OOJSFlasher.mm \ ++ OOJSExhaustPlume.mm \ ++ OOJSFunction.mm \ ++ OOJSGlobal.mm \ ++ OOJSInterfaceDefinition.mm \ ++ OOJSManifest.mm \ ++ OOJSMission.mm \ ++ OOJSMissionVariables.mm \ ++ OOJSOolite.mm \ ++ OOJSPlanet.mm \ ++ OOJSPlayer.mm \ + OOJSPlayerShip.m \ +- OOJSPopulatorDefinition.m \ +- OOJSQuaternion.m \ +- OOJSScript.m \ +- OOJSShip.m \ +- OOJSShipGroup.m \ +- OOJSSound.m \ +- OOJSSoundSource.m \ +- OOJSSpecialFunctions.m \ +- OOJSStation.m \ +- OOJSSun.m \ +- OOJSSystem.m \ +- OOJSSystemInfo.m \ +- OOJSTimer.m \ +- OOJSVisualEffect.m \ +- OOJSVector.m \ +- OOJSWorldScripts.m \ +- OOJSWormhole.m \ +- OOJSWaypoint.m \ +- OOLegacyScriptWhitelist.m \ +- OOPListScript.m \ +- OOScript.m \ +- OOScriptTimer.m \ +- OOJSFrameCallbacks.m \ +- OOJSFont.m ++ OOJSPopulatorDefinition.mm \ ++ OOJSQuaternion.mm \ ++ OOJSScript.mm \ ++ OOJSShip.mm \ ++ OOJSShipGroup.mm \ ++ OOJSSound.mm \ ++ OOJSSoundSource.mm \ ++ OOJSSpecialFunctions.mm \ ++ OOJSStation.mm \ ++ OOJSSun.mm \ ++ OOJSSystem.mm \ ++ OOJSSystemInfo.mm \ ++ OOJSTimer.mm \ ++ OOJSVisualEffect.mm \ ++ OOJSVector.mm \ ++ OOJSWorldScripts.mm \ ++ OOJSWaypoint.mm \ ++ OOJSWormhole.mm \ ++ OOLegacyScriptWhitelist.mm \ ++ OOPListScript.mm \ ++ OOScript.mm \ ++ OOScriptTimer.mm \ ++ OOJSFrameCallbacks.mm \ ++ OOJSFont.mm + + OOLITE_SOUND_FILES = \ + OOOpenALController.m \ + OOMusicController.m \ + OOSoundSource.m \ +- OOSoundSourcePool.m \ + OOALMusic.m \ + OOALSound.m \ + OOALSoundChannel.m \ +@@ -359,12 +385,18 @@ + OOALBufferedSound.m \ + OOALStreamedSound.m + ++# SOUND ObjC++ files. ++oolite_OBJCC_FILES += \ ++ OOSoundSourcePool.mm + + OOLITE_UI_FILES = \ +- GuiDisplayGen.m \ +- HeadUpDisplay.m \ + OOEncodingConverter.m + ++# UI ObjC++ files. ++oolite_OBJCC_FILES += \ ++ GuiDisplayGen.mm \ ++ HeadUpDisplay.mm ++ + OO_UTILITY_FILES = \ + Comparison.m \ + NSDataOOExtensions.m \ +@@ -379,49 +411,55 @@ + OOAsyncWorkManager.m \ + OOCollectionExtractors.m \ + OOColor.m \ +- OOConstToString.m \ + OOCPUInfo.m \ +- OOEntityFilterPredicate.m \ + OOExcludeObjectEnumerator.m \ + OOFilteringEnumerator.m \ + OOIsNumberLiteral.m \ + OOLogging.m \ +- OOLogHeader.m \ + OOLogOutputHandler.m \ + OOPriorityQueue.m \ + OOProbabilitySet.m \ +- OOShipGroup.m \ +- OOStringExpander.m \ +- OOStringParsing.m \ + OOWeakReference.m \ + OOWeakSet.m \ + OOXMLExtensions.m \ + OODeepCopy.m \ +- OORegExpMatcher.m \ + NSObjectOOExtensions.m + ++# UTILITY ObjC++ files. ++oolite_OBJCC_FILES += \ ++ OOConstToString.mm \ ++ OOEntityFilterPredicate.mm \ ++ OOLogHeader.mm \ ++ OOShipGroup.mm \ ++ OOStringExpander.mm \ ++ OOStringParsing.mm \ ++ OORegExpMatcher.mm ++ + OOLITE_MISC_FILES = \ +- AI.m \ + AIGraphViz.m \ +- GameController.m \ +- GameController+SDLFullScreen.m \ + OOJoystickManager.m \ +- OOJoystickProfile.m \ + OOSDLJoystickManager.m \ + main.m \ +- MyOpenGLView.m \ +- OOCharacter.m \ + OOCocoa.m \ +- OOCommodities.m \ + OOCommodityMarket.m \ +- OOEquipmentType.m \ + OOMouseInteractionMode.m \ + OORoleSet.m \ +- OOShipLibraryDescriptions.m \ +- OOShipRegistry.m \ +- OOSpatialReference.m \ +- OOTrumble.m \ +- Universe.m ++ OOSpatialReference.m ++ ++# MISC ObjC++ files. ++oolite_OBJCC_FILES += \ ++ AI.m \ ++ GameController.mm \ ++ GameController+SDLFullScreen.mm \ ++ OOJoystickProfile.mm \ ++ OOCharacter.mm \ ++ MyOpenGLView.mm \ ++ OOCommodities.mm \ ++ OOEquipmentType.mm \ ++ OOShipLibraryDescriptions.mm \ ++ OOShipRegistry.mm \ ++ OOTrumble.mm \ ++ Universe.mm + + oolite_OBJC_FILES = \ + $(OOLITE_DEBUG_FILES) \ diff --git a/debian/patches/series b/debian/patches/series index fdcaef2..cdd3d45 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -9,3 +9,4 @@ simplify_gnumakefile.diff avoid_depending_on_xcode.diff typo-identifer.diff initialize-nsdate-before-threads-locks.diff +gobjc++.patch diff --git a/debian/rules b/debian/rules index 9c57af2..0f08331 100755 --- a/debian/rules +++ b/debian/rules @@ -69,9 +69,14 @@ OOLITE_OPTS += DEPLOYMENT_RELEASE_CONFIGURATION=yes override_dh_auto_build-arch: $(OOLITE_APP) override_dh_auto_build-indep: $(OOLITE_APP) $(OOLITE_APP): +# Create .mm symlinks. Only some files need to be compiled as +# Objective-C++ but it is easier to create symlinks for all of them; +# it does no harm either. + find -name \*.m -execdir ln -s '{}' '{}'m \; $(MAKE) $(GSMAKE) $(OOLITE_OPTS) override_dh_auto_clean:: $(MAKE) $(GSMAKE) $(OOLITE_OPTS) distclean clean + find -name \*.mm -delete rm -rf $(OOLITE_APP) ######################################################################