Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lex/Yacc files aren't compiled in IDE generated files. #3662

Closed
IsaccBarker opened this issue Apr 21, 2023 · 5 comments
Closed

Lex/Yacc files aren't compiled in IDE generated files. #3662

IsaccBarker opened this issue Apr 21, 2023 · 5 comments

Comments

@IsaccBarker
Copy link

Xmake Version

v2.7.8+master.025fbe955

Operating System Version and Architecture

macOS Ventura 13.2

Describe Bug

Take the example Lex and Yacc project located at /tests/projects/lex_yacc. If you compile it with just Xmake, it runs fine. However, if you try and generate a Makefile or CMakeLists.txt file to compile it with (with xmake project -k makefile or xmake project -k cmake), it compile the source that lex or yacc spit out.

In fact, in the generated build files, it doesn't even attempt to link against them, or even invoke the tools in the first place. The only thing it does is include the directory where Xmake in theory told yacc to output the header file.

Expected Behavior

A successful compilation.

Project Configuration

https://github.com/xmake-io/xmake/tree/025fbe9559af74fac774b76b39cbd28f1f5bba6d/tests/projects/lex_yacc

Additional Information and Error Logs

# this is the build file for project
# it is autogenerated by the xmake build system.
# do not edit by hand.

ifneq ($(VERBOSE),1)
VV=@
endif

RC=/opt/local/bin/rustc
CU=/usr/local/bin/clang
SC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
AS=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
MM=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
MXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
GC=/opt/local/bin/go

SH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
SCSH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
RCSH=/opt/local/bin/rustc
AR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar
RCAR=/opt/local/bin/rustc
GCAR=/opt/local/bin/go
LD=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
SCLD=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
RCLD=/opt/local/bin/rustc
GCLD=/opt/local/bin/go


calc_CCFLAGS=-Qunused-arguments -target arm64-apple-macos13.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -fvisibility=hidden -O3 -Ibuild/.gens/calc/macosx/arm64/release/rules/yacc_yacc -DNDEBUG
calc_LDFLAGS=-target arm64-apple-macos13.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -stdlib=libc++ -Wl,-x -Wl,-dead_strip -lz

default:  calc

all:  calc

.PHONY: default all  calc

calc: build/macosx/arm64/release/calc
build/macosx/arm64/release/calc: build/.objs/calc/macosx/arm64/release/src/test.c.o
	@echo linking.release calc
	@mkdir -p build/macosx/arm64/release
	$(VV)$(LD) -o build/macosx/arm64/release/calc build/.objs/calc/macosx/arm64/release/src/test.c.o $(calc_LDFLAGS)

build/.objs/calc/macosx/arm64/release/src/test.c.o: src/test.c
	@echo compiling.release src/test.c
	@mkdir -p build/.objs/calc/macosx/arm64/release/src
	$(VV)$(CC) -c $(calc_CCFLAGS) -o build/.objs/calc/macosx/arm64/release/src/test.c.o src/test.c

clean:  clean_calc

clean_calc:
	@rm -rf build/macosx/arm64/release/calc
	@rm -rf build/macosx/arm64/release/calc.dSYM
	@rm -rf build/.objs/calc/macosx/arm64/release/src/test.c.o

As you can see, the Makefile doesn't even mention yacc or lex, with the exception of including build/.gens/calc/macosx/arm64/release/rules/yacc_yacc.

@waruqi
Copy link
Member

waruqi commented Apr 21, 2023

I have improved cmake generator, you can try it again.

xmake update -s github:xmake-io/xmake#cmakelists
xmake project -k cmake
mkdir build
cd build
cmake ..
make
ruki-2:build ruki$ cmake ..
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/
Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Develope
r/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ruki/projects/personal/xmake/tes
ts/projects/lex_yacc/build
ruki-2:build ruki$ make
[ 33%] Generating output_calc_B61241E5
[ 33%] Built target target_calc_B61241E5
[ 66%] Building C object CMakeFiles/calc.dir/src/test.c.o
[100%] Linking C executable macosx/x86_64/release/calc
[100%] Built target calc

The makefile generator still needs a lot of work and is not supported yet, I will improve it in the future.

@IsaccBarker
Copy link
Author

Ah, sorry, didn't know that the makefile generator wasn't finished. Was it in the docs and I just missed it?

Otherwise, it seems to work fine, thanks for the quick response :)

@waruqi
Copy link
Member

waruqi commented Apr 22, 2023

I just fixed cmake generator, not makefile

@waruqi
Copy link
Member

waruqi commented Apr 26, 2023

I have improved makefile generator, you can try it again. xmake update -s github:xmake-io/xmake#gencmds

$ rm -rf build/; xmake project -k make; make
create ok!
/usr/bin/bison -d -o build/.gens/calc/macosx/x86_64/release/rules/yacc_yacc/
calc.tab.c src/calc.y
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolcha
in/usr/bin/clang -c -Qunused-arguments -target x86_64-apple-macos12.6 -isysr
oot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Dev
eloper/SDKs/MacOSX13.0.sdk -fvisibility=hidden -O3 -Ibuild/.gens/calc/macosx
/x86_64/release/rules/yacc_yacc -DNDEBUG -o build/.objs/calc/macosx/x86_64/r
elease/gens/rules/yacc_yacc/calc.tab.c.o build/.gens/calc/macosx/x86_64/rele
ase/rules/yacc_yacc/calc.tab.c
/usr/bin/flex -o build/.gens/calc/macosx/x86_64/release/rules/lex_yacc/calc.
c src/calc.l
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolcha
in/usr/bin/clang -c -Qunused-arguments -target x86_64-apple-macos12.6 -isysr
oot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Dev
eloper/SDKs/MacOSX13.0.sdk -fvisibility=hidden -O3 -Ibuild/.gens/calc/macosx
/x86_64/release/rules/yacc_yacc -DNDEBUG -o build/.objs/calc/macosx/x86_64/r
elease/gens/rules/lex_yacc/calc.c.o build/.gens/calc/macosx/x86_64/release/r
ules/lex_yacc/calc.c
ccache compiling.release src/test.c
linking.release calc

@waruqi
Copy link
Member

waruqi commented Apr 26, 2023

xmake update -s dev

@waruqi waruqi closed this as completed Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants