Skip to content

Commit

Permalink
astyle 3 -> 3.1
Browse files Browse the repository at this point in the history
Code results unchanged
  • Loading branch information
GiovanniBussi committed Feb 11, 2018
1 parent 95486cf commit 92767f9
Show file tree
Hide file tree
Showing 35 changed files with 2,615 additions and 944 deletions.
172 changes: 172 additions & 0 deletions astyle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
cmake_minimum_required(VERSION 3.0)
project(astyle CXX)

# Release Build - release by default (except for Borland)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

# Build Options - executable by default, libraries on request
option(BUILD_JAVA_LIBS "Build java library" OFF)
option(BUILD_SHARED_LIBS "Build shared library" OFF)
option(BUILD_STATIC_LIBS "Build static library" OFF)

# Linux Soname Version
set(MAJORVER 3)
set(MINORVER 1)
set(PATCHVER 0)
set(SOLIBVER ${MAJORVER}.${MINORVER}.${PATCHVER})

# AStyle Source
list(APPEND SRCS
src/ASBeautifier.cpp
src/ASEnhancer.cpp
src/ASFormatter.cpp
src/ASLocalizer.cpp
src/ASResource.cpp
src/astyle_main.cpp)

# AStyle Documentation
list(APPEND DOCS
doc/astyle.html
doc/install.html
doc/news.html
doc/notes.html
doc/styles.css)

# If a java library is requested, shared libraries should be enabled
# and the Java Development Kit 'include' directories added
if(BUILD_JAVA_LIBS)
set(BUILD_SHARED_LIBS ON)
if(WIN32)
set(java_home $ENV{JAVA_HOME})
if(NOT java_home)
message(FATAL_ERROR "Environment variable JAVA_HOME not defined")
endif()
if(NOT EXISTS ${java_home}/include)
message(FATAL_ERROR "Java Development Kit not installed at ${java_home}")
endif()
else()
if(NOT EXISTS /usr/lib/jvm/default-java/include)
message(FATAL_ERROR "Java Development Kit not installed")
endif()
endif()
endif()

# Define the output type and install directories
# To uninstall 'xargs rm < install_manifest.txt'
if(BUILD_SHARED_LIBS OR BUILD_STATIC_LIBS)
add_library(astyle ${SRCS})
if(NOT WIN32)
install(TARGETS astyle DESTINATION /usr/lib)
endif()
else()
add_executable(astyle ${SRCS})
if(WIN32)
set(pf86 "PROGRAMFILES(x86)")
set(prog_files $ENV{${pf86}})
if(NOT prog_files)
set(prog_files $ENV{PROGRAMFILES})
endif()
install(TARGETS astyle DESTINATION ${prog_files}/AStyle)
install(FILES ${DOCS} DESTINATION ${prog_files}/AStyle/doc/)
else()
install(TARGETS astyle DESTINATION /usr/bin)
install(FILES ${DOCS} DESTINATION /usr/share/doc/astyle)
endif()
endif()

# Set build-specific compile options
if(BUILD_SHARED_LIBS OR BUILD_STATIC_LIBS)
if(BUILD_JAVA_LIBS)
target_compile_options(astyle PRIVATE -DASTYLE_JNI)
if(WIN32)
target_include_directories(astyle PRIVATE $ENV{JAVA_HOME}/include)
target_include_directories(astyle PRIVATE $ENV{JAVA_HOME}/include/win32)
else()
target_include_directories(astyle PRIVATE /usr/lib/jvm/default-java/include)
target_include_directories(astyle PRIVATE /usr/lib/jvm/default-java/include/linux)
endif()
else()
target_compile_options(astyle PRIVATE -DASTYLE_LIB)
endif()
# Windows DLL exports removed
set_property(TARGET astyle PROPERTY DEFINE_SYMBOL "")
# Linux solib version added
set_property(TARGET astyle PROPERTY VERSION ${SOLIBVER})
set_property(TARGET astyle PROPERTY SOVERSION ${MAJORVER})
endif()

# Set file names if different than 'astyle'
if(BUILD_JAVA_LIBS)
if(WIN32)
set_property(TARGET astyle PROPERTY OUTPUT_NAME AStyle31j)
set_property(TARGET astyle PROPERTY PREFIX "")
else()
set_property(TARGET astyle PROPERTY OUTPUT_NAME astylej)
endif()
elseif(BUILD_SHARED_LIBS)
if(WIN32)
set_property(TARGET astyle PROPERTY OUTPUT_NAME AStyle31)
set_property(TARGET astyle PROPERTY PREFIX "")
endif()
elseif(BUILD_STATIC_LIBS)
if(WIN32)
set_property(TARGET astyle PROPERTY OUTPUT_NAME AStyleLib)
set_property(TARGET astyle PROPERTY PREFIX "")
endif()
else()
if(WIN32)
set_property(TARGET astyle PROPERTY OUTPUT_NAME AStyle)
endif()
endif()

macro(set_linker_options strip_option)
# Remove -rdynamic and add 'strip' to linker flags
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${strip_option}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${strip_option}")
endif()
# Shared library options
if(BUILD_SHARED_LIBS)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel")
elseif(MINGW)
# minGW dlls don't work
# tdm-gcc dlls work with everything except python
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -Wl,--add-stdcall-alias -Wl,--dll")
elseif(BORLAND)
# use a development environment to compile Borland dlls
endif()
endif()
endmacro()

# Set default compile options for supported compilers
if(APPLE)
target_compile_options(
astyle PRIVATE -W -Wall -fno-rtti -fno-exceptions -std=c++11 -stdlib=libc++)
set_linker_options("")
elseif(NOT WIN32) # Linux
target_compile_options(astyle PRIVATE -Wall -fno-rtti -fno-exceptions -std=c++11)
set_linker_options("-s")
elseif(BORLAND) # Release must be explicitely requested for Borland
target_compile_options(astyle PRIVATE -w -x-) # Cannot use no-rtti (-RT-)
set_linker_options("")
elseif(MINGW)
target_compile_options(astyle PRIVATE -Wall -Wextra -fno-rtti -fno-exceptions -std=c++0x)
set_linker_options("-s")
endif()

# Display build information
if(BUILD_JAVA_LIBS)
message("CMAKE_BUILD_TYPE is Java ${CMAKE_BUILD_TYPE} ${SOLIBVER}")
elseif(BUILD_SHARED_LIBS)
message("CMAKE_BUILD_TYPE is Shared ${CMAKE_BUILD_TYPE} ${SOLIBVER}")
elseif(BUILD_STATIC_LIBS)
message("CMAKE_BUILD_TYPE is Static ${CMAKE_BUILD_TYPE}")
else()
message("CMAKE_BUILD_TYPE is Executable ${CMAKE_BUILD_TYPE}")
endif()
set(CMAKE_VERBOSE_MAKEFILE ON)
2 changes: 1 addition & 1 deletion astyle/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### MIT License

Copyright (c) 2017 by Jim Pattee <jimp03@email.com>.
Copyright (c) 2018 by Jim Pattee <jimp03@email.com>.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 3 additions & 1 deletion astyle/build/cb-clang/Clang AStyle Java.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<Add option="-fno-exceptions" />
<Add option="-fPIC" />
<Add option="-Wno-c++98-compat" />
<Add option="-Wno-c++98-compat-pedantic" />
<Add option="-Wno-exit-time-destructors" />
<Add option="-Wno-global-constructors" />
<Add option="-Wno-missing-variable-declarations" />
Expand Down Expand Up @@ -54,6 +55,7 @@
<Add option="-fno-exceptions" />
<Add option="-fPIC" />
<Add option="-Wno-c++98-compat" />
<Add option="-Wno-c++98-compat-pedantic" />
<Add option="-Wno-exit-time-destructors" />
<Add option="-Wno-global-constructors" />
<Add option="-Wno-missing-variable-declarations" />
Expand All @@ -76,7 +78,7 @@
</Target>
<Environment>
<Variable name="MAJORVER" value="3" />
<Variable name="MINORVER" value="0" />
<Variable name="MINORVER" value="1" />
<Variable name="PATCHVER" value="0" />
<Variable name="SOLIBVER" value="$(MAJORVER).$(MINORVER).$(PATCHVER)" />
</Environment>
Expand Down
4 changes: 2 additions & 2 deletions astyle/build/cb-clang/Clang AStyle So.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<Add option="-Wno-sign-conversion" />
<Add option="-Wno-weak-vtables" />
<Add option="-DASTYLE_LIB" />
<Add option="-DDNDEBUG" />
<Add option="-DNDEBUG" />
</Compiler>
<Linker>
<Add option="-s" />
Expand All @@ -68,7 +68,7 @@
</Target>
<Environment>
<Variable name="MAJORVER" value="3" />
<Variable name="MINORVER" value="0" />
<Variable name="MINORVER" value="1" />
<Variable name="PATCHVER" value="0" />
<Variable name="SOLIBVER" value="$(MAJORVER).$(MINORVER).$(PATCHVER)" />
</Environment>
Expand Down
2 changes: 1 addition & 1 deletion astyle/build/cb-clang/Clang AStyle.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="clang" />
<Option parameters='&apos;&quot;$HOME/Projects/AStyleDev/test-c/*.cpp&quot;&apos; &apos;&quot;$HOME/Projects/AStyleDev/test-c/*.h&quot;&apos; -vR' />
<Option parameters='&apos;&quot;$HOME/Projects/AStyleFuzz/afl-out/crashes/*.cpp&quot;&apos; -v' />
<Option projectLinkerOptionsRelation="0" />
<Option projectIncludeDirsRelation="0" />
<Option projectResourceIncludeDirsRelation="0" />
Expand Down
2 changes: 1 addition & 1 deletion astyle/build/cb-gcc/Gcc AStyle Java.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</Target>
<Environment>
<Variable name="MAJORVER" value="3" />
<Variable name="MINORVER" value="0" />
<Variable name="MINORVER" value="1" />
<Variable name="PATCHVER" value="0" />
<Variable name="SOLIBVER" value="$(MAJORVER).$(MINORVER).$(PATCHVER)" />
</Environment>
Expand Down
2 changes: 1 addition & 1 deletion astyle/build/cb-gcc/Gcc AStyle So.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</Target>
<Environment>
<Variable name="MAJORVER" value="3" />
<Variable name="MINORVER" value="0" />
<Variable name="MINORVER" value="1" />
<Variable name="PATCHVER" value="0" />
<Variable name="SOLIBVER" value="$(MAJORVER).$(MINORVER).$(PATCHVER)" />
</Environment>
Expand Down
38 changes: 36 additions & 2 deletions astyle/build/cb-gcc/Gcc AStyle.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@
<Add option="-g" />
<Add option="-fno-rtti" />
<Add option="-fno-exceptions" />
<Add option="-Wswitch" />
<Add option="-Wno-deprecated-declarations" />
<Add option="-Wempty-body" />
<Add option="-Wconversion" />
<Add option="-Wreturn-type" />
<Add option="-Wparentheses" />
<Add option="-Wno-format" />
<Add option="-Wuninitialized" />
<Add option="-Wunused-function" />
<Add option="-Wunused-value" />
<Add option="-Wunused-variable" />
</Compiler>
</Target>
<Target title="Release">
Expand Down Expand Up @@ -62,6 +73,18 @@
<Add option="-std=c++11" />
<Add option="-fno-rtti" />
<Add option="-fno-exceptions" />
<Add option="-Wswitch" />
<Add option="-Wno-deprecated-declarations" />
<Add option="-Wempty-body" />
<Add option="-Wconversion" />
<Add option="-Wreturn-type" />
<Add option="-Wparentheses" />
<Add option="-Wno-format" />
<Add option="-Wuninitialized" />
<Add option="-Wunreachable-code" />
<Add option="-Wunused-function" />
<Add option="-Wunused-value" />
<Add option="-Wunused-variable" />
<Add option="-DNDEBUG" />
</Compiler>
<Linker>
Expand Down Expand Up @@ -90,12 +113,23 @@
<Add option="-Wextra" />
<Add option="-Wall" />
<Add option="-std=c++11" />
<Add option="-fno-exceptions" />
<Add option="-fno-rtti" />
<Add option="-Wint-to-pointer-cast" />
<Add option="-Woverloaded-virtual" />
<Add option="-Wwrite-strings" />
<Add option="-Wno-switch-default" />
<Add option="-fno-exceptions" />
<Add option="-fno-rtti" />
<Add option="-Wswitch" />
<Add option="-Wno-deprecated-declarations" />
<Add option="-Wempty-body" />
<Add option="-Wconversion" />
<Add option="-Wreturn-type" />
<Add option="-Wparentheses" />
<Add option="-Wno-format" />
<Add option="-Wuninitialized" />
<Add option="-Wunused-function" />
<Add option="-Wunused-value" />
<Add option="-Wunused-variable" />
</Compiler>
</Target>
<Target title="Coverage">
Expand Down
4 changes: 1 addition & 3 deletions astyle/build/cb-intel/Intel AStyle Java.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<Add option="-g" />
<Add option="-w3" />
<Add option="-Wextra" />
<Add option="-std=c++11" />
<Add option="-fno-exceptions" />
<Add option="-fPIC" />
<Add option="-DASTYLE_JNI" />
Expand All @@ -41,7 +40,6 @@
<Add option="-Wall" />
<Add option="-w3" />
<Add option="-Wextra" />
<Add option="-std=c++11" />
<Add option="-fno-exceptions" />
<Add option="-fPIC" />
<Add option="-wd11074,11076" />
Expand All @@ -59,7 +57,7 @@
</Target>
<Environment>
<Variable name="MAJORVER" value="3" />
<Variable name="MINORVER" value="0" />
<Variable name="MINORVER" value="1" />
<Variable name="PATCHVER" value="0" />
<Variable name="SOLIBVER" value="$(MAJORVER).$(MINORVER).$(PATCHVER)" />
</Environment>
Expand Down
2 changes: 1 addition & 1 deletion astyle/build/cb-intel/Intel AStyle So.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</Target>
<Environment>
<Variable name="MAJORVER" value="3" />
<Variable name="MINORVER" value="0" />
<Variable name="MINORVER" value="1" />
<Variable name="PATCHVER" value="0" />
<Variable name="SOLIBVER" value="$(MAJORVER).$(MINORVER).$(PATCHVER)" />
</Environment>
Expand Down
2 changes: 1 addition & 1 deletion astyle/build/clang/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ INSTALL=install -o $(USER) -g $(USER)
MAJORVER = 3
# Library's minor version number -- Increment when functionnality is added in a
# backward-compatible manner; reset to 0 when major number changes.
MINORVER = 0
MINORVER = 1
# Library's patch version number -- Increment in case of backward-compatible
# bug fixes or refactoring; reset to 0 when minor number changes.
PATCHVER = 0
Expand Down
2 changes: 1 addition & 1 deletion astyle/build/gcc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ INSTALL=install -o $(USER) -g $(USER)
MAJORVER = 3
# Library's minor version number -- Increment when functionnality is added in a
# backward-compatible manner; reset to 0 when major number changes.
MINORVER = 0
MINORVER = 1
# Library's patch version number -- Increment in case of backward-compatible
# bug fixes or refactoring; reset to 0 when minor number changes.
PATCHVER = 0
Expand Down
2 changes: 1 addition & 1 deletion astyle/build/intel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ INSTALL=install -o $(USER) -g $(USER)
MAJORVER = 3
# Library's minor version number -- Increment when functionnality is added in a
# backward-compatible manner; reset to 0 when major number changes.
MINORVER = 0
MINORVER = 1
# Library's patch version number -- Increment in case of backward-compatible
# bug fixes or refactoring; reset to 0 when minor number changes.
PATCHVER = 0
Expand Down
Loading

0 comments on commit 92767f9

Please sign in to comment.